Changeset 5356 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Nov 2, 2003, 2:51:46 PM (22 years ago)
Author:
darin
Message:

Reviewed by Maciej.

  • changed list manipulation to use Harri Porten's idea of a circular linked list that is built from head to tail rather than building the list backwards and reversing the list when done
  • kjs/grammar.y: Handle CatchNode and FinallyNode in a type-safe way. Change many places that passed 0L to pass nothing at all, or to pass 0.
  • kjs/nodes.h: (KJS::ElementNode::ElementNode): Build a circular list instead of a 0-terminated backwards list. (KJS::ArrayNode::ArrayNode): Break the circular list instead of reversing the list. (KJS::PropertyValueNode::PropertyValueNode): Moved before ObjectLiteralNode so the inline code in ObjectLiteralNode works. Build a circular list instead of a 0-terminated backwards list. Made the case for the first node separate so we don't need a nil check. (KJS::ObjectLiteralNode::ObjectLiteralNode): Break the circular list instead of reversing the list. (KJS::ArgumentListNode::ArgumentListNode): Build a circular list instead of a 0-terminated backwards list. Also, made the constructors inline (moved here from .cpp file). (KJS::ArgumentsNode::ArgumentsNode): Break the circular list instead of reversing the list. (KJS::NewExprNode::NewExprNode): Changed a 0L to 0. (KJS::StatListNode::StatListNode): Make this constructor no longer inline (moved into .cpp file). The one in the .cpp file builds a circular list instead of a 0-terminated backwards list. (KJS::VarDeclListNode::VarDeclListNode): Build a circular list instead of a 0-terminated backwards list. (KJS::VarStatementNode::VarStatementNode): Break the circular list instead of reversing the list. (KJS::BlockNode::BlockNode): Make this constructor no longer inline (moved into .cpp file). The one in the .cpp file breaks the list instead of reversing it. (KJS::ForNode::ForNode): Break the circular list instead of reversing the list. (KJS::CaseClauseNode::CaseClauseNode): Break the circular list instead of reversing the list. (KJS::ClauseListNode::ClauseListNode): Build a circular list instead of a 0-terminated backwards list. (KJS::CaseBlockNode::CaseBlockNode): Make this constructor no longer inline (moved into .cpp file). The one in the .cpp file breaks the list instead of reversing it. (KJS::TryNode::TryNode): Changed constructor to take typed parameters for the catch and finally nodes rather than just Node. (KJS::ParameterNode::ParameterNode): Build a circular list instead of a 0-terminated backwards list. (KJS::FuncDeclNode::FuncDeclNode): Break the circular list instead of reversing the list. (KJS::FuncExprNode::FuncExprNode): Break the circular list instead of reversing the list.
  • kjs/nodes.cpp: (StatListNode::StatListNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. Added setLoc calls to match KJS in the KDE tree; since we don't currently use the JavaScript debugging support, it's unclear whether there's any benefit, but later we might be using it and it's good to be as close as possible. (BlockNode::BlockNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. Added setLoc calls. (CaseBlockNode::CaseBlockNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. (SourceElementsNode::SourceElementsNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. Added setLoc calls.
  • kjs/grammar.cpp: Regenerated.
  • kjs/grammar.cpp.h: Regenerated.
  • kjs/grammar.h: Regenerated.
Location:
trunk/JavaScriptCore/kjs
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/grammar.cpp

    r5314 r5356  
    153153  PropertyValueNode   *plist;
    154154  PropertyNode        *pnode;
     155  CatchNode           *cnode;
     156  FinallyNode         *fnode;
    155157} YYSTYPE;
    156158
     
    318320#if YYDEBUG != 0
    319321static const short yyrline[] = { 0,
    320    165,   167,   168,   169,   170,   171,   174,   180,   182,   183,
    321    184,   185,   186,   187,   190,   192,   193,   196,   198,   202,
    322    204,   207,   209,   212,   214,   218,   220,   221,   224,   226,
    323    227,   228,   229,   232,   234,   237,   239,   240,   241,   244,
    324    246,   249,   251,   254,   256,   259,   261,   262,   265,   267,
    325    268,   269,   270,   271,   272,   273,   274,   275,   276,   277,
    326    280,   282,   283,   284,   287,   289,   290,   293,   295,   296,
    327    297,   300,   302,   304,   306,   308,   310,   312,   316,   318,
    328    319,   320,   321,   324,   326,   329,   331,   334,   336,   339,
    329    341,   345,   347,   351,   353,   357,   359,   363,   365,   366,
    330    367,   368,   369,   370,   371,   372,   373,   374,   375,   378,
    331    380,   383,   385,   386,   387,   388,   389,   390,   391,   392,
    332    393,   394,   395,   396,   397,   400,   402,   405,   407,   410,
    333    413,   422,   424,   428,   430,   433,   437,   441,   444,   451,
    334    453,   457,   459,   460,   463,   466,   469,   472,   477,   479,
    335    482,   484,   488,   489,   495,   497,   501,   502,   509,   511,
    336    515,   516,   522,   527,   532,   534,   538,   540,   543,   545,
    337    548,   550,   553,   555,   558,   563,   567,   569,   570,   573,
    338    577,   581,   583,   586,   588,   593,   595,   598,   601,   605,
    339    608,   612,   614,   617,   619
     322   169,   171,   172,   173,   174,   175,   178,   184,   186,   187,
     323   188,   189,   190,   191,   194,   196,   197,   200,   202,   206,
     324   208,   211,   213,   216,   218,   222,   224,   225,   228,   230,
     325   231,   232,   233,   236,   238,   241,   243,   244,   245,   248,
     326   250,   253,   255,   258,   260,   263,   265,   266,   269,   271,
     327   272,   273,   274,   275,   276,   277,   278,   279,   280,   281,
     328   284,   286,   287,   288,   291,   293,   294,   297,   299,   300,
     329   301,   304,   306,   308,   310,   312,   314,   316,   320,   322,
     330   323,   324,   325,   328,   330,   333,   335,   338,   340,   343,
     331   345,   349,   351,   355,   357,   361,   363,   367,   369,   370,
     332   371,   372,   373,   374,   375,   376,   377,   378,   379,   382,
     333   384,   387,   389,   390,   391,   392,   393,   394,   395,   396,
     334   397,   398,   399,   400,   401,   404,   406,   409,   411,   414,
     335   417,   426,   428,   432,   434,   437,   441,   445,   448,   455,
     336   457,   461,   463,   464,   467,   470,   473,   476,   481,   483,
     337   486,   488,   492,   493,   499,   501,   505,   506,   513,   515,
     338   519,   520,   526,   531,   536,   538,   542,   544,   547,   549,
     339   552,   554,   557,   559,   562,   567,   571,   573,   574,   577,
     340   581,   585,   587,   590,   592,   597,   599,   602,   605,   609,
     341   612,   616,   618,   621,   623
    340342};
    341343#endif
     
    13341336
    13351337case 1:
    1336 #line 166 "grammar.y"
     1338#line 170 "grammar.y"
    13371339{ yyval.node = new NullNode(); ;
    13381340    break;}
    13391341case 2:
    1340 #line 167 "grammar.y"
     1342#line 171 "grammar.y"
    13411343{ yyval.node = new BooleanNode(true); ;
    13421344    break;}
    13431345case 3:
    1344 #line 168 "grammar.y"
     1346#line 172 "grammar.y"
    13451347{ yyval.node = new BooleanNode(false); ;
    13461348    break;}
    13471349case 4:
    1348 #line 169 "grammar.y"
     1350#line 173 "grammar.y"
    13491351{ yyval.node = new NumberNode(yyvsp[0].dval); ;
    13501352    break;}
    13511353case 5:
    1352 #line 170 "grammar.y"
     1354#line 174 "grammar.y"
    13531355{ yyval.node = new StringNode(yyvsp[0].ustr); ;
    13541356    break;}
    13551357case 6:
    1356 #line 171 "grammar.y"
     1358#line 175 "grammar.y"
    13571359{ Lexer *l = Lexer::curr();
    13581360                                     if (!l->scanRegExp()) YYABORT;
     
    13601362    break;}
    13611363case 7:
    1362 #line 175 "grammar.y"
     1364#line 179 "grammar.y"
    13631365{ Lexer *l = Lexer::curr();
    13641366                                     if (!l->scanRegExp()) YYABORT;
     
    13661368    break;}
    13671369case 8:
    1368 #line 181 "grammar.y"
     1370#line 185 "grammar.y"
    13691371{ yyval.node = new ThisNode(); ;
    13701372    break;}
    13711373case 9:
    1372 #line 182 "grammar.y"
     1374#line 186 "grammar.y"
    13731375{ yyval.node = new ResolveNode(*yyvsp[0].ident); ;
    13741376    break;}
    13751377case 12:
    1376 #line 185 "grammar.y"
     1378#line 189 "grammar.y"
    13771379{ yyval.node = new GroupNode(yyvsp[-1].node); ;
    13781380    break;}
    13791381case 13:
    1380 #line 186 "grammar.y"
    1381 { yyval.node = new ObjectLiteralNode(0L); ;
     1382#line 190 "grammar.y"
     1383{ yyval.node = new ObjectLiteralNode(); ;
    13821384    break;}
    13831385case 14:
    1384 #line 187 "grammar.y"
     1386#line 191 "grammar.y"
    13851387{ yyval.node = new ObjectLiteralNode(yyvsp[-1].plist); ;
    13861388    break;}
    13871389case 15:
    1388 #line 191 "grammar.y"
     1390#line 195 "grammar.y"
    13891391{ yyval.node = new ArrayNode(yyvsp[-1].ival); ;
    13901392    break;}
    13911393case 16:
    1392 #line 192 "grammar.y"
     1394#line 196 "grammar.y"
    13931395{ yyval.node = new ArrayNode(yyvsp[-1].elm); ;
    13941396    break;}
    13951397case 17:
    1396 #line 193 "grammar.y"
     1398#line 197 "grammar.y"
    13971399{ yyval.node = new ArrayNode(yyvsp[-1].ival, yyvsp[-3].elm); ;
    13981400    break;}
    13991401case 18:
    1400 #line 197 "grammar.y"
     1402#line 201 "grammar.y"
    14011403{ yyval.elm = new ElementNode(yyvsp[-1].ival, yyvsp[0].node); ;
    14021404    break;}
    14031405case 19:
    1404 #line 199 "grammar.y"
     1406#line 203 "grammar.y"
    14051407{ yyval.elm = new ElementNode(yyvsp[-3].elm, yyvsp[-1].ival, yyvsp[0].node); ;
    14061408    break;}
    14071409case 20:
    1408 #line 203 "grammar.y"
     1410#line 207 "grammar.y"
    14091411{ yyval.ival = 0; ;
    14101412    break;}
    14111413case 22:
    1412 #line 208 "grammar.y"
     1414#line 212 "grammar.y"
    14131415{ yyval.ival = 1; ;
    14141416    break;}
    14151417case 23:
    1416 #line 209 "grammar.y"
     1418#line 213 "grammar.y"
    14171419{ yyval.ival = yyvsp[-1].ival + 1; ;
    14181420    break;}
    14191421case 24:
    1420 #line 213 "grammar.y"
     1422#line 217 "grammar.y"
    14211423{ yyval.plist = new PropertyValueNode(yyvsp[-2].pnode, yyvsp[0].node); ;
    14221424    break;}
    14231425case 25:
    1424 #line 215 "grammar.y"
     1426#line 219 "grammar.y"
    14251427{ yyval.plist = new PropertyValueNode(yyvsp[-2].pnode, yyvsp[0].node, yyvsp[-4].plist); ;
    14261428    break;}
    14271429case 26:
    1428 #line 219 "grammar.y"
     1430#line 223 "grammar.y"
    14291431{ yyval.pnode = new PropertyNode(*yyvsp[0].ident); ;
    14301432    break;}
    14311433case 27:
    1432 #line 220 "grammar.y"
     1434#line 224 "grammar.y"
    14331435{ yyval.pnode = new PropertyNode(Identifier(*yyvsp[0].ustr)); ;
    14341436    break;}
    14351437case 28:
    1436 #line 221 "grammar.y"
     1438#line 225 "grammar.y"
    14371439{ yyval.pnode = new PropertyNode(yyvsp[0].dval); ;
    14381440    break;}
    14391441case 31:
    1440 #line 227 "grammar.y"
     1442#line 231 "grammar.y"
    14411443{ yyval.node = new AccessorNode1(yyvsp[-3].node, yyvsp[-1].node); ;
    14421444    break;}
    14431445case 32:
    1444 #line 228 "grammar.y"
     1446#line 232 "grammar.y"
    14451447{ yyval.node = new AccessorNode2(yyvsp[-2].node, *yyvsp[0].ident); ;
    14461448    break;}
    14471449case 33:
    1448 #line 229 "grammar.y"
     1450#line 233 "grammar.y"
    14491451{ yyval.node = new NewExprNode(yyvsp[-1].node, yyvsp[0].args); ;
    14501452    break;}
    14511453case 35:
    1452 #line 234 "grammar.y"
     1454#line 238 "grammar.y"
    14531455{ yyval.node = new NewExprNode(yyvsp[0].node); ;
    14541456    break;}
    14551457case 36:
    1456 #line 238 "grammar.y"
     1458#line 242 "grammar.y"
    14571459{ yyval.node = new FunctionCallNode(yyvsp[-1].node, yyvsp[0].args); ;
    14581460    break;}
    14591461case 37:
    1460 #line 239 "grammar.y"
     1462#line 243 "grammar.y"
    14611463{ yyval.node = new FunctionCallNode(yyvsp[-1].node, yyvsp[0].args); ;
    14621464    break;}
    14631465case 38:
    1464 #line 240 "grammar.y"
     1466#line 244 "grammar.y"
    14651467{ yyval.node = new AccessorNode1(yyvsp[-3].node, yyvsp[-1].node); ;
    14661468    break;}
    14671469case 39:
    1468 #line 241 "grammar.y"
     1470#line 245 "grammar.y"
    14691471{ yyval.node = new AccessorNode2(yyvsp[-2].node, *yyvsp[0].ident); ;
    14701472    break;}
    14711473case 40:
    1472 #line 245 "grammar.y"
    1473 { yyval.args = new ArgumentsNode(0L); ;
     1474#line 249 "grammar.y"
     1475{ yyval.args = new ArgumentsNode(); ;
    14741476    break;}
    14751477case 41:
    1476 #line 246 "grammar.y"
     1478#line 250 "grammar.y"
    14771479{ yyval.args = new ArgumentsNode(yyvsp[-1].alist); ;
    14781480    break;}
    14791481case 42:
    1480 #line 250 "grammar.y"
     1482#line 254 "grammar.y"
    14811483{ yyval.alist = new ArgumentListNode(yyvsp[0].node); ;
    14821484    break;}
    14831485case 43:
    1484 #line 251 "grammar.y"
     1486#line 255 "grammar.y"
    14851487{ yyval.alist = new ArgumentListNode(yyvsp[-2].alist, yyvsp[0].node); ;
    14861488    break;}
    14871489case 47:
    1488 #line 261 "grammar.y"
     1490#line 265 "grammar.y"
    14891491{ yyval.node = new PostfixNode(yyvsp[-1].node, OpPlusPlus); ;
    14901492    break;}
    14911493case 48:
    1492 #line 262 "grammar.y"
     1494#line 266 "grammar.y"
    14931495{ yyval.node = new PostfixNode(yyvsp[-1].node, OpMinusMinus); ;
    14941496    break;}
    14951497case 50:
    1496 #line 267 "grammar.y"
     1498#line 271 "grammar.y"
    14971499{ yyval.node = new DeleteNode(yyvsp[0].node); ;
    14981500    break;}
    14991501case 51:
    1500 #line 268 "grammar.y"
     1502#line 272 "grammar.y"
    15011503{ yyval.node = new VoidNode(yyvsp[0].node); ;
    15021504    break;}
    15031505case 52:
    1504 #line 269 "grammar.y"
     1506#line 273 "grammar.y"
    15051507{ yyval.node = new TypeOfNode(yyvsp[0].node); ;
    15061508    break;}
    15071509case 53:
    1508 #line 270 "grammar.y"
     1510#line 274 "grammar.y"
    15091511{ yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ;
    15101512    break;}
    15111513case 54:
    1512 #line 271 "grammar.y"
     1514#line 275 "grammar.y"
    15131515{ yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ;
    15141516    break;}
    15151517case 55:
    1516 #line 272 "grammar.y"
     1518#line 276 "grammar.y"
    15171519{ yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ;
    15181520    break;}
    15191521case 56:
    1520 #line 273 "grammar.y"
     1522#line 277 "grammar.y"
    15211523{ yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ;
    15221524    break;}
    15231525case 57:
    1524 #line 274 "grammar.y"
     1526#line 278 "grammar.y"
    15251527{ yyval.node = new UnaryPlusNode(yyvsp[0].node); ;
    15261528    break;}
    15271529case 58:
    1528 #line 275 "grammar.y"
     1530#line 279 "grammar.y"
    15291531{ yyval.node = new NegateNode(yyvsp[0].node); ;
    15301532    break;}
    15311533case 59:
    1532 #line 276 "grammar.y"
     1534#line 280 "grammar.y"
    15331535{ yyval.node = new BitwiseNotNode(yyvsp[0].node); ;
    15341536    break;}
    15351537case 60:
    1536 #line 277 "grammar.y"
     1538#line 281 "grammar.y"
    15371539{ yyval.node = new LogicalNotNode(yyvsp[0].node); ;
    15381540    break;}
    15391541case 62:
    1540 #line 282 "grammar.y"
     1542#line 286 "grammar.y"
    15411543{ yyval.node = new MultNode(yyvsp[-2].node, yyvsp[0].node, '*'); ;
    15421544    break;}
    15431545case 63:
    1544 #line 283 "grammar.y"
     1546#line 287 "grammar.y"
    15451547{ yyval.node = new MultNode(yyvsp[-2].node, yyvsp[0].node, '/'); ;
    15461548    break;}
    15471549case 64:
    1548 #line 284 "grammar.y"
     1550#line 288 "grammar.y"
    15491551{ yyval.node = new MultNode(yyvsp[-2].node,yyvsp[0].node,'%'); ;
    15501552    break;}
    15511553case 66:
    1552 #line 289 "grammar.y"
     1554#line 293 "grammar.y"
    15531555{ yyval.node = new AddNode(yyvsp[-2].node, yyvsp[0].node, '+'); ;
    15541556    break;}
    15551557case 67:
    1556 #line 290 "grammar.y"
     1558#line 294 "grammar.y"
    15571559{ yyval.node = new AddNode(yyvsp[-2].node, yyvsp[0].node, '-'); ;
    15581560    break;}
    15591561case 69:
    1560 #line 295 "grammar.y"
     1562#line 299 "grammar.y"
    15611563{ yyval.node = new ShiftNode(yyvsp[-2].node, OpLShift, yyvsp[0].node); ;
    15621564    break;}
    15631565case 70:
    1564 #line 296 "grammar.y"
     1566#line 300 "grammar.y"
    15651567{ yyval.node = new ShiftNode(yyvsp[-2].node, OpRShift, yyvsp[0].node); ;
    15661568    break;}
    15671569case 71:
    1568 #line 297 "grammar.y"
     1570#line 301 "grammar.y"
    15691571{ yyval.node = new ShiftNode(yyvsp[-2].node, OpURShift, yyvsp[0].node); ;
    15701572    break;}
    15711573case 73:
    1572 #line 303 "grammar.y"
     1574#line 307 "grammar.y"
    15731575{ yyval.node = new RelationalNode(yyvsp[-2].node, OpLess, yyvsp[0].node); ;
    15741576    break;}
    15751577case 74:
    1576 #line 305 "grammar.y"
     1578#line 309 "grammar.y"
    15771579{ yyval.node = new RelationalNode(yyvsp[-2].node, OpGreater, yyvsp[0].node); ;
    15781580    break;}
    15791581case 75:
    1580 #line 307 "grammar.y"
     1582#line 311 "grammar.y"
    15811583{ yyval.node = new RelationalNode(yyvsp[-2].node, OpLessEq, yyvsp[0].node); ;
    15821584    break;}
    15831585case 76:
    1584 #line 309 "grammar.y"
     1586#line 313 "grammar.y"
    15851587{ yyval.node = new RelationalNode(yyvsp[-2].node, OpGreaterEq, yyvsp[0].node); ;
    15861588    break;}
    15871589case 77:
    1588 #line 311 "grammar.y"
     1590#line 315 "grammar.y"
    15891591{ yyval.node = new RelationalNode(yyvsp[-2].node, OpInstanceOf, yyvsp[0].node); ;
    15901592    break;}
    15911593case 78:
    1592 #line 313 "grammar.y"
     1594#line 317 "grammar.y"
    15931595{ yyval.node = new RelationalNode(yyvsp[-2].node, OpIn, yyvsp[0].node); ;
    15941596    break;}
    15951597case 80:
    1596 #line 318 "grammar.y"
     1598#line 322 "grammar.y"
    15971599{ yyval.node = new EqualNode(yyvsp[-2].node, OpEqEq, yyvsp[0].node); ;
    15981600    break;}
    15991601case 81:
    1600 #line 319 "grammar.y"
     1602#line 323 "grammar.y"
    16011603{ yyval.node = new EqualNode(yyvsp[-2].node, OpNotEq, yyvsp[0].node); ;
    16021604    break;}
    16031605case 82:
    1604 #line 320 "grammar.y"
     1606#line 324 "grammar.y"
    16051607{ yyval.node = new EqualNode(yyvsp[-2].node, OpStrEq, yyvsp[0].node); ;
    16061608    break;}
    16071609case 83:
    1608 #line 321 "grammar.y"
     1610#line 325 "grammar.y"
    16091611{ yyval.node = new EqualNode(yyvsp[-2].node, OpStrNEq, yyvsp[0].node);;
    16101612    break;}
    16111613case 85:
    1612 #line 326 "grammar.y"
     1614#line 330 "grammar.y"
    16131615{ yyval.node = new BitOperNode(yyvsp[-2].node, OpBitAnd, yyvsp[0].node); ;
    16141616    break;}
    16151617case 87:
    1616 #line 331 "grammar.y"
     1618#line 335 "grammar.y"
    16171619{ yyval.node = new BitOperNode(yyvsp[-2].node, OpBitXOr, yyvsp[0].node); ;
    16181620    break;}
    16191621case 89:
    1620 #line 336 "grammar.y"
     1622#line 340 "grammar.y"
    16211623{ yyval.node = new BitOperNode(yyvsp[-2].node, OpBitOr, yyvsp[0].node); ;
    16221624    break;}
    16231625case 91:
    1624 #line 342 "grammar.y"
     1626#line 346 "grammar.y"
    16251627{ yyval.node = new BinaryLogicalNode(yyvsp[-2].node, OpAnd, yyvsp[0].node); ;
    16261628    break;}
    16271629case 93:
    1628 #line 348 "grammar.y"
     1630#line 352 "grammar.y"
    16291631{ yyval.node = new BinaryLogicalNode(yyvsp[-2].node, OpOr, yyvsp[0].node); ;
    16301632    break;}
    16311633case 95:
    1632 #line 354 "grammar.y"
     1634#line 358 "grammar.y"
    16331635{ yyval.node = new ConditionalNode(yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
    16341636    break;}
    16351637case 97:
    1636 #line 360 "grammar.y"
     1638#line 364 "grammar.y"
    16371639{ yyval.node = new AssignNode(yyvsp[-2].node, yyvsp[-1].op, yyvsp[0].node);;
    16381640    break;}
    16391641case 98:
    1640 #line 364 "grammar.y"
     1642#line 368 "grammar.y"
    16411643{ yyval.op = OpEqual; ;
    16421644    break;}
    16431645case 99:
    1644 #line 365 "grammar.y"
     1646#line 369 "grammar.y"
    16451647{ yyval.op = OpPlusEq; ;
    16461648    break;}
    16471649case 100:
    1648 #line 366 "grammar.y"
     1650#line 370 "grammar.y"
    16491651{ yyval.op = OpMinusEq; ;
    16501652    break;}
    16511653case 101:
    1652 #line 367 "grammar.y"
     1654#line 371 "grammar.y"
    16531655{ yyval.op = OpMultEq; ;
    16541656    break;}
    16551657case 102:
    1656 #line 368 "grammar.y"
     1658#line 372 "grammar.y"
    16571659{ yyval.op = OpDivEq; ;
    16581660    break;}
    16591661case 103:
    1660 #line 369 "grammar.y"
     1662#line 373 "grammar.y"
    16611663{ yyval.op = OpLShift; ;
    16621664    break;}
    16631665case 104:
    1664 #line 370 "grammar.y"
     1666#line 374 "grammar.y"
    16651667{ yyval.op = OpRShift; ;
    16661668    break;}
    16671669case 105:
    1668 #line 371 "grammar.y"
     1670#line 375 "grammar.y"
    16691671{ yyval.op = OpURShift; ;
    16701672    break;}
    16711673case 106:
    1672 #line 372 "grammar.y"
     1674#line 376 "grammar.y"
    16731675{ yyval.op = OpAndEq; ;
    16741676    break;}
    16751677case 107:
    1676 #line 373 "grammar.y"
     1678#line 377 "grammar.y"
    16771679{ yyval.op = OpXOrEq; ;
    16781680    break;}
    16791681case 108:
    1680 #line 374 "grammar.y"
     1682#line 378 "grammar.y"
    16811683{ yyval.op = OpOrEq; ;
    16821684    break;}
    16831685case 109:
    1684 #line 375 "grammar.y"
     1686#line 379 "grammar.y"
    16851687{ yyval.op = OpModEq; ;
    16861688    break;}
    16871689case 111:
    1688 #line 380 "grammar.y"
     1690#line 384 "grammar.y"
    16891691{ yyval.node = new CommaNode(yyvsp[-2].node, yyvsp[0].node); ;
    16901692    break;}
    16911693case 126:
    1692 #line 401 "grammar.y"
    1693 { yyval.stat = new BlockNode(0L); DBG(yyval.stat, yylsp[0], yylsp[0]); ;
     1694#line 405 "grammar.y"
     1695{ yyval.stat = new BlockNode(0); DBG(yyval.stat, yylsp[0], yylsp[0]); ;
    16941696    break;}
    16951697case 127:
    1696 #line 402 "grammar.y"
     1698#line 406 "grammar.y"
    16971699{ yyval.stat = new BlockNode(yyvsp[-1].srcs); DBG(yyval.stat, yylsp[0], yylsp[0]); ;
    16981700    break;}
    16991701case 128:
    1700 #line 406 "grammar.y"
     1702#line 410 "grammar.y"
    17011703{ yyval.slist = new StatListNode(yyvsp[0].stat); ;
    17021704    break;}
    17031705case 129:
    1704 #line 407 "grammar.y"
     1706#line 411 "grammar.y"
    17051707{ yyval.slist = new StatListNode(yyvsp[-1].slist, yyvsp[0].stat); ;
    17061708    break;}
    17071709case 130:
    1708 #line 411 "grammar.y"
     1710#line 415 "grammar.y"
    17091711{ yyval.stat = new VarStatementNode(yyvsp[-1].vlist);
    17101712                                      DBG(yyval.stat, yylsp[-2], yylsp[0]); ;
    17111713    break;}
    17121714case 131:
    1713 #line 413 "grammar.y"
     1715#line 417 "grammar.y"
    17141716{ if (automatic()) {
    17151717                                          yyval.stat = new VarStatementNode(yyvsp[-1].vlist);
     
    17211723    break;}
    17221724case 132:
    1723 #line 423 "grammar.y"
     1725#line 427 "grammar.y"
    17241726{ yyval.vlist = new VarDeclListNode(yyvsp[0].decl); ;
    17251727    break;}
    17261728case 133:
    1727 #line 425 "grammar.y"
     1729#line 429 "grammar.y"
    17281730{ yyval.vlist = new VarDeclListNode(yyvsp[-2].vlist, yyvsp[0].decl); ;
    17291731    break;}
    17301732case 134:
    1731 #line 429 "grammar.y"
     1733#line 433 "grammar.y"
    17321734{ yyval.decl = new VarDeclNode(*yyvsp[0].ident, 0); ;
    17331735    break;}
    17341736case 135:
    1735 #line 430 "grammar.y"
     1737#line 434 "grammar.y"
    17361738{ yyval.decl = new VarDeclNode(*yyvsp[-1].ident, yyvsp[0].init); ;
    17371739    break;}
    17381740case 136:
    1739 #line 434 "grammar.y"
     1741#line 438 "grammar.y"
    17401742{ yyval.init = new AssignExprNode(yyvsp[0].node); ;
    17411743    break;}
    17421744case 137:
    1743 #line 438 "grammar.y"
     1745#line 442 "grammar.y"
    17441746{ yyval.stat = new EmptyStatementNode(); ;
    17451747    break;}
    17461748case 138:
    1747 #line 442 "grammar.y"
     1749#line 446 "grammar.y"
    17481750{ yyval.stat = new ExprStatementNode(yyvsp[-1].node);
    17491751                                     DBG(yyval.stat, yylsp[-1], yylsp[0]); ;
    17501752    break;}
    17511753case 139:
    1752 #line 444 "grammar.y"
     1754#line 448 "grammar.y"
    17531755{ if (automatic()) {
    17541756                                       yyval.stat = new ExprStatementNode(yyvsp[-1].node);
     
    17581760    break;}
    17591761case 140:
    1760 #line 452 "grammar.y"
    1761 { yyval.stat = new IfNode(yyvsp[-2].node,yyvsp[0].stat,0L);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ;
     1762#line 456 "grammar.y"
     1763{ yyval.stat = new IfNode(yyvsp[-2].node,yyvsp[0].stat,0);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ;
    17621764    break;}
    17631765case 141:
    1764 #line 454 "grammar.y"
     1766#line 458 "grammar.y"
    17651767{ yyval.stat = new IfNode(yyvsp[-4].node,yyvsp[-2].stat,yyvsp[0].stat);DBG(yyval.stat,yylsp[-6],yylsp[-3]); ;
    17661768    break;}
    17671769case 142:
    1768 #line 458 "grammar.y"
     1770#line 462 "grammar.y"
    17691771{ yyval.stat=new DoWhileNode(yyvsp[-4].stat,yyvsp[-1].node);DBG(yyval.stat,yylsp[-5],yylsp[-3]);;
    17701772    break;}
    17711773case 143:
    1772 #line 459 "grammar.y"
     1774#line 463 "grammar.y"
    17731775{ yyval.stat = new WhileNode(yyvsp[-2].node,yyvsp[0].stat);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ;
    17741776    break;}
    17751777case 144:
    1776 #line 461 "grammar.y"
     1778#line 465 "grammar.y"
    17771779{ yyval.stat = new ForNode(yyvsp[-6].node,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].stat);
    17781780                                     DBG(yyval.stat,yylsp[-8],yylsp[-1]); ;
    17791781    break;}
    17801782case 145:
    1781 #line 464 "grammar.y"
     1783#line 468 "grammar.y"
    17821784{ yyval.stat = new ForNode(yyvsp[-6].vlist,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].stat);
    17831785                                     DBG(yyval.stat,yylsp[-9],yylsp[-1]); ;
    17841786    break;}
    17851787case 146:
    1786 #line 467 "grammar.y"
     1788#line 471 "grammar.y"
    17871789{ yyval.stat = new ForInNode(yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].stat);
    17881790                                     DBG(yyval.stat,yylsp[-6],yylsp[-1]); ;
    17891791    break;}
    17901792case 147:
    1791 #line 470 "grammar.y"
    1792 { yyval.stat = new ForInNode(*yyvsp[-4].ident,0L,yyvsp[-2].node,yyvsp[0].stat);
     1793#line 474 "grammar.y"
     1794{ yyval.stat = new ForInNode(*yyvsp[-4].ident,0,yyvsp[-2].node,yyvsp[0].stat);
    17931795                                     DBG(yyval.stat,yylsp[-7],yylsp[-1]); ;
    17941796    break;}
    17951797case 148:
    1796 #line 473 "grammar.y"
     1798#line 477 "grammar.y"
    17971799{ yyval.stat = new ForInNode(*yyvsp[-5].ident,yyvsp[-4].init,yyvsp[-2].node,yyvsp[0].stat);
    17981800                                     DBG(yyval.stat,yylsp[-8],yylsp[-1]); ;
    17991801    break;}
    18001802case 149:
    1801 #line 478 "grammar.y"
    1802 { yyval.node = 0L; ;
     1803#line 482 "grammar.y"
     1804{ yyval.node = 0; ;
    18031805    break;}
    18041806case 151:
    1805 #line 483 "grammar.y"
     1807#line 487 "grammar.y"
    18061808{ yyval.stat = new ContinueNode(); DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
    18071809    break;}
    18081810case 152:
    1809 #line 484 "grammar.y"
     1811#line 488 "grammar.y"
    18101812{ if (automatic()) {
    18111813                                       yyval.stat = new ContinueNode(); DBG(yyval.stat,yylsp[-1],yylsp[0]);
     
    18141816    break;}
    18151817case 153:
    1816 #line 488 "grammar.y"
     1818#line 492 "grammar.y"
    18171819{ yyval.stat = new ContinueNode(*yyvsp[-1].ident); DBG(yyval.stat,yylsp[-2],yylsp[0]); ;
    18181820    break;}
    18191821case 154:
    1820 #line 489 "grammar.y"
     1822#line 493 "grammar.y"
    18211823{ if (automatic()) {
    18221824                                       yyval.stat = new ContinueNode(*yyvsp[-1].ident);DBG(yyval.stat,yylsp[-2],yylsp[-1]);
     
    18251827    break;}
    18261828case 155:
    1827 #line 496 "grammar.y"
     1829#line 500 "grammar.y"
    18281830{ yyval.stat = new BreakNode();DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
    18291831    break;}
    18301832case 156:
    1831 #line 497 "grammar.y"
     1833#line 501 "grammar.y"
    18321834{ if (automatic()) {
    18331835                                       yyval.stat = new BreakNode(); DBG(yyval.stat,yylsp[-1],yylsp[-1]);
     
    18361838    break;}
    18371839case 157:
    1838 #line 501 "grammar.y"
     1840#line 505 "grammar.y"
    18391841{ yyval.stat = new BreakNode(*yyvsp[-1].ident); DBG(yyval.stat,yylsp[-2],yylsp[0]); ;
    18401842    break;}
    18411843case 158:
    1842 #line 502 "grammar.y"
     1844#line 506 "grammar.y"
    18431845{ if (automatic()) {
    18441846                                       yyval.stat = new BreakNode(*yyvsp[-1].ident); DBG(yyval.stat,yylsp[-2],yylsp[-1]);
     
    18481850    break;}
    18491851case 159:
    1850 #line 510 "grammar.y"
    1851 { yyval.stat = new ReturnNode(0L); DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
     1852#line 514 "grammar.y"
     1853{ yyval.stat = new ReturnNode(0); DBG(yyval.stat,yylsp[-1],yylsp[0]); ;
    18521854    break;}
    18531855case 160:
    1854 #line 511 "grammar.y"
     1856#line 515 "grammar.y"
    18551857{ if (automatic()) {
    1856                                        yyval.stat = new ReturnNode(0L); DBG(yyval.stat,yylsp[-1],yylsp[-1]);
     1858                                       yyval.stat = new ReturnNode(0); DBG(yyval.stat,yylsp[-1],yylsp[-1]);
    18571859                                     } else
    18581860                                       YYABORT; ;
    18591861    break;}
    18601862case 161:
    1861 #line 515 "grammar.y"
     1863#line 519 "grammar.y"
    18621864{ yyval.stat = new ReturnNode(yyvsp[-1].node); ;
    18631865    break;}
    18641866case 162:
    1865 #line 516 "grammar.y"
     1867#line 520 "grammar.y"
    18661868{ if (automatic())
    18671869                                       yyval.stat = new ReturnNode(yyvsp[-1].node);
     
    18701872    break;}
    18711873case 163:
    1872 #line 523 "grammar.y"
     1874#line 527 "grammar.y"
    18731875{ yyval.stat = new WithNode(yyvsp[-2].node,yyvsp[0].stat);
    18741876                                     DBG(yyval.stat, yylsp[-4], yylsp[-1]); ;
    18751877    break;}
    18761878case 164:
    1877 #line 528 "grammar.y"
     1879#line 532 "grammar.y"
    18781880{ yyval.stat = new SwitchNode(yyvsp[-2].node, yyvsp[0].cblk);
    18791881                                     DBG(yyval.stat, yylsp[-4], yylsp[-1]); ;
    18801882    break;}
    18811883case 165:
    1882 #line 533 "grammar.y"
    1883 { yyval.cblk = new CaseBlockNode(yyvsp[-1].clist, 0L, 0L); ;
     1884#line 537 "grammar.y"
     1885{ yyval.cblk = new CaseBlockNode(yyvsp[-1].clist, 0, 0); ;
    18841886    break;}
    18851887case 166:
    1886 #line 535 "grammar.y"
     1888#line 539 "grammar.y"
    18871889{ yyval.cblk = new CaseBlockNode(yyvsp[-3].clist, yyvsp[-2].ccl, yyvsp[-1].clist); ;
    18881890    break;}
    18891891case 167:
    1890 #line 539 "grammar.y"
    1891 { yyval.clist = 0L; ;
     1892#line 543 "grammar.y"
     1893{ yyval.clist = 0; ;
    18921894    break;}
    18931895case 169:
    1894 #line 544 "grammar.y"
     1896#line 548 "grammar.y"
    18951897{ yyval.clist = new ClauseListNode(yyvsp[0].ccl); ;
    18961898    break;}
    18971899case 170:
    1898 #line 545 "grammar.y"
     1900#line 549 "grammar.y"
    18991901{ yyval.clist = new ClauseListNode(yyvsp[-1].clist, yyvsp[0].ccl); ;
    19001902    break;}
    19011903case 171:
    1902 #line 549 "grammar.y"
    1903 { yyval.ccl = new CaseClauseNode(yyvsp[-1].node, 0L); ;
     1904#line 553 "grammar.y"
     1905{ yyval.ccl = new CaseClauseNode(yyvsp[-1].node); ;
    19041906    break;}
    19051907case 172:
    1906 #line 550 "grammar.y"
     1908#line 554 "grammar.y"
    19071909{ yyval.ccl = new CaseClauseNode(yyvsp[-2].node, yyvsp[0].slist); ;
    19081910    break;}
    19091911case 173:
    1910 #line 554 "grammar.y"
    1911 { yyval.ccl = new CaseClauseNode(0L, 0L);; ;
     1912#line 558 "grammar.y"
     1913{ yyval.ccl = new CaseClauseNode(0); ;
    19121914    break;}
    19131915case 174:
    1914 #line 555 "grammar.y"
    1915 { yyval.ccl = new CaseClauseNode(0L, yyvsp[0].slist); ;
     1916#line 559 "grammar.y"
     1917{ yyval.ccl = new CaseClauseNode(0, yyvsp[0].slist); ;
    19161918    break;}
    19171919case 175:
    1918 #line 559 "grammar.y"
     1920#line 563 "grammar.y"
    19191921{ yyvsp[0].stat->pushLabel(*yyvsp[-2].ident);
    19201922                                     yyval.stat = new LabelNode(*yyvsp[-2].ident, yyvsp[0].stat); ;
    19211923    break;}
    19221924case 176:
    1923 #line 564 "grammar.y"
     1925#line 568 "grammar.y"
    19241926{ yyval.stat = new ThrowNode(yyvsp[-1].node); ;
    19251927    break;}
    19261928case 177:
    1927 #line 568 "grammar.y"
    1928 { yyval.stat = new TryNode(yyvsp[-1].stat, yyvsp[0].node); ;
     1929#line 572 "grammar.y"
     1930{ yyval.stat = new TryNode(yyvsp[-1].stat, yyvsp[0].cnode); ;
    19291931    break;}
    19301932case 178:
    1931 #line 569 "grammar.y"
    1932 { yyval.stat = new TryNode(yyvsp[-1].stat, 0L, yyvsp[0].node); ;
     1933#line 573 "grammar.y"
     1934{ yyval.stat = new TryNode(yyvsp[-1].stat, yyvsp[0].fnode); ;
    19331935    break;}
    19341936case 179:
    1935 #line 570 "grammar.y"
    1936 { yyval.stat = new TryNode(yyvsp[-2].stat, yyvsp[-1].node, yyvsp[0].node); ;
     1937#line 574 "grammar.y"
     1938{ yyval.stat = new TryNode(yyvsp[-2].stat, yyvsp[-1].cnode, yyvsp[0].fnode); ;
    19371939    break;}
    19381940case 180:
    1939 #line 574 "grammar.y"
    1940 { yyval.node = new CatchNode(*yyvsp[-2].ident, yyvsp[0].stat); ;
     1941#line 578 "grammar.y"
     1942{ yyval.cnode = new CatchNode(*yyvsp[-2].ident, yyvsp[0].stat); ;
    19411943    break;}
    19421944case 181:
    1943 #line 578 "grammar.y"
    1944 { yyval.node = new FinallyNode(yyvsp[0].stat); ;
     1945#line 582 "grammar.y"
     1946{ yyval.fnode = new FinallyNode(yyvsp[0].stat); ;
    19451947    break;}
    19461948case 182:
    1947 #line 582 "grammar.y"
    1948 { yyval.func = new FuncDeclNode(*yyvsp[-3].ident, 0L, yyvsp[0].body); ;
     1949#line 586 "grammar.y"
     1950{ yyval.func = new FuncDeclNode(*yyvsp[-3].ident, yyvsp[0].body); ;
    19491951    break;}
    19501952case 183:
    1951 #line 584 "grammar.y"
     1953#line 588 "grammar.y"
    19521954{ yyval.func = new FuncDeclNode(*yyvsp[-4].ident, yyvsp[-2].param, yyvsp[0].body); ;
    19531955    break;}
    19541956case 184:
    1955 #line 587 "grammar.y"
    1956 { yyval.node = new FuncExprNode(0L, yyvsp[0].body); ;
     1957#line 591 "grammar.y"
     1958{ yyval.node = new FuncExprNode(yyvsp[0].body); ;
    19571959    break;}
    19581960case 185:
    1959 #line 589 "grammar.y"
     1961#line 593 "grammar.y"
    19601962{ yyval.node = new FuncExprNode(yyvsp[-2].param, yyvsp[0].body); ;
    19611963    break;}
    19621964case 186:
    1963 #line 594 "grammar.y"
     1965#line 598 "grammar.y"
    19641966{ yyval.param = new ParameterNode(*yyvsp[0].ident); ;
    19651967    break;}
    19661968case 187:
    1967 #line 595 "grammar.y"
     1969#line 599 "grammar.y"
    19681970{ yyval.param = new ParameterNode(yyvsp[-2].param, *yyvsp[0].ident); ;
    19691971    break;}
    19701972case 188:
    1971 #line 599 "grammar.y"
    1972 { yyval.body = new FunctionBodyNode(0L);
     1973#line 603 "grammar.y"
     1974{ yyval.body = new FunctionBodyNode(0);
    19731975                                     DBG(yyval.body, yylsp[-1], yylsp[0]);;
    19741976    break;}
    19751977case 189:
    1976 #line 601 "grammar.y"
     1978#line 605 "grammar.y"
    19771979{ yyval.body = new FunctionBodyNode(yyvsp[-1].srcs);
    19781980                                     DBG(yyval.body, yylsp[-2], yylsp[0]);;
    19791981    break;}
    19801982case 190:
    1981 #line 606 "grammar.y"
    1982 { yyval.prog = new ProgramNode(0L);
     1983#line 610 "grammar.y"
     1984{ yyval.prog = new ProgramNode(0);
    19831985                                     Parser::progNode = yyval.prog; ;
    19841986    break;}
    19851987case 191:
    1986 #line 608 "grammar.y"
     1988#line 612 "grammar.y"
    19871989{ yyval.prog = new ProgramNode(yyvsp[0].srcs);
    19881990                                     Parser::progNode = yyval.prog; ;
    19891991    break;}
    19901992case 192:
    1991 #line 613 "grammar.y"
     1993#line 617 "grammar.y"
    19921994{ yyval.srcs = new SourceElementsNode(yyvsp[0].stat); ;
    19931995    break;}
    19941996case 193:
    1995 #line 614 "grammar.y"
     1997#line 618 "grammar.y"
    19961998{ yyval.srcs = new SourceElementsNode(yyvsp[-1].srcs, yyvsp[0].stat); ;
    19971999    break;}
    19982000case 194:
    1999 #line 618 "grammar.y"
     2001#line 622 "grammar.y"
    20002002{ yyval.stat = yyvsp[0].stat; ;
    20012003    break;}
    20022004case 195:
    2003 #line 619 "grammar.y"
     2005#line 623 "grammar.y"
    20042006{ yyval.stat = yyvsp[0].func; ;
    20052007    break;}
     
    22272229  return 1;
    22282230}
    2229 #line 622 "grammar.y"
     2231#line 626 "grammar.y"
    22302232
    22312233
  • trunk/JavaScriptCore/kjs/grammar.cpp.h

    r3215 r5356  
    2424  PropertyValueNode   *plist;
    2525  PropertyNode        *pnode;
     26  CatchNode           *cnode;
     27  FinallyNode         *fnode;
    2628} YYSTYPE;
    2729
  • trunk/JavaScriptCore/kjs/grammar.h

    r3215 r5356  
    2424  PropertyValueNode   *plist;
    2525  PropertyNode        *pnode;
     26  CatchNode           *cnode;
     27  FinallyNode         *fnode;
    2628} YYSTYPE;
    2729
  • trunk/JavaScriptCore/kjs/grammar.y

    r5314 r5356  
    7878  PropertyValueNode   *plist;
    7979  PropertyNode        *pnode;
     80  CatchNode           *cnode;
     81  FinallyNode         *fnode;
    8082}
    8183
     
    131133%type <node>  ExprOpt
    132134%type <node>  CallExpr
    133 %type <node>  Catch Finally
     135
     136%type <cnode> Catch
     137%type <fnode> Finally
    134138
    135139%type <stat>  Statement Block
     
    184188  | ArrayLiteral
    185189  | '(' Expr ')'                   { $$ = new GroupNode($2); }
    186   | '{' '}'                        { $$ = new ObjectLiteralNode(0L); }
     190  | '{' '}'                        { $$ = new ObjectLiteralNode(); }
    187191  | '{' PropertyNameAndValueList '}'   { $$ = new ObjectLiteralNode($2); }
    188192;
     
    243247
    244248Arguments:
    245     '(' ')'                        { $$ = new ArgumentsNode(0L); }
     249    '(' ')'                        { $$ = new ArgumentsNode(); }
    246250  | '(' ArgumentList ')'           { $$ = new ArgumentsNode($2); }
    247251;
     
    399403
    400404Block:
    401     '{' '}'                        { $$ = new BlockNode(0L); DBG($$, @2, @2); }
     405    '{' '}'                        { $$ = new BlockNode(0); DBG($$, @2, @2); }
    402406  | '{' SourceElements '}'          { $$ = new BlockNode($2); DBG($$, @3, @3); }
    403407;
     
    450454
    451455IfStatement: /* shift/reduce conflict due to dangling else */
    452     IF '(' Expr ')' Statement      { $$ = new IfNode($3,$5,0L);DBG($$,@1,@4); }
     456    IF '(' Expr ')' Statement      { $$ = new IfNode($3,$5,0);DBG($$,@1,@4); }
    453457  | IF '(' Expr ')' Statement ELSE Statement
    454458                                   { $$ = new IfNode($3,$5,$7);DBG($$,@1,@4); }
     
    468472                                     DBG($$,@1,@6); }
    469473  | FOR '(' VAR IDENT IN Expr ')'
    470             Statement              { $$ = new ForInNode(*$4,0L,$6,$8);
     474            Statement              { $$ = new ForInNode(*$4,0,$6,$8);
    471475                                     DBG($$,@1,@7); }
    472476  | FOR '(' VAR IDENT Initializer IN Expr ')'
     
    476480
    477481ExprOpt:
    478     /* nothing */                  { $$ = 0L; }
     482    /* nothing */                  { $$ = 0; }
    479483  | Expr
    480484;
     
    508512
    509513ReturnStatement:
    510     RETURN ';'                     { $$ = new ReturnNode(0L); DBG($$,@1,@2); }
     514    RETURN ';'                     { $$ = new ReturnNode(0); DBG($$,@1,@2); }
    511515  | RETURN error                   { if (automatic()) {
    512                                        $$ = new ReturnNode(0L); DBG($$,@1,@1);
     516                                       $$ = new ReturnNode(0); DBG($$,@1,@1);
    513517                                     } else
    514518                                       YYABORT; }
     
    531535
    532536CaseBlock:
    533     '{' CaseClausesOpt '}'         { $$ = new CaseBlockNode($2, 0L, 0L); }
     537    '{' CaseClausesOpt '}'         { $$ = new CaseBlockNode($2, 0, 0); }
    534538  | '{' CaseClausesOpt DefaultClause CaseClausesOpt '}'
    535539                                   { $$ = new CaseBlockNode($2, $3, $4); }
     
    537541
    538542CaseClausesOpt:
    539     /* nothing */                  { $$ = 0L; }
     543    /* nothing */                  { $$ = 0; }
    540544  | CaseClauses
    541545;
     
    547551
    548552CaseClause:
    549     CASE Expr ':'                  { $$ = new CaseClauseNode($2, 0L); }
     553    CASE Expr ':'                  { $$ = new CaseClauseNode($2); }
    550554  | CASE Expr ':' StatementList    { $$ = new CaseClauseNode($2, $4); }
    551555;
    552556
    553557DefaultClause:
    554     DEFAULT ':'                    { $$ = new CaseClauseNode(0L, 0L);; }
    555   | DEFAULT ':' StatementList      { $$ = new CaseClauseNode(0L, $3); }
     558    DEFAULT ':'                    { $$ = new CaseClauseNode(0); }
     559  | DEFAULT ':' StatementList      { $$ = new CaseClauseNode(0, $3); }
    556560;
    557561
     
    567571TryStatement:
    568572    TRY Block Catch                { $$ = new TryNode($2, $3); }
    569   | TRY Block Finally              { $$ = new TryNode($2, 0L, $3); }
     573  | TRY Block Finally              { $$ = new TryNode($2, $3); }
    570574  | TRY Block Catch Finally        { $$ = new TryNode($2, $3, $4); }
    571575;
     
    580584
    581585FunctionDeclaration:
    582     FUNCTION IDENT '(' ')' FunctionBody    { $$ = new FuncDeclNode(*$2, 0L, $5); }
     586    FUNCTION IDENT '(' ')' FunctionBody    { $$ = new FuncDeclNode(*$2, $5); }
    583587  | FUNCTION IDENT '(' FormalParameterList ')' FunctionBody
    584588                                   { $$ = new FuncDeclNode(*$2, $4, $6); }
    585589
    586590FunctionExpr:
    587     FUNCTION '(' ')' FunctionBody  { $$ = new FuncExprNode(0L, $4); }
     591    FUNCTION '(' ')' FunctionBody  { $$ = new FuncExprNode($4); }
    588592  | FUNCTION '(' FormalParameterList ')' FunctionBody
    589593                                   { $$ = new FuncExprNode($3, $5); }
     
    597601
    598602FunctionBody:
    599     '{' '}'  /* TODO: spec ??? */  { $$ = new FunctionBodyNode(0L);
     603    '{' '}'  /* TODO: spec ??? */  { $$ = new FunctionBodyNode(0);
    600604                                     DBG($$, @1, @2);}
    601605  | '{' SourceElements '}'         { $$ = new FunctionBodyNode($2);
     
    604608
    605609Program:
    606     /* nothing, empty script */      { $$ = new ProgramNode(0L);
     610    /* nothing, empty script */      { $$ = new ProgramNode(0);
    607611                                     Parser::progNode = $$; }
    608612    | SourceElements                 { $$ = new ProgramNode($1);
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r5291 r5356  
    342342// ------------------------------ ArrayNode ------------------------------------
    343343
    344 void ArrayNode::reverseElementList()
    345 {
    346   ElementNode *head = 0;
    347   ElementNode *next;
    348   for (ElementNode *n = element; n; n = next) {
    349     next = n->list;
    350     n->list = head;
    351     head = n;
    352   }
    353   element = head;
    354 }
    355 
    356344void ArrayNode::ref()
    357345{
     
    391379
    392380// ------------------------------ ObjectLiteralNode ----------------------------
    393 
    394 void ObjectLiteralNode::reverseList()
    395 {
    396   PropertyValueNode *head = 0;
    397   PropertyValueNode *next;
    398   for (PropertyValueNode *n = list; n; n = next) {
    399     next = n->list;
    400     n->list = head;
    401     head = n;
    402   }
    403   list = head;
    404 }
    405381
    406382void ObjectLiteralNode::ref()
     
    561537// ------------------------------ ArgumentListNode -----------------------------
    562538
    563 ArgumentListNode::ArgumentListNode(Node *e) : list(0L), expr(e)
    564 {
    565 }
    566 
    567 ArgumentListNode::ArgumentListNode(ArgumentListNode *l, Node *e)
    568   : list(l), expr(e)
    569 {
    570 }
    571 
    572539void ArgumentListNode::ref()
    573540{
     
    613580
    614581// ------------------------------ ArgumentsNode --------------------------------
    615 
    616 void ArgumentsNode::reverseList()
    617 {
    618   ArgumentListNode *head = 0;
    619   ArgumentListNode *next;
    620   for (ArgumentListNode *n = list; n; n = next) {
    621     next = n->list;
    622     n->list = head;
    623     head = n;
    624   }
    625   list = head;
    626 }
    627582
    628583void ArgumentsNode::ref()
     
    15131468// ------------------------------ StatListNode ---------------------------------
    15141469
     1470StatListNode::StatListNode(StatementNode *s)
     1471  : statement(s), list(this)
     1472{
     1473  setLoc(s->firstLine(), s->lastLine(), s->sourceId());
     1474}
     1475 
     1476StatListNode::StatListNode(StatListNode *l, StatementNode *s)
     1477  : statement(s), list(l->list)
     1478{
     1479  l->list = this;
     1480  setLoc(l->firstLine(), s->lastLine(), l->sourceId());
     1481}
     1482
    15151483void StatListNode::ref()
    15161484{
     
    17011669// ------------------------------ VarStatementNode -----------------------------
    17021670
    1703 void VarStatementNode::reverseList()
    1704 {
    1705   VarDeclListNode *head = 0;
    1706   VarDeclListNode *next;
    1707   for (VarDeclListNode *n = list; n; n = next) {
    1708     next = n->list;
    1709     n->list = head;
    1710     head = n;
    1711   }
    1712   list = head;
    1713 }
    1714 
    17151671void VarStatementNode::ref()
    17161672{
     
    17451701// ------------------------------ BlockNode ------------------------------------
    17461702
    1747 void BlockNode::reverseList()
    1748 {
    1749   SourceElementsNode *head = 0;
    1750   SourceElementsNode *next;
    1751   for (SourceElementsNode *n = source; n; n = next) {
    1752     next = n->elements;
    1753     n->elements = head;
    1754     head = n;
    1755   }
    1756   source = head;
     1703BlockNode::BlockNode(SourceElementsNode *s)
     1704{
     1705  if (s) {
     1706    source = s->elements;
     1707    s->elements = 0;
     1708    setLoc(s->firstLine(), s->lastLine(), s->sourceId());
     1709  } else {
     1710    source = 0;
     1711  }
    17571712}
    17581713
     
    19881943
    19891944// ------------------------------ ForNode --------------------------------------
    1990 
    1991 VarDeclListNode *ForNode::reverseList(VarDeclListNode *list)
    1992 {
    1993   VarDeclListNode *head = 0;
    1994   VarDeclListNode *next;
    1995   for (VarDeclListNode *n = list; n; n = next) {
    1996     next = n->list;
    1997     n->list = head;
    1998     head = n;
    1999   }
    2000   return head;
    2001 }
    20021945
    20031946void ForNode::ref()
     
    22752218// ------------------------------ CaseClauseNode -------------------------------
    22762219
    2277 void CaseClauseNode::reverseList()
    2278 {
    2279   StatListNode *head = 0;
    2280   StatListNode *next;
    2281   for (StatListNode *n = list; n; n = next) {
    2282     next = n->list;
    2283     n->list = head;
    2284     head = n;
    2285   }
    2286   list = head;
    2287 }
    2288 
    22892220void CaseClauseNode::ref()
    22902221{
     
    23702301// ------------------------------ CaseBlockNode --------------------------------
    23712302
    2372 void CaseBlockNode::reverseLists()
    2373 {
    2374   ClauseListNode *head = 0;
    2375   ClauseListNode *next;
    2376   for (ClauseListNode *n = list1; n; n = next) {
    2377     next = n->nx;
    2378     n->nx = head;
    2379     head = n;
    2380   }
    2381   list1 = head;
    2382  
    2383   head = 0;
    2384   for (ClauseListNode *n = list2; n; n = next) {
    2385     next = n->nx;
    2386     n->nx = head;
    2387     head = n;
    2388   }
    2389   list2 = head;
    2390 }
    2391 
     2303CaseBlockNode::CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d,
     2304                             ClauseListNode *l2)
     2305{
     2306  if (l1) {
     2307    list1 = l1->nx;
     2308    l1->nx = 0;
     2309  } else {
     2310    list1 = 0;
     2311  }
     2312
     2313  def = d;
     2314
     2315  if (l2) {
     2316    list2 = l2->nx;
     2317    l2->nx = 0;
     2318  } else {
     2319    list2 = 0;
     2320  }
     2321}
     2322 
    23922323void CaseBlockNode::ref()
    23932324{
     
    27732704// ------------------------------ FuncDeclNode ---------------------------------
    27742705
    2775 void FuncDeclNode::reverseParameterList()
    2776 {
    2777   ParameterNode *head = 0;
    2778   ParameterNode *next;
    2779   for (ParameterNode *n = param; n; n = next) {
    2780     next = n->next;
    2781     n->next = head;
    2782     head = n;
    2783   }
    2784   param = head;
    2785 }
    2786 
    27872706void FuncDeclNode::ref()
    27882707{
     
    28382757// ------------------------------ FuncExprNode ---------------------------------
    28392758
    2840 void FuncExprNode::reverseParameterList()
    2841 {
    2842   ParameterNode *head = 0;
    2843   ParameterNode *next;
    2844   for (ParameterNode *n = param; n; n = next) {
    2845     next = n->next;
    2846     n->next = head;
    2847     head = n;
    2848   }
    2849   param = head;
    2850 }
    2851 
    28522759void FuncExprNode::ref()
    28532760{
     
    28862793
    28872794// ------------------------------ SourceElementsNode ---------------------------
     2795
     2796SourceElementsNode::SourceElementsNode(StatementNode *s1)
     2797  : element(s1), elements(this)
     2798{
     2799  setLoc(s1->firstLine(), s1->lastLine(), s1->sourceId());
     2800}
     2801 
     2802SourceElementsNode::SourceElementsNode(SourceElementsNode *s1, StatementNode *s2)
     2803  : element(s2), elements(s1->elements)
     2804{
     2805  s1->elements = this;
     2806  setLoc(s1->firstLine(), s2->lastLine(), s1->sourceId());
     2807}
    28882808
    28892809void SourceElementsNode::ref()
  • trunk/JavaScriptCore/kjs/nodes.h

    r5209 r5356  
    210210  class ElementNode : public Node {
    211211  public:
    212     ElementNode(int e, Node *n) : list(0L), elision(e), node(n) { }
     212    // list pointer is tail of a circular list, cracked in the ArrayNode ctor
     213    ElementNode(int e, Node *n) : list(this), elision(e), node(n) { }
    213214    ElementNode(ElementNode *l, int e, Node *n)
    214       : list(l), elision(e), node(n) { }
     215      : list(l->list), elision(e), node(n) { l->list = this; }
    215216    virtual void ref();
    216217    virtual bool deref();
     
    226227  class ArrayNode : public Node {
    227228  public:
    228     ArrayNode(int e) : element(0L), elision(e), opt(true) { }
     229    ArrayNode(int e) : element(0), elision(e), opt(true) { }
    229230    ArrayNode(ElementNode *ele)
    230       : element(ele), elision(0), opt(false) { reverseElementList(); }
     231      : element(ele->list), elision(0), opt(false) { ele->list = 0; }
    231232    ArrayNode(int eli, ElementNode *ele)
    232       : element(ele), elision(eli), opt(true) { reverseElementList(); }
    233     virtual void ref();
    234     virtual bool deref();
    235     Value evaluate(ExecState *exec);
    236     virtual void streamTo(SourceStream &s) const;
    237   private:
    238     void reverseElementList();
     233      : element(ele->list), elision(eli), opt(true) { ele->list = 0; }
     234    virtual void ref();
     235    virtual bool deref();
     236    Value evaluate(ExecState *exec);
     237    virtual void streamTo(SourceStream &s) const;
     238  private:
    239239    ElementNode *element;
    240240    int elision;
     
    242242  };
    243243
    244   class ObjectLiteralNode : public Node {
    245   public:
    246     ObjectLiteralNode(PropertyValueNode *l) : list(l) { reverseList(); }
    247     virtual void ref();
    248     virtual bool deref();
    249     Value evaluate(ExecState *exec);
    250     virtual void streamTo(SourceStream &s) const;
    251   private:
    252     void reverseList();
    253     PropertyValueNode *list;
    254   };
    255 
    256244  class PropertyValueNode : public Node {
    257245  public:
    258     PropertyValueNode(PropertyNode *n, Node *a, PropertyValueNode *l = 0L)
    259       : name(n), assign(a), list(l) { }
     246    // list pointer is tail of a circular list, cracked in the ObjectLiteralNode ctor
     247    PropertyValueNode(PropertyNode *n, Node *a)
     248      : name(n), assign(a), list(this) { }
     249    PropertyValueNode(PropertyNode *n, Node *a, PropertyValueNode *l)
     250      : name(n), assign(a), list(l->list) { l->list = this; }
    260251    virtual void ref();
    261252    virtual bool deref();
     
    269260  };
    270261
     262  class ObjectLiteralNode : public Node {
     263  public:
     264    ObjectLiteralNode() : list(0) { }
     265    ObjectLiteralNode(PropertyValueNode *l) : list(l->list) { l->list = 0; }
     266    virtual void ref();
     267    virtual bool deref();
     268    Value evaluate(ExecState *exec);
     269    virtual void streamTo(SourceStream &s) const;
     270  private:
     271    PropertyValueNode *list;
     272  };
     273
    271274  class PropertyNode : public Node {
    272275  public:
     
    308311  class ArgumentListNode : public Node {
    309312  public:
    310     ArgumentListNode(Node *e);
    311     ArgumentListNode(ArgumentListNode *l, Node *e);
     313    // list pointer is tail of a circular list, cracked in the ArgumentsNode ctor
     314    ArgumentListNode(Node *e) : list(this), expr(e) { }
     315    ArgumentListNode(ArgumentListNode *l, Node *e)
     316      : list(l->list), expr(e) { l->list = this; }
    312317    virtual void ref();
    313318    virtual bool deref();
     
    323328  class ArgumentsNode : public Node {
    324329  public:
    325     ArgumentsNode(ArgumentListNode *l) : list(l) { reverseList(); }
     330    ArgumentsNode() : list(0) { }
     331    ArgumentsNode(ArgumentListNode *l)
     332      : list(l->list) { l->list = 0; }
    326333    virtual void ref();
    327334    virtual bool deref();
     
    330337    virtual void streamTo(SourceStream &s) const;
    331338  private:
    332     void reverseList();
    333339    ArgumentListNode *list;
    334340  };
     
    336342  class NewExprNode : public Node {
    337343  public:
    338     NewExprNode(Node *e) : expr(e), args(0L) {}
     344    NewExprNode(Node *e) : expr(e), args(0) {}
    339345    NewExprNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
    340346    virtual void ref();
     
    593599  class StatListNode : public StatementNode {
    594600  public:
    595     StatListNode(StatementNode *s) : statement(s), list(0L) { }
    596     StatListNode(StatListNode *l, StatementNode *s) : statement(s), list(l) { }
     601    // list pointer is tail of a circular list, cracked in the CaseClauseNode ctor
     602    StatListNode(StatementNode *s);
     603    StatListNode(StatListNode *l, StatementNode *s);
    597604    virtual void ref();
    598605    virtual bool deref();
     
    632639  class VarDeclListNode : public Node {
    633640  public:
    634     VarDeclListNode(VarDeclNode *v) : list(0L), var(v) {}
    635     VarDeclListNode(VarDeclListNode *l, VarDeclNode *v) : list(l), var(v) {}
     641    // list pointer is tail of a circular list, cracked in the ForNode/VarStatementNode ctor
     642    VarDeclListNode(VarDeclNode *v) : list(this), var(v) {}
     643    VarDeclListNode(VarDeclListNode *l, VarDeclNode *v)
     644      : list(l->list), var(v) { l->list = this; }
    636645    virtual void ref();
    637646    virtual bool deref();
     
    648657  class VarStatementNode : public StatementNode {
    649658  public:
    650     VarStatementNode(VarDeclListNode *l) : list(l) { reverseList(); }
    651     virtual void ref();
    652     virtual bool deref();
    653     virtual Completion execute(ExecState *exec);
    654     virtual void processVarDecls(ExecState *exec);
    655     virtual void streamTo(SourceStream &s) const;
    656   private:
    657     void reverseList();
     659    VarStatementNode(VarDeclListNode *l)
     660      : list(l->list) { l->list = 0; }
     661    virtual void ref();
     662    virtual bool deref();
     663    virtual Completion execute(ExecState *exec);
     664    virtual void processVarDecls(ExecState *exec);
     665    virtual void streamTo(SourceStream &s) const;
     666  private:
    658667    VarDeclListNode *list;
    659668  };
     
    661670  class BlockNode : public StatementNode {
    662671  public:
    663     BlockNode(SourceElementsNode *s) : source(s) { reverseList(); }
     672    BlockNode(SourceElementsNode *s);
    664673    virtual void ref();
    665674    virtual bool deref();
     
    668677    virtual void streamTo(SourceStream &s) const;
    669678  protected:
    670     void reverseList();
    671679    SourceElementsNode *source;
    672680  };
     
    735743      expr1(e1), expr2(e2), expr3(e3), statement(s) {}
    736744    ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) :
    737       expr1(reverseList(e1)), expr2(e2), expr3(e3), statement(s) {}
    738     virtual void ref();
    739     virtual bool deref();
    740     virtual Completion execute(ExecState *exec);
    741     virtual void processVarDecls(ExecState *exec);
    742     virtual void streamTo(SourceStream &s) const;
    743   private:
    744     static VarDeclListNode *reverseList(VarDeclListNode *);
     745      expr1(e1->list), expr2(e2), expr3(e3), statement(s) { e1->list = 0; }
     746    virtual void ref();
     747    virtual bool deref();
     748    virtual Completion execute(ExecState *exec);
     749    virtual void processVarDecls(ExecState *exec);
     750    virtual void streamTo(SourceStream &s) const;
     751  private:
    745752    Node *expr1, *expr2, *expr3;
    746753    StatementNode *statement;
     
    808815  };
    809816
    810   class CaseClauseNode: public Node {
    811   public:
    812     CaseClauseNode(Node *e, StatListNode *l) : expr(e), list(l) { reverseList(); }
     817  class CaseClauseNode : public Node {
     818  public:
     819    CaseClauseNode(Node *e) : expr(e), list(0) { }
     820    CaseClauseNode(Node *e, StatListNode *l)
     821      : expr(e), list(l->list) { l->list = 0; }
    813822    virtual void ref();
    814823    virtual bool deref();
     
    818827    virtual void streamTo(SourceStream &s) const;
    819828  private:
    820     void reverseList();
    821829    Node *expr;
    822830    StatListNode *list;
     
    825833  class ClauseListNode : public Node {
    826834  public:
    827     ClauseListNode(CaseClauseNode *c) : cl(c), nx(0L) { }
    828     ClauseListNode(ClauseListNode *n, CaseClauseNode *c) : cl(c), nx(n) { }
     835    // list pointer is tail of a circular list, cracked in the CaseBlockNode ctor
     836    ClauseListNode(CaseClauseNode *c) : cl(c), nx(this) { }
     837    ClauseListNode(ClauseListNode *n, CaseClauseNode *c)
     838      : cl(c), nx(n->nx) { n->nx = this; }
    829839    virtual void ref();
    830840    virtual bool deref();
     
    840850  };
    841851
    842   class CaseBlockNode: public Node {
    843   public:
    844     CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2)
    845       : list1(l1), def(d), list2(l2) { reverseLists(); }
     852  class CaseBlockNode : public Node {
     853  public:
     854    CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2);
    846855    virtual void ref();
    847856    virtual bool deref();
     
    851860    virtual void streamTo(SourceStream &s) const;
    852861  private:
    853     void reverseLists();
    854862    ClauseListNode *list1;
    855863    CaseClauseNode *def;
     
    922930  class TryNode : public StatementNode {
    923931  public:
    924     TryNode(StatementNode *b, Node *c = 0L, Node *f = 0L)
    925       : block(b), _catch((CatchNode*)c), _final((FinallyNode*)f) {}
     932    TryNode(StatementNode *b, CatchNode *c)
     933      : block(b), _catch(c), _final(0) {}
     934    TryNode(StatementNode *b, FinallyNode *f)
     935      : block(b), _catch(0), _final(f) {}
     936    TryNode(StatementNode *b, CatchNode *c, FinallyNode *f)
     937      : block(b), _catch(c), _final(f) {}
    926938    virtual void ref();
    927939    virtual bool deref();
     
    937949  class ParameterNode : public Node {
    938950  public:
    939     ParameterNode(const Identifier &i) : id(i), next(0L) { }
    940     ParameterNode(ParameterNode *list, const Identifier &i) : id(i), next(list) { }
     951    // list pointer is tail of a circular list, cracked in the FuncDeclNode/FuncExprNode ctor
     952    ParameterNode(const Identifier &i) : id(i), next(this) { }
     953    ParameterNode(ParameterNode *list, const Identifier &i)
     954      : id(i), next(list->next) { list->next = this; }
    941955    virtual void ref();
    942956    virtual bool deref();
     
    961975  class FuncDeclNode : public StatementNode {
    962976  public:
     977    FuncDeclNode(const Identifier &i, FunctionBodyNode *b)
     978      : ident(i), param(0), body(b) { }
    963979    FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b)
    964       : ident(i), param(p), body(b) { reverseParameterList(); }
     980      : ident(i), param(p->next), body(b) { p->next = 0; }
    965981    virtual void ref();
    966982    virtual bool deref();
     
    970986    virtual void streamTo(SourceStream &s) const;
    971987  private:
    972     void reverseParameterList();
    973988    Identifier ident;
    974989    ParameterNode *param;
     
    978993  class FuncExprNode : public Node {
    979994  public:
     995    FuncExprNode(FunctionBodyNode *b) : param(0), body(b) { }
    980996    FuncExprNode(ParameterNode *p, FunctionBodyNode *b)
    981         : param(p), body(b) { reverseParameterList(); }
    982     virtual void ref();
    983     virtual bool deref();
    984     Value evaluate(ExecState *exec);
    985     virtual void streamTo(SourceStream &s) const;
    986   private:
    987     void reverseParameterList();
     997      : param(p->next), body(b) { p->next = 0; }
     998    virtual void ref();
     999    virtual bool deref();
     1000    Value evaluate(ExecState *exec);
     1001    virtual void streamTo(SourceStream &s) const;
     1002  private:
    9881003    ParameterNode *param;
    9891004    FunctionBodyNode *body;
     
    9931008  class SourceElementsNode : public StatementNode {
    9941009  public:
    995     SourceElementsNode(StatementNode *s1) { element = s1; elements = 0L; }
    996     SourceElementsNode(SourceElementsNode *s1, StatementNode *s2)
    997       { elements = s1; element = s2; }
     1010    // list pointer is tail of a circular list, cracked in the BlockNode (or subclass) ctor
     1011    SourceElementsNode(StatementNode *s1);
     1012    SourceElementsNode(SourceElementsNode *s1, StatementNode *s2);
    9981013    virtual void ref();
    9991014    virtual bool deref();
Note: See TracChangeset for help on using the changeset viewer.