Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/void operator #465

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions Sources/Fuzzilli/Base/JavaScriptLifterUtil.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

func insertVoid() -> String{
return probability(0.05) ? "void " : ""
}
19 changes: 10 additions & 9 deletions Sources/Fuzzilli/Lifting/JavaScriptLifter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -746,13 +746,14 @@ public class JavaScriptLifter: Lifter {
// the function is a MemberExpression since it would otherwise be interpreted as a method call, not a function call.
let f = inputAsIdentifier(0)
let args = inputs.dropFirst()
let expr = CallExpression.new() + f + "(" + liftCallArguments(args) + ")"
let expr = CallExpression.new() + insertVoid() + f + "(" + liftCallArguments(args) + ")"
w.assign(expr, to: instr.output)

case .callFunctionWithSpread(let op):
let f = inputAsIdentifier(0)
let args = inputs.dropFirst()
let expr = CallExpression.new() + f + "(" + liftCallArguments(args, spreading: op.spreads) + ")"
let vo = probability(0.05) ? "void " : ""
let expr = CallExpression.new() + insertVoid() + f + "(" + liftCallArguments(args, spreading: op.spreads) + ")"
w.assign(expr, to: instr.output)

case .construct:
Expand All @@ -773,28 +774,28 @@ public class JavaScriptLifter: Lifter {
let obj = input(0)
let method = MemberExpression.new() + obj + "." + op.methodName
let args = inputs.dropFirst()
let expr = CallExpression.new() + method + "(" + liftCallArguments(args) + ")"
let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args) + ")"
w.assign(expr, to: instr.output)

case .callMethodWithSpread(let op):
let obj = input(0)
let method = MemberExpression.new() + obj + "." + op.methodName
let args = inputs.dropFirst()
let expr = CallExpression.new() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")"
let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")"
w.assign(expr, to: instr.output)

case .callComputedMethod:
let obj = input(0)
let method = MemberExpression.new() + obj + "[" + input(1).text + "]"
let args = inputs.dropFirst(2)
let expr = CallExpression.new() + method + "(" + liftCallArguments(args) + ")"
let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args) + ")"
w.assign(expr, to: instr.output)

case .callComputedMethodWithSpread(let op):
let obj = input(0)
let method = MemberExpression.new() + obj + "[" + input(1).text + "]"
let args = inputs.dropFirst(2)
let expr = CallExpression.new() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")"
let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")"
w.assign(expr, to: instr.output)

case .unaryOperation(let op):
Expand Down Expand Up @@ -951,11 +952,11 @@ public class JavaScriptLifter: Lifter {
break

case .callSuperConstructor:
let EXPR = CallExpression.new() + "super(" + liftCallArguments(inputs) + ")"
let EXPR = CallExpression.new() + insertVoid() + "super(" + liftCallArguments(inputs) + ")"
w.emit("\(EXPR);")

case .callSuperMethod(let op):
let expr = CallExpression.new() + "super.\(op.methodName)(" + liftCallArguments(inputs) + ")"
let expr = CallExpression.new() + insertVoid() + "super.\(op.methodName)(" + liftCallArguments(inputs) + ")"
w.assign(expr, to: instr.output)

case .getPrivateProperty(let op):
Expand All @@ -981,7 +982,7 @@ public class JavaScriptLifter: Lifter {
let obj = input(0)
let method = MemberExpression.new() + obj + ".#" + op.methodName
let args = inputs.dropFirst()
let expr = CallExpression.new() + method + "(" + liftCallArguments(args) + ")"
let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args) + ")"
w.assign(expr, to: instr.output)

case .getSuperProperty(let op):
Expand Down
Loading