+2002-11-21 Darin Adler <darin@apple.com>
+
+ - stop garbage collecting the ActivationImp objects, gets 3% on iBench
+ - pave the way to separate the argument lists from scope chains
+
+ * kjs/context.h: Added. Moved ContextImp here so it can use things defined
+ in function.h
+
+ * kjs/scope_chain.h: Added. Starting as a copy of List, to be improved.
+ * kjs/scope_chain.cpp: Added. Starting as a copy of List, to be improved.
+
+ * JavaScriptCore.pbproj/project.pbxproj: Rearranged things, added context.h.
+
+ * kjs/function.cpp:
+ (FunctionImp::call): Pass InterpreterImp, not ExecState, to ContextImp.
+ (DeclaredFunctionImp::DeclaredFunctionImp): List -> ScopeChain.
+ (ActivationImp::createArgumentsObject): ArgumentList -> List.
+ (GlobalFuncImp::call): Pass InterpreterImp, not an ExecState, to ContextImp.
+ * kjs/function.h: List -> ScopeChain.
+ * kjs/function_object.cpp: (FunctionObjectImp::construct): List -> ScopeChain.
+ * kjs/internal.cpp:
+ (ContextImp::ContextImp): Set the context in the interpreter.
+ (ContextImp::~ContextImp): Set the context in the interpreter to the caller.
+ (ContextImp::mark): Mark all the activation objects.
+ (InterpreterImp::InterpreterImp): Initialize context to 0.
+ (InterpreterImp::mark): Mark the top context.
+ (InterpreterImp::evaluate): Pass InterpreterImp to ContextImp.
+ * kjs/internal.h: Move ContextImp to its own header. Add setContext to InterpreterImp.
+ * kjs/interpreter.cpp: (Context::scopeChain): List -> ScopeChain.
+ * kjs/interpreter.h: List -> ScopeChain.
+ * kjs/nodes.cpp:
+ (ResolveNode::evaluateReference): List -> ScopeChain.
+ (FuncDeclNode::processFuncDecl): List -> ScopeChain.
+ (FuncExprNode::evaluate): List -> ScopeChain.
+ * kjs/object.cpp: List -> ScopeChain.
+ * kjs/object.h: List -> ScopeChain.
+
+ * kjs/types.h: Remove needsMarking features from List.
+ * kjs/types.cpp: Ditto.
+
2002-11-21 Maciej Stachowiak <mjs@apple.com>
- reduced the size of PropertyMap by storing sizes and such in the
+2002-11-21 Darin Adler <darin@apple.com>
+
+ - stop garbage collecting the ActivationImp objects, gets 3% on iBench
+ - pave the way to separate the argument lists from scope chains
+
+ * kjs/context.h: Added. Moved ContextImp here so it can use things defined
+ in function.h
+
+ * kjs/scope_chain.h: Added. Starting as a copy of List, to be improved.
+ * kjs/scope_chain.cpp: Added. Starting as a copy of List, to be improved.
+
+ * JavaScriptCore.pbproj/project.pbxproj: Rearranged things, added context.h.
+
+ * kjs/function.cpp:
+ (FunctionImp::call): Pass InterpreterImp, not ExecState, to ContextImp.
+ (DeclaredFunctionImp::DeclaredFunctionImp): List -> ScopeChain.
+ (ActivationImp::createArgumentsObject): ArgumentList -> List.
+ (GlobalFuncImp::call): Pass InterpreterImp, not an ExecState, to ContextImp.
+ * kjs/function.h: List -> ScopeChain.
+ * kjs/function_object.cpp: (FunctionObjectImp::construct): List -> ScopeChain.
+ * kjs/internal.cpp:
+ (ContextImp::ContextImp): Set the context in the interpreter.
+ (ContextImp::~ContextImp): Set the context in the interpreter to the caller.
+ (ContextImp::mark): Mark all the activation objects.
+ (InterpreterImp::InterpreterImp): Initialize context to 0.
+ (InterpreterImp::mark): Mark the top context.
+ (InterpreterImp::evaluate): Pass InterpreterImp to ContextImp.
+ * kjs/internal.h: Move ContextImp to its own header. Add setContext to InterpreterImp.
+ * kjs/interpreter.cpp: (Context::scopeChain): List -> ScopeChain.
+ * kjs/interpreter.h: List -> ScopeChain.
+ * kjs/nodes.cpp:
+ (ResolveNode::evaluateReference): List -> ScopeChain.
+ (FuncDeclNode::processFuncDecl): List -> ScopeChain.
+ (FuncExprNode::evaluate): List -> ScopeChain.
+ * kjs/object.cpp: List -> ScopeChain.
+ * kjs/object.h: List -> ScopeChain.
+
+ * kjs/types.h: Remove needsMarking features from List.
+ * kjs/types.cpp: Ditto.
+
2002-11-21 Maciej Stachowiak <mjs@apple.com>
- reduced the size of PropertyMap by storing sizes and such in the
+2002-11-21 Darin Adler <darin@apple.com>
+
+ - stop garbage collecting the ActivationImp objects, gets 3% on iBench
+ - pave the way to separate the argument lists from scope chains
+
+ * kjs/context.h: Added. Moved ContextImp here so it can use things defined
+ in function.h
+
+ * kjs/scope_chain.h: Added. Starting as a copy of List, to be improved.
+ * kjs/scope_chain.cpp: Added. Starting as a copy of List, to be improved.
+
+ * JavaScriptCore.pbproj/project.pbxproj: Rearranged things, added context.h.
+
+ * kjs/function.cpp:
+ (FunctionImp::call): Pass InterpreterImp, not ExecState, to ContextImp.
+ (DeclaredFunctionImp::DeclaredFunctionImp): List -> ScopeChain.
+ (ActivationImp::createArgumentsObject): ArgumentList -> List.
+ (GlobalFuncImp::call): Pass InterpreterImp, not an ExecState, to ContextImp.
+ * kjs/function.h: List -> ScopeChain.
+ * kjs/function_object.cpp: (FunctionObjectImp::construct): List -> ScopeChain.
+ * kjs/internal.cpp:
+ (ContextImp::ContextImp): Set the context in the interpreter.
+ (ContextImp::~ContextImp): Set the context in the interpreter to the caller.
+ (ContextImp::mark): Mark all the activation objects.
+ (InterpreterImp::InterpreterImp): Initialize context to 0.
+ (InterpreterImp::mark): Mark the top context.
+ (InterpreterImp::evaluate): Pass InterpreterImp to ContextImp.
+ * kjs/internal.h: Move ContextImp to its own header. Add setContext to InterpreterImp.
+ * kjs/interpreter.cpp: (Context::scopeChain): List -> ScopeChain.
+ * kjs/interpreter.h: List -> ScopeChain.
+ * kjs/nodes.cpp:
+ (ResolveNode::evaluateReference): List -> ScopeChain.
+ (FuncDeclNode::processFuncDecl): List -> ScopeChain.
+ (FuncExprNode::evaluate): List -> ScopeChain.
+ * kjs/object.cpp: List -> ScopeChain.
+ * kjs/object.h: List -> ScopeChain.
+
+ * kjs/types.h: Remove needsMarking features from List.
+ * kjs/types.cpp: Ditto.
+
2002-11-21 Maciej Stachowiak <mjs@apple.com>
- reduced the size of PropertyMap by storing sizes and such in the
F5BB2BC7030F772101FCFE1D,
933A349C038AE7C6008635CE,
938772E6038BFE19008635CE,
+ 9374D3A9038D9D74008635CE,
+ 9373524F038DA8C2008635CE,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
F5341395030CF5F8018BE7F3,
F5BB2BC6030F772101FCFE1D,
933A349E038AE80F008635CE,
+ 9374D3AA038D9D74008635CE,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
F692A8530255597D01FF60F7,
F5BB2BC4030F772101FCFE1D,
F5BB2BC5030F772101FCFE1D,
+ 9373524E038DA8C2008635CE,
F692A8550255597D01FF60F7,
F692A8560255597D01FF60F7,
F692A8570255597D01FF60F7,
F692A87C0255597D01FF60F7,
F692A87D0255597D01FF60F7,
F692A87E0255597D01FF60F7,
+ 9374D3A7038D9D74008635CE,
+ 9374D3A8038D9D74008635CE,
F50888B6030BB74C012A967E,
F692A87F0255597D01FF60F7,
F692A8800255597D01FF60F7,
F692A8810255597D01FF60F7,
- F692A8830255597D01FF60F7,
F692A8840255597D01FF60F7,
- F692A8850255597D01FF60F7,
+ F692A8830255597D01FF60F7,
F692A8860255597D01FF60F7,
- F692A8870255597D01FF60F7,
+ F692A8850255597D01FF60F7,
F692A8880255597D01FF60F7,
+ F692A8870255597D01FF60F7,
);
isa = PBXGroup;
name = Classes;
+ path = kjs;
refType = 4;
};
//080
933A3499038AE7C6008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
- name = grammar.y;
- path = kjs/grammar.y;
+ path = grammar.y;
refType = 4;
};
933A349A038AE7C6008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
- name = identifier.h;
- path = kjs/identifier.h;
+ path = identifier.h;
refType = 4;
};
933A349C038AE7C6008635CE = {
933A349D038AE80F008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
- name = identifier.cpp;
- path = kjs/identifier.cpp;
+ path = identifier.cpp;
refType = 4;
};
933A349E038AE80F008635CE = {
settings = {
};
};
+ 9373524E038DA8C2008635CE = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ path = context.h;
+ refType = 4;
+ };
+ 9373524F038DA8C2008635CE = {
+ fileRef = 9373524E038DA8C2008635CE;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Private,
+ );
+ };
+ };
+ 9374D3A7038D9D74008635CE = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ path = scope_chain.h;
+ refType = 4;
+ };
+ 9374D3A8038D9D74008635CE = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ path = scope_chain.cpp;
+ refType = 4;
+ };
+ 9374D3A9038D9D74008635CE = {
+ fileRef = 9374D3A7038D9D74008635CE;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Private,
+ );
+ };
+ };
+ 9374D3AA038D9D74008635CE = {
+ fileRef = 9374D3A8038D9D74008635CE;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
938772E5038BFE19008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
F50888B6030BB74C012A967E = {
fileEncoding = 30;
isa = PBXFileReference;
- name = simple_number.h;
- path = kjs/simple_number.h;
+ path = simple_number.h;
refType = 4;
};
F50888B7030BB74C012A967E = {
F5341390030CEEB1018BE7F3 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = reference.cpp;
- path = kjs/reference.cpp;
+ path = reference.cpp;
refType = 4;
};
F5341391030CEEB1018BE7F3 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = reference.h;
- path = kjs/reference.h;
+ path = reference.h;
refType = 4;
};
F5341392030CEEB1018BE7F3 = {
F5341394030CF5F8018BE7F3 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = reference_list.cpp;
- path = kjs/reference_list.cpp;
+ path = reference_list.cpp;
refType = 4;
};
F5341395030CF5F8018BE7F3 = {
F54F0800030CD22001B5C2EB = {
fileEncoding = 30;
isa = PBXFileReference;
- name = reference_list.h;
- path = kjs/reference_list.h;
+ path = reference_list.h;
refType = 4;
};
F54F0801030CD22001B5C2EB = {
F5BB2BC4030F772101FCFE1D = {
fileEncoding = 30;
isa = PBXFileReference;
- name = completion.cpp;
- path = kjs/completion.cpp;
+ path = completion.cpp;
refType = 4;
};
F5BB2BC5030F772101FCFE1D = {
fileEncoding = 30;
isa = PBXFileReference;
- name = completion.h;
- path = kjs/completion.h;
+ path = completion.h;
refType = 4;
};
F5BB2BC6030F772101FCFE1D = {
);
isa = PBXGroup;
name = "Other Sources";
- path = "";
+ path = kjs;
refType = 4;
};
F5C290E60284F98E018635CA = {
fileEncoding = 30;
isa = PBXFileReference;
- path = JavaScriptCorePrefix.h;
+ name = JavaScriptCorePrefix.h;
+ path = ../JavaScriptCorePrefix.h;
refType = 4;
};
F5C290E70284F98E018635CA = {
F5FFE656026B47A6018635CA = {
fileEncoding = 30;
isa = PBXFileReference;
- name = nodes2string.cpp;
- path = kjs/nodes2string.cpp;
+ path = nodes2string.cpp;
refType = 4;
};
F5FFE657026B47A6018635CA = {
F68EBB8C0255D4C601FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = config.h;
- path = kjs/config.h;
+ path = config.h;
refType = 4;
};
F68EBB8E0255D4C601FF60F7 = {
F692A84D0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = array_object.cpp;
- path = kjs/array_object.cpp;
+ path = array_object.cpp;
refType = 4;
};
F692A84E0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = array_object.h;
- path = kjs/array_object.h;
+ path = array_object.h;
refType = 4;
};
F692A84F0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = array_object.lut.h;
- path = kjs/array_object.lut.h;
+ path = array_object.lut.h;
refType = 4;
};
F692A8500255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = bool_object.cpp;
- path = kjs/bool_object.cpp;
+ path = bool_object.cpp;
refType = 4;
};
F692A8510255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = bool_object.h;
- path = kjs/bool_object.h;
+ path = bool_object.h;
refType = 4;
};
F692A8520255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = collector.cpp;
- path = kjs/collector.cpp;
+ path = collector.cpp;
refType = 4;
};
F692A8530255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = collector.h;
- path = kjs/collector.h;
+ path = collector.h;
refType = 4;
};
F692A8540255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXExecutableFileReference;
- name = create_hash_table;
- path = kjs/create_hash_table;
+ path = create_hash_table;
refType = 4;
};
F692A8550255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = date_object.cpp;
- path = kjs/date_object.cpp;
+ path = date_object.cpp;
refType = 4;
};
F692A8560255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = date_object.h;
- path = kjs/date_object.h;
+ path = date_object.h;
refType = 4;
};
F692A8570255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = date_object.lut.h;
- path = kjs/date_object.lut.h;
+ path = date_object.lut.h;
refType = 4;
};
F692A8580255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = debugger.cpp;
- path = kjs/debugger.cpp;
+ path = debugger.cpp;
refType = 4;
};
F692A8590255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = debugger.h;
- path = kjs/debugger.h;
+ path = debugger.h;
refType = 4;
};
F692A85A0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = error_object.cpp;
- path = kjs/error_object.cpp;
+ path = error_object.cpp;
refType = 4;
};
F692A85B0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = error_object.h;
- path = kjs/error_object.h;
+ path = error_object.h;
refType = 4;
};
F692A85C0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = function_object.cpp;
- path = kjs/function_object.cpp;
+ path = function_object.cpp;
refType = 4;
};
F692A85D0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = function_object.h;
- path = kjs/function_object.h;
+ path = function_object.h;
refType = 4;
};
F692A85E0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = function.cpp;
- path = kjs/function.cpp;
+ path = function.cpp;
refType = 4;
};
F692A85F0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = function.h;
- path = kjs/function.h;
+ path = function.h;
refType = 4;
};
F692A8610255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = internal.cpp;
- path = kjs/internal.cpp;
+ path = internal.cpp;
refType = 4;
};
F692A8620255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = internal.h;
- path = kjs/internal.h;
+ path = internal.h;
refType = 4;
};
F692A8630255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = interpreter.cpp;
- path = kjs/interpreter.cpp;
+ path = interpreter.cpp;
refType = 4;
};
F692A8640255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = interpreter.h;
- path = kjs/interpreter.h;
+ path = interpreter.h;
refType = 4;
};
F692A8650255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = lexer.cpp;
- path = kjs/lexer.cpp;
+ path = lexer.cpp;
refType = 4;
};
F692A8660255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = lexer.h;
- path = kjs/lexer.h;
+ path = lexer.h;
refType = 4;
};
F692A8670255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = lexer.lut.h;
- path = kjs/lexer.lut.h;
+ path = lexer.lut.h;
refType = 4;
};
F692A8680255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = lookup.cpp;
- path = kjs/lookup.cpp;
+ path = lookup.cpp;
refType = 4;
};
F692A8690255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = lookup.h;
- path = kjs/lookup.h;
+ path = lookup.h;
refType = 4;
};
F692A86A0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = math_object.cpp;
- path = kjs/math_object.cpp;
+ path = math_object.cpp;
refType = 4;
};
F692A86B0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = math_object.h;
- path = kjs/math_object.h;
+ path = math_object.h;
refType = 4;
};
F692A86C0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = math_object.lut.h;
- path = kjs/math_object.lut.h;
+ path = math_object.lut.h;
refType = 4;
};
F692A86D0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = nodes.cpp;
- path = kjs/nodes.cpp;
+ path = nodes.cpp;
refType = 4;
};
F692A86E0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = nodes.h;
- path = kjs/nodes.h;
+ path = nodes.h;
refType = 4;
};
F692A8700255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = number_object.cpp;
- path = kjs/number_object.cpp;
+ path = number_object.cpp;
refType = 4;
};
F692A8710255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = number_object.h;
- path = kjs/number_object.h;
+ path = number_object.h;
refType = 4;
};
F692A8720255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = number_object.lut.h;
- path = kjs/number_object.lut.h;
+ path = number_object.lut.h;
refType = 4;
};
F692A8730255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = object_object.cpp;
- path = kjs/object_object.cpp;
+ path = object_object.cpp;
refType = 4;
};
F692A8740255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = object_object.h;
- path = kjs/object_object.h;
+ path = object_object.h;
refType = 4;
};
F692A8750255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = object.cpp;
- path = kjs/object.cpp;
+ path = object.cpp;
refType = 4;
};
F692A8760255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = object.h;
- path = kjs/object.h;
+ path = object.h;
refType = 4;
};
F692A8770255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = operations.cpp;
- path = kjs/operations.cpp;
+ path = operations.cpp;
refType = 4;
};
F692A8780255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = operations.h;
- path = kjs/operations.h;
+ path = operations.h;
refType = 4;
};
F692A8790255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = property_map.cpp;
- path = kjs/property_map.cpp;
+ path = property_map.cpp;
refType = 4;
};
F692A87A0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = property_map.h;
- path = kjs/property_map.h;
+ path = property_map.h;
refType = 4;
};
F692A87B0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = regexp_object.cpp;
- path = kjs/regexp_object.cpp;
+ path = regexp_object.cpp;
refType = 4;
};
F692A87C0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = regexp_object.h;
- path = kjs/regexp_object.h;
+ path = regexp_object.h;
refType = 4;
};
F692A87D0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = regexp.cpp;
- path = kjs/regexp.cpp;
+ path = regexp.cpp;
refType = 4;
};
F692A87E0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = regexp.h;
- path = kjs/regexp.h;
+ path = regexp.h;
refType = 4;
};
F692A87F0255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = string_object.cpp;
- path = kjs/string_object.cpp;
+ path = string_object.cpp;
refType = 4;
};
F692A8800255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = string_object.h;
- path = kjs/string_object.h;
+ path = string_object.h;
refType = 4;
};
F692A8810255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = string_object.lut.h;
- path = kjs/string_object.lut.h;
+ path = string_object.lut.h;
refType = 4;
};
F692A8830255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = types.cpp;
- path = kjs/types.cpp;
+ path = types.cpp;
refType = 4;
};
F692A8840255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = types.h;
- path = kjs/types.h;
+ path = types.h;
refType = 4;
};
F692A8850255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = ustring.cpp;
- path = kjs/ustring.cpp;
+ path = ustring.cpp;
refType = 4;
};
F692A8860255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = ustring.h;
- path = kjs/ustring.h;
+ path = ustring.h;
refType = 4;
};
F692A8870255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = value.cpp;
- path = kjs/value.cpp;
+ path = value.cpp;
refType = 4;
};
F692A8880255597D01FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = value.h;
- path = kjs/value.h;
+ path = value.h;
refType = 4;
};
F692A8890255597D01FF60F7 = {
F692A8C802555BA201FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = grammar.cpp;
- path = kjs/grammar.cpp;
+ path = grammar.cpp;
refType = 4;
};
F692A8C902555BA201FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = grammar.cpp.h;
- path = kjs/grammar.cpp.h;
+ path = grammar.cpp.h;
refType = 4;
};
F692A8CA02555BA201FF60F7 = {
fileEncoding = 30;
isa = PBXFileReference;
- name = grammar.h;
- path = kjs/grammar.h;
+ path = grammar.h;
refType = 4;
};
F692A8CB02555BA201FF60F7 = {
--- /dev/null
+// -*- c-basic-offset: 2 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef KJS_CONTEXT_H
+#define KJS_CONTEXT_H
+
+#include "function.h"
+
+namespace KJS {
+
+ /**
+ * @short Execution context.
+ */
+ class ContextImp {
+ public:
+ ContextImp(Object &glob, InterpreterImp *, Object &thisV, CodeType type = GlobalCode,
+ ContextImp *callingContext = 0, FunctionImp *functiion = 0, const List *args = 0);
+ ~ContextImp();
+
+ const ScopeChain scopeChain() const { return scope; }
+ Object variableObject() const { return variable; }
+ void setVariableObject(const Object &v) { variable = v; }
+ Object thisValue() const { return thisVal; }
+ ContextImp *callingContext() { return _callingContext; }
+ ObjectImp *activationObject() { return activation.imp(); }
+ FunctionImp *function() const { return _function; }
+ const List *arguments() const { return _arguments; }
+
+ void pushScope(const Object &s);
+ void popScope();
+ LabelStack *seenLabels() { return &ls; }
+
+ void mark();
+
+ private:
+ InterpreterImp *_interpreter;
+ ContextImp *_callingContext;
+ ActivationImp _activationImp;
+ FunctionImp *_function;
+ const List *_arguments;
+ Object activation;
+
+ ScopeChain scope;
+ Object variable;
+ Object thisVal;
+
+ LabelStack ls;
+ CodeType codeType;
+ };
+
+} // namespace KJS
+
+#endif
#include "nodes.h"
#include "operations.h"
#include "debugger.h"
+#include "context.h"
#include <stdio.h>
#include <errno.h>
}
// enter a new execution context
- ContextImp ctx(globalObj, exec, thisObj, codeType(),
+ ContextImp ctx(globalObj, exec->interpreter()->imp(), thisObj, codeType(),
exec->context().imp(), this, &args);
ExecState newExec(exec->interpreter(), &ctx);
newExec.setException(exec->exception()); // could be null
const ClassInfo DeclaredFunctionImp::info = {"Function", &FunctionImp::info, 0, 0};
DeclaredFunctionImp::DeclaredFunctionImp(ExecState *exec, const Identifier &n,
- FunctionBodyNode *b, const List &sc)
+ FunctionBodyNode *b, const ScopeChain &sc)
: FunctionImp(exec,n), body(b)
{
Value protect(this);
void ActivationImp::createArgumentsObject(ExecState *exec) const
{
FunctionImp *function = _context->function();
- const ArgumentList *arguments = _context->arguments();
+ const List *arguments = _context->arguments();
if (arguments)
_argumentsObject = new ArgumentsImp(exec, function, *arguments);
else
// enter a new execution context
Object thisVal(Object::dynamicCast(exec->context().thisValue()));
ContextImp ctx(exec->interpreter()->globalObject(),
- exec,
+ exec->interpreter()->imp(),
thisVal,
EvalCode,
exec->context().imp());
class DeclaredFunctionImp : public FunctionImp {
public:
DeclaredFunctionImp(ExecState *exec, const Identifier &n,
- FunctionBodyNode *b, const List &sc);
+ FunctionBodyNode *b, const ScopeChain &sc);
~DeclaredFunctionImp();
bool implementsConstruct() const;
return err;
}
- List scopeChain;
- scopeChain.append(exec->interpreter()->globalObject());
+ ScopeChain scopeChain;
+ scopeChain.prepend(exec->interpreter()->globalObject());
FunctionBodyNode *bodyNode = progNode;
FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null, bodyNode,
#include "array_object.h"
#include "bool_object.h"
#include "collector.h"
+#include "context.h"
#include "date_object.h"
#include "debugger.h"
#include "error_object.h"
// ------------------------------ ContextImp -----------------------------------
// ECMA 10.2
-ContextImp::ContextImp(Object &glob, ExecState *exec, Object &thisV, CodeType type,
- ContextImp *_callingContext, FunctionImp *func, const ArgumentList *args)
- : _function(func), _arguments(args)
+ContextImp::ContextImp(Object &glob, InterpreterImp *interpreter, Object &thisV, CodeType type,
+ ContextImp *callingCon, FunctionImp *func, const List *args)
+ : _interpreter(interpreter), _activationImp(this), _function(func), _arguments(args)
{
codeType = type;
- callingCon = _callingContext;
+ _callingContext = callingCon;
// create and initialize activation object (ECMA 10.1.6)
if (type == FunctionCode || type == AnonymousCode ) {
- activation = Object(new ActivationImp(this));
+ activation = Object(&_activationImp);
variable = activation;
} else {
activation = Object();
// ECMA 10.2
switch(type) {
case EvalCode:
- if (callingCon) {
- scope = callingCon->scopeChain().copy();
- variable = callingCon->variableObject();
- thisVal = callingCon->thisValue();
+ if (_callingContext) {
+ scope = _callingContext->scopeChain().copy();
+ variable = _callingContext->variableObject();
+ thisVal = _callingContext->thisValue();
break;
} // else same as GlobalCode
case GlobalCode:
- scope = List();
- scope.append(glob);
+ scope = ScopeChain();
+ scope.prepend(glob);
thisVal = Object(static_cast<ObjectImp*>(glob.imp()));
break;
case FunctionCode:
scope = func->scope().copy();
scope.prepend(activation);
} else {
- scope = List();
- scope.append(activation);
- scope.append(glob);
+ scope = ScopeChain();
+ scope.prepend(glob);
+ scope.prepend(activation);
}
variable = activation; // TODO: DontDelete ? (ECMA 10.2.3)
thisVal = thisV;
break;
}
+ _interpreter->setContext(this);
}
ContextImp::~ContextImp()
{
+ _interpreter->setContext(_callingContext);
}
void ContextImp::pushScope(const Object &s)
scope.removeFirst();
}
+void ContextImp::mark()
+{
+ for (ContextImp *context = this; context; context = context->_callingContext)
+ context->_activationImp.mark();
+}
+
// ------------------------------ Parser ---------------------------------------
ProgramNode *Parser::progNode = 0;
}
InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
+ : _context(0)
{
// add this interpreter to the global chain
// as a root set for garbage collection
global.imp()->mark();
if (m_interpreter)
m_interpreter->mark();
+ if (_context)
+ _context->mark();
}
bool InterpreterImp::checkSyntax(const UString &code)
}
else {
// execute the code
- ContextImp ctx(globalObj, 0, thisObj);
+ ContextImp ctx(globalObj, this, thisObj);
ExecState newExec(m_interpreter,&ctx);
res = progNode->execute(&newExec);
}
#include "object.h"
#include "types.h"
#include "interpreter.h"
+#include "scope_chain.h"
#define I18N_NOOP(s) s
FunctionCode,
AnonymousCode };
- /**
- * @short Execution context.
- */
- class ContextImp {
- public:
- ContextImp(Object &glob, ExecState *exec, Object &thisV, CodeType type = GlobalCode,
- ContextImp *_callingContext = 0L, FunctionImp *func = 0L, const ArgumentList *args = 0);
- ~ContextImp();
-
- const List scopeChain() const { return scope; }
- Object variableObject() const { return variable; }
- void setVariableObject(const Object &v) { variable = v; }
- Object thisValue() const { return thisVal; }
- ContextImp *callingContext() { return callingCon; }
- ObjectImp *activationObject() { return activation.imp(); }
- FunctionImp *function() const { return _function; }
- const ArgumentList *arguments() const { return _arguments; }
-
- void pushScope(const Object &s);
- void popScope();
- LabelStack *seenLabels() { return &ls; }
-
- private:
-
- List scope;
- Object variable;
- Object thisVal;
- ContextImp *callingCon;
- Object activation;
- FunctionImp *_function;
- const ArgumentList *_arguments;
-
- LabelStack ls;
- CodeType codeType;
- };
-
/**
* @internal
*
static InterpreterImp* firstInterpreter() { return s_hook; }
InterpreterImp *nextInterpreter() const { return next; }
InterpreterImp *prevInterpreter() const { return prev; }
+
+ void setContext(ContextImp *c) { _context = c; }
private:
void clear();
// Chained list of interpreters (ring) - for collector
static InterpreterImp* s_hook;
InterpreterImp *next, *prev;
+
+ ContextImp *_context;
int recursion;
};
#include "operations.h"
#include "error_object.h"
#include "nodes.h"
+#include "context.h"
using namespace KJS;
return rep;
}
-const List Context::scopeChain() const
+const ScopeChain Context::scopeChain() const
{
return rep->scopeChain();
}
*
* @return The execution context's scope chain
*/
- const List scopeChain() const;
+ const ScopeChain scopeChain() const;
/**
* Returns the variable object for the execution context. This contains a
#endif
#include "collector.h"
+#include "context.h"
#include "debugger.h"
#include "function_object.h"
#include "internal.h"
Reference ResolveNode::evaluateReference(ExecState *exec)
{
- const List chain = exec->context().scopeChain();
- ListIterator scope = chain.begin();
+ const ScopeChain chain = exec->context().scopeChain();
+ ScopeChainIterator scope = chain.begin();
while (scope != chain.end()) {
ObjectImp *o = static_cast<ObjectImp*>((*scope).imp());
// ECMA 13
void FuncDeclNode::processFuncDecl(ExecState *exec)
{
- const List sc = exec->context().imp()->scopeChain();
+ const ScopeChain sc = exec->context().imp()->scopeChain();
// TODO: let this be an object with [[Class]] property "Function"
FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, sc);
// ECMA 13
Value FuncExprNode::evaluate(ExecState *exec)
{
- const List sc = exec->context().scopeChain();
+ const ScopeChain sc = exec->context().scopeChain();
FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null, body, sc);
Value ret(fimp);
List empty;
return Boolean(false);
}
-const List ObjectImp::scope() const
+const ScopeChain ObjectImp::scope() const
{
return _scope;
}
-void ObjectImp::setScope(const List &s)
+void ObjectImp::setScope(const ScopeChain &s)
{
_scope = s;
}
#include "types.h"
#include "reference_list.h"
#include "property_map.h"
+#include "scope_chain.h"
namespace KJS {
* @param exec The current execution state
* @return The function's scope
*/
- const List scope() const;
- void setScope(const List &s);
+ const ScopeChain scope() const;
+ void setScope(const ScopeChain &s);
/**
* Returns a List of References to all the properties of the object. Used
*
* @see Object::scope()
*/
- const List scope() const;
- void setScope(const List &s);
+ const ScopeChain scope() const;
+ void setScope(const ScopeChain &s);
ReferenceList propList(ExecState *exec, bool recursive = true);
PropertyMap _prop;
ValueImp *_proto;
ValueImp *_internalValue;
- List _scope;
+ ScopeChain _scope;
};
/**
inline Boolean Object::hasInstance(ExecState *exec, const Value &value)
{ return imp()->hasInstance(exec,value); }
- inline const List Object::scope() const
+ inline const ScopeChain Object::scope() const
{ return imp()->scope(); }
- inline void Object::setScope(const List &s)
+ inline void Object::setScope(const ScopeChain &s)
{ imp()->setScope(s); }
inline ReferenceList Object::propList(ExecState *exec, bool recursive)
namespace KJS {
+struct PropertyMapHashTable
+{
+ int sizeMask;
+ int size;
+ int keyCount;
+ PropertyMapHashTableEntry entries[1];
+};
+
class SavedProperty {
public:
Identifier key;
inline void PropertyMap::insert(UString::Rep *key, ValueImp *value, int attributes)
{
- assert(_table);
+ assert(_table);
- int i = hash(key);
- while (_table->entries[i].key)
- i = (i + 1) & _table->sizeMask;
+ int i = hash(key);
+ while (_table->entries[i].key)
+ i = (i + 1) & _table->sizeMask;
- _table->entries[i].key = key;
- _table->entries[i].value = value;
- _table->entries[i].attributes = attributes;
+ _table->entries[i].key = key;
+ _table->entries[i].value = value;
+ _table->entries[i].attributes = attributes;
}
void PropertyMap::expand()
checkConsistency();
Table *oldTable = _table;
- int oldTableSize = oldTable ? _table->size : 0;
+ int oldTableSize = oldTable ? oldTable->size : 0;
int newTableSize = oldTableSize ? oldTableSize * 2 : 16;
_table = (Table *)calloc(1, sizeof(Table) + (newTableSize - 1) * sizeof(Entry) );
_table->size = newTableSize;
- _table->sizeMask = _table->size - 1;
+ _table->sizeMask = newTableSize - 1;
#if USE_SINGLE_ENTRY
UString::Rep *key = _singleEntry.key;
class SavedProperty;
+ struct PropertyMapHashTable;
+
class SavedProperties {
friend class PropertyMap;
public:
int attributes;
};
- struct PropertyMapHashTable
- {
- int sizeMask;
- int size;
- int keyCount;
- PropertyMapHashTableEntry entries[1];
- };
-
class PropertyMap {
public:
PropertyMap();
--- /dev/null
+// -*- c-basic-offset: 2 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "scope_chain.h"
+
+namespace KJS {
+
+ struct ScopeChainNode {
+ ScopeChainNode(const Value &val, ScopeChainNode *p, ScopeChainNode *n)
+ : member(val.imp()), prev(p), next(n) { }
+ ScopeChainNode(ValueImp *val, ScopeChainNode *p, ScopeChainNode *n)
+ : member(val), prev(p), next(n) { }
+ ValueImp *member;
+ ScopeChainNode *prev, *next;
+ };
+
+ struct ScopeChainHookNode : public ScopeChainNode {
+ ScopeChainHookNode(bool needsMarking) : ScopeChainNode(Value(), this, this),
+ listRefCount(1), nodesRefCount(needsMarking ? 0 : 1) { }
+ int listRefCount;
+ int nodesRefCount;
+ };
+
+// ------------------------------ ScopeChainIterator ---------------------------------
+
+ValueImp* ScopeChainIterator::operator->() const
+{
+ return node->member;
+}
+
+Value ScopeChainIterator::operator*() const
+{
+ return Value(node->member);
+}
+
+Value ScopeChainIterator::operator++()
+{
+ node = node->next;
+ return Value(node->member);
+}
+
+Value ScopeChainIterator::operator++(int)
+{
+ const ScopeChainNode *n = node;
+ ++*this;
+ return Value(n->member);
+}
+
+// ------------------------------ ScopeChain -----------------------------------------
+
+ScopeChain::ScopeChain(bool needsMarking) : hook(new ScopeChainHookNode(needsMarking)), m_needsMarking(needsMarking)
+{
+}
+
+ScopeChain::ScopeChain(const ScopeChain& l) : hook(l.hook), m_needsMarking(false)
+{
+ ++hook->listRefCount;
+ if (hook->nodesRefCount++ == 0)
+ refAll();
+}
+
+ScopeChain& ScopeChain::operator=(const ScopeChain& l)
+{
+ ScopeChain(l).swap(*this);
+ return *this;
+}
+
+ScopeChain::~ScopeChain()
+{
+ if (!m_needsMarking)
+ if (--hook->nodesRefCount == 0)
+ derefAll();
+
+ if (--hook->listRefCount == 0) {
+ assert(hook->nodesRefCount == 0);
+ clearInternal();
+ delete hook;
+ }
+}
+
+void ScopeChain::mark() const
+{
+ ScopeChainNode *n = hook->next;
+ while (n != hook) {
+ if (!n->member->marked())
+ n->member->mark();
+ n = n->next;
+ }
+}
+
+void ScopeChain::append(const Value& val)
+{
+ ScopeChainNode *n = new ScopeChainNode(val, hook->prev, hook);
+ if (hook->nodesRefCount)
+ n->member->ref();
+ hook->prev->next = n;
+ hook->prev = n;
+}
+
+void ScopeChain::prepend(const Value& val)
+{
+ ScopeChainNode *n = new ScopeChainNode(val, hook, hook->next);
+ if (hook->nodesRefCount)
+ n->member->ref();
+ hook->next->prev = n;
+ hook->next = n;
+}
+
+void ScopeChain::prepend(ValueImp *val)
+{
+ ScopeChainNode *n = new ScopeChainNode(val, hook, hook->next);
+ if (hook->nodesRefCount)
+ n->member->ref();
+ hook->next->prev = n;
+ hook->next = n;
+}
+
+void ScopeChain::prependList(const ScopeChain& lst)
+{
+ ScopeChainNode *otherHook = lst.hook;
+ ScopeChainNode *n = otherHook->prev;
+ while (n != otherHook) {
+ prepend(n->member);
+ n = n->prev;
+ }
+}
+
+void ScopeChain::removeFirst()
+{
+ erase(hook->next);
+}
+
+void ScopeChain::clearInternal()
+{
+ ScopeChainNode *n = hook->next;
+ while (n != hook) {
+ n = n->next;
+ delete n->prev;
+ }
+
+ hook->next = hook;
+ hook->prev = hook;
+}
+
+ScopeChain ScopeChain::copy() const
+{
+ ScopeChain newScopeChain;
+ newScopeChain.prependList(*this);
+ return newScopeChain;
+}
+
+ScopeChainIterator ScopeChain::begin() const
+{
+ return ScopeChainIterator(hook->next);
+}
+
+ScopeChainIterator ScopeChain::end() const
+{
+ return ScopeChainIterator(hook);
+}
+
+void ScopeChain::erase(ScopeChainNode *n)
+{
+ if (n != hook) {
+ if (hook->nodesRefCount)
+ n->member->deref();
+ n->next->prev = n->prev;
+ n->prev->next = n->next;
+ delete n;
+ }
+}
+
+void ScopeChain::refAll() const
+{
+ for (ScopeChainNode *n = hook->next; n != hook; n = n->next)
+ n->member->ref();
+}
+
+void ScopeChain::derefAll() const
+{
+ for (ScopeChainNode *n = hook->next; n != hook; n = n->next)
+ n->member->deref();
+}
+
+void ScopeChain::swap(ScopeChain &other)
+{
+ if (!m_needsMarking)
+ if (other.hook->nodesRefCount++ == 0)
+ other.refAll();
+ if (!other.m_needsMarking)
+ if (hook->nodesRefCount++ == 0)
+ refAll();
+
+ if (!m_needsMarking)
+ if (--hook->nodesRefCount == 0)
+ derefAll();
+ if (!other.m_needsMarking)
+ if (--other.hook->nodesRefCount == 0)
+ other.derefAll();
+
+ ScopeChainHookNode *tmp = hook;
+ hook = other.hook;
+ other.hook = tmp;
+}
+
+bool ScopeChain::isEmpty() const
+{
+ return hook->next == hook;
+}
+
+} // namespace KJS
--- /dev/null
+// -*- c-basic-offset: 2 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef KJS_SCOPE_CHAIN_H
+#define KJS_SCOPE_CHAIN_H
+
+#include "value.h"
+
+// internal data types
+
+namespace KJS {
+
+ class ScopeChain;
+ class ScopeChainIterator;
+ class ScopeChainNode;
+ class ScopeChainHookNode;
+
+ /**
+ * @short Iterator for @ref KJS::ScopeChain objects.
+ */
+ class ScopeChainIterator {
+ friend class ScopeChain;
+ ScopeChainIterator() : node(0) { }
+ ScopeChainIterator(ScopeChainNode *n) : node(n) { }
+ public:
+ /**
+ * Construct an iterator that points to the first element of the list.
+ * @param l The list the iterator will operate on.
+ */
+ ScopeChainIterator(const ScopeChain &l);
+ /**
+ * Dereference the iterator.
+ * @return A pointer to the element the iterator operates on.
+ */
+ ValueImp* operator->() const;
+ Value operator*() const;
+ /**
+ * Postfix increment operator.
+ * @return The element after the increment.
+ */
+ Value operator++();
+ /**
+ * Prefix increment operator.
+ */
+ Value operator++(int);
+ /**
+ * Compare the iterator with another one.
+ * @return True if the two iterators operate on the same list element.
+ * False otherwise.
+ */
+ bool operator==(const ScopeChainIterator &it) const { return node == it.node; }
+ /**
+ * Check for inequality with another iterator.
+ * @return True if the two iterators operate on different list elements.
+ */
+ bool operator!=(const ScopeChainIterator &it) const { return node != it.node; }
+ private:
+ ScopeChainNode *node;
+ };
+
+ /**
+ * @short Native list type.
+ *
+ * ScopeChain is a native ECMAScript type. ScopeChain values are only used for
+ * intermediate results of expression evaluation and cannot be stored
+ * as properties of objects.
+ *
+ * The list is explicitly shared. Note that while copy() returns a
+ * copy of the list the referenced objects are still shared.
+ */
+ class ScopeChain {
+ friend class ScopeChainIterator;
+ public:
+ ScopeChain(bool needsMarking = false);
+ ScopeChain(const ScopeChain& l);
+ ScopeChain &operator=(const ScopeChain& l);
+
+ ~ScopeChain();
+
+ /**
+ * Insert an object at the beginning of the list.
+ *
+ * @param val Pointer to object.
+ */
+ void prepend(const Value& val);
+ /**
+ * Remove the element at the beginning of the list.
+ */
+ void removeFirst();
+ /**
+ * Returns a shallow copy of the list. Ownership is passed to the user
+ * who is responsible for deleting the list then.
+ */
+ ScopeChain copy() const;
+ /**
+ * @return A @ref KJS::ScopeChainIterator pointing to the first element.
+ */
+ ScopeChainIterator begin() const;
+ /**
+ * @return A @ref KJS::ScopeChainIterator pointing to the last element.
+ */
+ ScopeChainIterator end() const;
+
+ bool isEmpty() const;
+
+ void mark() const;
+
+ // temporary
+ void prependList(const ScopeChain &);
+ void append(const Value &);
+
+ private:
+
+ void prepend(ValueImp *val);
+ void erase(ScopeChainNode *n);
+ void clearInternal();
+ void refAll() const;
+ void derefAll() const;
+ void swap(ScopeChain &other);
+
+ ScopeChainHookNode *hook;
+ bool m_needsMarking;
+ };
+
+}; // namespace
+
+#endif // KJS_SCOPE_CHAIN_H
};
struct ListHookNode : public ListNode {
- ListHookNode(bool needsMarking) : ListNode(Value(), this, this),
- listRefCount(1), nodesRefCount(needsMarking ? 0 : 1) { }
+ ListHookNode() : ListNode(0, this, this),
+ listRefCount(1), nodesRefCount(1) { }
int listRefCount;
int nodesRefCount;
};
// ------------------------------ List -----------------------------------------
-List::List(bool needsMarking) : hook(new ListHookNode(needsMarking)), m_needsMarking(needsMarking)
+List::List() : hook(new ListHookNode)
{
}
-List::List(const List& l) : hook(l.hook), m_needsMarking(false)
+List::List(const List& l) : hook(l.hook)
{
++hook->listRefCount;
if (hook->nodesRefCount++ == 0)
List::~List()
{
- if (!m_needsMarking)
- if (--hook->nodesRefCount == 0)
- derefAll();
+ if (--hook->nodesRefCount == 0)
+ derefAll();
if (--hook->listRefCount == 0) {
assert(hook->nodesRefCount == 0);
void List::swap(List &other)
{
- if (!m_needsMarking)
- if (other.hook->nodesRefCount++ == 0)
- other.refAll();
- if (!other.m_needsMarking)
- if (hook->nodesRefCount++ == 0)
- refAll();
-
- if (!m_needsMarking)
- if (--hook->nodesRefCount == 0)
- derefAll();
- if (!other.m_needsMarking)
- if (--other.hook->nodesRefCount == 0)
- other.derefAll();
-
ListHookNode *tmp = hook;
hook = other.hook;
other.hook = tmp;
#ifndef _KJS_TYPES_H_
#define _KJS_TYPES_H_
-// internal data types
-
#include "value.h"
-#include "reference.h"
#include "completion.h"
+// internal data types
+
namespace KJS {
class List;
class List {
friend class ListIterator;
public:
- List(bool needsMarking = false);
+ List();
List(const List& l);
List &operator=(const List& l);
void swap(List &other);
ListHookNode *hook;
- bool m_needsMarking;
};
- typedef List ArgumentList;
+ typedef List List;
}; // namespace
+2002-11-21 Darin Adler <darin@apple.com>
+
+ * khtml/ecma/kjs_dom.cpp: (DOMNode::eventHandlerScope): List -> ScopeChain.
+ * khtml/ecma/kjs_dom.h: List -> ScopeChain.
+ * khtml/ecma/kjs_events.cpp: (JSEventListener::handleEvent): List -> ScopeChain.
+ * khtml/ecma/kjs_html.cpp: (KJS::HTMLElement::eventHandlerScope): List -> ScopeChain.
+ * khtml/ecma/kjs_html.h: List -> ScopeChain.
+
+ * force-js-clean-timestamp: Not sure this is required, but better safe than sorry.
+
2002-11-21 Maciej Stachowiak <mjs@apple.com>
* force-js-clean-timestamp: Touch so other people's builds work.
+2002-11-21 Darin Adler <darin@apple.com>
+
+ * khtml/ecma/kjs_dom.cpp: (DOMNode::eventHandlerScope): List -> ScopeChain.
+ * khtml/ecma/kjs_dom.h: List -> ScopeChain.
+ * khtml/ecma/kjs_events.cpp: (JSEventListener::handleEvent): List -> ScopeChain.
+ * khtml/ecma/kjs_html.cpp: (KJS::HTMLElement::eventHandlerScope): List -> ScopeChain.
+ * khtml/ecma/kjs_html.h: List -> ScopeChain.
+
+ * force-js-clean-timestamp: Not sure this is required, but better safe than sorry.
+
2002-11-21 Maciej Stachowiak <mjs@apple.com>
* force-js-clean-timestamp: Touch so other people's builds work.
+2002-11-21 Darin Adler <darin@apple.com>
+
+ * khtml/ecma/kjs_dom.cpp: (DOMNode::eventHandlerScope): List -> ScopeChain.
+ * khtml/ecma/kjs_dom.h: List -> ScopeChain.
+ * khtml/ecma/kjs_events.cpp: (JSEventListener::handleEvent): List -> ScopeChain.
+ * khtml/ecma/kjs_html.cpp: (KJS::HTMLElement::eventHandlerScope): List -> ScopeChain.
+ * khtml/ecma/kjs_html.h: List -> ScopeChain.
+
+ * force-js-clean-timestamp: Not sure this is required, but better safe than sorry.
+
2002-11-21 Maciej Stachowiak <mjs@apple.com>
* force-js-clean-timestamp: Touch so other people's builds work.
-PRopertyMap size change 11/21 - Maciej
+List -> ScopeChain 11/21 - Darin
return Null();
}
-List DOMNode::eventHandlerScope(ExecState *) const
+ScopeChain DOMNode::eventHandlerScope(ExecState *) const
{
- return List::empty();
+ return ScopeChain();
}
Value DOMNodeProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
virtual UString toString(ExecState *exec) const;
void setListener(ExecState *exec, int eventId, Value func) const;
Value getListener(int eventId) const;
- virtual List eventHandlerScope(ExecState *exec) const;
+ virtual ScopeChain eventHandlerScope(ExecState *exec) const;
enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling,
// Add the event's target element to the scope
// (and the document, and the form - see KJS::HTMLElement::eventHandlerScope)
Object thisObj = Object::dynamicCast(getDOMNode(exec,evt.currentTarget()));
- List scope;
- List oldScope = listener.scope();
+ ScopeChain scope;
+ ScopeChain oldScope = listener.scope();
//if (thisVal.type() != NullType)
if ( !thisObj.isNull() ) {
scope = static_cast<DOMNode*>(thisObj.imp())->eventHandlerScope(exec);
if ( !scope.isEmpty() ) {
- List curScope = oldScope.copy();
+ ScopeChain curScope = oldScope.copy();
curScope.prependList( scope );
listener.setScope( curScope );
}
return DOMElement::toString(exec);
}
-List KJS::HTMLElement::eventHandlerScope(ExecState *exec) const
+ScopeChain KJS::HTMLElement::eventHandlerScope(ExecState *exec) const
{
DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
- List scope;
+ ScopeChain scope;
// The element is the first one, so that it is the most prioritary
scope.append(getDOMNode(exec,element));
void putValue(ExecState *exec, int token, const Value& value, int);
virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
virtual UString toString(ExecState *exec) const;
- virtual List eventHandlerScope(ExecState *exec) const;
+ virtual ScopeChain eventHandlerScope(ExecState *exec) const;
virtual const ClassInfo* classInfo() const;
static const ClassInfo info;