[webkit-changes] cvs commit: JavaScriptCore/kjs shared_ptr.h
function.cpp function.h function_object.cpp grammar.y
internal.cpp internal.h nodes.cpp nodes.h nodes2string.cpp
Maciej
mjs at opensource.apple.com
Sun Aug 28 16:26:55 PDT 2005
mjs 05/08/28 16:26:55
Modified: . Tag: Safari-2-0-branch ChangeLog
JavaScriptCore.xcodeproj Tag: Safari-2-0-branch
project.pbxproj
kjs Tag: Safari-2-0-branch function.cpp function.h
function_object.cpp grammar.y internal.cpp
internal.h nodes.cpp nodes.h nodes2string.cpp
Added: kjs Tag: Safari-2-0-branch shared_ptr.h
Log:
Merges fixes from HEAD to Safari-2-0-branch
2005-08-26 Maciej Stachowiak <mjs at apple.com>
Reviewed by John.
<rdar://problem/4224911> many many leaks in kjsyyparse with malformed Javascript
Record all nodes that are created during parsing, and delete any
that are left floating with a refcount of 0.
* kjs/internal.cpp:
(KJS::Parser::saveNewNode):
(KJS::clearNewNodes):
(KJS::Parser::parse):
* kjs/internal.h:
* kjs/nodes.cpp:
(Node::Node):
* kjs/nodes.h:
(KJS::Node::refcount):
2005-08-26 Maciej Stachowiak <mjs at apple.com>
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):
Revision Changes Path
No revision
No revision
1.677.6.30 +161 -0 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.677.6.29
retrieving revision 1.677.6.30
diff -u -r1.677.6.29 -r1.677.6.30
--- ChangeLog 25 Aug 2005 19:05:22 -0000 1.677.6.29
+++ ChangeLog 28 Aug 2005 23:26:50 -0000 1.677.6.30
@@ -1,3 +1,164 @@
+2005-08-28 Maciej Stachowiak <mjs at apple.com>
+
+ Merges fixes from HEAD to Safari-2-0-branch
+
+ 2005-08-26 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by John.
+
+ <rdar://problem/4224911> many many leaks in kjsyyparse with malformed Javascript
+
+ Record all nodes that are created during parsing, and delete any
+ that are left floating with a refcount of 0.
+
+ * kjs/internal.cpp:
+ (KJS::Parser::saveNewNode):
+ (KJS::clearNewNodes):
+ (KJS::Parser::parse):
+ * kjs/internal.h:
+ * kjs/nodes.cpp:
+ (Node::Node):
+ * kjs/nodes.h:
+ (KJS::Node::refcount):
+
+ 2005-08-26 Maciej Stachowiak <mjs at apple.com>
+
+ 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):
+
=== Safari-416.3 ===
=== Safari-416.2 ===
No revision
No revision
1.2.2.11 +3 -0 JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Index: project.pbxproj
===================================================================
RCS file: /cvs/root/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj,v
retrieving revision 1.2.2.10
retrieving revision 1.2.2.11
diff -u -r1.2.2.10 -r1.2.2.11
--- project.pbxproj 23 Aug 2005 19:14:56 -0000 1.2.2.10
+++ project.pbxproj 28 Aug 2005 23:26:51 -0000 1.2.2.11
@@ -89,6 +89,8 @@
932F5B850822A1C700736975 /* npruntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 5199B1BE061B65BC0070C006 /* npruntime.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B870822A1C700736975 /* interpreter_map.h in Headers */ = {isa = PBXBuildFile; fileRef = 65AB004906261CBA0076DE63 /* interpreter_map.h */; };
932F5B880822A1C700736975 /* protect.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C02FBB0637462A003E7EE6 /* protect.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 65EF2DF508BECC80000894BB /* shared_ptr.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EF2DF408BECC80000894BB /* shared_ptr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 65EF2DF808BECC8A000894BB /* shared_ptr.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EF2DF408BECC80000894BB /* shared_ptr.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B890822A1C700736975 /* protected_values.h in Headers */ = {isa = PBXBuildFile; fileRef = 650B68D90639033F009D42DE /* protected_values.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B8A0822A1C700736975 /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 51863F6F065420E800E9E8DD /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B8B0822A1C700736975 /* WebScriptObjectPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 700DA117065984CE00747C0B /* WebScriptObjectPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -309,6 +311,7 @@
65AB004806261CBA0076DE63 /* interpreter_map.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = interpreter_map.cpp; sourceTree = "<group>"; };
65AB004906261CBA0076DE63 /* interpreter_map.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = interpreter_map.h; sourceTree = "<group>"; };
65C02FBB0637462A003E7EE6 /* protect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protect.h; sourceTree = "<group>"; };
+ 65EF2DF408BECC80000894BB /* shared_ptr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = shared_ptr.h; sourceTree = "<group>"; };
700DA117065984CE00747C0B /* WebScriptObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = WebScriptObjectPrivate.h; path = bindings/objc/WebScriptObjectPrivate.h; sourceTree = "<group>"; };
704FD35305697E6D003DBED9 /* bool_object.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = bool_object.h; sourceTree = "<group>"; };
704FD44505698F17003DBED9 /* runtime.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = runtime.cpp; path = bindings/runtime.cpp; sourceTree = "<group>"; };
No revision
No revision
1.38.8.5 +4 -13 JavaScriptCore/kjs/function.cpp
Index: function.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/function.cpp,v
retrieving revision 1.38.8.4
retrieving revision 1.38.8.5
diff -u -r1.38.8.4 -r1.38.8.5
--- function.cpp 10 Aug 2005 02:45:51 -0000 1.38.8.4
+++ function.cpp 28 Aug 2005 23:26:52 -0000 1.38.8.5
@@ -31,6 +31,7 @@
#include "operations.h"
#include "debugger.h"
#include "context.h"
+#include "shared_ptr.h"
#include <stdio.h>
#include <errno.h>
@@ -42,6 +43,8 @@
#include <unicode/uchar.h>
#endif
+using namespace kxmlcore;
+
namespace KJS {
// ----------------------------- FunctionImp ----------------------------------
@@ -267,16 +270,9 @@
: FunctionImp(exec,n), body(b)
{
Value protect(this);
- body->ref();
setScope(sc);
}
-DeclaredFunctionImp::~DeclaredFunctionImp()
-{
- if ( body->deref() )
- delete body;
-}
-
bool DeclaredFunctionImp::implementsConstruct() const
{
return true;
@@ -644,7 +640,7 @@
int sid;
int errLine;
UString errMsg;
- ProgramNode *progNode = Parser::parse(UString(), 0, s.data(),s.size(),&sid,&errLine,&errMsg);
+ SharedPtr<ProgramNode> progNode(Parser::parse(UString(), 0, s.data(),s.size(),&sid,&errLine,&errMsg));
Debugger *dbg = exec->dynamicInterpreter()->imp()->debugger();
if (dbg) {
@@ -661,8 +657,6 @@
return err;
}
- progNode->ref();
-
// enter a new execution context
Object thisVal(Object::dynamicCast(exec->context().thisValue()));
ContextImp ctx(exec->dynamicInterpreter()->globalObject(),
@@ -686,9 +680,6 @@
exec->setException(c.value());
else if (c.isValueCompletion())
res = c.value();
-
- if ( progNode->deref() )
- delete progNode;
}
break;
}
1.19.28.2 +1 -2 JavaScriptCore/kjs/function.h
Index: function.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/function.h,v
retrieving revision 1.19.28.1
retrieving revision 1.19.28.2
diff -u -r1.19.28.1 -r1.19.28.2
--- function.h 2 Aug 2005 21:26:20 -0000 1.19.28.1
+++ function.h 28 Aug 2005 23:26:52 -0000 1.19.28.2
@@ -72,14 +72,13 @@
public:
DeclaredFunctionImp(ExecState *exec, const Identifier &n,
FunctionBodyNode *b, const ScopeChain &sc);
- ~DeclaredFunctionImp();
bool implementsConstruct() const;
Object construct(ExecState *exec, const List &args);
virtual Completion execute(ExecState *exec);
CodeType codeType() const { return FunctionCode; }
- FunctionBodyNode *body;
+ kxmlcore::SharedPtr<FunctionBodyNode> body;
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
1.24.10.2 +3 -2 JavaScriptCore/kjs/function_object.cpp
Index: function_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/function_object.cpp,v
retrieving revision 1.24.10.1
retrieving revision 1.24.10.2
diff -u -r1.24.10.1 -r1.24.10.2
--- function_object.cpp 2 Aug 2005 20:39:11 -0000 1.24.10.1
+++ function_object.cpp 28 Aug 2005 23:26:52 -0000 1.24.10.2
@@ -34,6 +34,7 @@
#include <string.h>
using namespace KJS;
+using namespace kxmlcore;
// ------------------------------ FunctionPrototypeImp -------------------------
@@ -212,7 +213,7 @@
int sid;
int errLine;
UString errMsg;
- ProgramNode *progNode = Parser::parse(sourceURL, lineNumber, body.data(),body.size(),&sid,&errLine,&errMsg);
+ SharedPtr<ProgramNode> progNode = Parser::parse(sourceURL, lineNumber, body.data(),body.size(),&sid,&errLine,&errMsg);
// notify debugger that source has been parsed
Debugger *dbg = exec->dynamicInterpreter()->imp()->debugger();
@@ -236,7 +237,7 @@
ScopeChain scopeChain;
scopeChain.push(exec->dynamicInterpreter()->globalObject().imp());
- FunctionBodyNode *bodyNode = progNode;
+ FunctionBodyNode *bodyNode = progNode.get();
FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), bodyNode,
scopeChain);
1.17.22.2 +2 -2 JavaScriptCore/kjs/grammar.y
Index: grammar.y
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/grammar.y,v
retrieving revision 1.17.22.1
retrieving revision 1.17.22.2
diff -u -r1.17.22.1 -r1.17.22.2
--- grammar.y 2 Aug 2005 20:39:11 -0000 1.17.22.1
+++ grammar.y 28 Aug 2005 23:26:52 -0000 1.17.22.2
@@ -609,9 +609,9 @@
Program:
/* nothing, empty script */ { $$ = new ProgramNode(0);
- Parser::progNode = $$; }
+ Parser::accept($$); }
| SourceElements { $$ = new ProgramNode($1);
- Parser::progNode = $$; }
+ Parser::accept($$); }
;
SourceElements:
1.53.10.4 +22 -29 JavaScriptCore/kjs/internal.cpp
Index: internal.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/internal.cpp,v
retrieving revision 1.53.10.3
retrieving revision 1.53.10.4
diff -u -r1.53.10.3 -r1.53.10.4
--- internal.cpp 2 Aug 2005 20:39:11 -0000 1.53.10.3
+++ internal.cpp 28 Aug 2005 23:26:52 -0000 1.53.10.4
@@ -54,6 +54,7 @@
extern int kjsyyparse();
using namespace KJS;
+using namespace kxmlcore;
#if !APPLE_CHANGES
@@ -435,20 +436,22 @@
// ------------------------------ Parser ---------------------------------------
-ProgramNode *Parser::progNode = 0;
+static SharedPtr<ProgramNode> *progNode;
int Parser::sid = 0;
-ProgramNode *Parser::parse(const UString &sourceURL, int startingLineNumber,
- const UChar *code, unsigned int length, int *sourceId,
- int *errLine, UString *errMsg)
+SharedPtr<ProgramNode> Parser::parse(const UString &sourceURL, int startingLineNumber,
+ const UChar *code, unsigned int length, int *sourceId,
+ int *errLine, UString *errMsg)
{
if (errLine)
*errLine = -1;
if (errMsg)
*errMsg = 0;
-
+ if (!progNode)
+ progNode = new SharedPtr<ProgramNode>;
+
Lexer::curr()->setCode(sourceURL, startingLineNumber, code, length);
- progNode = 0;
+ *progNode = 0;
sid++;
if (sourceId)
*sourceId = sid;
@@ -458,9 +461,9 @@
int parseError = kjsyyparse();
bool lexError = Lexer::curr()->sawError();
Lexer::curr()->doneParsing();
- ProgramNode *prog = progNode;
- progNode = 0;
-// sid = -1;
+ SharedPtr<ProgramNode> prog = *progNode;
+ *progNode = 0;
+ // sid = -1;
if (parseError || lexError) {
int eline = Lexer::curr()->lineNo();
@@ -468,18 +471,18 @@
*errLine = eline;
if (errMsg)
*errMsg = "Parse error";
- if (prog) {
- // must ref and deref to clean up properly
- prog->ref();
- prog->deref();
- delete prog;
- }
- return 0;
+ return SharedPtr<ProgramNode>();
}
return prog;
}
+void Parser::accept(ProgramNode *prog)
+{
+ *progNode = prog;
+}
+
+
// ------------------------------ InterpreterImp -------------------------------
InterpreterImp* InterpreterImp::s_hook = 0L;
@@ -769,15 +772,8 @@
bool InterpreterImp::checkSyntax(const UString &code)
{
// Parser::parse() returns 0 in a syntax error occurs, so we just check for that
- ProgramNode *progNode = Parser::parse(UString(), 0, code.data(),code.size(),0,0,0);
- bool ok = (progNode != 0);
- if (progNode) {
- // must ref and deref to clean up properly
- progNode->ref();
- progNode->deref();
- delete progNode;
- }
- return ok;
+ SharedPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(),code.size(),0,0,0);
+ return progNode;
}
Completion InterpreterImp::evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber)
@@ -800,7 +796,7 @@
int sid;
int errLine;
UString errMsg;
- ProgramNode *progNode = Parser::parse(sourceURL, startingLineNumber, code.data(),code.size(),&sid,&errLine,&errMsg);
+ SharedPtr<ProgramNode> progNode = Parser::parse(sourceURL, startingLineNumber, code.data(),code.size(),&sid,&errLine,&errMsg);
// notify debugger that source has been parsed
if (dbg) {
@@ -829,7 +825,6 @@
globExec->clearException();
recursion++;
- progNode->ref();
Object &globalObj = globalObject();
Object thisObj = globalObject();
@@ -857,8 +852,6 @@
res = progNode->execute(&newExec);
}
- if (progNode->deref())
- delete progNode;
recursion--;
#if APPLE_CHANGES
1.25.10.3 +5 -4 JavaScriptCore/kjs/internal.h
Index: internal.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/internal.h,v
retrieving revision 1.25.10.2
retrieving revision 1.25.10.3
diff -u -r1.25.10.2 -r1.25.10.3
--- internal.h 2 Aug 2005 20:39:11 -0000 1.25.10.2
+++ internal.h 28 Aug 2005 23:26:52 -0000 1.25.10.3
@@ -31,6 +31,7 @@
#include "types.h"
#include "interpreter.h"
#include "scope_chain.h"
+#include "shared_ptr.h"
#define I18N_NOOP(s) s
@@ -205,11 +206,11 @@
*/
class Parser {
public:
- static ProgramNode *parse(const UString &sourceURL, int startingLineNumber,
- const UChar *code, unsigned int length, int *sourceId = 0,
- int *errLine = 0, UString *errMsg = 0);
+ static kxmlcore::SharedPtr<ProgramNode> parse(const UString &sourceURL, int startingLineNumber,
+ const UChar *code, unsigned int length, int *sourceId = 0,
+ int *errLine = 0, UString *errMsg = 0);
+ static void accept(ProgramNode *prog);
- static ProgramNode *progNode;
static int sid;
};
1.52.12.6 +26 -1032 JavaScriptCore/kjs/nodes.cpp
Index: nodes.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/nodes.cpp,v
retrieving revision 1.52.12.5
retrieving revision 1.52.12.6
diff -u -r1.52.12.5 -r1.52.12.6
--- nodes.cpp 10 Aug 2005 02:45:51 -0000 1.52.12.5
+++ nodes.cpp 28 Aug 2005 23:26:52 -0000 1.52.12.6
@@ -91,19 +91,11 @@
{
line = Lexer::curr()->lineNo();
sourceURL = Lexer::curr()->sourceURL();
- refcount = 0;
-#ifdef KJS_DEBUG_MEM
- if (!s_nodes)
- s_nodes = new std::list<Node *>;
- s_nodes->push_back(this);
-#endif
+ m_refcount = 0;
}
Node::~Node()
{
-#ifdef KJS_DEBUG_MEM
- s_nodes->remove( this );
-#endif
}
Reference Node::evaluateReference(ExecState *exec)
@@ -283,20 +275,6 @@
// ------------------------------ GroupNode ------------------------------------
-void GroupNode::ref()
-{
- Node::ref();
- if ( group )
- group->ref();
-}
-
-bool GroupNode::deref()
-{
- if ( group && group->deref() )
- delete group;
- return Node::deref();
-}
-
// ECMA 11.1.6
Value GroupNode::evaluate(ExecState *exec)
{
@@ -310,34 +288,12 @@
// ------------------------------ ElementNode ----------------------------------
-void ElementNode::ref()
-{
- for (ElementNode *n = this; n; n = n->list) {
- n->Node::ref();
- if (n->node)
- n->node->ref();
- }
-}
-
-bool ElementNode::deref()
-{
- ElementNode *next;
- for (ElementNode *n = this; n; n = next) {
- next = n->list;
- if (n->node && n->node->deref())
- delete n->node;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
// ECMA 11.1.4
Value ElementNode::evaluate(ExecState *exec)
{
Object array = exec->lexicalInterpreter()->builtinArray().construct(exec, List::empty());
int length = 0;
- for (ElementNode *n = this; n; n = n->list) {
+ for (ElementNode *n = this; n; n = n->list.get()) {
Value val = n->node->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
length += n->elision;
@@ -348,20 +304,6 @@
// ------------------------------ ArrayNode ------------------------------------
-void ArrayNode::ref()
-{
- Node::ref();
- if ( element )
- element->ref();
-}
-
-bool ArrayNode::deref()
-{
- if ( element && element->deref() )
- delete element;
- return Node::deref();
-}
-
// ECMA 11.1.4
Value ArrayNode::evaluate(ExecState *exec)
{
@@ -386,20 +328,6 @@
// ------------------------------ ObjectLiteralNode ----------------------------
-void ObjectLiteralNode::ref()
-{
- Node::ref();
- if ( list )
- list->ref();
-}
-
-bool ObjectLiteralNode::deref()
-{
- if ( list && list->deref() )
- delete list;
- return Node::deref();
-}
-
// ECMA 11.1.5
Value ObjectLiteralNode::evaluate(ExecState *exec)
{
@@ -411,38 +339,12 @@
// ------------------------------ PropertyValueNode ----------------------------
-void PropertyValueNode::ref()
-{
- for (PropertyValueNode *n = this; n; n = n->list) {
- n->Node::ref();
- if (n->name)
- n->name->ref();
- if (n->assign)
- n->assign->ref();
- }
-}
-
-bool PropertyValueNode::deref()
-{
- PropertyValueNode *next;
- for (PropertyValueNode *n = this; n; n = next) {
- next = n->list;
- if ( n->name && n->name->deref() )
- delete n->name;
- if ( n->assign && n->assign->deref() )
- delete n->assign;
- if (n != this && n->Node::deref() )
- delete n;
- }
- return Node::deref();
-}
-
// ECMA 11.1.5
Value PropertyValueNode::evaluate(ExecState *exec)
{
Object obj = exec->lexicalInterpreter()->builtinObject().construct(exec, List::empty());
- for (PropertyValueNode *p = this; p; p = p->list) {
+ for (PropertyValueNode *p = this; p; p = p->list.get()) {
Value n = p->name->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
Value v = p->assign->evaluate(exec);
@@ -472,24 +374,6 @@
// ------------------------------ AccessorNode1 --------------------------------
-void AccessorNode1::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
-}
-
-bool AccessorNode1::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- return Node::deref();
-}
-
// ECMA 11.2.1a
Value AccessorNode1::evaluate(ExecState *exec)
{
@@ -513,20 +397,6 @@
// ------------------------------ AccessorNode2 --------------------------------
-void AccessorNode2::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool AccessorNode2::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.2.1b
Value AccessorNode2::evaluate(ExecState *exec)
{
@@ -543,28 +413,6 @@
// ------------------------------ ArgumentListNode -----------------------------
-void ArgumentListNode::ref()
-{
- for (ArgumentListNode *n = this; n; n = n->list) {
- n->Node::ref();
- if (n->expr)
- n->expr->ref();
- }
-}
-
-bool ArgumentListNode::deref()
-{
- ArgumentListNode *next;
- for (ArgumentListNode *n = this; n; n = next) {
- next = n->list;
- if (n->expr && n->expr->deref())
- delete n->expr;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
Value ArgumentListNode::evaluate(ExecState */*exec*/)
{
assert(0);
@@ -576,7 +424,7 @@
{
List l;
- for (ArgumentListNode *n = this; n; n = n->list) {
+ for (ArgumentListNode *n = this; n; n = n->list.get()) {
Value v = n->expr->evaluate(exec);
KJS_CHECKEXCEPTIONLIST
l.append(v);
@@ -587,20 +435,6 @@
// ------------------------------ ArgumentsNode --------------------------------
-void ArgumentsNode::ref()
-{
- Node::ref();
- if ( list )
- list->ref();
-}
-
-bool ArgumentsNode::deref()
-{
- if ( list && list->deref() )
- delete list;
- return Node::deref();
-}
-
Value ArgumentsNode::evaluate(ExecState */*exec*/)
{
assert(0);
@@ -620,24 +454,6 @@
// ECMA 11.2.2
-void NewExprNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
- if ( args )
- args->ref();
-}
-
-bool NewExprNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- if ( args && args->deref() )
- delete args;
- return Node::deref();
-}
-
Value NewExprNode::evaluate(ExecState *exec)
{
Value v = expr->evaluate(exec);
@@ -650,12 +466,12 @@
}
if (v.type() != ObjectType) {
- return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr);
+ return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr.get());
}
Object constr = Object(static_cast<ObjectImp*>(v.imp()));
if (!constr.implementsConstruct()) {
- return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr);
+ return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr.get());
}
Value res = constr.construct(exec,argList);
@@ -665,24 +481,6 @@
// ------------------------------ FunctionCallNode -----------------------------
-void FunctionCallNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
- if ( args )
- args->ref();
-}
-
-bool FunctionCallNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- if ( args && args->deref() )
- delete args;
- return Node::deref();
-}
-
// ECMA 11.2.3
Value FunctionCallNode::evaluate(ExecState *exec)
{
@@ -696,13 +494,13 @@
Value v = ref.getValue(exec);
if (v.type() != ObjectType) {
- return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, expr);
+ return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, expr.get());
}
ObjectImp *func = static_cast<ObjectImp*>(v.imp());
if (!func->implementsCall()) {
- return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, expr);
+ return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, expr.get());
}
ObjectImp *thisObjImp = 0;
@@ -726,20 +524,6 @@
// ------------------------------ PostfixNode ----------------------------------
-void PostfixNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool PostfixNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.3
Value PostfixNode::evaluate(ExecState *exec)
{
@@ -758,20 +542,6 @@
// ------------------------------ DeleteNode -----------------------------------
-void DeleteNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool DeleteNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.1
Value DeleteNode::evaluate(ExecState *exec)
{
@@ -782,20 +552,6 @@
// ------------------------------ VoidNode -------------------------------------
-void VoidNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool VoidNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.2
Value VoidNode::evaluate(ExecState *exec)
{
@@ -807,20 +563,6 @@
// ------------------------------ TypeOfNode -----------------------------------
-void TypeOfNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool TypeOfNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.3
Value TypeOfNode::evaluate(ExecState *exec)
{
@@ -861,20 +603,6 @@
// ------------------------------ PrefixNode -----------------------------------
-void PrefixNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool PrefixNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.4 and 11.4.5
Value PrefixNode::evaluate(ExecState *exec)
{
@@ -895,20 +623,6 @@
// ------------------------------ UnaryPlusNode --------------------------------
-void UnaryPlusNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool UnaryPlusNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.6
Value UnaryPlusNode::evaluate(ExecState *exec)
{
@@ -920,20 +634,6 @@
// ------------------------------ NegateNode -----------------------------------
-void NegateNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool NegateNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.7
Value NegateNode::evaluate(ExecState *exec)
{
@@ -947,20 +647,6 @@
// ------------------------------ BitwiseNotNode -------------------------------
-void BitwiseNotNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool BitwiseNotNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.8
Value BitwiseNotNode::evaluate(ExecState *exec)
{
@@ -971,20 +657,6 @@
// ------------------------------ LogicalNotNode -------------------------------
-void LogicalNotNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool LogicalNotNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.4.9
Value LogicalNotNode::evaluate(ExecState *exec)
{
@@ -995,24 +667,6 @@
// ------------------------------ MultNode -------------------------------------
-void MultNode::ref()
-{
- Node::ref();
- if ( term1 )
- term1->ref();
- if ( term2 )
- term2->ref();
-}
-
-bool MultNode::deref()
-{
- if ( term1 && term1->deref() )
- delete term1;
- if ( term2 && term2->deref() )
- delete term2;
- return Node::deref();
-}
-
// ECMA 11.5
Value MultNode::evaluate(ExecState *exec)
{
@@ -1027,24 +681,6 @@
// ------------------------------ AddNode --------------------------------------
-void AddNode::ref()
-{
- Node::ref();
- if ( term1 )
- term1->ref();
- if ( term2 )
- term2->ref();
-}
-
-bool AddNode::deref()
-{
- if ( term1 && term1->deref() )
- delete term1;
- if ( term2 && term2->deref() )
- delete term2;
- return Node::deref();
-}
-
// ECMA 11.6
Value AddNode::evaluate(ExecState *exec)
{
@@ -1059,24 +695,6 @@
// ------------------------------ ShiftNode ------------------------------------
-void ShiftNode::ref()
-{
- Node::ref();
- if ( term1 )
- term1->ref();
- if ( term2 )
- term2->ref();
-}
-
-bool ShiftNode::deref()
-{
- if ( term1 && term1->deref() )
- delete term1;
- if ( term2 && term2->deref() )
- delete term2;
- return Node::deref();
-}
-
// ECMA 11.7
Value ShiftNode::evaluate(ExecState *exec)
{
@@ -1102,24 +720,6 @@
// ------------------------------ RelationalNode -------------------------------
-void RelationalNode::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
-}
-
-bool RelationalNode::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- return Node::deref();
-}
-
// ECMA 11.8
Value RelationalNode::evaluate(ExecState *exec)
{
@@ -1145,13 +745,13 @@
// Is all of this OK for host objects?
if (v2.type() != ObjectType)
return throwError(exec, TypeError,
- "Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2);
+ "Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2.get());
Object o2(static_cast<ObjectImp*>(v2.imp()));
b = o2.hasProperty(exec, Identifier(v1.toString(exec)));
} else {
if (v2.type() != ObjectType)
return throwError(exec, TypeError,
- "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2);
+ "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2.get());
Object o2(static_cast<ObjectImp*>(v2.imp()));
if (!o2.implementsHasInstance()) {
@@ -1171,24 +771,6 @@
// ------------------------------ EqualNode ------------------------------------
-void EqualNode::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
-}
-
-bool EqualNode::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- return Node::deref();
-}
-
// ECMA 11.9
Value EqualNode::evaluate(ExecState *exec)
{
@@ -1212,24 +794,6 @@
// ------------------------------ BitOperNode ----------------------------------
-void BitOperNode::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
-}
-
-bool BitOperNode::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- return Node::deref();
-}
-
// ECMA 11.10
Value BitOperNode::evaluate(ExecState *exec)
{
@@ -1252,24 +816,6 @@
// ------------------------------ BinaryLogicalNode ----------------------------
-void BinaryLogicalNode::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
-}
-
-bool BinaryLogicalNode::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- return Node::deref();
-}
-
// ECMA 11.11
Value BinaryLogicalNode::evaluate(ExecState *exec)
{
@@ -1287,28 +833,6 @@
// ------------------------------ ConditionalNode ------------------------------
-void ConditionalNode::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
- if ( logical )
- logical->ref();
-}
-
-bool ConditionalNode::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- if ( logical && logical->deref() )
- delete logical;
- return Node::deref();
-}
-
// ECMA 11.12
Value ConditionalNode::evaluate(ExecState *exec)
{
@@ -1327,24 +851,6 @@
// ------------------------------ AssignNode -----------------------------------
-void AssignNode::ref()
-{
- Node::ref();
- if ( left )
- left->ref();
- if ( expr )
- expr->ref();
-}
-
-bool AssignNode::deref()
-{
- if ( left && left->deref() )
- delete left;
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 11.13
Value AssignNode::evaluate(ExecState *exec)
{
@@ -1425,24 +931,6 @@
// ------------------------------ CommaNode ------------------------------------
-void CommaNode::ref()
-{
- Node::ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
-}
-
-bool CommaNode::deref()
-{
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- return Node::deref();
-}
-
// ECMA 11.14
Value CommaNode::evaluate(ExecState *exec)
{
@@ -1469,28 +957,6 @@
setLoc(l->firstLine(), s->lastLine(), l->sourceId());
}
-void StatListNode::ref()
-{
- for (StatListNode *n = this; n; n = n->list) {
- n->Node::ref();
- if (n->statement)
- n->statement->ref();
- }
-}
-
-bool StatListNode::deref()
-{
- StatListNode *next;
- for (StatListNode *n = this; n; n = next) {
- next = n->list;
- if (n->statement && n->statement->deref())
- delete n->statement;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
// ECMA 12.1
Completion StatListNode::execute(ExecState *exec)
{
@@ -1507,7 +973,7 @@
Value v = c.value();
- for (StatListNode *n = list; n; n = n->list) {
+ for (StatListNode *n = list.get(); n; n = n->list.get()) {
Completion c2 = n->statement->execute(exec);
KJS_ABORTPOINT
if (c2.complType() != Normal)
@@ -1529,26 +995,12 @@
void StatListNode::processVarDecls(ExecState *exec)
{
- for (StatListNode *n = this; n; n = n->list)
+ for (StatListNode *n = this; n; n = n->list.get())
n->statement->processVarDecls(exec);
}
// ------------------------------ AssignExprNode -------------------------------
-void AssignExprNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool AssignExprNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.2
Value AssignExprNode::evaluate(ExecState *exec)
{
@@ -1562,20 +1014,6 @@
{
}
-void VarDeclNode::ref()
-{
- Node::ref();
- if ( init )
- init->ref();
-}
-
-bool VarDeclNode::deref()
-{
- if ( init && init->deref() )
- delete init;
- return Node::deref();
-}
-
// ECMA 12.2
Value VarDeclNode::evaluate(ExecState *exec)
{
@@ -1616,33 +1054,10 @@
// ------------------------------ VarDeclListNode ------------------------------
-void VarDeclListNode::ref()
-{
- for (VarDeclListNode *n = this; n; n = n->list) {
- n->Node::ref();
- if (n->var)
- n->var->ref();
- }
-}
-
-bool VarDeclListNode::deref()
-{
- VarDeclListNode *next;
- for (VarDeclListNode *n = this; n; n = next) {
- next = n->list;
- if (n->var && n->var->deref())
- delete n->var;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
-
// ECMA 12.2
Value VarDeclListNode::evaluate(ExecState *exec)
{
- for (VarDeclListNode *n = this; n; n = n->list) {
+ for (VarDeclListNode *n = this; n; n = n->list.get()) {
n->var->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
}
@@ -1651,26 +1066,12 @@
void VarDeclListNode::processVarDecls(ExecState *exec)
{
- for (VarDeclListNode *n = this; n; n = n->list)
+ for (VarDeclListNode *n = this; n; n = n->list.get())
n->var->processVarDecls(exec);
}
// ------------------------------ VarStatementNode -----------------------------
-void VarStatementNode::ref()
-{
- Node::ref();
- if ( list )
- list->ref();
-}
-
-bool VarStatementNode::deref()
-{
- if ( list && list->deref() )
- delete list;
- return Node::deref();
-}
-
// ECMA 12.2
Completion VarStatementNode::execute(ExecState *exec)
{
@@ -1700,20 +1101,6 @@
}
}
-void BlockNode::ref()
-{
- Node::ref();
- if ( source )
- source->ref();
-}
-
-bool BlockNode::deref()
-{
- if ( source && source->deref() )
- delete source;
- return Node::deref();
-}
-
// ECMA 12.1
Completion BlockNode::execute(ExecState *exec)
{
@@ -1741,20 +1128,6 @@
// ------------------------------ ExprStatementNode ----------------------------
-void ExprStatementNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool ExprStatementNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.4
Completion ExprStatementNode::execute(ExecState *exec)
{
@@ -1768,28 +1141,6 @@
// ------------------------------ IfNode ---------------------------------------
-void IfNode::ref()
-{
- Node::ref();
- if ( statement1 )
- statement1->ref();
- if ( statement2 )
- statement2->ref();
- if ( expr )
- expr->ref();
-}
-
-bool IfNode::deref()
-{
- if ( statement1 && statement1->deref() )
- delete statement1;
- if ( statement2 && statement2->deref() )
- delete statement2;
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.5
Completion IfNode::execute(ExecState *exec)
{
@@ -1821,24 +1172,6 @@
// ------------------------------ DoWhileNode ----------------------------------
-void DoWhileNode::ref()
-{
- Node::ref();
- if ( statement )
- statement->ref();
- if ( expr )
- expr->ref();
-}
-
-bool DoWhileNode::deref()
-{
- if ( statement && statement->deref() )
- delete statement;
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.6.1
Completion DoWhileNode::execute(ExecState *exec)
{
@@ -1873,24 +1206,6 @@
// ------------------------------ WhileNode ------------------------------------
-void WhileNode::ref()
-{
- Node::ref();
- if ( statement )
- statement->ref();
- if ( expr )
- expr->ref();
-}
-
-bool WhileNode::deref()
-{
- if ( statement && statement->deref() )
- delete statement;
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.6.2
Completion WhileNode::execute(ExecState *exec)
{
@@ -1934,32 +1249,6 @@
// ------------------------------ ForNode --------------------------------------
-void ForNode::ref()
-{
- Node::ref();
- if ( statement )
- statement->ref();
- if ( expr1 )
- expr1->ref();
- if ( expr2 )
- expr2->ref();
- if ( expr3 )
- expr3->ref();
-}
-
-bool ForNode::deref()
-{
- if ( statement && statement->deref() )
- delete statement;
- if ( expr1 && expr1->deref() )
- delete expr1;
- if ( expr2 && expr2->deref() )
- delete expr2;
- if ( expr3 && expr3->deref() )
- delete expr3;
- return Node::deref();
-}
-
// ECMA 12.6.3
Completion ForNode::execute(ExecState *exec)
{
@@ -2016,40 +1305,10 @@
: ident(i), init(in), expr(e), statement(s)
{
// for( var foo = bar in baz )
- varDecl = new VarDeclNode(ident, init);
+ varDecl = new VarDeclNode(ident, init.get());
lexpr = new ResolveNode(ident);
}
-void ForInNode::ref()
-{
- Node::ref();
- if ( statement )
- statement->ref();
- if ( expr )
- expr->ref();
- if ( lexpr )
- lexpr->ref();
- if ( init )
- init->ref();
- if ( varDecl )
- varDecl->ref();
-}
-
-bool ForInNode::deref()
-{
- if ( statement && statement->deref() )
- delete statement;
- if ( expr && expr->deref() )
- delete expr;
- if ( lexpr && lexpr->deref() )
- delete lexpr;
- if ( init && init->deref() )
- delete init;
- if ( varDecl && varDecl->deref() )
- delete varDecl;
- return Node::deref();
-}
-
// ECMA 12.6.4
Completion ForInNode::execute(ExecState *exec)
{
@@ -2146,20 +1405,6 @@
// ------------------------------ ReturnNode -----------------------------------
-void ReturnNode::ref()
-{
- Node::ref();
- if ( value )
- value->ref();
-}
-
-bool ReturnNode::deref()
-{
- if ( value && value->deref() )
- delete value;
- return Node::deref();
-}
-
// ECMA 12.9
Completion ReturnNode::execute(ExecState *exec)
{
@@ -2176,24 +1421,6 @@
// ------------------------------ WithNode -------------------------------------
-void WithNode::ref()
-{
- Node::ref();
- if ( statement )
- statement->ref();
- if ( expr )
- expr->ref();
-}
-
-bool WithNode::deref()
-{
- if ( statement && statement->deref() )
- delete statement;
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.10
Completion WithNode::execute(ExecState *exec)
{
@@ -2217,24 +1444,6 @@
// ------------------------------ CaseClauseNode -------------------------------
-void CaseClauseNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
- if ( list )
- list->ref();
-}
-
-bool CaseClauseNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- if ( list && list->deref() )
- delete list;
- return Node::deref();
-}
-
// ECMA 12.11
Value CaseClauseNode::evaluate(ExecState *exec)
{
@@ -2261,28 +1470,6 @@
// ------------------------------ ClauseListNode -------------------------------
-void ClauseListNode::ref()
-{
- for (ClauseListNode *n = this; n; n = n->nx) {
- n->Node::ref();
- if (n->cl)
- n->cl->ref();
- }
-}
-
-bool ClauseListNode::deref()
-{
- ClauseListNode *next;
- for (ClauseListNode *n = this; n; n = next) {
- next = n->nx;
- if (n->cl && n->cl->deref())
- delete n->cl;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
Value ClauseListNode::evaluate(ExecState */*exec*/)
{
/* should never be called */
@@ -2293,7 +1480,7 @@
// ECMA 12.11
void ClauseListNode::processVarDecls(ExecState *exec)
{
- for (ClauseListNode *n = this; n; n = n->nx)
+ for (ClauseListNode *n = this; n; n = n->nx.get())
if (n->cl)
n->cl->processVarDecls(exec);
}
@@ -2320,28 +1507,6 @@
}
}
-void CaseBlockNode::ref()
-{
- Node::ref();
- if ( def )
- def->ref();
- if ( list1 )
- list1->ref();
- if ( list2 )
- list2->ref();
-}
-
-bool CaseBlockNode::deref()
-{
- if ( def && def->deref() )
- delete def;
- if ( list1 && list1->deref() )
- delete list1;
- if ( list2 && list2->deref() )
- delete list2;
- return Node::deref();
-}
-
Value CaseBlockNode::evaluate(ExecState */*exec*/)
{
/* should never be called */
@@ -2354,7 +1519,8 @@
{
Value v;
Completion res;
- ClauseListNode *a = list1, *b = list2;
+ ClauseListNode *a = list1.get();
+ ClauseListNode *b = list2.get();
CaseClauseNode *clause;
while (a) {
@@ -2395,7 +1561,7 @@
if (res.complType() != Normal)
return res;
}
- b = list2;
+ b = list2.get();
step18:
while (b) {
clause = b->clause();
@@ -2423,24 +1589,6 @@
// ------------------------------ SwitchNode -----------------------------------
-void SwitchNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
- if ( block )
- block->ref();
-}
-
-bool SwitchNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- if ( block && block->deref() )
- delete block;
- return Node::deref();
-}
-
// ECMA 12.11
Completion SwitchNode::execute(ExecState *exec)
{
@@ -2462,20 +1610,6 @@
// ------------------------------ LabelNode ------------------------------------
-void LabelNode::ref()
-{
- Node::ref();
- if ( statement )
- statement->ref();
-}
-
-bool LabelNode::deref()
-{
- if ( statement && statement->deref() )
- delete statement;
- return Node::deref();
-}
-
// ECMA 12.12
Completion LabelNode::execute(ExecState *exec)
{
@@ -2500,20 +1634,6 @@
// ------------------------------ ThrowNode ------------------------------------
-void ThrowNode::ref()
-{
- Node::ref();
- if ( expr )
- expr->ref();
-}
-
-bool ThrowNode::deref()
-{
- if ( expr && expr->deref() )
- delete expr;
- return Node::deref();
-}
-
// ECMA 12.13
Completion ThrowNode::execute(ExecState *exec)
{
@@ -2527,20 +1647,6 @@
// ------------------------------ CatchNode ------------------------------------
-void CatchNode::ref()
-{
- Node::ref();
- if ( block )
- block->ref();
-}
-
-bool CatchNode::deref()
-{
- if ( block && block->deref() )
- delete block;
- return Node::deref();
-}
-
Completion CatchNode::execute(ExecState */*exec*/)
{
// should never be reached. execute(exec, arg) is used instead
@@ -2571,20 +1677,6 @@
// ------------------------------ FinallyNode ----------------------------------
-void FinallyNode::ref()
-{
- Node::ref();
- if ( block )
- block->ref();
-}
-
-bool FinallyNode::deref()
-{
- if ( block && block->deref() )
- delete block;
- return Node::deref();
-}
-
// ECMA 12.14
Completion FinallyNode::execute(ExecState *exec)
{
@@ -2598,28 +1690,6 @@
// ------------------------------ TryNode --------------------------------------
-void TryNode::ref()
-{
- Node::ref();
- if ( block )
- block->ref();
- if ( _final )
- _final->ref();
- if ( _catch )
- _catch->ref();
-}
-
-bool TryNode::deref()
-{
- if ( block && block->deref() )
- delete block;
- if ( _final && _final->deref() )
- delete _final;
- if ( _catch && _catch->deref() )
- delete _catch;
- return Node::deref();
-}
-
// ECMA 12.14
Completion TryNode::execute(ExecState *exec)
{
@@ -2665,23 +1735,6 @@
// ------------------------------ ParameterNode --------------------------------
-void ParameterNode::ref()
-{
- for (ParameterNode *n = this; n; n = n->next)
- n->Node::ref();
-}
-
-bool ParameterNode::deref()
-{
- ParameterNode *next;
- for (ParameterNode *n = this; n; n = next) {
- next = n->next;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
// ECMA 13
Value ParameterNode::evaluate(ExecState */*exec*/)
{
@@ -2705,29 +1758,11 @@
// ------------------------------ FuncDeclNode ---------------------------------
-void FuncDeclNode::ref()
-{
- Node::ref();
- if ( param )
- param->ref();
- if ( body )
- body->ref();
-}
-
-bool FuncDeclNode::deref()
-{
- if ( param && param->deref() )
- delete param;
- if ( body && body->deref() )
- delete body;
- return Node::deref();
-}
-
// ECMA 13
void FuncDeclNode::processFuncDecl(ExecState *exec)
{
// TODO: let this be an object with [[Class]] property "Function"
- FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, exec->context().imp()->scopeChain());
+ FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body.get(), exec->context().imp()->scopeChain());
Object func(fimp); // protect from GC
// Value proto = exec->lexicalInterpreter()->builtinObject().construct(exec,List::empty());
@@ -2737,7 +1772,7 @@
func.put(exec, prototypePropertyName, proto, Internal|DontDelete);
int plen = 0;
- for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
+ for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
fimp->addParameter(p->ident());
func.put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
@@ -2758,36 +1793,17 @@
// ------------------------------ FuncExprNode ---------------------------------
-void FuncExprNode::ref()
-{
- Node::ref();
- if ( param )
- param->ref();
- if ( body )
- body->ref();
-}
-
-bool FuncExprNode::deref()
-{
- if ( param && param->deref() )
- delete param;
- if ( body && body->deref() )
- delete body;
- return Node::deref();
-}
-
-
// ECMA 13
Value FuncExprNode::evaluate(ExecState *exec)
{
- FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), body, exec->context().imp()->scopeChain());
+ FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), body.get(), exec->context().imp()->scopeChain());
Value ret(fimp);
List empty;
Value proto = exec->lexicalInterpreter()->builtinObject().construct(exec,empty);
fimp->put(exec, prototypePropertyName, proto, Internal|DontDelete);
int plen = 0;
- for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
+ for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
fimp->addParameter(p->ident());
return ret;
@@ -2808,28 +1824,6 @@
setLoc(s1->firstLine(), s2->lastLine(), s1->sourceId());
}
-void SourceElementsNode::ref()
-{
- for (SourceElementsNode *n = this; n; n = n->elements) {
- n->Node::ref();
- if (n->element)
- n->element->ref();
- }
-}
-
-bool SourceElementsNode::deref()
-{
- SourceElementsNode *next;
- for (SourceElementsNode *n = this; n; n = next) {
- next = n->elements;
- if (n->element && n->element->deref())
- delete n->element;
- if (n != this && n->Node::deref())
- delete n;
- }
- return Node::deref();
-}
-
// ECMA 14
Completion SourceElementsNode::execute(ExecState *exec)
{
@@ -2840,7 +1834,7 @@
if (c1.complType() != Normal)
return c1;
- for (SourceElementsNode *n = elements; n; n = n->elements) {
+ for (SourceElementsNode *n = elements.get(); n; n = n->elements.get()) {
Completion c2 = n->element->execute(exec);
if (c2.complType() != Normal)
return c2;
@@ -2856,13 +1850,13 @@
// ECMA 14
void SourceElementsNode::processFuncDecl(ExecState *exec)
{
- for (SourceElementsNode *n = this; n; n = n->elements)
+ for (SourceElementsNode *n = this; n; n = n->elements.get())
n->element->processFuncDecl(exec);
}
void SourceElementsNode::processVarDecls(ExecState *exec)
{
- for (SourceElementsNode *n = this; n; n = n->elements)
+ for (SourceElementsNode *n = this; n; n = n->elements.get())
n->element->processVarDecls(exec);
}
1.19.12.2 +105 -215 JavaScriptCore/kjs/nodes.h
Index: nodes.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/nodes.h,v
retrieving revision 1.19.12.1
retrieving revision 1.19.12.2
diff -u -r1.19.12.1 -r1.19.12.2
--- nodes.h 22 Jul 2005 03:09:33 -0000 1.19.12.1
+++ nodes.h 28 Aug 2005 23:26:53 -0000 1.19.12.2
@@ -26,6 +26,7 @@
#define _NODES_H_
#include "fast_malloc.h"
+#include "shared_ptr.h"
#include "internal.h"
//#include "debugger.h"
@@ -91,30 +92,18 @@
public:
// reference counting mechanism
- virtual void ref() { refcount++; }
-#ifdef KJS_DEBUG_MEM
- virtual bool deref() { assert( refcount > 0 ); return (!--refcount); }
-#else
- virtual bool deref() { return (!--refcount); }
-#endif
-
+ void ref() { ++m_refcount; }
+ void deref() { --m_refcount; if (!m_refcount) delete this; }
-#ifdef KJS_DEBUG_MEM
- static void finalCheck();
-#endif
protected:
Value throwError(ExecState *exec, ErrorType e, const char *msg);
Value throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr);
Value throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
int line;
UString sourceURL;
- unsigned int refcount;
+ unsigned int m_refcount;
virtual int sourceId() const { return -1; }
private:
-#ifdef KJS_DEBUG_MEM
- // List of all nodes, for debugging purposes. Don't remove!
- static std::list<Node *> *s_nodes;
-#endif
// disallow assignment
Node& operator=(const Node&);
Node(const Node &other);
@@ -205,13 +194,11 @@
class GroupNode : public Node {
public:
GroupNode(Node *g) : group(g) { }
- virtual void ref();
- virtual bool deref();
virtual Value evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const { group->streamTo(s); }
private:
- Node *group;
+ kxmlcore::SharedPtr<Node> group;
};
class ElementNode : public Node {
@@ -220,15 +207,13 @@
ElementNode(int e, Node *n) : list(this), elision(e), node(n) { }
ElementNode(ElementNode *l, int e, Node *n)
: list(l->list), elision(e), node(n) { l->list = this; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class ArrayNode;
- ElementNode *list;
+ kxmlcore::SharedPtr<ElementNode> list;
int elision;
- Node *node;
+ kxmlcore::SharedPtr<Node> node;
};
class ArrayNode : public Node {
@@ -238,12 +223,10 @@
: element(ele->list), elision(0), opt(false) { ele->list = 0; }
ArrayNode(int eli, ElementNode *ele)
: element(ele->list), elision(eli), opt(true) { ele->list = 0; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- ElementNode *element;
+ kxmlcore::SharedPtr<ElementNode> element;
int elision;
bool opt;
};
@@ -255,27 +238,23 @@
: name(n), assign(a), list(this) { }
PropertyValueNode(PropertyNode *n, Node *a, PropertyValueNode *l)
: name(n), assign(a), list(l->list) { l->list = this; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class ObjectLiteralNode;
- PropertyNode *name;
- Node *assign;
- PropertyValueNode *list;
+ kxmlcore::SharedPtr<PropertyNode> name;
+ kxmlcore::SharedPtr<Node> assign;
+ kxmlcore::SharedPtr<PropertyValueNode> list;
};
class ObjectLiteralNode : public Node {
public:
ObjectLiteralNode() : list(0) { }
ObjectLiteralNode(PropertyValueNode *l) : list(l->list) { l->list = 0; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- PropertyValueNode *list;
+ kxmlcore::SharedPtr<PropertyValueNode> list;
};
class PropertyNode : public Node {
@@ -292,26 +271,22 @@
class AccessorNode1 : public Node {
public:
AccessorNode1(Node *e1, Node *e2) : expr1(e1), expr2(e2) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1;
- Node *expr2;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
};
class AccessorNode2 : public Node {
public:
AccessorNode2(Node *e, const Identifier &s) : expr(e), ident(s) { }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
Identifier ident;
};
@@ -321,15 +296,13 @@
ArgumentListNode(Node *e) : list(this), expr(e) { }
ArgumentListNode(ArgumentListNode *l, Node *e)
: list(l->list), expr(e) { l->list = this; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
List evaluateList(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class ArgumentsNode;
- ArgumentListNode *list;
- Node *expr;
+ kxmlcore::SharedPtr<ArgumentListNode> list;
+ kxmlcore::SharedPtr<Node> expr;
};
class ArgumentsNode : public Node {
@@ -337,57 +310,47 @@
ArgumentsNode() : list(0) { }
ArgumentsNode(ArgumentListNode *l)
: list(l->list) { l->list = 0; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
List evaluateList(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- ArgumentListNode *list;
+ kxmlcore::SharedPtr<ArgumentListNode> list;
};
class NewExprNode : public Node {
public:
NewExprNode(Node *e) : expr(e), args(0) {}
NewExprNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- ArgumentsNode *args;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<ArgumentsNode> args;
};
class FunctionCallNode : public Node {
public:
FunctionCallNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- ArgumentsNode *args;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<ArgumentsNode> args;
};
class PostfixNode : public Node {
public:
PostfixNode(Node *e, Operator o) : expr(e), oper(o) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
Operator oper;
};
class DeleteNode : public Node {
public:
DeleteNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -397,19 +360,15 @@
class VoidNode : public Node {
public:
VoidNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class TypeOfNode : public Node {
public:
TypeOfNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -419,80 +378,68 @@
class PrefixNode : public Node {
public:
PrefixNode(Operator o, Node *e) : oper(o), expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Operator oper;
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class UnaryPlusNode : public Node {
public:
UnaryPlusNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class NegateNode : public Node {
public:
NegateNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class BitwiseNotNode : public Node {
public:
BitwiseNotNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class LogicalNotNode : public Node {
public:
LogicalNotNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class MultNode : public Node {
public:
MultNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *term1, *term2;
+ kxmlcore::SharedPtr<Node> term1;
+ kxmlcore::SharedPtr<Node> term2;
char oper;
};
class AddNode : public Node {
public:
AddNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *term1, *term2;
+ kxmlcore::SharedPtr<Node> term1;
+ kxmlcore::SharedPtr<Node> term2;
char oper;
};
@@ -500,12 +447,11 @@
public:
ShiftNode(Node *t1, Operator o, Node *t2)
: term1(t1), term2(t2), oper(o) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *term1, *term2;
+ kxmlcore::SharedPtr<Node> term1;
+ kxmlcore::SharedPtr<Node> term2;
Operator oper;
};
@@ -513,12 +459,11 @@
public:
RelationalNode(Node *e1, Operator o, Node *e2) :
expr1(e1), expr2(e2), oper(o) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1, *expr2;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
Operator oper;
};
@@ -526,12 +471,11 @@
public:
EqualNode(Node *e1, Operator o, Node *e2)
: expr1(e1), expr2(e2), oper(o) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1, *expr2;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
Operator oper;
};
@@ -539,12 +483,11 @@
public:
BitOperNode(Node *e1, Operator o, Node *e2) :
expr1(e1), expr2(e2), oper(o) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1, *expr2;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
Operator oper;
};
@@ -555,12 +498,11 @@
public:
BinaryLogicalNode(Node *e1, Operator o, Node *e2) :
expr1(e1), expr2(e2), oper(o) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1, *expr2;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
Operator oper;
};
@@ -571,36 +513,33 @@
public:
ConditionalNode(Node *l, Node *e1, Node *e2) :
logical(l), expr1(e1), expr2(e2) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *logical, *expr1, *expr2;
+ kxmlcore::SharedPtr<Node> logical;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
};
class AssignNode : public Node {
public:
AssignNode(Node *l, Operator o, Node *e) : left(l), oper(o), expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *left;
+ kxmlcore::SharedPtr<Node> left;
Operator oper;
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class CommaNode : public Node {
public:
CommaNode(Node *e1, Node *e2) : expr1(e1), expr2(e2) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1, *expr2;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
};
class StatListNode : public StatementNode {
@@ -608,39 +547,33 @@
// list pointer is tail of a circular list, cracked in the CaseClauseNode ctor
StatListNode(StatementNode *s);
StatListNode(StatListNode *l, StatementNode *s);
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class CaseClauseNode;
- StatementNode *statement;
- StatListNode *list;
+ kxmlcore::SharedPtr<StatementNode> statement;
+ kxmlcore::SharedPtr<StatListNode> list;
};
class AssignExprNode : public Node {
public:
AssignExprNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class VarDeclNode : public Node {
public:
VarDeclNode(const Identifier &id, AssignExprNode *in);
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Identifier ident;
- AssignExprNode *init;
+ kxmlcore::SharedPtr<AssignExprNode> init;
};
class VarDeclListNode : public Node {
@@ -649,41 +582,35 @@
VarDeclListNode(VarDeclNode *v) : list(this), var(v) {}
VarDeclListNode(VarDeclListNode *l, VarDeclNode *v)
: list(l->list), var(v) { l->list = this; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class ForNode;
friend class VarStatementNode;
- VarDeclListNode *list;
- VarDeclNode *var;
+ kxmlcore::SharedPtr<VarDeclListNode> list;
+ kxmlcore::SharedPtr<VarDeclNode> var;
};
class VarStatementNode : public StatementNode {
public:
VarStatementNode(VarDeclListNode *l)
: list(l->list) { l->list = 0; }
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- VarDeclListNode *list;
+ kxmlcore::SharedPtr<VarDeclListNode> list;
};
class BlockNode : public StatementNode {
public:
BlockNode(SourceElementsNode *s);
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
protected:
- SourceElementsNode *source;
+ kxmlcore::SharedPtr<SourceElementsNode> source;
};
class EmptyStatementNode : public StatementNode {
@@ -696,52 +623,45 @@
class ExprStatementNode : public StatementNode {
public:
ExprStatementNode(Node *e) : expr(e) { }
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class IfNode : public StatementNode {
public:
IfNode(Node *e, StatementNode *s1, StatementNode *s2)
: expr(e), statement1(s1), statement2(s2) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- StatementNode *statement1, *statement2;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<StatementNode> statement1;
+ kxmlcore::SharedPtr<StatementNode> statement2;
};
class DoWhileNode : public StatementNode {
public:
DoWhileNode(StatementNode *s, Node *e) : statement(s), expr(e) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- StatementNode *statement;
- Node *expr;
+ kxmlcore::SharedPtr<StatementNode> statement;
+ kxmlcore::SharedPtr<Node> expr;
};
class WhileNode : public StatementNode {
public:
WhileNode(Node *e, StatementNode *s) : expr(e), statement(s) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- StatementNode *statement;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<StatementNode> statement;
};
class ForNode : public StatementNode {
@@ -750,31 +670,30 @@
expr1(e1), expr2(e2), expr3(e3), statement(s) {}
ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) :
expr1(e1->list), expr2(e2), expr3(e3), statement(s) { e1->list = 0; }
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr1, *expr2, *expr3;
- StatementNode *statement;
+ kxmlcore::SharedPtr<Node> expr1;
+ kxmlcore::SharedPtr<Node> expr2;
+ kxmlcore::SharedPtr<Node> expr3;
+ kxmlcore::SharedPtr<StatementNode> statement;
};
class ForInNode : public StatementNode {
public:
ForInNode(Node *l, Node *e, StatementNode *s);
ForInNode(const Identifier &i, AssignExprNode *in, Node *e, StatementNode *s);
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Identifier ident;
- AssignExprNode *init;
- Node *lexpr, *expr;
- VarDeclNode *varDecl;
- StatementNode *statement;
+ kxmlcore::SharedPtr<AssignExprNode> init;
+ kxmlcore::SharedPtr<Node> lexpr;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<VarDeclNode> varDecl;
+ kxmlcore::SharedPtr<StatementNode> statement;
};
class ContinueNode : public StatementNode {
@@ -800,25 +719,21 @@
class ReturnNode : public StatementNode {
public:
ReturnNode(Node *v) : value(v) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *value;
+ kxmlcore::SharedPtr<Node> value;
};
class WithNode : public StatementNode {
public:
WithNode(Node *e, StatementNode *s) : expr(e), statement(s) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- StatementNode *statement;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<StatementNode> statement;
};
class CaseClauseNode : public Node {
@@ -826,15 +741,13 @@
CaseClauseNode(Node *e) : expr(e), list(0) { }
CaseClauseNode(Node *e, StatListNode *l)
: expr(e), list(l->list) { l->list = 0; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
Completion evalStatements(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- StatListNode *list;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<StatListNode> list;
};
class ClauseListNode : public Node {
@@ -843,95 +756,81 @@
ClauseListNode(CaseClauseNode *c) : cl(c), nx(this) { }
ClauseListNode(ClauseListNode *n, CaseClauseNode *c)
: cl(c), nx(n->nx) { n->nx = this; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
- CaseClauseNode *clause() const { return cl; }
- ClauseListNode *next() const { return nx; }
+ CaseClauseNode *clause() const { return cl.get(); }
+ ClauseListNode *next() const { return nx.get(); }
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class CaseBlockNode;
- CaseClauseNode *cl;
- ClauseListNode *nx;
+ kxmlcore::SharedPtr<CaseClauseNode> cl;
+ kxmlcore::SharedPtr<ClauseListNode> nx;
};
class CaseBlockNode : public Node {
public:
CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2);
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
Completion evalBlock(ExecState *exec, const Value& input);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- ClauseListNode *list1;
- CaseClauseNode *def;
- ClauseListNode *list2;
+ kxmlcore::SharedPtr<ClauseListNode> list1;
+ kxmlcore::SharedPtr<CaseClauseNode> def;
+ kxmlcore::SharedPtr<ClauseListNode> list2;
};
class SwitchNode : public StatementNode {
public:
SwitchNode(Node *e, CaseBlockNode *b) : expr(e), block(b) { }
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
- CaseBlockNode *block;
+ kxmlcore::SharedPtr<Node> expr;
+ kxmlcore::SharedPtr<CaseBlockNode> block;
};
class LabelNode : public StatementNode {
public:
LabelNode(const Identifier &l, StatementNode *s) : label(l), statement(s) { }
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Identifier label;
- StatementNode *statement;
+ kxmlcore::SharedPtr<StatementNode> statement;
};
class ThrowNode : public StatementNode {
public:
ThrowNode(Node *e) : expr(e) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- Node *expr;
+ kxmlcore::SharedPtr<Node> expr;
};
class CatchNode : public StatementNode {
public:
CatchNode(const Identifier &i, StatementNode *b) : ident(i), block(b) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
Completion execute(ExecState *exec, const Value &arg);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Identifier ident;
- StatementNode *block;
+ kxmlcore::SharedPtr<StatementNode> block;
};
class FinallyNode : public StatementNode {
public:
FinallyNode(StatementNode *b) : block(b) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- StatementNode *block;
+ kxmlcore::SharedPtr<StatementNode> block;
};
class TryNode : public StatementNode {
@@ -942,15 +841,13 @@
: block(b), _catch(0), _final(f) {}
TryNode(StatementNode *b, CatchNode *c, FinallyNode *f)
: block(b), _catch(c), _final(f) {}
- virtual void ref();
- virtual bool deref();
virtual Completion execute(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- StatementNode *block;
- CatchNode *_catch;
- FinallyNode *_final;
+ kxmlcore::SharedPtr<StatementNode> block;
+ kxmlcore::SharedPtr<CatchNode> _catch;
+ kxmlcore::SharedPtr<FinallyNode> _final;
};
class ParameterNode : public Node {
@@ -959,17 +856,15 @@
ParameterNode(const Identifier &i) : id(i), next(this) { }
ParameterNode(ParameterNode *list, const Identifier &i)
: id(i), next(list->next) { list->next = this; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
Identifier ident() { return id; }
- ParameterNode *nextParam() { return next; }
+ ParameterNode *nextParam() { return next.get(); }
virtual void streamTo(SourceStream &s) const;
private:
friend class FuncDeclNode;
friend class FuncExprNode;
Identifier id;
- ParameterNode *next;
+ kxmlcore::SharedPtr<ParameterNode> next;
};
// inherited by ProgramNode
@@ -985,16 +880,14 @@
: ident(i), param(0), body(b) { }
FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b)
: ident(i), param(p->next), body(b) { p->next = 0; }
- virtual void ref();
- virtual bool deref();
Completion execute(ExecState */*exec*/)
{ /* empty */ return Completion(); }
void processFuncDecl(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Identifier ident;
- ParameterNode *param;
- FunctionBodyNode *body;
+ kxmlcore::SharedPtr<ParameterNode> param;
+ kxmlcore::SharedPtr<FunctionBodyNode> body;
};
class FuncExprNode : public Node {
@@ -1002,13 +895,11 @@
FuncExprNode(FunctionBodyNode *b) : param(0), body(b) { }
FuncExprNode(ParameterNode *p, FunctionBodyNode *b)
: param(p->next), body(b) { p->next = 0; }
- virtual void ref();
- virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
- ParameterNode *param;
- FunctionBodyNode *body;
+ kxmlcore::SharedPtr<ParameterNode> param;
+ kxmlcore::SharedPtr<FunctionBodyNode> body;
};
// A linked list of source element nodes
@@ -1017,16 +908,15 @@
// list pointer is tail of a circular list, cracked in the BlockNode (or subclass) ctor
SourceElementsNode(StatementNode *s1);
SourceElementsNode(SourceElementsNode *s1, StatementNode *s2);
- virtual void ref();
- virtual bool deref();
+
Completion execute(ExecState *exec);
void processFuncDecl(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class BlockNode;
- StatementNode *element; // 'this' element
- SourceElementsNode *elements; // pointer to next
+ kxmlcore::SharedPtr<StatementNode> element; // 'this' element
+ kxmlcore::SharedPtr<SourceElementsNode> elements; // pointer to next
};
class ProgramNode : public FunctionBodyNode {
1.10.62.1 +12 -9 JavaScriptCore/kjs/nodes2string.cpp
Index: nodes2string.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/nodes2string.cpp,v
retrieving revision 1.10
retrieving revision 1.10.62.1
diff -u -r1.10 -r1.10.62.1
--- nodes2string.cpp 22 Jan 2003 00:11:44 -0000 1.10
+++ nodes2string.cpp 28 Aug 2005 23:26:53 -0000 1.10.62.1
@@ -23,6 +23,8 @@
#include "nodes.h"
+using namespace kxmlcore;
+
namespace KJS {
/**
* A simple text streaming class that helps with code indentation.
@@ -40,6 +42,7 @@
SourceStream& operator<<(char);
SourceStream& operator<<(Format f);
SourceStream& operator<<(const Node *);
+ template <typename T> SourceStream& operator<<(SharedPtr<T> n) { return this->operator<<(n.get()); }
private:
UString str; /* TODO: buffer */
UString ind;
@@ -126,7 +129,7 @@
void ElementNode::streamTo(SourceStream &s) const
{
- for (const ElementNode *n = this; n; n = n->list) {
+ for (const ElementNode *n = this; n; n = n->list.get()) {
for (int i = 0; i < n->elision; i++)
s << ",";
s << n->node;
@@ -151,7 +154,7 @@
void PropertyValueNode::streamTo(SourceStream &s) const
{
- for (const PropertyValueNode *n = this; n; n = n->list)
+ for (const PropertyValueNode *n = this; n; n = n->list.get())
s << n->name << ": " << n->assign;
}
@@ -176,7 +179,7 @@
void ArgumentListNode::streamTo(SourceStream &s) const
{
s << expr;
- for (ArgumentListNode *n = list; n; n = n->list)
+ for (ArgumentListNode *n = list.get(); n; n = n->list.get())
s << ", " << n->expr;
}
@@ -392,7 +395,7 @@
void StatListNode::streamTo(SourceStream &s) const
{
- for (const StatListNode *n = this; n; n = n->list)
+ for (const StatListNode *n = this; n; n = n->list.get())
s << n->statement;
}
@@ -409,7 +412,7 @@
void VarDeclListNode::streamTo(SourceStream &s) const
{
s << var;
- for (VarDeclListNode *n = list; n; n = n->list)
+ for (VarDeclListNode *n = list.get(); n; n = n->list.get())
s << ", " << n->var;
}
@@ -527,11 +530,11 @@
void CaseBlockNode::streamTo(SourceStream &s) const
{
- for (const ClauseListNode *n = list1; n; n = n->next())
+ for (const ClauseListNode *n = list1.get(); n; n = n->next())
s << n->clause();
if (def)
s << def;
- for (const ClauseListNode *n = list2; n; n = n->next())
+ for (const ClauseListNode *n = list2.get(); n; n = n->next())
s << n->clause();
}
@@ -573,7 +576,7 @@
void ParameterNode::streamTo(SourceStream &s) const
{
s << id;
- for (ParameterNode *n = next; n; n = n->next)
+ for (ParameterNode *n = next.get(); n; n = n->next.get())
s << ", " << n->id;
}
@@ -593,7 +596,7 @@
void SourceElementsNode::streamTo(SourceStream &s) const
{
- for (const SourceElementsNode *n = this; n; n = n->elements)
+ for (const SourceElementsNode *n = this; n; n = n->elements.get())
s << n->element;
}
No revision
No revision
1.1.2.2 +91 -0 JavaScriptCore/kjs/shared_ptr.h
More information about the webkit-changes
mailing list