Skip to content

Commit 2d98f7a

Browse files
author
Samuel Groß
committed
Rename ProgramBuilder.randXYZ to ProgramBuilder.randomXYZ
1 parent fcd6f53 commit 2d98f7a

16 files changed

+316
-316
lines changed

Docs/HowFuzzilliWorks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ Up to this point, a code generator is a simple function that fetches zero or mor
210210

211211
```swift
212212
CodeGenerator("FunctionCallGenerator") { b in
213-
let function = b.randVar()
214-
let arguments = [b.randVar(), b.randVar(), b.randVar()]
213+
let function = b.randomVariable()
214+
let arguments = [b.randomVariable(), b.randomVariable(), b.randomVariable()]
215215
b.callFunction(f, with: arguments)
216216
}
217217
```
@@ -261,8 +261,8 @@ With type information available, the CodeGenerator from above can now request a
261261

262262
```swift
263263
CodeGenerator("FunctionCallGenerator") { b in
264-
let function = b.randVar(ofType: .function())
265-
let arguments = b.randArguments(forCalling: function)
264+
let function = b.randomVariable(ofType: .function())
265+
let arguments = b.randomCallArguments(forCalling: function)
266266
b.callFunction(f, with: arguments)
267267
}
268268
```

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

Sources/Fuzzilli/CodeGen/CodeGenerators.swift

Lines changed: 156 additions & 156 deletions
Large diffs are not rendered by default.

Sources/Fuzzilli/CodeGen/ProgramTemplates.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ public let ProgramTemplates = [
142142
b.build(n: 5)
143143
let array = b.generateVariable(ofType: .object(ofGroup: "Array"))
144144

145-
let index = b.randIndex()
145+
let index = b.randomIndex()
146146
b.getElement(index, of: array)
147-
b.doReturn(b.randVar())
147+
b.doReturn(b.randomVariable())
148148
}
149149

150150
// TODO: check if these are actually different, or if

Sources/Fuzzilli/Minimization/PostProcessor.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ struct MinimizationPostProcessor {
4646
.endObjectLiteralGetter:
4747
// Insert return statements at the end of functions, but only if there is not one already.
4848
if lastInstr.op is Return || !b.hasVisibleVariables { break }
49-
addedInstruction = Instruction(Return(), inputs: [b.randVar()])
49+
addedInstruction = Instruction(Return(), inputs: [b.randomVariable()])
5050
case .callFunction:
5151
// (Sometimes) insert random arguments, but only if there are none currently.
5252
if instr.hasAnyVariadicInputs || !b.hasVisibleVariables || probability(0.5) { break }
53-
guard let args = b.randCallArguments(for: instr.input(0)), args.count > 0 else { break }
53+
guard let args = b.randomCallArguments(for: instr.input(0)), args.count > 0 else { break }
5454
replacementInstruction = Instruction(CallFunction(numArguments: args.count), output: instr.output, inputs: [instr.input(0)] + args)
5555
case .callMethod(let op):
5656
// (Sometimes) insert random arguments, but only if there are none currently.
5757
if instr.hasAnyVariadicInputs || !b.hasVisibleVariables || probability(0.5) { break }
58-
guard let args = b.randCallArguments(forMethod: op.methodName, on: instr.input(0)), args.count > 0 else { break }
58+
guard let args = b.randomCallArguments(forMethod: op.methodName, on: instr.input(0)), args.count > 0 else { break }
5959
replacementInstruction = Instruction(CallMethod(methodName: op.methodName, numArguments: args.count), output: instr.output, inputs: [instr.input(0)] + args)
6060
case .construct:
6161
// (Sometimes) insert random arguments, but only if there are none currently.
6262
if instr.hasAnyVariadicInputs || !b.hasVisibleVariables || probability(0.5) { break }
63-
guard let args = b.randCallArguments(for: instr.input(0)), args.count > 0 else { break }
63+
guard let args = b.randomCallArguments(for: instr.input(0)), args.count > 0 else { break }
6464
replacementInstruction = Instruction(Construct(numArguments: args.count), output: instr.output, inputs: [instr.input(0)] + args)
6565
case .createArray:
6666
// Add initial values, but only if there are none currently.
6767
if instr.hasAnyVariadicInputs || !b.hasVisibleVariables { break }
68-
let initialValues = Array<Variable>(repeating: b.randVar(), count: Int.random(in: 1...5))
68+
let initialValues = Array<Variable>(repeating: b.randomVariable(), count: Int.random(in: 1...5))
6969
replacementInstruction = Instruction(CreateArray(numInitialValues: initialValues.count), output: instr.output, inputs: initialValues)
7070
default:
7171
assert(!(instr.op is EndAnyFunction))

Sources/Fuzzilli/Mutators/ExplorationMutator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public class ExplorationMutator: Mutator {
233233
var ids = [String]()
234234
// Helper function for inserting the Explore operation and tracking its id.
235235
func explore(_ v: Variable) {
236-
let args = b.randVars(upTo: 5)
236+
let args = b.randomVariables(upTo: 5)
237237
assert(args.count > 0)
238238
let id = String(v.number)
239239
assert(!ids.contains(id))

Sources/Fuzzilli/Mutators/InputMutator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public class InputMutator: BaseInstructionMutator {
5050
if isTypeAware {
5151
let type = b.type(of: inouts[selectedInput]).generalize()
5252
// We are guaranteed to find at least the current input.
53-
replacement = b.randVar(ofType: type, excludeInnermostScope: instr.isBlockEnd)!
53+
replacement = b.randomVariable(ofType: type, excludeInnermostScope: instr.isBlockEnd)!
5454
} else {
55-
replacement = b.randVar(excludeInnermostScope: instr.isBlockEnd)
55+
replacement = b.randomVariable(excludeInnermostScope: instr.isBlockEnd)
5656
}
5757
b.trace("Replacing input \(selectedInput) (\(inouts[selectedInput])) with \(replacement)")
5858
inouts[selectedInput] = replacement

Sources/Fuzzilli/Mutators/JITStressMutator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public class JITStressMutator: Mutator {
2525
b.build(n: defaultCodeGenerationAmount)
2626

2727
// Call an existing (and hopefully JIT compiled) function again
28-
guard let f = b.randVar(ofConservativeType: .function()) else { return nil }
29-
guard let arguments = b.randCallArguments(for: f) else { return nil }
28+
guard let f = b.randomVariable(ofConservativeType: .function()) else { return nil }
29+
guard let arguments = b.randomCallArguments(for: f) else { return nil }
3030
b.callFunction(f, withArgs: arguments)
3131
return b.finalize()
3232
}

0 commit comments

Comments
 (0)