Skip to content
Draft
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
1,220 changes: 1,220 additions & 0 deletions javascript/downgrades/49e6663bb7d470c5f0e8e4bcef0ac01a8fb1a30a/old.dbscheme

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
description: Remove parenthesized expression from AST, add has_parentheses relation
compatibility: partial

has_parentheses.rel: delete
Original file line number Diff line number Diff line change
Expand Up @@ -1473,9 +1473,18 @@ public Label visit(SequenceExpression nd, Context c) {

@Override
public Label visit(ParenthesizedExpression nd, Context c) {
Label key = super.visit(nd, c);
visit(nd.getExpression(), key, 0, IdContext.VAR_BIND);
return key;
// Bypass the parenthesized expression node: visit the inner expression
// with the parent's context so it takes the place of the ParExpr in the tree.
// Count nested parentheses so that ((x)) results in depth 2.
int depth = 1;
Expression inner = nd.getExpression();
while (inner instanceof ParenthesizedExpression) {
depth++;
inner = ((ParenthesizedExpression) inner).getExpression();
}
Label innerLabel = inner.accept(this, c);
trapwriter.addTuple("has_parentheses", innerLabel, depth);
return innerLabel;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ public Node visit(XMLDotDotExpression nd, Void c) {
return nd.getLeft().accept(this, c);
}

@Override
public Node visit(ParenthesizedExpression nd, Void c) {
return nd.getExpression().accept(this, c);
}

public static Node of(Node nd) {
return nd.accept(new First(), null);
}
Expand Down Expand Up @@ -1299,7 +1304,7 @@ public Void visit(ExpressionStatement nd, SuccessorInfo i) {

@Override
public Void visit(ParenthesizedExpression nd, SuccessorInfo i) {
writeSuccessor(nd, First.of(nd.getExpression()));
// Bypass parenthesized expression - it has no DB entry, so just delegate to the inner expression
return nd.getExpression().accept(this, i);
}

Expand Down
147 changes: 70 additions & 77 deletions javascript/extractor/tests/cfg/output/trap/ternary.js.trap
Original file line number Diff line number Diff line change
Expand Up @@ -96,125 +96,118 @@ hasLocation(#20032,#20033)
enclosing_stmt(#20032,#20031)
expr_containers(#20032,#20001)
#20034=*
exprs(#20034,63,#20032,0,"(a ? b || c : d)")
#20035=@"loc,{#10000},1,1,1,16"
locations_default(#20035,#10000,1,1,1,16)
exprs(#20034,11,#20032,0,"a ? b || c : d")
#20035=@"loc,{#10000},1,2,1,15"
locations_default(#20035,#10000,1,2,1,15)
hasLocation(#20034,#20035)
enclosing_stmt(#20034,#20031)
expr_containers(#20034,#20001)
#20036=*
exprs(#20036,11,#20034,0,"a ? b || c : d")
#20037=@"loc,{#10000},1,2,1,15"
locations_default(#20037,#10000,1,2,1,15)
hasLocation(#20036,#20037)
exprs(#20036,79,#20034,0,"a")
hasLocation(#20036,#20007)
enclosing_stmt(#20036,#20031)
expr_containers(#20036,#20001)
literals("a","a",#20036)
#20037=@"var;{a};{#20000}"
variables(#20037,"a",#20000)
bind(#20036,#20037)
#20038=*
exprs(#20038,79,#20036,0,"a")
hasLocation(#20038,#20007)
exprs(#20038,45,#20034,1,"b || c")
#20039=@"loc,{#10000},1,6,1,11"
locations_default(#20039,#10000,1,6,1,11)
hasLocation(#20038,#20039)
enclosing_stmt(#20038,#20031)
expr_containers(#20038,#20001)
literals("a","a",#20038)
#20039=@"var;{a};{#20000}"
variables(#20039,"a",#20000)
bind(#20038,#20039)
#20040=*
exprs(#20040,45,#20036,1,"b || c")
#20041=@"loc,{#10000},1,6,1,11"
locations_default(#20041,#10000,1,6,1,11)
hasLocation(#20040,#20041)
exprs(#20040,79,#20038,0,"b")
hasLocation(#20040,#20011)
enclosing_stmt(#20040,#20031)
expr_containers(#20040,#20001)
literals("b","b",#20040)
#20041=@"var;{b};{#20000}"
variables(#20041,"b",#20000)
bind(#20040,#20041)
#20042=*
exprs(#20042,79,#20040,0,"b")
hasLocation(#20042,#20011)
exprs(#20042,79,#20038,1,"c")
hasLocation(#20042,#20015)
enclosing_stmt(#20042,#20031)
expr_containers(#20042,#20001)
literals("b","b",#20042)
#20043=@"var;{b};{#20000}"
variables(#20043,"b",#20000)
literals("c","c",#20042)
#20043=@"var;{c};{#20000}"
variables(#20043,"c",#20000)
bind(#20042,#20043)
#20044=*
exprs(#20044,79,#20040,1,"c")
hasLocation(#20044,#20015)
exprs(#20044,79,#20034,2,"d")
hasLocation(#20044,#20019)
enclosing_stmt(#20044,#20031)
expr_containers(#20044,#20001)
literals("c","c",#20044)
#20045=@"var;{c};{#20000}"
variables(#20045,"c",#20000)
literals("d","d",#20044)
#20045=@"var;{d};{#20000}"
variables(#20045,"d",#20000)
bind(#20044,#20045)
has_parentheses(#20034,1)
#20046=*
exprs(#20046,79,#20036,2,"d")
hasLocation(#20046,#20019)
exprs(#20046,79,#20032,1,"e")
hasLocation(#20046,#20025)
enclosing_stmt(#20046,#20031)
expr_containers(#20046,#20001)
literals("d","d",#20046)
#20047=@"var;{d};{#20000}"
variables(#20047,"d",#20000)
literals("e","e",#20046)
#20047=@"var;{e};{#20000}"
variables(#20047,"e",#20000)
bind(#20046,#20047)
#20048=*
exprs(#20048,79,#20032,1,"e")
hasLocation(#20048,#20025)
enclosing_stmt(#20048,#20031)
expr_containers(#20048,#20001)
literals("e","e",#20048)
#20049=@"var;{e};{#20000}"
variables(#20049,"e",#20000)
bind(#20048,#20049)
entry_cfg_node(#20048,#20001)
#20049=@"loc,{#10000},1,1,1,0"
locations_default(#20049,#10000,1,1,1,0)
hasLocation(#20048,#20049)
#20050=*
entry_cfg_node(#20050,#20001)
#20051=@"loc,{#10000},1,1,1,0"
locations_default(#20051,#10000,1,1,1,0)
hasLocation(#20050,#20051)
#20052=*
exit_cfg_node(#20052,#20001)
hasLocation(#20052,#20029)
exit_cfg_node(#20050,#20001)
hasLocation(#20050,#20029)
successor(#20031,#20032)
successor(#20032,#20034)
successor(#20034,#20036)
successor(#20036,#20038)
#20051=*
guard_node(#20051,1,#20036)
hasLocation(#20051,#20007)
successor(#20051,#20038)
#20052=*
guard_node(#20052,0,#20036)
hasLocation(#20052,#20007)
successor(#20052,#20044)
successor(#20036,#20051)
successor(#20036,#20052)
successor(#20038,#20040)
#20053=*
guard_node(#20053,1,#20038)
hasLocation(#20053,#20007)
successor(#20053,#20040)
guard_node(#20053,1,#20040)
hasLocation(#20053,#20011)
successor(#20053,#20050)
#20054=*
guard_node(#20054,0,#20038)
hasLocation(#20054,#20007)
successor(#20054,#20046)
successor(#20038,#20053)
successor(#20038,#20054)
successor(#20040,#20042)
guard_node(#20054,0,#20040)
hasLocation(#20054,#20011)
successor(#20054,#20042)
successor(#20040,#20053)
successor(#20040,#20054)
#20055=*
guard_node(#20055,1,#20042)
hasLocation(#20055,#20011)
successor(#20055,#20052)
hasLocation(#20055,#20015)
successor(#20055,#20050)
#20056=*
guard_node(#20056,0,#20042)
hasLocation(#20056,#20011)
successor(#20056,#20044)
hasLocation(#20056,#20015)
successor(#20056,#20046)
successor(#20042,#20055)
successor(#20042,#20056)
#20057=*
guard_node(#20057,1,#20044)
hasLocation(#20057,#20015)
successor(#20057,#20052)
hasLocation(#20057,#20019)
successor(#20057,#20050)
#20058=*
guard_node(#20058,0,#20044)
hasLocation(#20058,#20015)
successor(#20058,#20048)
hasLocation(#20058,#20019)
successor(#20058,#20046)
successor(#20044,#20057)
successor(#20044,#20058)
#20059=*
guard_node(#20059,1,#20046)
hasLocation(#20059,#20019)
successor(#20059,#20052)
#20060=*
guard_node(#20060,0,#20046)
hasLocation(#20060,#20019)
successor(#20060,#20048)
successor(#20046,#20059)
successor(#20046,#20060)
successor(#20048,#20052)
successor(#20050,#20031)
successor(#20046,#20050)
successor(#20048,#20031)
numlines(#10000,1,1,0)
filetype(#10000,"javascript")
Loading