Changeset 10352 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Aug 26, 2005, 4:42:16 PM (20 years ago)
Author:
mjs
Message:

Reviewed by John.

  • fixed <rdar://problem/4232452> many many leaks in kjsyyparse on some well-formed JavaScript (can repro on sony.com, webkit tests)

Fixed by changing the refcounting scheme for nodes. Instead of each node implementing a custom ref and
deref for all its children (and being responsible for deleting them), nodes use a smart pointer to
hold their children, and smart pointers are used outside the node tree as well. This change mostly
removes code.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/function.cpp: (KJS::DeclaredFunctionImp::DeclaredFunctionImp): (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function.h:
  • kjs/function_object.cpp: (FunctionObjectImp::construct):
  • kjs/grammar.y:
  • kjs/internal.cpp: (KJS::Parser::parse): (KJS::Parser::accept): (KJS::InterpreterImp::checkSyntax): (KJS::InterpreterImp::evaluate):
  • kjs/internal.h:
  • kjs/nodes.cpp: (Node::Node): (Node::~Node): (ElementNode::evaluate): (PropertyValueNode::evaluate): (ArgumentListNode::evaluateList): (NewExprNode::evaluate): (FunctionCallValueNode::evaluate): (FunctionCallBracketNode::evaluate): (FunctionCallDotNode::evaluate): (RelationalNode::evaluate): (StatListNode::execute): (StatListNode::processVarDecls): (VarDeclListNode::evaluate): (VarDeclListNode::processVarDecls): (ForInNode::ForInNode): (ClauseListNode::processVarDecls): (CaseBlockNode::evalBlock): (FuncDeclNode::processFuncDecl): (FuncExprNode::evaluate): (SourceElementsNode::execute): (SourceElementsNode::processFuncDecl): (SourceElementsNode::processVarDecls):
  • kjs/nodes.h: (KJS::Node::ref): (KJS::Node::deref): (KJS::NumberNode::NumberNode): (KJS::GroupNode::GroupNode): (KJS::ElementNode::ElementNode): (KJS::ArrayNode::ArrayNode): (KJS::PropertyValueNode::PropertyValueNode): (KJS::ObjectLiteralNode::ObjectLiteralNode): (KJS::BracketAccessorNode::BracketAccessorNode): (KJS::DotAccessorNode::DotAccessorNode): (KJS::ArgumentListNode::ArgumentListNode): (KJS::ArgumentsNode::ArgumentsNode): (KJS::NewExprNode::NewExprNode): (KJS::FunctionCallValueNode::FunctionCallValueNode): (KJS::FunctionCallResolveNode::FunctionCallResolveNode): (KJS::FunctionCallBracketNode::FunctionCallBracketNode): (KJS::FunctionCallDotNode::FunctionCallDotNode): (KJS::PostfixNode::PostfixNode): (KJS::DeleteNode::DeleteNode): (KJS::VoidNode::VoidNode): (KJS::TypeOfNode::TypeOfNode): (KJS::PrefixNode::PrefixNode): (KJS::UnaryPlusNode::UnaryPlusNode): (KJS::NegateNode::NegateNode): (KJS::BitwiseNotNode::BitwiseNotNode): (KJS::LogicalNotNode::LogicalNotNode): (KJS::MultNode::MultNode): (KJS::AddNode::AddNode): (KJS::ShiftNode::ShiftNode): (KJS::RelationalNode::RelationalNode): (KJS::EqualNode::EqualNode): (KJS::BitOperNode::BitOperNode): (KJS::BinaryLogicalNode::BinaryLogicalNode): (KJS::ConditionalNode::ConditionalNode): (KJS::AssignResolveNode::AssignResolveNode): (KJS::AssignBracketNode::AssignBracketNode): (KJS::AssignDotNode::AssignDotNode): (KJS::CommaNode::CommaNode): (KJS::AssignExprNode::AssignExprNode): (KJS::VarDeclListNode::VarDeclListNode): (KJS::VarStatementNode::VarStatementNode): (KJS::ExprStatementNode::ExprStatementNode): (KJS::IfNode::IfNode): (KJS::DoWhileNode::DoWhileNode): (KJS::WhileNode::WhileNode): (KJS::ForNode::ForNode): (KJS::ReturnNode::ReturnNode): (KJS::WithNode::WithNode): (KJS::CaseClauseNode::CaseClauseNode): (KJS::ClauseListNode::ClauseListNode): (KJS::ClauseListNode::clause): (KJS::ClauseListNode::next): (KJS::SwitchNode::SwitchNode): (KJS::LabelNode::LabelNode): (KJS::ThrowNode::ThrowNode): (KJS::CatchNode::CatchNode): (KJS::FinallyNode::FinallyNode): (KJS::TryNode::TryNode): (KJS::ParameterNode::ParameterNode): (KJS::ParameterNode::nextParam): (KJS::FuncDeclNode::FuncDeclNode): (KJS::FuncExprNode::FuncExprNode):
  • kjs/nodes2string.cpp: (KJS::SourceStream::operator<<): (ElementNode::streamTo): (PropertyValueNode::streamTo): (ArgumentListNode::streamTo): (StatListNode::streamTo): (VarDeclListNode::streamTo): (CaseBlockNode::streamTo): (ParameterNode::streamTo): (SourceElementsNode::streamTo):
  • kjs/shared_ptr.h: Added. (kxmlcore::SharedPtr::SharedPtr): (kxmlcore::SharedPtr::~SharedPtr): (kxmlcore::SharedPtr::isNull): (kxmlcore::SharedPtr::notNull): (kxmlcore::SharedPtr::reset): (kxmlcore::SharedPtr::get): (kxmlcore::SharedPtr::operator*): (kxmlcore::SharedPtr::operator->): (kxmlcore::SharedPtr::operator!): (kxmlcore::SharedPtr::operator bool): (kxmlcore::SharedPtr::operator==): (kxmlcore::::operator): (kxmlcore::operator!=): (kxmlcore::static_pointer_cast): (kxmlcore::const_pointer_cast):
File:
1 edited

Legend:

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

    r10258 r10352  
    9999  line = Lexer::curr()->lineNo();
    100100  sourceURL = Lexer::curr()->sourceURL();
    101   refcount = 0;
    102 #ifdef KJS_DEBUG_MEM
    103   if (!s_nodes)
    104     s_nodes = new std::list<Node *>;
    105   s_nodes->push_back(this);
    106 #endif
     101  m_refcount = 0;
    107102}
    108103
    109104Node::~Node()
    110105{
    111 #ifdef KJS_DEBUG_MEM
    112   s_nodes->remove( this );
    113 #endif
    114106}
    115107
     
    337329// ------------------------------ GroupNode ------------------------------------
    338330
    339 void GroupNode::ref()
    340 {
    341   Node::ref();
    342   if ( group )
    343     group->ref();
    344 }
    345 
    346 bool GroupNode::deref()
    347 {
    348   if ( group && group->deref() )
    349     delete group;
    350   return Node::deref();
    351 }
    352 
    353331// ECMA 11.1.6
    354332ValueImp *GroupNode::evaluate(ExecState *exec)
     
    364342// ------------------------------ ElementNode ----------------------------------
    365343
    366 void ElementNode::ref()
    367 {
    368   for (ElementNode *n = this; n; n = n->list) {
    369     n->Node::ref();
    370     if (n->node)
    371       n->node->ref();
    372   }
    373 }
    374 
    375 bool ElementNode::deref()
    376 {
    377   ElementNode *next;
    378   for (ElementNode *n = this; n; n = next) {
    379     next = n->list;
    380     if (n->node && n->node->deref())
    381       delete n->node;
    382     if (n != this && n->Node::deref())
    383       delete n;
    384   }
    385   return Node::deref();
    386 }
    387 
    388344// ECMA 11.1.4
    389345ValueImp *ElementNode::evaluate(ExecState *exec)
     
    391347  ObjectImp *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty());
    392348  int length = 0;
    393   for (ElementNode *n = this; n; n = n->list) {
     349  for (ElementNode *n = this; n; n = n->list.get()) {
    394350    ValueImp *val = n->node->evaluate(exec);
    395351    KJS_CHECKEXCEPTIONVALUE
     
    401357
    402358// ------------------------------ ArrayNode ------------------------------------
    403 
    404 void ArrayNode::ref()
    405 {
    406   Node::ref();
    407   if ( element )
    408     element->ref();
    409 }
    410 
    411 bool ArrayNode::deref()
    412 {
    413   if ( element && element->deref() )
    414     delete element;
    415   return Node::deref();
    416 }
    417359
    418360// ECMA 11.1.4
     
    440382// ------------------------------ ObjectLiteralNode ----------------------------
    441383
    442 void ObjectLiteralNode::ref()
    443 {
    444   Node::ref();
    445   if ( list )
    446     list->ref();
    447 }
    448 
    449 bool ObjectLiteralNode::deref()
    450 {
    451   if ( list && list->deref() )
    452     delete list;
    453   return Node::deref();
    454 }
    455 
    456384// ECMA 11.1.5
    457385ValueImp *ObjectLiteralNode::evaluate(ExecState *exec)
     
    465393// ------------------------------ PropertyValueNode ----------------------------
    466394
    467 void PropertyValueNode::ref()
    468 {
    469   for (PropertyValueNode *n = this; n; n = n->list) {
    470     n->Node::ref();
    471     if (n->name)
    472       n->name->ref();
    473     if (n->assign)
    474       n->assign->ref();
    475   }
    476 }
    477 
    478 bool PropertyValueNode::deref()
    479 {
    480   PropertyValueNode *next;
    481   for (PropertyValueNode *n = this; n; n = next) {
    482     next = n->list;
    483     if ( n->name && n->name->deref() )
    484       delete n->name;
    485     if ( n->assign && n->assign->deref() )
    486       delete n->assign;
    487     if (n != this && n->Node::deref() )
    488       delete n;
    489   }
    490   return Node::deref();
    491 }
    492 
    493395// ECMA 11.1.5
    494396ValueImp *PropertyValueNode::evaluate(ExecState *exec)
     
    496398  ObjectImp *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
    497399 
    498   for (PropertyValueNode *p = this; p; p = p->list) {
     400  for (PropertyValueNode *p = this; p; p = p->list.get()) {
    499401    ValueImp *n = p->name->evaluate(exec);
    500402    KJS_CHECKEXCEPTIONVALUE
     
    525427
    526428// ------------------------------ BracketAccessorNode --------------------------------
    527 
    528 void BracketAccessorNode::ref()
    529 {
    530   Node::ref();
    531   if ( expr1 )
    532     expr1->ref();
    533   if ( expr2 )
    534     expr2->ref();
    535 }
    536 
    537 bool BracketAccessorNode::deref()
    538 {
    539   if ( expr1 && expr1->deref() )
    540     delete expr1;
    541   if ( expr2 && expr2->deref() )
    542     delete expr2;
    543   return Node::deref();
    544 }
    545429
    546430// ECMA 11.2.1a
     
    573457// ------------------------------ DotAccessorNode --------------------------------
    574458
    575 void DotAccessorNode::ref()
    576 {
    577   Node::ref();
    578   if ( expr )
    579     expr->ref();
    580 }
    581 
    582 bool DotAccessorNode::deref()
    583 {
    584   if ( expr && expr->deref() )
    585     delete expr;
    586   return Node::deref();
    587 }
    588 
    589459// ECMA 11.2.1b
    590460ValueImp *DotAccessorNode::evaluate(ExecState *exec)
     
    606476// ------------------------------ ArgumentListNode -----------------------------
    607477
    608 void ArgumentListNode::ref()
    609 {
    610   for (ArgumentListNode *n = this; n; n = n->list) {
    611     n->Node::ref();
    612     if (n->expr)
    613       n->expr->ref();
    614   }
    615 }
    616 
    617 bool ArgumentListNode::deref()
    618 {
    619   ArgumentListNode *next;
    620   for (ArgumentListNode *n = this; n; n = next) {
    621     next = n->list;
    622     if (n->expr && n->expr->deref())
    623       delete n->expr;
    624     if (n != this && n->Node::deref())
    625       delete n;
    626   }
    627   return Node::deref();
    628 }
    629 
    630478ValueImp *ArgumentListNode::evaluate(ExecState */*exec*/)
    631479{
     
    639487  List l;
    640488
    641   for (ArgumentListNode *n = this; n; n = n->list) {
     489  for (ArgumentListNode *n = this; n; n = n->list.get()) {
    642490    ValueImp *v = n->expr->evaluate(exec);
    643491    KJS_CHECKEXCEPTIONLIST
     
    650498// ------------------------------ ArgumentsNode --------------------------------
    651499
    652 void ArgumentsNode::ref()
    653 {
    654   Node::ref();
    655   if ( list )
    656     list->ref();
    657 }
    658 
    659 bool ArgumentsNode::deref()
    660 {
    661   if ( list && list->deref() )
    662     delete list;
    663   return Node::deref();
    664 }
    665 
    666500ValueImp *ArgumentsNode::evaluate(ExecState */*exec*/)
    667501{
     
    682516
    683517// ECMA 11.2.2
    684 
    685 void NewExprNode::ref()
    686 {
    687   Node::ref();
    688   if ( expr )
    689     expr->ref();
    690   if ( args )
    691     args->ref();
    692 }
    693 
    694 bool NewExprNode::deref()
    695 {
    696   if ( expr && expr->deref() )
    697     delete expr;
    698   if ( args && args->deref() )
    699     delete args;
    700   return Node::deref();
    701 }
    702518
    703519ValueImp *NewExprNode::evaluate(ExecState *exec)
     
    713529
    714530  if (!v->isObject()) {
    715     return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr);
     531    return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr.get());
    716532  }
    717533
    718534  ObjectImp *constr = static_cast<ObjectImp*>(v);
    719535  if (!constr->implementsConstruct()) {
    720     return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr);
     536    return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr.get());
    721537  }
    722538
    723539  return constr->construct(exec, argList);
    724 }
    725 
    726 void FunctionCallValueNode::ref()
    727 {
    728   Node::ref();
    729   if (expr)
    730     expr->ref();
    731   if (args)
    732     args->ref();
    733 }
    734 
    735 bool FunctionCallValueNode::deref()
    736 {
    737   if (expr && expr->deref())
    738     delete expr;
    739   if (args && args->deref())
    740     delete args;
    741   return Node::deref();
    742540}
    743541
     
    749547
    750548  if (!v->isObject()) {
    751     return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, expr);
     549    return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, expr.get());
    752550  }
    753551 
     
    755553
    756554  if (!func->implementsCall()) {
    757     return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, expr);
     555    return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, expr.get());
    758556  }
    759557
     
    764562
    765563  return func->call(exec, thisObj, argList);
    766 }
    767 
    768 
    769 void FunctionCallResolveNode::ref()
    770 {
    771   Node::ref();
    772   if (args)
    773     args->ref();
    774 }
    775 
    776 bool FunctionCallResolveNode::deref()
    777 {
    778   if (args && args->deref())
    779     delete args;
    780   return Node::deref();
    781564}
    782565
     
    830613}
    831614
    832 void FunctionCallBracketNode::ref()
    833 {
    834   Node::ref();
    835   if (base)
    836     base->ref();
    837   if (subscript)
    838     base->ref();
    839   if (args)
    840     args->ref();
    841 }
    842 
    843 bool FunctionCallBracketNode::deref()
    844 {
    845   if (base && base->deref())
    846     delete base;
    847   if (subscript && subscript->deref())
    848     delete subscript;
    849   if (args && args->deref())
    850     delete args;
    851   return Node::deref();
    852 }
    853 
    854615// ECMA 11.2.3
    855616ValueImp *FunctionCallBracketNode::evaluate(ExecState *exec)
     
    881642 
    882643  if (!funcVal->isObject()) {
    883     return throwError(exec, TypeError, "Value %s (result of expression %s[%s]) is not object.", funcVal, base, subscript);
     644    return throwError(exec, TypeError, "Value %s (result of expression %s[%s]) is not object.", funcVal, base.get(), subscript.get());
    884645  }
    885646 
     
    887648
    888649  if (!func->implementsCall()) {
    889     return throwError(exec, TypeError, "Object %s (result of expression %s[%s]) does not allow calls.", funcVal, base, subscript);
     650    return throwError(exec, TypeError, "Object %s (result of expression %s[%s]) does not allow calls.", funcVal, base.get(), subscript.get());
    890651  }
    891652
     
    901662}
    902663
    903 
    904 void FunctionCallDotNode::ref()
    905 {
    906   Node::ref();
    907   if (base)
    908     base->ref();
    909   if (args)
    910     args->ref();
    911 }
    912 
    913 bool FunctionCallDotNode::deref()
    914 {
    915   if (base && base->deref())
    916     delete base;
    917   if (args && args->deref())
    918     delete args;
    919   return Node::deref();
    920 }
    921 
    922664static const char *dotExprNotAnObjectString()
    923665{
     
    941683
    942684  if (!funcVal->isObject())
    943     return throwError(exec, TypeError, dotExprNotAnObjectString(), funcVal, base, ident);
     685    return throwError(exec, TypeError, dotExprNotAnObjectString(), funcVal, base.get(), ident);
    944686 
    945687  ObjectImp *func = static_cast<ObjectImp*>(funcVal);
    946688
    947689  if (!func->implementsCall())
    948     return throwError(exec, TypeError, dotExprDoesNotAllowCallsString(), funcVal, base, ident);
     690    return throwError(exec, TypeError, dotExprDoesNotAllowCallsString(), funcVal, base.get(), ident);
    949691
    950692  List argList = args->evaluateList(exec);
     
    961703// ------------------------------ PostfixNode ----------------------------------
    962704
    963 void PostfixNode::ref()
    964 {
    965   Node::ref();
    966   if ( expr )
    967     expr->ref();
    968 }
    969 
    970 bool PostfixNode::deref()
    971 {
    972   if ( expr && expr->deref() )
    973     delete expr;
    974   return Node::deref();
    975 }
    976 
    977705// ECMA 11.3
    978706ValueImp *PostfixNode::evaluate(ExecState *exec)
     
    993721// ------------------------------ DeleteNode -----------------------------------
    994722
    995 void DeleteNode::ref()
    996 {
    997   Node::ref();
    998   if ( expr )
    999     expr->ref();
    1000 }
    1001 
    1002 bool DeleteNode::deref()
    1003 {
    1004   if ( expr && expr->deref() )
    1005     delete expr;
    1006   return Node::deref();
    1007 }
    1008 
    1009723// ECMA 11.4.1
    1010724ValueImp *DeleteNode::evaluate(ExecState *exec)
     
    1017731// ------------------------------ VoidNode -------------------------------------
    1018732
    1019 void VoidNode::ref()
    1020 {
    1021   Node::ref();
    1022   if ( expr )
    1023     expr->ref();
    1024 }
    1025 
    1026 bool VoidNode::deref()
    1027 {
    1028   if ( expr && expr->deref() )
    1029     delete expr;
    1030   return Node::deref();
    1031 }
    1032 
    1033733// ECMA 11.4.2
    1034734ValueImp *VoidNode::evaluate(ExecState *exec)
     
    1041741
    1042742// ------------------------------ TypeOfNode -----------------------------------
    1043 
    1044 void TypeOfNode::ref()
    1045 {
    1046   Node::ref();
    1047   if ( expr )
    1048     expr->ref();
    1049 }
    1050 
    1051 bool TypeOfNode::deref()
    1052 {
    1053   if ( expr && expr->deref() )
    1054     delete expr;
    1055   return Node::deref();
    1056 }
    1057743
    1058744// ECMA 11.4.3
     
    1096782// ------------------------------ PrefixNode -----------------------------------
    1097783
    1098 void PrefixNode::ref()
    1099 {
    1100   Node::ref();
    1101   if ( expr )
    1102     expr->ref();
    1103 }
    1104 
    1105 bool PrefixNode::deref()
    1106 {
    1107   if ( expr && expr->deref() )
    1108     delete expr;
    1109   return Node::deref();
    1110 }
    1111 
    1112784// ECMA 11.4.4 and 11.4.5
    1113785ValueImp *PrefixNode::evaluate(ExecState *exec)
     
    1130802// ------------------------------ UnaryPlusNode --------------------------------
    1131803
    1132 void UnaryPlusNode::ref()
    1133 {
    1134   Node::ref();
    1135   if ( expr )
    1136     expr->ref();
    1137 }
    1138 
    1139 bool UnaryPlusNode::deref()
    1140 {
    1141   if ( expr && expr->deref() )
    1142     delete expr;
    1143   return Node::deref();
    1144 }
    1145 
    1146804// ECMA 11.4.6
    1147805ValueImp *UnaryPlusNode::evaluate(ExecState *exec)
     
    1154812
    1155813// ------------------------------ NegateNode -----------------------------------
    1156 
    1157 void NegateNode::ref()
    1158 {
    1159   Node::ref();
    1160   if ( expr )
    1161     expr->ref();
    1162 }
    1163 
    1164 bool NegateNode::deref()
    1165 {
    1166   if ( expr && expr->deref() )
    1167     delete expr;
    1168   return Node::deref();
    1169 }
    1170814
    1171815// ECMA 11.4.7
     
    1182826// ------------------------------ BitwiseNotNode -------------------------------
    1183827
    1184 void BitwiseNotNode::ref()
    1185 {
    1186   Node::ref();
    1187   if ( expr )
    1188     expr->ref();
    1189 }
    1190 
    1191 bool BitwiseNotNode::deref()
    1192 {
    1193   if ( expr && expr->deref() )
    1194     delete expr;
    1195   return Node::deref();
    1196 }
    1197 
    1198828// ECMA 11.4.8
    1199829ValueImp *BitwiseNotNode::evaluate(ExecState *exec)
     
    1206836// ------------------------------ LogicalNotNode -------------------------------
    1207837
    1208 void LogicalNotNode::ref()
    1209 {
    1210   Node::ref();
    1211   if ( expr )
    1212     expr->ref();
    1213 }
    1214 
    1215 bool LogicalNotNode::deref()
    1216 {
    1217   if ( expr && expr->deref() )
    1218     delete expr;
    1219   return Node::deref();
    1220 }
    1221 
    1222838// ECMA 11.4.9
    1223839ValueImp *LogicalNotNode::evaluate(ExecState *exec)
     
    1230846// ------------------------------ MultNode -------------------------------------
    1231847
    1232 void MultNode::ref()
    1233 {
    1234   Node::ref();
    1235   if ( term1 )
    1236     term1->ref();
    1237   if ( term2 )
    1238     term2->ref();
    1239 }
    1240 
    1241 bool MultNode::deref()
    1242 {
    1243   if ( term1 && term1->deref() )
    1244     delete term1;
    1245   if ( term2 && term2->deref() )
    1246     delete term2;
    1247   return Node::deref();
    1248 }
    1249 
    1250848// ECMA 11.5
    1251849ValueImp *MultNode::evaluate(ExecState *exec)
     
    1262860// ------------------------------ AddNode --------------------------------------
    1263861
    1264 void AddNode::ref()
    1265 {
    1266   Node::ref();
    1267   if ( term1 )
    1268     term1->ref();
    1269   if ( term2 )
    1270     term2->ref();
    1271 }
    1272 
    1273 bool AddNode::deref()
    1274 {
    1275   if ( term1 && term1->deref() )
    1276     delete term1;
    1277   if ( term2 && term2->deref() )
    1278     delete term2;
    1279   return Node::deref();
    1280 }
    1281 
    1282862// ECMA 11.6
    1283863ValueImp *AddNode::evaluate(ExecState *exec)
     
    1293873
    1294874// ------------------------------ ShiftNode ------------------------------------
    1295 
    1296 void ShiftNode::ref()
    1297 {
    1298   Node::ref();
    1299   if ( term1 )
    1300     term1->ref();
    1301   if ( term2 )
    1302     term2->ref();
    1303 }
    1304 
    1305 bool ShiftNode::deref()
    1306 {
    1307   if ( term1 && term1->deref() )
    1308     delete term1;
    1309   if ( term2 && term2->deref() )
    1310     delete term2;
    1311   return Node::deref();
    1312 }
    1313875
    1314876// ECMA 11.7
     
    1336898
    1337899// ------------------------------ RelationalNode -------------------------------
    1338 
    1339 void RelationalNode::ref()
    1340 {
    1341   Node::ref();
    1342   if ( expr1 )
    1343     expr1->ref();
    1344   if ( expr2 )
    1345     expr2->ref();
    1346 }
    1347 
    1348 bool RelationalNode::deref()
    1349 {
    1350   if ( expr1 && expr1->deref() )
    1351     delete expr1;
    1352   if ( expr2 && expr2->deref() )
    1353     delete expr2;
    1354   return Node::deref();
    1355 }
    1356900
    1357901// ECMA 11.8
     
    1380924      if (!v2->isObject())
    1381925          return throwError(exec,  TypeError,
    1382                              "Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2);
     926                             "Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2.get());
    1383927      ObjectImp *o2(static_cast<ObjectImp*>(v2));
    1384928      b = o2->hasProperty(exec, Identifier(v1->toString(exec)));
     
    1386930    if (!v2->isObject())
    1387931        return throwError(exec,  TypeError,
    1388                            "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2);
     932                           "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2.get());
    1389933
    1390934    ObjectImp *o2(static_cast<ObjectImp*>(v2));
     
    1406950// ------------------------------ EqualNode ------------------------------------
    1407951
    1408 void EqualNode::ref()
    1409 {
    1410   Node::ref();
    1411   if ( expr1 )
    1412     expr1->ref();
    1413   if ( expr2 )
    1414     expr2->ref();
    1415 }
    1416 
    1417 bool EqualNode::deref()
    1418 {
    1419   if ( expr1 && expr1->deref() )
    1420     delete expr1;
    1421   if ( expr2 && expr2->deref() )
    1422     delete expr2;
    1423   return Node::deref();
    1424 }
    1425 
    1426952// ECMA 11.9
    1427953ValueImp *EqualNode::evaluate(ExecState *exec)
     
    1447973// ------------------------------ BitOperNode ----------------------------------
    1448974
    1449 void BitOperNode::ref()
    1450 {
    1451   Node::ref();
    1452   if ( expr1 )
    1453     expr1->ref();
    1454   if ( expr2 )
    1455     expr2->ref();
    1456 }
    1457 
    1458 bool BitOperNode::deref()
    1459 {
    1460   if ( expr1 && expr1->deref() )
    1461     delete expr1;
    1462   if ( expr2 && expr2->deref() )
    1463     delete expr2;
    1464   return Node::deref();
    1465 }
    1466 
    1467975// ECMA 11.10
    1468976ValueImp *BitOperNode::evaluate(ExecState *exec)
     
    1487995// ------------------------------ BinaryLogicalNode ----------------------------
    1488996
    1489 void BinaryLogicalNode::ref()
    1490 {
    1491   Node::ref();
    1492   if ( expr1 )
    1493     expr1->ref();
    1494   if ( expr2 )
    1495     expr2->ref();
    1496 }
    1497 
    1498 bool BinaryLogicalNode::deref()
    1499 {
    1500   if ( expr1 && expr1->deref() )
    1501     delete expr1;
    1502   if ( expr2 && expr2->deref() )
    1503     delete expr2;
    1504   return Node::deref();
    1505 }
    1506 
    1507997// ECMA 11.11
    1508998ValueImp *BinaryLogicalNode::evaluate(ExecState *exec)
     
    15211011
    15221012// ------------------------------ ConditionalNode ------------------------------
    1523 
    1524 void ConditionalNode::ref()
    1525 {
    1526   Node::ref();
    1527   if ( expr1 )
    1528     expr1->ref();
    1529   if ( expr2 )
    1530     expr2->ref();
    1531   if ( logical )
    1532     logical->ref();
    1533 }
    1534 
    1535 bool ConditionalNode::deref()
    1536 {
    1537   if ( expr1 && expr1->deref() )
    1538     delete expr1;
    1539   if ( expr2 && expr2->deref() )
    1540     delete expr2;
    1541   if ( logical && logical->deref() )
    1542     delete logical;
    1543   return Node::deref();
    1544 }
    15451013
    15461014// ECMA 11.12
     
    16321100// ------------------------------ AssignResolveNode -----------------------------------
    16331101
    1634 void AssignResolveNode::ref()
    1635 {
    1636   Node::ref();
    1637   if (m_right)
    1638     m_right->ref();
    1639 }
    1640 
    1641 bool AssignResolveNode::deref()
    1642 {
    1643   if (m_right && m_right->deref())
    1644     delete m_right;
    1645 
    1646   return Node::deref();
    1647 }
    1648 
    16491102ValueImp *AssignResolveNode::evaluate(ExecState *exec)
    16501103{
     
    16881141
    16891142// ------------------------------ AssignDotNode -----------------------------------
    1690 
    1691 void AssignDotNode::ref()
    1692 {
    1693   Node::ref();
    1694   if (m_base)
    1695     m_base->ref();
    1696   if (m_right)
    1697     m_right->ref();
    1698 }
    1699 
    1700 bool AssignDotNode::deref()
    1701 {
    1702   if (m_base && m_base->deref())
    1703     delete m_base;
    1704   if (m_right && m_right->deref())
    1705     delete m_right;
    1706   return Node::deref();
    1707 }
    17081143
    17091144ValueImp *AssignDotNode::evaluate(ExecState *exec)
     
    17321167
    17331168// ------------------------------ AssignBracketNode -----------------------------------
    1734 
    1735 void AssignBracketNode::ref()
    1736 {
    1737   Node::ref();
    1738   if (m_base)
    1739     m_base->ref();
    1740   if (m_subscript)
    1741     m_subscript->ref();
    1742   if (m_right)
    1743     m_right->ref();
    1744 }
    1745 
    1746 bool AssignBracketNode::deref()
    1747 {
    1748   if (m_base && m_base->deref())
    1749     delete m_base;
    1750   if (m_subscript && m_subscript->deref())
    1751     delete m_subscript;
    1752   if (m_right && m_right->deref())
    1753     delete m_right;
    1754 
    1755   return Node::deref();
    1756 }
    17571169
    17581170ValueImp *AssignBracketNode::evaluate(ExecState *exec)
     
    18051217// ------------------------------ CommaNode ------------------------------------
    18061218
    1807 void CommaNode::ref()
    1808 {
    1809   Node::ref();
    1810   if ( expr1 )
    1811     expr1->ref();
    1812   if ( expr2 )
    1813     expr2->ref();
    1814 }
    1815 
    1816 bool CommaNode::deref()
    1817 {
    1818   if ( expr1 && expr1->deref() )
    1819     delete expr1;
    1820   if ( expr2 && expr2->deref() )
    1821     delete expr2;
    1822   return Node::deref();
    1823 }
    1824 
    18251219// ECMA 11.14
    18261220ValueImp *CommaNode::evaluate(ExecState *exec)
     
    18471241  l->list = this;
    18481242  setLoc(l->firstLine(), s->lastLine(), l->sourceId());
    1849 }
    1850 
    1851 void StatListNode::ref()
    1852 {
    1853   for (StatListNode *n = this; n; n = n->list) {
    1854     n->Node::ref();
    1855     if (n->statement)
    1856       n->statement->ref();
    1857   }
    1858 }
    1859 
    1860 bool StatListNode::deref()
    1861 {
    1862   StatListNode *next;
    1863   for (StatListNode *n = this; n; n = next) {
    1864     next = n->list;
    1865     if (n->statement && n->statement->deref())
    1866       delete n->statement;
    1867     if (n != this && n->Node::deref())
    1868       delete n;
    1869   }
    1870   return Node::deref();
    18711243}
    18721244
     
    18871259  ValueImp *v = c.value();
    18881260 
    1889   for (StatListNode *n = list; n; n = n->list) {
     1261  for (StatListNode *n = list.get(); n; n = n->list.get()) {
    18901262    Completion c2 = n->statement->execute(exec);
    18911263    KJS_ABORTPOINT
     
    19091281void StatListNode::processVarDecls(ExecState *exec)
    19101282{
    1911   for (StatListNode *n = this; n; n = n->list)
     1283  for (StatListNode *n = this; n; n = n->list.get())
    19121284    n->statement->processVarDecls(exec);
    19131285}
    19141286
    19151287// ------------------------------ AssignExprNode -------------------------------
    1916 
    1917 void AssignExprNode::ref()
    1918 {
    1919   Node::ref();
    1920   if ( expr )
    1921     expr->ref();
    1922 }
    1923 
    1924 bool AssignExprNode::deref()
    1925 {
    1926   if ( expr && expr->deref() )
    1927     delete expr;
    1928   return Node::deref();
    1929 }
    19301288
    19311289// ECMA 12.2
     
    19411299    : varType(t), ident(id), init(in)
    19421300{
    1943 }
    1944 
    1945 void VarDeclNode::ref()
    1946 {
    1947   Node::ref();
    1948   if ( init )
    1949     init->ref();
    1950 }
    1951 
    1952 bool VarDeclNode::deref()
    1953 {
    1954   if ( init && init->deref() )
    1955     delete init;
    1956   return Node::deref();
    19571301}
    19581302
     
    20071351// ------------------------------ VarDeclListNode ------------------------------
    20081352
    2009 void VarDeclListNode::ref()
    2010 {
    2011   for (VarDeclListNode *n = this; n; n = n->list) {
    2012     n->Node::ref();
    2013     if (n->var)
    2014       n->var->ref();
    2015   }
    2016 }
    2017 
    2018 bool VarDeclListNode::deref()
    2019 {
    2020   VarDeclListNode *next;
    2021   for (VarDeclListNode *n = this; n; n = next) {
    2022     next = n->list;
    2023     if (n->var && n->var->deref())
    2024       delete n->var;
    2025     if (n != this && n->Node::deref())
    2026       delete n;
    2027   }
    2028   return Node::deref();
    2029 }
    2030 
    2031 
    20321353// ECMA 12.2
    20331354ValueImp *VarDeclListNode::evaluate(ExecState *exec)
    20341355{
    2035   for (VarDeclListNode *n = this; n; n = n->list) {
     1356  for (VarDeclListNode *n = this; n; n = n->list.get()) {
    20361357    n->var->evaluate(exec);
    20371358    KJS_CHECKEXCEPTIONVALUE
     
    20421363void VarDeclListNode::processVarDecls(ExecState *exec)
    20431364{
    2044   for (VarDeclListNode *n = this; n; n = n->list)
     1365  for (VarDeclListNode *n = this; n; n = n->list.get())
    20451366    n->var->processVarDecls(exec);
    20461367}
    20471368
    20481369// ------------------------------ VarStatementNode -----------------------------
    2049 
    2050 void VarStatementNode::ref()
    2051 {
    2052   Node::ref();
    2053   if ( list )
    2054     list->ref();
    2055 }
    2056 
    2057 bool VarStatementNode::deref()
    2058 {
    2059   if ( list && list->deref() )
    2060     delete list;
    2061   return Node::deref();
    2062 }
    20631370
    20641371// ECMA 12.2
     
    20911398}
    20921399
    2093 void BlockNode::ref()
    2094 {
    2095   Node::ref();
    2096   if ( source )
    2097     source->ref();
    2098 }
    2099 
    2100 bool BlockNode::deref()
    2101 {
    2102   if ( source && source->deref() )
    2103     delete source;
    2104   return Node::deref();
    2105 }
    2106 
    21071400// ECMA 12.1
    21081401Completion BlockNode::execute(ExecState *exec)
     
    21321425// ------------------------------ ExprStatementNode ----------------------------
    21331426
    2134 void ExprStatementNode::ref()
    2135 {
    2136   Node::ref();
    2137   if ( expr )
    2138     expr->ref();
    2139 }
    2140 
    2141 bool ExprStatementNode::deref()
    2142 {
    2143   if ( expr && expr->deref() )
    2144     delete expr;
    2145   return Node::deref();
    2146 }
    2147 
    21481427// ECMA 12.4
    21491428Completion ExprStatementNode::execute(ExecState *exec)
     
    21581437
    21591438// ------------------------------ IfNode ---------------------------------------
    2160 
    2161 void IfNode::ref()
    2162 {
    2163   Node::ref();
    2164   if ( statement1 )
    2165     statement1->ref();
    2166   if ( statement2 )
    2167     statement2->ref();
    2168   if ( expr )
    2169     expr->ref();
    2170 }
    2171 
    2172 bool IfNode::deref()
    2173 {
    2174   if ( statement1 && statement1->deref() )
    2175     delete statement1;
    2176   if ( statement2 && statement2->deref() )
    2177     delete statement2;
    2178   if ( expr && expr->deref() )
    2179     delete expr;
    2180   return Node::deref();
    2181 }
    21821439
    21831440// ECMA 12.5
     
    22111468
    22121469// ------------------------------ DoWhileNode ----------------------------------
    2213 
    2214 void DoWhileNode::ref()
    2215 {
    2216   Node::ref();
    2217   if ( statement )
    2218     statement->ref();
    2219   if ( expr )
    2220     expr->ref();
    2221 }
    2222 
    2223 bool DoWhileNode::deref()
    2224 {
    2225   if ( statement && statement->deref() )
    2226     delete statement;
    2227   if ( expr && expr->deref() )
    2228     delete expr;
    2229   return Node::deref();
    2230 }
    22311470
    22321471// ECMA 12.6.1
     
    22651504// ------------------------------ WhileNode ------------------------------------
    22661505
    2267 void WhileNode::ref()
    2268 {
    2269   Node::ref();
    2270   if ( statement )
    2271     statement->ref();
    2272   if ( expr )
    2273     expr->ref();
    2274 }
    2275 
    2276 bool WhileNode::deref()
    2277 {
    2278   if ( statement && statement->deref() )
    2279     delete statement;
    2280   if ( expr && expr->deref() )
    2281     delete expr;
    2282   return Node::deref();
    2283 }
    2284 
    22851506// ECMA 12.6.2
    22861507Completion WhileNode::execute(ExecState *exec)
     
    23271548
    23281549// ------------------------------ ForNode --------------------------------------
    2329 
    2330 void ForNode::ref()
    2331 {
    2332   Node::ref();
    2333   if ( statement )
    2334     statement->ref();
    2335   if ( expr1 )
    2336     expr1->ref();
    2337   if ( expr2 )
    2338     expr2->ref();
    2339   if ( expr3 )
    2340     expr3->ref();
    2341 }
    2342 
    2343 bool ForNode::deref()
    2344 {
    2345   if ( statement && statement->deref() )
    2346     delete statement;
    2347   if ( expr1 && expr1->deref() )
    2348     delete expr1;
    2349   if ( expr2 && expr2->deref() )
    2350     delete expr2;
    2351   if ( expr3 && expr3->deref() )
    2352     delete expr3;
    2353   return Node::deref();
    2354 }
    23551550
    23561551// ECMA 12.6.3
     
    24121607{
    24131608  // for( var foo = bar in baz )
    2414   varDecl = new VarDeclNode(ident, init, VarDeclNode::Variable);
     1609  varDecl = new VarDeclNode(ident, init.get(), VarDeclNode::Variable);
    24151610  lexpr = new ResolveNode(ident);
    2416 }
    2417 
    2418 void ForInNode::ref()
    2419 {
    2420   Node::ref();
    2421   if ( statement )
    2422     statement->ref();
    2423   if ( expr )
    2424     expr->ref();
    2425   if ( lexpr )
    2426     lexpr->ref();
    2427   if ( init )
    2428     init->ref();
    2429   if ( varDecl )
    2430     varDecl->ref();
    2431 }
    2432 
    2433 bool ForInNode::deref()
    2434 {
    2435   if ( statement && statement->deref() )
    2436     delete statement;
    2437   if ( expr && expr->deref() )
    2438     delete expr;
    2439   if ( lexpr && lexpr->deref() )
    2440     delete lexpr;
    2441   if ( init && init->deref() )
    2442     delete init;
    2443   if ( varDecl && varDecl->deref() )
    2444     delete varDecl;
    2445   return Node::deref();
    24461611}
    24471612
     
    25521717// ------------------------------ ReturnNode -----------------------------------
    25531718
    2554 void ReturnNode::ref()
    2555 {
    2556   Node::ref();
    2557   if ( value )
    2558     value->ref();
    2559 }
    2560 
    2561 bool ReturnNode::deref()
    2562 {
    2563   if ( value && value->deref() )
    2564     delete value;
    2565   return Node::deref();
    2566 }
    2567 
    25681719// ECMA 12.9
    25691720Completion ReturnNode::execute(ExecState *exec)
     
    25861737
    25871738// ------------------------------ WithNode -------------------------------------
    2588 
    2589 void WithNode::ref()
    2590 {
    2591   Node::ref();
    2592   if ( statement )
    2593     statement->ref();
    2594   if ( expr )
    2595     expr->ref();
    2596 }
    2597 
    2598 bool WithNode::deref()
    2599 {
    2600   if ( statement && statement->deref() )
    2601     delete statement;
    2602   if ( expr && expr->deref() )
    2603     delete expr;
    2604   return Node::deref();
    2605 }
    26061739
    26071740// ECMA 12.10
     
    26281761// ------------------------------ CaseClauseNode -------------------------------
    26291762
    2630 void CaseClauseNode::ref()
    2631 {
    2632   Node::ref();
    2633   if ( expr )
    2634     expr->ref();
    2635   if ( list )
    2636     list->ref();
    2637 }
    2638 
    2639 bool CaseClauseNode::deref()
    2640 {
    2641   if ( expr && expr->deref() )
    2642     delete expr;
    2643   if ( list && list->deref() )
    2644     delete list;
    2645   return Node::deref();
    2646 }
    2647 
    26481763// ECMA 12.11
    26491764ValueImp *CaseClauseNode::evaluate(ExecState *exec)
     
    26721787// ------------------------------ ClauseListNode -------------------------------
    26731788
    2674 void ClauseListNode::ref()
    2675 {
    2676   for (ClauseListNode *n = this; n; n = n->nx) {
    2677     n->Node::ref();
    2678     if (n->cl)
    2679       n->cl->ref();
    2680   }
    2681 }
    2682 
    2683 bool ClauseListNode::deref()
    2684 {
    2685   ClauseListNode *next;
    2686   for (ClauseListNode *n = this; n; n = next) {
    2687     next = n->nx;
    2688     if (n->cl && n->cl->deref())
    2689       delete n->cl;
    2690     if (n != this && n->Node::deref())
    2691       delete n;
    2692   }
    2693   return Node::deref();
    2694 }
    2695 
    26961789ValueImp *ClauseListNode::evaluate(ExecState */*exec*/)
    26971790{
     
    27041797void ClauseListNode::processVarDecls(ExecState *exec)
    27051798{
    2706   for (ClauseListNode *n = this; n; n = n->nx)
     1799  for (ClauseListNode *n = this; n; n = n->nx.get())
    27071800    if (n->cl)
    27081801      n->cl->processVarDecls(exec);
     
    27311824}
    27321825 
    2733 void CaseBlockNode::ref()
    2734 {
    2735   Node::ref();
    2736   if ( def )
    2737     def->ref();
    2738   if ( list1 )
    2739     list1->ref();
    2740   if ( list2 )
    2741     list2->ref();
    2742 }
    2743 
    2744 bool CaseBlockNode::deref()
    2745 {
    2746   if ( def && def->deref() )
    2747     delete def;
    2748   if ( list1 && list1->deref() )
    2749     delete list1;
    2750   if ( list2 && list2->deref() )
    2751     delete list2;
    2752   return Node::deref();
    2753 }
    2754 
    27551826ValueImp *CaseBlockNode::evaluate(ExecState */*exec*/)
    27561827{
     
    27651836  ValueImp *v;
    27661837  Completion res;
    2767   ClauseListNode *a = list1, *b = list2;
     1838  ClauseListNode *a = list1.get();
     1839  ClauseListNode *b = list2.get();
    27681840  CaseClauseNode *clause;
    27691841
     
    28061878      return res;
    28071879  }
    2808   b = list2;
     1880  b = list2.get();
    28091881 step18:
    28101882  while (b) {
     
    28341906// ------------------------------ SwitchNode -----------------------------------
    28351907
    2836 void SwitchNode::ref()
    2837 {
    2838   Node::ref();
    2839   if ( expr )
    2840     expr->ref();
    2841   if ( block )
    2842     block->ref();
    2843 }
    2844 
    2845 bool SwitchNode::deref()
    2846 {
    2847   if ( expr && expr->deref() )
    2848     delete expr;
    2849   if ( block && block->deref() )
    2850     delete block;
    2851   return Node::deref();
    2852 }
    2853 
    28541908// ECMA 12.11
    28551909Completion SwitchNode::execute(ExecState *exec)
     
    28751929
    28761930// ------------------------------ LabelNode ------------------------------------
    2877 
    2878 void LabelNode::ref()
    2879 {
    2880   Node::ref();
    2881   if ( statement )
    2882     statement->ref();
    2883 }
    2884 
    2885 bool LabelNode::deref()
    2886 {
    2887   if ( statement && statement->deref() )
    2888     delete statement;
    2889   return Node::deref();
    2890 }
    28911931
    28921932// ECMA 12.12
     
    29141954// ------------------------------ ThrowNode ------------------------------------
    29151955
    2916 void ThrowNode::ref()
    2917 {
    2918   Node::ref();
    2919   if ( expr )
    2920     expr->ref();
    2921 }
    2922 
    2923 bool ThrowNode::deref()
    2924 {
    2925   if ( expr && expr->deref() )
    2926     delete expr;
    2927   return Node::deref();
    2928 }
    2929 
    29301956// ECMA 12.13
    29311957Completion ThrowNode::execute(ExecState *exec)
     
    29401966
    29411967// ------------------------------ CatchNode ------------------------------------
    2942 
    2943 void CatchNode::ref()
    2944 {
    2945   Node::ref();
    2946   if ( block )
    2947     block->ref();
    2948 }
    2949 
    2950 bool CatchNode::deref()
    2951 {
    2952   if ( block && block->deref() )
    2953     delete block;
    2954   return Node::deref();
    2955 }
    29561968
    29571969Completion CatchNode::execute(ExecState */*exec*/)
     
    29851997// ------------------------------ FinallyNode ----------------------------------
    29861998
    2987 void FinallyNode::ref()
    2988 {
    2989   Node::ref();
    2990   if ( block )
    2991     block->ref();
    2992 }
    2993 
    2994 bool FinallyNode::deref()
    2995 {
    2996   if ( block && block->deref() )
    2997     delete block;
    2998   return Node::deref();
    2999 }
    3000 
    30011999// ECMA 12.14
    30022000Completion FinallyNode::execute(ExecState *exec)
     
    30112009
    30122010// ------------------------------ TryNode --------------------------------------
    3013 
    3014 void TryNode::ref()
    3015 {
    3016   Node::ref();
    3017   if ( block )
    3018     block->ref();
    3019   if ( _final )
    3020     _final->ref();
    3021   if ( _catch )
    3022     _catch->ref();
    3023 }
    3024 
    3025 bool TryNode::deref()
    3026 {
    3027   if ( block && block->deref() )
    3028     delete block;
    3029   if ( _final && _final->deref() )
    3030     delete _final;
    3031   if ( _catch && _catch->deref() )
    3032     delete _catch;
    3033   return Node::deref();
    3034 }
    30352011
    30362012// ECMA 12.14
     
    30792055// ------------------------------ ParameterNode --------------------------------
    30802056
    3081 void ParameterNode::ref()
    3082 {
    3083   for (ParameterNode *n = this; n; n = n->next)
    3084     n->Node::ref();
    3085 }
    3086 
    3087 bool ParameterNode::deref()
    3088 {
    3089   ParameterNode *next;
    3090   for (ParameterNode *n = this; n; n = next) {
    3091     next = n->next;
    3092     if (n != this && n->Node::deref())
    3093       delete n;
    3094   }
    3095   return Node::deref();
    3096 }
    3097 
    30982057// ECMA 13
    30992058ValueImp *ParameterNode::evaluate(ExecState */*exec*/)
     
    31192078// ------------------------------ FuncDeclNode ---------------------------------
    31202079
    3121 void FuncDeclNode::ref()
    3122 {
    3123   Node::ref();
    3124   if ( param )
    3125     param->ref();
    3126   if ( body )
    3127     body->ref();
    3128 }
    3129 
    3130 bool FuncDeclNode::deref()
    3131 {
    3132   if ( param && param->deref() )
    3133     delete param;
    3134   if ( body && body->deref() )
    3135     delete body;
    3136   return Node::deref();
    3137 }
    3138 
    31392080// ECMA 13
    31402081void FuncDeclNode::processFuncDecl(ExecState *exec)
     
    31432084
    31442085  // TODO: let this be an object with [[Class]] property "Function"
    3145   FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, context->scopeChain());
     2086  FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
    31462087  ObjectImp *func(fimp); // protect from GC
    31472088
     
    31512092
    31522093  int plen = 0;
    3153   for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
     2094  for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
    31542095    fimp->addParameter(p->ident());
    31552096
     
    31732114// ------------------------------ FuncExprNode ---------------------------------
    31742115
    3175 void FuncExprNode::ref()
    3176 {
    3177   Node::ref();
    3178   if ( param )
    3179     param->ref();
    3180   if ( body )
    3181     body->ref();
    3182 }
    3183 
    3184 bool FuncExprNode::deref()
    3185 {
    3186   if ( param && param->deref() )
    3187     delete param;
    3188   if ( body && body->deref() )
    3189     delete body;
    3190   return Node::deref();
    3191 }
    3192 
    3193 
    31942116// ECMA 13
    31952117ValueImp *FuncExprNode::evaluate(ExecState *exec)
    31962118{
    3197   FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), body, exec->context().imp()->scopeChain());
     2119  FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), body.get(), exec->context().imp()->scopeChain());
    31982120  ValueImp *ret(fimp);
    31992121  ValueImp *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
     
    32012123
    32022124  int plen = 0;
    3203   for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
     2125  for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
    32042126    fimp->addParameter(p->ident());
    32052127
     
    32202142  s1->elements = this;
    32212143  setLoc(s1->firstLine(), s2->lastLine(), s1->sourceId());
    3222 }
    3223 
    3224 void SourceElementsNode::ref()
    3225 {
    3226   for (SourceElementsNode *n = this; n; n = n->elements) {
    3227     n->Node::ref();
    3228     if (n->element)
    3229       n->element->ref();
    3230   }
    3231 }
    3232 
    3233 bool SourceElementsNode::deref()
    3234 {
    3235   SourceElementsNode *next;
    3236   for (SourceElementsNode *n = this; n; n = next) {
    3237     next = n->elements;
    3238     if (n->element && n->element->deref())
    3239       delete n->element;
    3240     if (n != this && n->Node::deref())
    3241       delete n;
    3242   }
    3243   return Node::deref();
    32442144}
    32452145
     
    32542154    return c1;
    32552155 
    3256   for (SourceElementsNode *n = elements; n; n = n->elements) {
     2156  for (SourceElementsNode *n = elements.get(); n; n = n->elements.get()) {
    32572157    Completion c2 = n->element->execute(exec);
    32582158    if (c2.complType() != Normal)
     
    32702170void SourceElementsNode::processFuncDecl(ExecState *exec)
    32712171{
    3272   for (SourceElementsNode *n = this; n; n = n->elements)
     2172  for (SourceElementsNode *n = this; n; n = n->elements.get())
    32732173    n->element->processFuncDecl(exec);
    32742174}
     
    32762176void SourceElementsNode::processVarDecls(ExecState *exec)
    32772177{
    3278   for (SourceElementsNode *n = this; n; n = n->elements)
     2178  for (SourceElementsNode *n = this; n; n = n->elements.get())
    32792179    n->element->processVarDecls(exec);
    32802180}
Note: See TracChangeset for help on using the changeset viewer.