|
|
|
|
| 531 |
|
531 |
|
| 532 |
bool withStatement(HandleValue expr, HandleValue stmt, TokenPos *pos, MutableHandleValue dst); |
532 |
bool withStatement(HandleValue expr, HandleValue stmt, TokenPos *pos, MutableHandleValue dst); |
| 533 |
|
533 |
|
| 534 |
bool whileStatement(HandleValue test, HandleValue stmt, TokenPos *pos, MutableHandleValue dst); |
534 |
bool whileStatement(HandleValue test, HandleValue stmt, TokenPos *pos, MutableHandleValue dst); |
| 535 |
|
535 |
|
| 536 |
bool doWhileStatement(HandleValue stmt, HandleValue test, TokenPos *pos, |
536 |
bool doWhileStatement(HandleValue stmt, HandleValue test, TokenPos *pos, |
| 537 |
MutableHandleValue dst); |
537 |
MutableHandleValue dst); |
| 538 |
|
538 |
|
|
|
539 |
bool exportStatement(HandleValue expr, TokenPos *pos, MutableHandleValue dst); |
| 540 |
|
| 539 |
bool switchStatement(HandleValue disc, NodeVector &elts, bool lexical, TokenPos *pos, |
541 |
bool switchStatement(HandleValue disc, NodeVector &elts, bool lexical, TokenPos *pos, |
| 540 |
MutableHandleValue dst); |
542 |
MutableHandleValue dst); |
| 541 |
|
543 |
|
| 542 |
bool tryStatement(HandleValue body, NodeVector &guarded, HandleValue unguarded, |
544 |
bool tryStatement(HandleValue body, NodeVector &guarded, HandleValue unguarded, |
| 543 |
HandleValue finally, TokenPos *pos, MutableHandleValue dst); |
545 |
HandleValue finally, TokenPos *pos, MutableHandleValue dst); |
| 544 |
|
546 |
|
| 545 |
bool debuggerStatement(TokenPos *pos, MutableHandleValue dst); |
547 |
bool debuggerStatement(TokenPos *pos, MutableHandleValue dst); |
| 546 |
|
548 |
|
|
Lines 958-973
NodeBuilder::doWhileStatement(HandleValu
|
Link Here
|
|---|
|
| 958 |
|
960 |
|
| 959 |
return newNode(AST_DO_STMT, pos, |
961 |
return newNode(AST_DO_STMT, pos, |
| 960 |
"body", stmt, |
962 |
"body", stmt, |
| 961 |
"test", test, |
963 |
"test", test, |
| 962 |
dst); |
964 |
dst); |
| 963 |
} |
965 |
} |
| 964 |
|
966 |
|
| 965 |
bool |
967 |
bool |
|
|
968 |
NodeBuilder::exportStatement(HandleValue expr, TokenPos *pos, MutableHandleValue dst) |
| 969 |
{ |
| 970 |
RootedValue cb(cx, callbacks[AST_EXPORT_STMT]); |
| 971 |
if (!cb.isNull()) |
| 972 |
return callback(cb, expr, pos, dst); |
| 973 |
|
| 974 |
return newNode(AST_EXPORT_STMT, pos, |
| 975 |
"expr", expr, |
| 976 |
dst); |
| 977 |
} |
| 978 |
|
| 979 |
bool |
| 966 |
NodeBuilder::switchStatement(HandleValue disc, NodeVector &elts, bool lexical, TokenPos *pos, |
980 |
NodeBuilder::switchStatement(HandleValue disc, NodeVector &elts, bool lexical, TokenPos *pos, |
| 967 |
MutableHandleValue dst) |
981 |
MutableHandleValue dst) |
| 968 |
{ |
982 |
{ |
| 969 |
RootedValue array(cx); |
983 |
RootedValue array(cx); |
| 970 |
if (!newArray(elts, &array)) |
984 |
if (!newArray(elts, &array)) |
| 971 |
return false; |
985 |
return false; |
| 972 |
|
986 |
|
| 973 |
RootedValue lexicalVal(cx, BooleanValue(lexical)); |
987 |
RootedValue lexicalVal(cx, BooleanValue(lexical)); |
|
Lines 1744-1759
class ASTSerializer
|
Link Here
|
|---|
|
| 1744 |
return statement(pn, dst); |
1758 |
return statement(pn, dst); |
| 1745 |
} |
1759 |
} |
| 1746 |
|
1760 |
|
| 1747 |
bool forInit(ParseNode *pn, MutableHandleValue dst); |
1761 |
bool forInit(ParseNode *pn, MutableHandleValue dst); |
| 1748 |
bool forOfOrIn(ParseNode *loop, ParseNode *head, HandleValue var, HandleValue stmt, |
1762 |
bool forOfOrIn(ParseNode *loop, ParseNode *head, HandleValue var, HandleValue stmt, |
| 1749 |
MutableHandleValue dst); |
1763 |
MutableHandleValue dst); |
| 1750 |
bool statement(ParseNode *pn, MutableHandleValue dst); |
1764 |
bool statement(ParseNode *pn, MutableHandleValue dst); |
| 1751 |
bool blockStatement(ParseNode *pn, MutableHandleValue dst); |
1765 |
bool blockStatement(ParseNode *pn, MutableHandleValue dst); |
|
|
1766 |
bool exportStatement(ParseNode *pn, MutableHandleValue dst); |
| 1752 |
bool switchStatement(ParseNode *pn, MutableHandleValue dst); |
1767 |
bool switchStatement(ParseNode *pn, MutableHandleValue dst); |
| 1753 |
bool switchCase(ParseNode *pn, MutableHandleValue dst); |
1768 |
bool switchCase(ParseNode *pn, MutableHandleValue dst); |
| 1754 |
bool tryStatement(ParseNode *pn, MutableHandleValue dst); |
1769 |
bool tryStatement(ParseNode *pn, MutableHandleValue dst); |
| 1755 |
bool catchClause(ParseNode *pn, bool *isGuarded, MutableHandleValue dst); |
1770 |
bool catchClause(ParseNode *pn, bool *isGuarded, MutableHandleValue dst); |
| 1756 |
|
1771 |
|
| 1757 |
bool optExpression(ParseNode *pn, MutableHandleValue dst) { |
1772 |
bool optExpression(ParseNode *pn, MutableHandleValue dst) { |
| 1758 |
if (!pn) { |
1773 |
if (!pn) { |
| 1759 |
dst.setMagic(JS_SERIALIZE_NO_NODE); |
1774 |
dst.setMagic(JS_SERIALIZE_NO_NODE); |
|
Lines 2139-2154
ASTSerializer::switchCase(ParseNode *pn,
|
Link Here
|
|---|
|
| 2139 |
RootedValue expr(cx); |
2154 |
RootedValue expr(cx); |
| 2140 |
|
2155 |
|
| 2141 |
return optExpression(pn->pn_left, &expr) && |
2156 |
return optExpression(pn->pn_left, &expr) && |
| 2142 |
statements(pn->pn_right, stmts) && |
2157 |
statements(pn->pn_right, stmts) && |
| 2143 |
builder.switchCase(expr, stmts, &pn->pn_pos, dst); |
2158 |
builder.switchCase(expr, stmts, &pn->pn_pos, dst); |
| 2144 |
} |
2159 |
} |
| 2145 |
|
2160 |
|
| 2146 |
bool |
2161 |
bool |
|
|
2162 |
ASTSerializer::exportStatement(ParseNode *pn, MutableHandleValue dst) |
| 2163 |
{ |
| 2164 |
RootedValue expr(cx); |
| 2165 |
return declaration(pn->pn_kid, &expr) |
| 2166 |
&& builder.exportStatement(expr, &pn->pn_pos, dst); |
| 2167 |
} |
| 2168 |
|
| 2169 |
bool |
| 2147 |
ASTSerializer::switchStatement(ParseNode *pn, MutableHandleValue dst) |
2170 |
ASTSerializer::switchStatement(ParseNode *pn, MutableHandleValue dst) |
| 2148 |
{ |
2171 |
{ |
| 2149 |
JS_ASSERT(pn->pn_pos.encloses(pn->pn_left->pn_pos)); |
2172 |
JS_ASSERT(pn->pn_pos.encloses(pn->pn_left->pn_pos)); |
| 2150 |
JS_ASSERT(pn->pn_pos.encloses(pn->pn_right->pn_pos)); |
2173 |
JS_ASSERT(pn->pn_pos.encloses(pn->pn_right->pn_pos)); |
| 2151 |
|
2174 |
|
| 2152 |
RootedValue disc(cx); |
2175 |
RootedValue disc(cx); |
| 2153 |
|
2176 |
|
| 2154 |
if (!expression(pn->pn_left, &disc)) |
2177 |
if (!expression(pn->pn_left, &disc)) |
|
Lines 2309-2324
ASTSerializer::statement(ParseNode *pn,
|
Link Here
|
|---|
|
| 2309 |
RootedValue test(cx), cons(cx), alt(cx); |
2332 |
RootedValue test(cx), cons(cx), alt(cx); |
| 2310 |
|
2333 |
|
| 2311 |
return expression(pn->pn_kid1, &test) && |
2334 |
return expression(pn->pn_kid1, &test) && |
| 2312 |
statement(pn->pn_kid2, &cons) && |
2335 |
statement(pn->pn_kid2, &cons) && |
| 2313 |
optStatement(pn->pn_kid3, &alt) && |
2336 |
optStatement(pn->pn_kid3, &alt) && |
| 2314 |
builder.ifStatement(test, cons, alt, &pn->pn_pos, dst); |
2337 |
builder.ifStatement(test, cons, alt, &pn->pn_pos, dst); |
| 2315 |
} |
2338 |
} |
| 2316 |
|
2339 |
|
|
|
2340 |
case PNK_EXPORT: |
| 2341 |
return exportStatement(pn, dst); |
| 2342 |
|
| 2317 |
case PNK_SWITCH: |
2343 |
case PNK_SWITCH: |
| 2318 |
return switchStatement(pn, dst); |
2344 |
return switchStatement(pn, dst); |
| 2319 |
|
2345 |
|
| 2320 |
case PNK_TRY: |
2346 |
case PNK_TRY: |
| 2321 |
return tryStatement(pn, dst); |
2347 |
return tryStatement(pn, dst); |
| 2322 |
|
2348 |
|
| 2323 |
case PNK_WITH: |
2349 |
case PNK_WITH: |
| 2324 |
case PNK_WHILE: |
2350 |
case PNK_WHILE: |