@@ -34,8 +34,8 @@ function tryReadFile(path) {
34
34
35
35
// Parse the given JavaScript script and return an AST compatible with Fuzzilli's protobuf-based AST format.
36
36
function parse ( script , proto ) {
37
- let ast = Parser . parse ( script , { plugins : [ "v8intrinsic" ] } ) ;
38
-
37
+ let ast = Parser . parse ( script , { plugins : [ "v8intrinsic" ] } ) ;
38
+
39
39
function assertNoError ( err ) {
40
40
if ( err ) throw err ;
41
41
}
@@ -519,6 +519,12 @@ function parse(script, proto) {
519
519
let argument = visitExpression ( node . argument ) ;
520
520
return makeExpression ( 'UnaryExpression' , { operator, argument } ) ;
521
521
}
522
+ case 'ConditionalExpression' : {
523
+ let condition = visitExpression ( node . test ) ;
524
+ let consequent = visitExpression ( node . consequent ) ;
525
+ let alternate = visitExpression ( node . alternate ) ;
526
+ return makeExpression ( 'TernaryExpression' , { condition, consequent, alternate } ) ;
527
+ }
522
528
case 'BinaryExpression' :
523
529
case 'LogicalExpression' : {
524
530
let operator = node . operator ;
@@ -571,7 +577,7 @@ protobuf.load(astProtobufDefinitionPath, function(err, root) {
571
577
572
578
// Uncomment this to print the AST to stdout (will be very verbose).
573
579
//console.log(JSON.stringify(ast, null, 2));
574
-
580
+
575
581
const AST = root . lookupType ( 'compiler.protobuf.AST' ) ;
576
582
let buffer = AST . encode ( ast ) . finish ( ) ;
577
583
0 commit comments