Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/Fuzzilli/CodeGen/CodeGeneratorWeights.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public let codeGeneratorWeights = [
"AsyncGeneratorFunctionGenerator": 1,
"ConstructorGenerator": 5,
"SubroutineReturnGenerator": 3,
"YieldGenerator": 2,
"YieldGenerator": 5,
"YieldEachGenerator": 5,
"AwaitGenerator": 2,
"PropertyRetrievalGenerator": 20,
"PropertyAssignmentGenerator": 20,
Expand Down
24 changes: 14 additions & 10 deletions Sources/Fuzzilli/CodeGen/CodeGenerators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,9 @@ public let CodeGenerators: [CodeGenerator] = [
if probability(0.5) {
b.yield(b.randomVariable())
} else {
b.yieldEach(b.randomVariable())
let randomVariables = b.randomVariables(n: Int.random(in: 1...5))
let array = b.createArray(with: randomVariables)
b.yieldEach(array)
}
b.doReturn(b.randomVariable())
}
Expand Down Expand Up @@ -807,7 +809,9 @@ public let CodeGenerators: [CodeGenerator] = [
if probability(0.5) {
b.yield(b.randomVariable())
} else {
b.yieldEach(b.randomVariable())
let randomVariables = b.randomVariables(n: Int.random(in: 1...5))
let array = b.createArray(with: randomVariables)
b.yieldEach(array)
}
b.doReturn(b.randomVariable())
}
Expand Down Expand Up @@ -1077,18 +1081,18 @@ public let CodeGenerators: [CodeGenerator] = [

CodeGenerator("YieldGenerator", inContext: .generatorFunction, inputs: .one) { b, val in
assert(b.context.contains(.generatorFunction))
if probability(0.5) {
if probability(0.9) {
b.yield(val)
} else {
b.yield()
}
if probability(0.9) {
b.yield(val)
} else {
// TODO only do this when the value is iterable?
b.yieldEach(val)
b.yield()
}
},

CodeGenerator("YieldEachGenerator", inContext: .generatorFunction, inputs: .required(.iterable)) { b, val in
assert(b.context.contains(.generatorFunction))
b.yieldEach(val)
},

CodeGenerator("AwaitGenerator", inContext: .asyncFunction, inputs: .one) { b, val in
assert(b.context.contains(.asyncFunction))
b.await(val)
Expand Down
Loading