+2007-12-07 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Next step in refactoring JSGlobalObject: Added JSVariableObject class,
+ and factored symbol-table-related code into it. (JSGlobalObject doesn't
+ use the symbol table code yet, though.)
+
+ Layout and JS tests, and testapi, pass. SunSpider reports no regression.
+
2007-12-07 Darin Adler <darin@apple.com>
Reviewed by Geoff.
__ZN3KJS15JSWrapperObject4markEv
__ZN3KJS15SavedPropertiesC1Ev
__ZN3KJS15SavedPropertiesD1Ev
+__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS16RuntimeObjectImp4infoE
__ZN3KJS16RuntimeObjectImpC1EPNS_8Bindings8InstanceE
__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
__ZN3KJS9Collector7collectEv
__ZN3KJS9Collector7protectEPNS_7JSValueE
__ZN3KJS9Collector9unprotectEPNS_7JSValueE
+__ZN3KJS9ExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectEPNS_16FunctionBodyNodeENS_8CodeTypeEPS0_S8_PNS_11FunctionImpEPKNS_4ListE
__ZN3KJS9ExecStateD1Ev
__ZN3KJSeqERKNS_7UStringEPKc
__ZN3WTF10fastCallocEmm
__ZTVN3KJS14JSGlobalObjectE
__ZTVN3KJS14StringInstanceE
__ZTVN3KJS15JSWrapperObjectE
+__ZTVN3KJS16JSVariableObjectE
__ZTVN3KJS19InternalFunctionImpE
__ZTVN3KJS8JSObjectE
_jscore_collector_introspection
RelativePath="..\..\kjs\JSGlobalObject.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\kjs\JSVariableObject.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\kjs\JSVariableObject.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\kjs\JSImmediate.cpp"\r
>\r
1482B7E30A43076000517CFC /* JSObjectRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B7E10A43076000517CFC /* JSObjectRef.h */; settings = {ATTRIBUTES = (Public, ); }; };
1482B7E40A43076000517CFC /* JSObjectRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1482B7E20A43076000517CFC /* JSObjectRef.cpp */; };
1483B58A099BC1950016E4F0 /* JSImmediate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1483B589099BC1950016E4F0 /* JSImmediate.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 148A1627095D16BB00666D0D /* ListRefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 148A1626095D16BB00666D0D /* ListRefPtr.h */; };
+ 148A1627095D16BB00666D0D /* ListRefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 148A1626095D16BB00666D0D /* ListRefPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
14A396A70CD2933100B5B4FF /* SymbolTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A396A60CD2933100B5B4FF /* SymbolTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
14ABB36F099C076400E2A24F /* value.h in Headers */ = {isa = PBXBuildFile; fileRef = 14ABB36E099C076400E2A24F /* value.h */; settings = {ATTRIBUTES = (Private, ); }; };
14ABB455099C2A0F00E2A24F /* JSType.h in Headers */ = {isa = PBXBuildFile; fileRef = 14ABB454099C2A0F00E2A24F /* JSType.h */; settings = {ATTRIBUTES = (Private, ); }; };
14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */; };
14BD5A360A3E91F600BAF59C /* JavaScriptCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */; };
+ 14F252570D08DD8D004ECFFF /* JSVariableObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F252560D08DD8D004ECFFF /* JSVariableObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 14F252610D08DF2F004ECFFF /* JSVariableObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */; };
1CAF34890A6C421700ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34880A6C421700ABE06E /* WebScriptObject.h */; };
5186111E0CC824900081412B /* Deque.h in Headers */ = {isa = PBXBuildFile; fileRef = 5186111D0CC824830081412B /* Deque.h */; settings = {ATTRIBUTES = (Private, ); }; };
51F648D70BB4E2CA0033D760 /* RetainPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F648D60BB4E2CA0033D760 /* RetainPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B4B0822A1C700736975 /* lexer.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8660255597D01FF60F7 /* lexer.h */; };
932F5B4D0822A1C700736975 /* lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8690255597D01FF60F7 /* lookup.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B4E0822A1C700736975 /* math_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A86B0255597D01FF60F7 /* math_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 932F5B500822A1C700736975 /* nodes.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A86E0255597D01FF60F7 /* nodes.h */; };
+ 932F5B500822A1C700736975 /* nodes.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A86E0255597D01FF60F7 /* nodes.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B510822A1C700736975 /* number_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8710255597D01FF60F7 /* number_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B530822A1C700736975 /* object_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8740255597D01FF60F7 /* object_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B540822A1C700736975 /* object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8760255597D01FF60F7 /* object.h */; settings = {ATTRIBUTES = (Private, ); }; };
93E26BD408B1514100F85226 /* pcre_xclass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E26BD308B1514100F85226 /* pcre_xclass.cpp */; };
93E26BE608B1517100F85226 /* pcre_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E26BE508B1517100F85226 /* pcre_internal.h */; };
93E26BFE08B151D400F85226 /* ucpinternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E26BFC08B151D400F85226 /* ucpinternal.h */; };
- 93F0B3AC09BB4DC00068FCE3 /* Parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F0B3AA09BB4DC00068FCE3 /* Parser.h */; };
+ 93F0B3AC09BB4DC00068FCE3 /* Parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F0B3AA09BB4DC00068FCE3 /* Parser.h */; settings = {ATTRIBUTES = (Private, ); }; };
95C18D490C90E82600E72F73 /* JSRetainPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 95C18D3E0C90E7EF00E72F73 /* JSRetainPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
A8E894320CD0602400367179 /* JSCallbackObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */; };
A8E894340CD0603F00367179 /* JSGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8E894330CD0603F00367179 /* JSGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JavaScriptCore.h; sourceTree = "<group>"; };
14D857740A4696C80032146C /* testapi.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = testapi.js; sourceTree = "<group>"; };
14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObject.cpp; sourceTree = "<group>"; };
+ 14F252560D08DD8D004ECFFF /* JSVariableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVariableObject.h; sourceTree = "<group>"; };
+ 14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVariableObject.cpp; sourceTree = "<group>"; };
1C9051420BA9E8A70081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = JavaScriptCore.xcconfig; sourceTree = "<group>"; };
1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
65417200039E01BA0058BFEB /* kjs */ = {
isa = PBXGroup;
children = (
+ 14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
93ADFCE60CCBD7AC00D30B08 /* array_instance.cpp */,
938772E5038BFE19008635CE /* array_instance.h */,
65EA4C9A092AF9E20093D800 /* JSLock.h */,
14ABB454099C2A0F00E2A24F /* JSType.h */,
1482B6EA0A4300B300517CFC /* JSValueRef.h */,
+ 14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
93F1981A08245AAE001E9ABC /* keywords.table */,
E1EF79AB0CE97BA60088D500 /* UTF8.h in Headers */,
1419D32D0CEA7CDE00FF507A /* RefCounted.h in Headers */,
5DA479660CFBCF56009328A0 /* TCPackedCache.h in Headers */,
+ 14F252570D08DD8D004ECFFF /* JSVariableObject.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
932F5BC50822A1C700736975 /* runtime_root.cpp in Sources */,
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */,
+ 14F252610D08DF2F004ECFFF /* JSVariableObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
kjs/internal.cpp
kjs/interpreter.cpp
kjs/JSGlobalObject.cpp
+ kjs/JSVariableObject.cpp
kjs/JSImmediate.cpp
kjs/JSLock.cpp
kjs/JSWrapperObject.cpp
// create and initialize activation object (ECMA 10.1.6)
if (type == FunctionCode) {
m_activation = new ActivationImp(this);
- m_variable = m_activation;
+ m_variableObject = m_activation;
} else {
m_activation = 0;
- m_variable = globalObject;
+ m_variableObject = globalObject;
}
// ECMA 10.2
case EvalCode:
if (m_callingExec) {
m_scopeChain = m_callingExec->scopeChain();
- m_variable = m_callingExec->variableObject();
+ m_variableObject = m_callingExec->variableObject();
m_thisVal = m_callingExec->thisValue();
break;
} // else same as GlobalCode
case FunctionCode:
m_scopeChain = func->scope();
m_scopeChain.push(m_activation);
- m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3)
+ m_variableObject = m_activation;
m_thisVal = thisV;
break;
}
void ExecState::updateLocalStorage()
{
- m_localStorageBuffer = static_cast<ActivationImp*>(m_activation)->localStorage().data();
+ m_localStorageBuffer = m_activation->localStorage().data();
}
} // namespace KJS
FunctionCode,
};
- class JSGlobalObject;
- class ScopeChain;
- class Interpreter;
+ class ActivationImp;
+ class FunctionBodyNode;
class FunctionImp;
class GlobalFuncImp;
- class FunctionBodyNode;
+ class Interpreter;
+ class JSGlobalObject;
+ class JSVariableObject;
+ class ScopeChain;
struct LocalStorageEntry;
/**
const ScopeChain& scopeChain() const { return m_scopeChain; }
- JSObject* variableObject() const { return m_variable; }
- void setVariableObject(JSObject* v) { m_variable = v; }
+ JSVariableObject* variableObject() const { return m_variableObject; }
+ void setVariableObject(JSVariableObject* v) { m_variableObject = v; }
JSObject* thisValue() const { return m_thisVal; }
ExecState* callingExecState() { return m_callingExec; }
- JSObject* activationObject() { return m_activation; }
+ ActivationImp* activationObject() { return m_activation; }
CodeType codeType() { return m_codeType; }
FunctionBodyNode* currentBody() { return m_currentBody; }
FunctionImp* function() const { return m_function; }
FunctionImp* m_function;
const List* m_arguments;
- JSObject* m_activation;
+ ActivationImp* m_activation;
LocalStorageEntry* m_localStorageBuffer;
ScopeChain m_scopeChain;
- JSObject* m_variable;
+ JSVariableObject* m_variableObject;
JSObject* m_thisVal;
LabelStack ls;
{
ASSERT(JSLock::currentThreadIsHoldingLock());
- if (d->debugger)
- d->debugger->detach(this);
+ if (d()->debugger)
+ d()->debugger->detach(this);
- d->next->d->prev = d->prev;
- d->prev->d->next = d->next;
- s_head = d->next;
+ d()->next->d()->prev = d()->prev;
+ d()->prev->d()->next = d()->next;
+ s_head = d()->next;
if (s_head == this)
s_head = 0;
+
+ delete d();
}
void JSGlobalObject::init()
{
ASSERT(JSLock::currentThreadIsHoldingLock());
- d.reset(new JSGlobalObjectData(this));
-
if (s_head) {
- d->prev = s_head;
- d->next = s_head->d->next;
- s_head->d->next->d->prev = this;
- s_head->d->next = this;
+ d()->prev = s_head;
+ d()->next = s_head->d()->next;
+ s_head->d()->next->d()->prev = this;
+ s_head->d()->next = this;
} else
- s_head = d->next = d->prev = this;
+ s_head = d()->next = d()->prev = this;
- d->compatMode = NativeMode;
+ d()->compatMode = NativeMode;
resetTimeoutCheck();
- d->timeoutTime = 0;
- d->timeoutCheckCount = 0;
+ d()->timeoutTime = 0;
+ d()->timeoutCheckCount = 0;
- d->currentExec = 0;
- d->recursion = 0;
- d->debugger = 0;
+ d()->currentExec = 0;
+ d()->recursion = 0;
+ d()->debugger = 0;
reset(prototype());
}
// stale (wasteful) pointers during possible garbage collection while creating
// new objects below.
- ExecState* exec = &d->globalExec;
+ ExecState* exec = &d()->globalExec;
// Prototypes
- d->functionPrototype = 0;
- d->objectPrototype = 0;
-
- d->arrayPrototype = 0;
- d->stringPrototype = 0;
- d->booleanPrototype = 0;
- d->numberPrototype = 0;
- d->datePrototype = 0;
- d->regExpPrototype = 0;
- d->errorPrototype = 0;
+ d()->functionPrototype = 0;
+ d()->objectPrototype = 0;
+
+ d()->arrayPrototype = 0;
+ d()->stringPrototype = 0;
+ d()->booleanPrototype = 0;
+ d()->numberPrototype = 0;
+ d()->datePrototype = 0;
+ d()->regExpPrototype = 0;
+ d()->errorPrototype = 0;
- d->evalErrorPrototype = 0;
- d->rangeErrorPrototype = 0;
- d->referenceErrorPrototype = 0;
- d->syntaxErrorPrototype = 0;
- d->typeErrorPrototype = 0;
- d->URIErrorPrototype = 0;
+ d()->evalErrorPrototype = 0;
+ d()->rangeErrorPrototype = 0;
+ d()->referenceErrorPrototype = 0;
+ d()->syntaxErrorPrototype = 0;
+ d()->typeErrorPrototype = 0;
+ d()->URIErrorPrototype = 0;
// Constructors
- d->objectConstructor = 0;
- d->functionConstructor = 0;
- d->arrayConstructor = 0;
- d->stringConstructor = 0;
- d->booleanConstructor = 0;
- d->numberConstructor = 0;
- d->dateConstructor = 0;
- d->regExpConstructor = 0;
- d->errorConstructor = 0;
+ d()->objectConstructor = 0;
+ d()->functionConstructor = 0;
+ d()->arrayConstructor = 0;
+ d()->stringConstructor = 0;
+ d()->booleanConstructor = 0;
+ d()->numberConstructor = 0;
+ d()->dateConstructor = 0;
+ d()->regExpConstructor = 0;
+ d()->errorConstructor = 0;
- d->evalErrorConstructor = 0;
- d->rangeErrorConstructor = 0;
- d->referenceErrorConstructor = 0;
- d->syntaxErrorConstructor = 0;
- d->typeErrorConstructor = 0;
- d->URIErrorConstructor = 0;
+ d()->evalErrorConstructor = 0;
+ d()->rangeErrorConstructor = 0;
+ d()->referenceErrorConstructor = 0;
+ d()->syntaxErrorConstructor = 0;
+ d()->typeErrorConstructor = 0;
+ d()->URIErrorConstructor = 0;
// Prototypes
- d->functionPrototype = new FunctionPrototype(exec);
- d->objectPrototype = new ObjectPrototype(exec, d->functionPrototype);
- d->functionPrototype->setPrototype(d->objectPrototype);
-
- d->arrayPrototype = new ArrayPrototype(exec, d->objectPrototype);
- d->stringPrototype = new StringPrototype(exec, d->objectPrototype);
- d->booleanPrototype = new BooleanPrototype(exec, d->objectPrototype, d->functionPrototype);
- d->numberPrototype = new NumberPrototype(exec, d->objectPrototype, d->functionPrototype);
- d->datePrototype = new DatePrototype(exec, d->objectPrototype);
- d->regExpPrototype = new RegExpPrototype(exec, d->objectPrototype, d->functionPrototype);;
- d->errorPrototype = new ErrorPrototype(exec, d->objectPrototype, d->functionPrototype);
+ d()->functionPrototype = new FunctionPrototype(exec);
+ d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype);
+ d()->functionPrototype->setPrototype(d()->objectPrototype);
+
+ d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype);
+ d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype);
+ d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);
+ d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);
+ d()->datePrototype = new DatePrototype(exec, d()->objectPrototype);
+ d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);;
+ d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);
- d->evalErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, EvalError, "EvalError", "EvalError");
- d->rangeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, RangeError, "RangeError", "RangeError");
- d->referenceErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError");
- d->syntaxErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError");
- d->typeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, TypeError, "TypeError", "TypeError");
- d->URIErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, URIError, "URIError", "URIError");
+ d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, EvalError, "EvalError", "EvalError");
+ d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, RangeError, "RangeError", "RangeError");
+ d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError");
+ d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError");
+ d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, TypeError, "TypeError", "TypeError");
+ d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, URIError, "URIError", "URIError");
// Constructors
- d->objectConstructor = new ObjectObjectImp(exec, d->objectPrototype, d->functionPrototype);
- d->functionConstructor = new FunctionObjectImp(exec, d->functionPrototype);
- d->arrayConstructor = new ArrayObjectImp(exec, d->functionPrototype, d->arrayPrototype);
- d->stringConstructor = new StringObjectImp(exec, d->functionPrototype, d->stringPrototype);
- d->booleanConstructor = new BooleanObjectImp(exec, d->functionPrototype, d->booleanPrototype);
- d->numberConstructor = new NumberObjectImp(exec, d->functionPrototype, d->numberPrototype);
- d->dateConstructor = new DateObjectImp(exec, d->functionPrototype, d->datePrototype);
- d->regExpConstructor = new RegExpObjectImp(exec, d->functionPrototype, d->regExpPrototype);
- d->errorConstructor = new ErrorObjectImp(exec, d->functionPrototype, d->errorPrototype);
+ d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype);
+ d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype);
+ d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype);
+ d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype);
+ d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype);
+ d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype);
+ d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype);
+ d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype);
+ d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype);
- d->evalErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->evalErrorPrototype);
- d->rangeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->rangeErrorPrototype);
- d->referenceErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->referenceErrorPrototype);
- d->syntaxErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->syntaxErrorPrototype);
- d->typeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->typeErrorPrototype);
- d->URIErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->URIErrorPrototype);
+ d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype);
+ d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype);
+ d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype);
+ d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype);
+ d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype);
+ d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype);
- d->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum);
-
- d->objectPrototype->put(exec, exec->propertyNames().constructor, d->objectConstructor, DontEnum | DontDelete | ReadOnly);
- d->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum | DontDelete | ReadOnly);
- d->arrayPrototype->put(exec, exec->propertyNames().constructor, d->arrayConstructor, DontEnum | DontDelete | ReadOnly);
- d->booleanPrototype->put(exec, exec->propertyNames().constructor, d->booleanConstructor, DontEnum | DontDelete | ReadOnly);
- d->stringPrototype->put(exec, exec->propertyNames().constructor, d->stringConstructor, DontEnum | DontDelete | ReadOnly);
- d->numberPrototype->put(exec, exec->propertyNames().constructor, d->numberConstructor, DontEnum | DontDelete | ReadOnly);
- d->datePrototype->put(exec, exec->propertyNames().constructor, d->dateConstructor, DontEnum | DontDelete | ReadOnly);
- d->regExpPrototype->put(exec, exec->propertyNames().constructor, d->regExpConstructor, DontEnum | DontDelete | ReadOnly);
- d->errorPrototype->put(exec, exec->propertyNames().constructor, d->errorConstructor, DontEnum | DontDelete | ReadOnly);
- d->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
- d->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
- d->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
- d->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
- d->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
- d->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
+
+ d()->objectPrototype->put(exec, exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->arrayPrototype->put(exec, exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->booleanPrototype->put(exec, exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->stringPrototype->put(exec, exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->numberPrototype->put(exec, exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->datePrototype->put(exec, exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->regExpPrototype->put(exec, exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->errorPrototype->put(exec, exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
+ d()->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
// Set global constructors
// FIXME: These properties should be handled by a static hash table.
- putDirect("Object", d->objectConstructor, DontEnum);
- putDirect("Function", d->functionConstructor, DontEnum);
- putDirect("Array", d->arrayConstructor, DontEnum);
- putDirect("Boolean", d->booleanConstructor, DontEnum);
- putDirect("String", d->stringConstructor, DontEnum);
- putDirect("Number", d->numberConstructor, DontEnum);
- putDirect("Date", d->dateConstructor, DontEnum);
- putDirect("RegExp", d->regExpConstructor, DontEnum);
- putDirect("Error", d->errorConstructor, DontEnum);
- putDirect("EvalError", d->evalErrorConstructor, Internal);
- putDirect("RangeError", d->rangeErrorConstructor, Internal);
- putDirect("ReferenceError", d->referenceErrorConstructor, Internal);
- putDirect("SyntaxError", d->syntaxErrorConstructor, Internal);
- putDirect("TypeError", d->typeErrorConstructor, Internal);
- putDirect("URIError", d->URIErrorConstructor, Internal);
+ putDirect("Object", d()->objectConstructor, DontEnum);
+ putDirect("Function", d()->functionConstructor, DontEnum);
+ putDirect("Array", d()->arrayConstructor, DontEnum);
+ putDirect("Boolean", d()->booleanConstructor, DontEnum);
+ putDirect("String", d()->stringConstructor, DontEnum);
+ putDirect("Number", d()->numberConstructor, DontEnum);
+ putDirect("Date", d()->dateConstructor, DontEnum);
+ putDirect("RegExp", d()->regExpConstructor, DontEnum);
+ putDirect("Error", d()->errorConstructor, DontEnum);
+ putDirect("EvalError", d()->evalErrorConstructor, Internal);
+ putDirect("RangeError", d()->rangeErrorConstructor, Internal);
+ putDirect("ReferenceError", d()->referenceErrorConstructor, Internal);
+ putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal);
+ putDirect("TypeError", d()->typeErrorConstructor, Internal);
+ putDirect("URIError", d()->URIErrorConstructor, Internal);
// Set global values.
- putDirect("Math", new MathObjectImp(exec, d->objectPrototype), DontEnum);
+ putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum);
putDirect("NaN", jsNaN(), DontEnum | DontDelete);
putDirect("Infinity", jsNumber(Inf), DontEnum | DontDelete);
// Set global functions.
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
#ifndef NDEBUG
- putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
+ putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
#endif
// Set prototype, and also insert the object prototype at the end of the chain.
setPrototype(prototype);
- lastInPrototypeChain(this)->setPrototype(d->objectPrototype);
+ lastInPrototypeChain(this)->setPrototype(d()->objectPrototype);
}
void JSGlobalObject::startTimeoutCheck()
{
- if (!d->timeoutCheckCount)
+ if (!d()->timeoutCheckCount)
resetTimeoutCheck();
- ++d->timeoutCheckCount;
+ ++d()->timeoutCheckCount;
}
void JSGlobalObject::stopTimeoutCheck()
{
- --d->timeoutCheckCount;
+ --d()->timeoutCheckCount;
}
void JSGlobalObject::resetTimeoutCheck()
{
- d->tickCount = 0;
- d->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
- d->timeAtLastCheckTimeout = 0;
- d->timeExecuting = 0;
+ d()->tickCount = 0;
+ d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
+ d()->timeAtLastCheckTimeout = 0;
+ d()->timeExecuting = 0;
}
bool JSGlobalObject::checkTimeout()
{
- d->tickCount = 0;
+ d()->tickCount = 0;
unsigned currentTime = getCurrentTime();
- if (!d->timeAtLastCheckTimeout) {
+ if (!d()->timeAtLastCheckTimeout) {
// Suspicious amount of looping in a script -- start timing it
- d->timeAtLastCheckTimeout = currentTime;
+ d()->timeAtLastCheckTimeout = currentTime;
return false;
}
- unsigned timeDiff = currentTime - d->timeAtLastCheckTimeout;
+ unsigned timeDiff = currentTime - d()->timeAtLastCheckTimeout;
if (timeDiff == 0)
timeDiff = 1;
- d->timeExecuting += timeDiff;
- d->timeAtLastCheckTimeout = currentTime;
+ d()->timeExecuting += timeDiff;
+ d()->timeAtLastCheckTimeout = currentTime;
// Adjust the tick threshold so we get the next checkTimeout call in the interval specified in
// preferredScriptCheckTimeInterval
- d->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d->ticksUntilNextTimeoutCheck;
+ d()->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d()->ticksUntilNextTimeoutCheck;
// If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the
// preferred script check time interval.
- if (d->ticksUntilNextTimeoutCheck == 0)
- d->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
+ if (d()->ticksUntilNextTimeoutCheck == 0)
+ d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
- if (d->timeoutTime && d->timeExecuting > d->timeoutTime) {
+ if (d()->timeoutTime && d()->timeExecuting > d()->timeoutTime) {
if (shouldInterruptScript())
return true;
if (!builtins._internal)
builtins._internal = new SavedBuiltinsInternal;
- builtins._internal->objectConstructor = d->objectConstructor;
- builtins._internal->functionConstructor = d->functionConstructor;
- builtins._internal->arrayConstructor = d->arrayConstructor;
- builtins._internal->booleanConstructor = d->booleanConstructor;
- builtins._internal->stringConstructor = d->stringConstructor;
- builtins._internal->numberConstructor = d->numberConstructor;
- builtins._internal->dateConstructor = d->dateConstructor;
- builtins._internal->regExpConstructor = d->regExpConstructor;
- builtins._internal->errorConstructor = d->errorConstructor;
- builtins._internal->evalErrorConstructor = d->evalErrorConstructor;
- builtins._internal->rangeErrorConstructor = d->rangeErrorConstructor;
- builtins._internal->referenceErrorConstructor = d->referenceErrorConstructor;
- builtins._internal->syntaxErrorConstructor = d->syntaxErrorConstructor;
- builtins._internal->typeErrorConstructor = d->typeErrorConstructor;
- builtins._internal->URIErrorConstructor = d->URIErrorConstructor;
+ builtins._internal->objectConstructor = d()->objectConstructor;
+ builtins._internal->functionConstructor = d()->functionConstructor;
+ builtins._internal->arrayConstructor = d()->arrayConstructor;
+ builtins._internal->booleanConstructor = d()->booleanConstructor;
+ builtins._internal->stringConstructor = d()->stringConstructor;
+ builtins._internal->numberConstructor = d()->numberConstructor;
+ builtins._internal->dateConstructor = d()->dateConstructor;
+ builtins._internal->regExpConstructor = d()->regExpConstructor;
+ builtins._internal->errorConstructor = d()->errorConstructor;
+ builtins._internal->evalErrorConstructor = d()->evalErrorConstructor;
+ builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor;
+ builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor;
+ builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor;
+ builtins._internal->typeErrorConstructor = d()->typeErrorConstructor;
+ builtins._internal->URIErrorConstructor = d()->URIErrorConstructor;
- builtins._internal->objectPrototype = d->objectPrototype;
- builtins._internal->functionPrototype = d->functionPrototype;
- builtins._internal->arrayPrototype = d->arrayPrototype;
- builtins._internal->booleanPrototype = d->booleanPrototype;
- builtins._internal->stringPrototype = d->stringPrototype;
- builtins._internal->numberPrototype = d->numberPrototype;
- builtins._internal->datePrototype = d->datePrototype;
- builtins._internal->regExpPrototype = d->regExpPrototype;
- builtins._internal->errorPrototype = d->errorPrototype;
- builtins._internal->evalErrorPrototype = d->evalErrorPrototype;
- builtins._internal->rangeErrorPrototype = d->rangeErrorPrototype;
- builtins._internal->referenceErrorPrototype = d->referenceErrorPrototype;
- builtins._internal->syntaxErrorPrototype = d->syntaxErrorPrototype;
- builtins._internal->typeErrorPrototype = d->typeErrorPrototype;
- builtins._internal->URIErrorPrototype = d->URIErrorPrototype;
+ builtins._internal->objectPrototype = d()->objectPrototype;
+ builtins._internal->functionPrototype = d()->functionPrototype;
+ builtins._internal->arrayPrototype = d()->arrayPrototype;
+ builtins._internal->booleanPrototype = d()->booleanPrototype;
+ builtins._internal->stringPrototype = d()->stringPrototype;
+ builtins._internal->numberPrototype = d()->numberPrototype;
+ builtins._internal->datePrototype = d()->datePrototype;
+ builtins._internal->regExpPrototype = d()->regExpPrototype;
+ builtins._internal->errorPrototype = d()->errorPrototype;
+ builtins._internal->evalErrorPrototype = d()->evalErrorPrototype;
+ builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype;
+ builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype;
+ builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype;
+ builtins._internal->typeErrorPrototype = d()->typeErrorPrototype;
+ builtins._internal->URIErrorPrototype = d()->URIErrorPrototype;
}
void JSGlobalObject::restoreBuiltins(const SavedBuiltins& builtins)
if (!builtins._internal)
return;
- d->objectConstructor = builtins._internal->objectConstructor;
- d->functionConstructor = builtins._internal->functionConstructor;
- d->arrayConstructor = builtins._internal->arrayConstructor;
- d->booleanConstructor = builtins._internal->booleanConstructor;
- d->stringConstructor = builtins._internal->stringConstructor;
- d->numberConstructor = builtins._internal->numberConstructor;
- d->dateConstructor = builtins._internal->dateConstructor;
- d->regExpConstructor = builtins._internal->regExpConstructor;
- d->errorConstructor = builtins._internal->errorConstructor;
- d->evalErrorConstructor = builtins._internal->evalErrorConstructor;
- d->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;
- d->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;
- d->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;
- d->typeErrorConstructor = builtins._internal->typeErrorConstructor;
- d->URIErrorConstructor = builtins._internal->URIErrorConstructor;
-
- d->objectPrototype = builtins._internal->objectPrototype;
- d->functionPrototype = builtins._internal->functionPrototype;
- d->arrayPrototype = builtins._internal->arrayPrototype;
- d->booleanPrototype = builtins._internal->booleanPrototype;
- d->stringPrototype = builtins._internal->stringPrototype;
- d->numberPrototype = builtins._internal->numberPrototype;
- d->datePrototype = builtins._internal->datePrototype;
- d->regExpPrototype = builtins._internal->regExpPrototype;
- d->errorPrototype = builtins._internal->errorPrototype;
- d->evalErrorPrototype = builtins._internal->evalErrorPrototype;
- d->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;
- d->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;
- d->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;
- d->typeErrorPrototype = builtins._internal->typeErrorPrototype;
- d->URIErrorPrototype = builtins._internal->URIErrorPrototype;
+ d()->objectConstructor = builtins._internal->objectConstructor;
+ d()->functionConstructor = builtins._internal->functionConstructor;
+ d()->arrayConstructor = builtins._internal->arrayConstructor;
+ d()->booleanConstructor = builtins._internal->booleanConstructor;
+ d()->stringConstructor = builtins._internal->stringConstructor;
+ d()->numberConstructor = builtins._internal->numberConstructor;
+ d()->dateConstructor = builtins._internal->dateConstructor;
+ d()->regExpConstructor = builtins._internal->regExpConstructor;
+ d()->errorConstructor = builtins._internal->errorConstructor;
+ d()->evalErrorConstructor = builtins._internal->evalErrorConstructor;
+ d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;
+ d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;
+ d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;
+ d()->typeErrorConstructor = builtins._internal->typeErrorConstructor;
+ d()->URIErrorConstructor = builtins._internal->URIErrorConstructor;
+
+ d()->objectPrototype = builtins._internal->objectPrototype;
+ d()->functionPrototype = builtins._internal->functionPrototype;
+ d()->arrayPrototype = builtins._internal->arrayPrototype;
+ d()->booleanPrototype = builtins._internal->booleanPrototype;
+ d()->stringPrototype = builtins._internal->stringPrototype;
+ d()->numberPrototype = builtins._internal->numberPrototype;
+ d()->datePrototype = builtins._internal->datePrototype;
+ d()->regExpPrototype = builtins._internal->regExpPrototype;
+ d()->errorPrototype = builtins._internal->errorPrototype;
+ d()->evalErrorPrototype = builtins._internal->evalErrorPrototype;
+ d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;
+ d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;
+ d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;
+ d()->typeErrorPrototype = builtins._internal->typeErrorPrototype;
+ d()->URIErrorPrototype = builtins._internal->URIErrorPrototype;
}
void JSGlobalObject::mark()
{
- JSObject::mark();
-
- if (d->currentExec)
- d->currentExec->mark();
-
- markIfNeeded(d->globalExec.exception());
-
- markIfNeeded(d->objectConstructor);
- markIfNeeded(d->functionConstructor);
- markIfNeeded(d->arrayConstructor);
- markIfNeeded(d->booleanConstructor);
- markIfNeeded(d->stringConstructor);
- markIfNeeded(d->numberConstructor);
- markIfNeeded(d->dateConstructor);
- markIfNeeded(d->regExpConstructor);
- markIfNeeded(d->errorConstructor);
- markIfNeeded(d->evalErrorConstructor);
- markIfNeeded(d->rangeErrorConstructor);
- markIfNeeded(d->referenceErrorConstructor);
- markIfNeeded(d->syntaxErrorConstructor);
- markIfNeeded(d->typeErrorConstructor);
- markIfNeeded(d->URIErrorConstructor);
+ JSVariableObject::mark();
+
+ if (d()->currentExec)
+ d()->currentExec->mark();
+
+ markIfNeeded(d()->globalExec.exception());
+
+ markIfNeeded(d()->objectConstructor);
+ markIfNeeded(d()->functionConstructor);
+ markIfNeeded(d()->arrayConstructor);
+ markIfNeeded(d()->booleanConstructor);
+ markIfNeeded(d()->stringConstructor);
+ markIfNeeded(d()->numberConstructor);
+ markIfNeeded(d()->dateConstructor);
+ markIfNeeded(d()->regExpConstructor);
+ markIfNeeded(d()->errorConstructor);
+ markIfNeeded(d()->evalErrorConstructor);
+ markIfNeeded(d()->rangeErrorConstructor);
+ markIfNeeded(d()->referenceErrorConstructor);
+ markIfNeeded(d()->syntaxErrorConstructor);
+ markIfNeeded(d()->typeErrorConstructor);
+ markIfNeeded(d()->URIErrorConstructor);
- markIfNeeded(d->objectPrototype);
- markIfNeeded(d->functionPrototype);
- markIfNeeded(d->arrayPrototype);
- markIfNeeded(d->booleanPrototype);
- markIfNeeded(d->stringPrototype);
- markIfNeeded(d->numberPrototype);
- markIfNeeded(d->datePrototype);
- markIfNeeded(d->regExpPrototype);
- markIfNeeded(d->errorPrototype);
- markIfNeeded(d->evalErrorPrototype);
- markIfNeeded(d->rangeErrorPrototype);
- markIfNeeded(d->referenceErrorPrototype);
- markIfNeeded(d->syntaxErrorPrototype);
- markIfNeeded(d->typeErrorPrototype);
- markIfNeeded(d->URIErrorPrototype);
+ markIfNeeded(d()->objectPrototype);
+ markIfNeeded(d()->functionPrototype);
+ markIfNeeded(d()->arrayPrototype);
+ markIfNeeded(d()->booleanPrototype);
+ markIfNeeded(d()->stringPrototype);
+ markIfNeeded(d()->numberPrototype);
+ markIfNeeded(d()->datePrototype);
+ markIfNeeded(d()->regExpPrototype);
+ markIfNeeded(d()->errorPrototype);
+ markIfNeeded(d()->evalErrorPrototype);
+ markIfNeeded(d()->rangeErrorPrototype);
+ markIfNeeded(d()->referenceErrorPrototype);
+ markIfNeeded(d()->syntaxErrorPrototype);
+ markIfNeeded(d()->typeErrorPrototype);
+ markIfNeeded(d()->URIErrorPrototype);
}
ExecState* JSGlobalObject::globalExec()
{
- return &d->globalExec;
+ return &d()->globalExec;
}
} // namespace KJS
#ifndef KJS_GlobalObject_h
#define KJS_GlobalObject_h
-#include "object.h"
+#include "JSVariableObject.h"
namespace KJS {
enum CompatMode { NativeMode, IECompat, NetscapeCompat };
- class JSGlobalObject : public JSObject {
+ class JSGlobalObject : public JSVariableObject {
protected:
- struct JSGlobalObjectData {
+ using JSVariableObject::JSVariableObjectData;
+
+ struct JSGlobalObjectData : public JSVariableObjectData {
JSGlobalObjectData(JSGlobalObject* globalObject)
- : globalExec(globalObject, globalObject, 0)
+ : JSVariableObjectData(&inlineSymbolTable)
+ , globalExec(globalObject, globalObject, 0)
{
}
Debugger* debugger;
CompatMode compatMode;
-
+
ExecState globalExec;
ExecState* currentExec;
int recursion;
NativeErrorPrototype* syntaxErrorPrototype;
NativeErrorPrototype* typeErrorPrototype;
NativeErrorPrototype* URIErrorPrototype;
+
+ SymbolTable inlineSymbolTable;
};
public:
JSGlobalObject()
+ : JSVariableObject(new JSGlobalObjectData(this))
{
init();
}
protected:
JSGlobalObject(JSValue* proto)
- : JSObject(proto)
+ : JSVariableObject(proto, new JSGlobalObjectData(this))
{
init();
}
// Linked list of all global objects.
static JSGlobalObject* head() { return s_head; }
- JSGlobalObject* next() { return d->next; }
+ JSGlobalObject* next() { return d()->next; }
// Resets the global object to contain only built-in properties, sets
// the global object's prototype to "prototype," then adds the
// The following accessors return pristine values, even if a script
// replaces the global object's associated property.
- ObjectObjectImp* objectConstructor() const { return d->objectConstructor; }
- FunctionObjectImp* functionConstructor() const { return d->functionConstructor; }
- ArrayObjectImp* arrayConstructor() const { return d->arrayConstructor; }
- BooleanObjectImp* booleanConstructor() const { return d->booleanConstructor; }
- StringObjectImp* stringConstructor() const{ return d->stringConstructor; }
- NumberObjectImp* numberConstructor() const{ return d->numberConstructor; }
- DateObjectImp* dateConstructor() const{ return d->dateConstructor; }
- RegExpObjectImp* regExpConstructor() const { return d->regExpConstructor; }
- ErrorObjectImp* errorConstructor() const { return d->errorConstructor; }
- NativeErrorImp* evalErrorConstructor() const { return d->evalErrorConstructor; }
- NativeErrorImp* rangeErrorConstructor() const { return d->rangeErrorConstructor; }
- NativeErrorImp* referenceErrorConstructor() const { return d->referenceErrorConstructor; }
- NativeErrorImp* syntaxErrorConstructor() const { return d->syntaxErrorConstructor; }
- NativeErrorImp* typeErrorConstructor() const { return d->typeErrorConstructor; }
- NativeErrorImp* URIErrorConstructor() const { return d->URIErrorConstructor; }
-
- ObjectPrototype* objectPrototype() const { return d->objectPrototype; }
- FunctionPrototype* functionPrototype() const { return d->functionPrototype; }
- ArrayPrototype* arrayPrototype() const { return d->arrayPrototype; }
- BooleanPrototype* booleanPrototype() const { return d->booleanPrototype; }
- StringPrototype* stringPrototype() const { return d->stringPrototype; }
- NumberPrototype* numberPrototype() const { return d->numberPrototype; }
- DatePrototype* datePrototype() const { return d->datePrototype; }
- RegExpPrototype* regExpPrototype() const { return d->regExpPrototype; }
- ErrorPrototype* errorPrototype() const { return d->errorPrototype; }
- NativeErrorPrototype* evalErrorPrototype() const { return d->evalErrorPrototype; }
- NativeErrorPrototype* rangeErrorPrototype() const { return d->rangeErrorPrototype; }
- NativeErrorPrototype* referenceErrorPrototype() const { return d->referenceErrorPrototype; }
- NativeErrorPrototype* syntaxErrorPrototype() const { return d->syntaxErrorPrototype; }
- NativeErrorPrototype* typeErrorPrototype() const { return d->typeErrorPrototype; }
- NativeErrorPrototype* URIErrorPrototype() const { return d->URIErrorPrototype; }
+ ObjectObjectImp* objectConstructor() const { return d()->objectConstructor; }
+ FunctionObjectImp* functionConstructor() const { return d()->functionConstructor; }
+ ArrayObjectImp* arrayConstructor() const { return d()->arrayConstructor; }
+ BooleanObjectImp* booleanConstructor() const { return d()->booleanConstructor; }
+ StringObjectImp* stringConstructor() const{ return d()->stringConstructor; }
+ NumberObjectImp* numberConstructor() const{ return d()->numberConstructor; }
+ DateObjectImp* dateConstructor() const{ return d()->dateConstructor; }
+ RegExpObjectImp* regExpConstructor() const { return d()->regExpConstructor; }
+ ErrorObjectImp* errorConstructor() const { return d()->errorConstructor; }
+ NativeErrorImp* evalErrorConstructor() const { return d()->evalErrorConstructor; }
+ NativeErrorImp* rangeErrorConstructor() const { return d()->rangeErrorConstructor; }
+ NativeErrorImp* referenceErrorConstructor() const { return d()->referenceErrorConstructor; }
+ NativeErrorImp* syntaxErrorConstructor() const { return d()->syntaxErrorConstructor; }
+ NativeErrorImp* typeErrorConstructor() const { return d()->typeErrorConstructor; }
+ NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; }
+
+ ObjectPrototype* objectPrototype() const { return d()->objectPrototype; }
+ FunctionPrototype* functionPrototype() const { return d()->functionPrototype; }
+ ArrayPrototype* arrayPrototype() const { return d()->arrayPrototype; }
+ BooleanPrototype* booleanPrototype() const { return d()->booleanPrototype; }
+ StringPrototype* stringPrototype() const { return d()->stringPrototype; }
+ NumberPrototype* numberPrototype() const { return d()->numberPrototype; }
+ DatePrototype* datePrototype() const { return d()->datePrototype; }
+ RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; }
+ ErrorPrototype* errorPrototype() const { return d()->errorPrototype; }
+ NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; }
+ NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; }
+ NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; }
+ NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; }
+ NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; }
+ NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; }
void saveBuiltins(SavedBuiltins&) const;
void restoreBuiltins(const SavedBuiltins&);
- void setTimeoutTime(unsigned timeoutTime) { d->timeoutTime = timeoutTime; }
+ void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; }
void startTimeoutCheck();
void stopTimeoutCheck();
bool timedOut();
- Debugger* debugger() const { return d->debugger; }
- void setDebugger(Debugger* debugger) { d->debugger = debugger; }
+ Debugger* debugger() const { return d()->debugger; }
+ void setDebugger(Debugger* debugger) { d()->debugger = debugger; }
- void setCurrentExec(ExecState* exec) { d->currentExec = exec; }
- ExecState* currentExec() const { return d->currentExec; }
+ void setCurrentExec(ExecState* exec) { d()->currentExec = exec; }
+ ExecState* currentExec() const { return d()->currentExec; }
// FIXME: Let's just pick one compatible behavior and go with it.
- void setCompatMode(CompatMode mode) { d->compatMode = mode; }
- CompatMode compatMode() const { return d->compatMode; }
+ void setCompatMode(CompatMode mode) { d()->compatMode = mode; }
+ CompatMode compatMode() const { return d()->compatMode; }
- int recursion() { return d->recursion; }
- void incRecursion() { ++d->recursion; }
- void decRecursion() { --d->recursion; }
+ int recursion() { return d()->recursion; }
+ void incRecursion() { ++d()->recursion; }
+ void decRecursion() { --d()->recursion; }
virtual void mark();
virtual bool isSafeScript(const JSGlobalObject*) const { return true; }
- protected:
- std::auto_ptr<JSGlobalObjectData> d;
-
private:
void init();
+
+ JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
bool checkTimeout();
void resetTimeoutCheck();
inline bool JSGlobalObject::timedOut()
{
- d->tickCount++;
+ d()->tickCount++;
- if (d->tickCount != d->ticksUntilNextTimeoutCheck)
+ if (d()->tickCount != d()->ticksUntilNextTimeoutCheck)
return false;
return checkTimeout();
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSVariableObject.h"
+
+#include "PropertyNameArray.h"
+
+namespace KJS {
+
+bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
+{
+ if (symbolTable().contains(propertyName.ustring().rep()))
+ return false;
+
+ return JSObject::deleteProperty(exec, propertyName);
+}
+
+void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
+{
+ SymbolTable::const_iterator::Keys end = symbolTable().end().keys();
+ for (SymbolTable::const_iterator::Keys it = symbolTable().begin().keys(); it != end; ++it)
+ propertyNames.add(Identifier(*it));
+
+ JSObject::getPropertyNames(exec, propertyNames);
+}
+
+void JSVariableObject::mark()
+{
+ JSObject::mark();
+
+ size_t size = d->localStorage.size();
+ for (size_t i = 0; i < size; ++i) {
+ JSValue* value = d->localStorage[i].value;
+ if (!value->marked())
+ value->mark();
+ }
+}
+
+} // namespace KJS
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSVariableObject_h
+#define JSVariableObject_h
+
+#include "LocalStorage.h"
+#include "SymbolTable.h"
+#include "object.h"
+
+namespace KJS {
+
+ class JSVariableObject : public JSObject {
+ public:
+ SymbolTable& symbolTable() { return *d->symbolTable; }
+ LocalStorage& localStorage() { return d->localStorage; }
+
+ virtual bool deleteProperty(ExecState*, const Identifier&);
+ virtual void getPropertyNames(ExecState*, PropertyNameArray&);
+
+ virtual void mark();
+
+ protected:
+ // Subclasses of JSVariableObject can subclass this struct to add data
+ // without increasing their own size (since there's a hard limit on the
+ // size of a JSCell).
+ struct JSVariableObjectData {
+ JSVariableObjectData(SymbolTable* s)
+ : symbolTable(s) // Subclass owns this pointer.
+ {
+ }
+
+ LocalStorage localStorage;
+ SymbolTable* symbolTable;
+ };
+
+ JSVariableObject(JSVariableObjectData* data)
+ : d(data) // Subclass owns this pointer.
+ {
+ }
+
+ JSVariableObject(JSValue* proto, JSVariableObjectData* data)
+ : JSObject(proto)
+ , d(data) // Subclass owns this pointer.
+ {
+ }
+
+ bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertySlot& slot)
+ {
+ size_t index = symbolTable().get(propertyName.ustring().rep());
+ if (index != missingSymbolMarker()) {
+ slot.setValueSlot(this, &d->localStorage[index].value);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool JSVariableObject::symbolTablePut(const Identifier& propertyName, JSValue* value, int attr)
+ {
+ size_t index = symbolTable().get(propertyName.ustring().rep());
+ if (index != missingSymbolMarker()) {
+ LocalStorageEntry& entry = d->localStorage[index];
+ entry.value = value;
+ entry.attributes = attr;
+ return true;
+ }
+
+ return false;
+ }
+
+ JSVariableObjectData* d;
+ };
+
+} // namespace KJS
+
+#endif // JSVariableObject_h
ExecState* e = exec;
while (e) {
if (e->function() == thisObj)
- return static_cast<ActivationImp*>(e->activationObject())->get(exec, propertyName);
+ return e->activationObject()->get(exec, propertyName);
e = e->callingExecState();
}
return jsNull();
const ClassInfo ActivationImp::info = { "Activation", 0, 0 };
-ActivationImp::ActivationImp(ExecState* exec)
- : d(new ActivationImpPrivate(exec))
- , m_symbolTable(&exec->function()->body->symbolTable())
-{
-}
-
JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
{
ActivationImp* thisObj = static_cast<ActivationImp*>(slot.slotBase());
- ActivationImpPrivate* d = thisObj->d.get();
- if (!d->argumentsObject)
+ if (!thisObj->d()->argumentsObject)
thisObj->createArgumentsObject(exec);
- return d->argumentsObject;
+ return thisObj->d()->argumentsObject;
}
PropertySlot::GetValueFunc ActivationImp::getArgumentsGetter()
bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- // We don't call through to JSObject because there's no way to give an
- // activation object getter/setter properties, and __proto__ is a
- // non-standard extension that other implementations do not expose in the
- // activation object.
- ASSERT(!_prop.hasGetterSetterProperties());
-
- // it's more efficient to just get and check for a special empty
- // value than to do a separate contains check
- size_t index = m_symbolTable->get(propertyName.ustring().rep());
- if (index != missingSymbolMarker()) {
- slot.setValueSlot(this, &d->localStorage[index].value);
+ if (symbolTableGet(propertyName, slot))
return true;
- }
if (JSValue** location = getDirectLocation(propertyName)) {
slot.setValueSlot(this, location);
return true;
}
+ // We don't call through to JSObject because there's no way to give an
+ // activation object getter properties or a prototype.
+ ASSERT(!_prop.hasGetterSetterProperties());
+ ASSERT(prototype() == jsNull());
return false;
}
if (propertyName == exec->propertyNames().arguments)
return false;
- if (m_symbolTable->contains(propertyName.ustring().rep()))
- return false;
-
- return JSObject::deleteProperty(exec, propertyName);
-}
-
-void ActivationImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
-{
- SymbolTable::const_iterator::Keys end = m_symbolTable->end().keys();
- for (SymbolTable::const_iterator::Keys it = m_symbolTable->begin().keys(); it != end; ++it)
- propertyNames.add(Identifier(*it));
-
- JSObject::getPropertyNames(exec, propertyNames);
+ return JSVariableObject::deleteProperty(exec, propertyName);
}
void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr)
{
- // There's no way that an activation object can have a prototype or getter/setter properties.
- ASSERT(!_prop.hasGetterSetterProperties());
- ASSERT(prototype() == jsNull());
-
- // it's more efficient to just get and check for a special empty
- // value than to do a separate contains check
- size_t index = m_symbolTable->get(propertyName.ustring().rep());
- if (index != missingSymbolMarker()) {
- LocalStorageEntry& entry = d->localStorage[index];
- entry.value = value;
- entry.attributes = attr;
- return;
- }
+ if (symbolTablePut(propertyName, value, attr))
+ return;
- _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete));
+ // We don't call through to JSObject because __proto__ and getter/setter
+ // properties are non-standard extensions that other implementations do not
+ // expose in the activation object.
+ ASSERT(!_prop.hasGetterSetterProperties());
+ _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete));
}
void ActivationImp::mark()
{
- JSObject::mark();
-
- size_t size = d->localStorage.size();
- for (size_t i = 0; i < size; ++i) {
- JSValue* value = d->localStorage[i].value;
- if (!value->marked())
- value->mark();
- }
-
- ASSERT(d->function);
- if (!d->function->marked())
- d->function->mark();
+ JSVariableObject::mark();
- if (d->argumentsObject && !d->argumentsObject->marked())
- d->argumentsObject->mark();
+ if (d()->argumentsObject && !d()->argumentsObject->marked())
+ d()->argumentsObject->mark();
}
void ActivationImp::createArgumentsObject(ExecState* exec)
// Since "arguments" is only accessible while a function is being called,
// we can retrieve our argument list from the ExecState for our function
// call instead of storing the list ourselves.
- d->argumentsObject = new Arguments(exec, d->function, *d->exec->arguments(), this);
+ d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this);
}
// ------------------------------ GlobalFunc -----------------------------------
if (switchGlobal) {
newExec.pushScope(thisObj);
- newExec.setVariableObject(thisObj);
+ newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj));
}
Completion c = progNode->execute(&newExec);
#ifndef KJS_FUNCTION_H
#define KJS_FUNCTION_H
+#include "JSVariableObject.h"
#include "LocalStorage.h"
#include "SymbolTable.h"
+#include "nodes.h"
#include "object.h"
-#include <wtf/OwnPtr.h>
namespace KJS {
mutable IndexToNameMap indexToNameMap;
};
- class ActivationImp : public JSObject {
+ class ActivationImp : public JSVariableObject {
private:
- struct ActivationImpPrivate {
- ActivationImpPrivate(ExecState* e)
- : exec(e)
- , function(e->function())
+ using JSVariableObject::JSVariableObjectData;
+
+ struct ActivationImpData : public JSVariableObjectData {
+ ActivationImpData(ExecState* e)
+ : JSVariableObjectData(&e->function()->body->symbolTable())
+ , exec(e)
, argumentsObject(0)
{
}
-
- LocalStorage localStorage;
+
ExecState* exec;
- FunctionImp* function;
Arguments* argumentsObject;
};
public:
- ActivationImp(ExecState*);
+ ActivationImp::ActivationImp(ExecState* exec)
+ : JSVariableObject(new ActivationImpData(exec))
+ {
+ }
+
+ virtual ~ActivationImp()
+ {
+ delete d();
+ }
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
- virtual void getPropertyNames(ExecState*, PropertyNameArray&);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
virtual void mark();
- bool isActivation() { return true; }
-
- LocalStorage& localStorage() { return d->localStorage; }
- SymbolTable& symbolTable() { return *m_symbolTable; }
+ virtual bool isActivationObject() { return true; }
private:
static PropertySlot::GetValueFunc getArgumentsGetter();
static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
void createArgumentsObject(ExecState*);
-
- OwnPtr<ActivationImpPrivate> d;
- SymbolTable* m_symbolTable;
+ ActivationImpData* d() { return static_cast<ActivationImpData*>(JSVariableObject::d); }
};
class GlobalFuncImp : public InternalFunctionImp {
if (exec->variableObject() != exec->scopeChain().top())
return false;
- ASSERT(exec->variableObject()->isActivation()); // Because this is function code.
-
// Static lookup is impossible if the symbol isn't statically declared.
- if (!static_cast<ActivationImp*>(exec->variableObject())->symbolTable().contains(ident.ustring().rep()))
+ if (!exec->variableObject()->symbolTable().contains(ident.ustring().rep()))
return false;
return true;
JSValue* LocalVarAccessNode::inlineEvaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
return exec->localStorage()[index].value;
}
// that the section does not apply to interal functions, but for simplicity
// of implementation we use the global object anyway here. This guarantees
// that in host objects you always get a valid object for this.
- if (thisObj->isActivation())
+ if (thisObj->isActivationObject())
thisObj = exec->dynamicGlobalObject();
return func->call(exec, thisObj, argList);
JSValue* LocalVarFunctionCallNode::inlineEvaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue* v = exec->localStorage()[index].value;
JSObject *thisObj = baseObj;
ASSERT(thisObj);
ASSERT(thisObj->isObject());
- ASSERT(!thisObj->isActivation());
+ ASSERT(!thisObj->isActivationObject());
return func->call(exec, thisObj, argList);
}
JSObject *thisObj = baseObj;
ASSERT(thisObj);
ASSERT(thisObj->isObject());
- ASSERT(!thisObj->isActivation());
+ ASSERT(!thisObj->isActivationObject());
return func->call(exec, thisObj, argList);
}
JSValue* PostIncLocalVarNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue** slot = &exec->localStorage()[m_index].value;
JSValue* v = (*slot)->toJSNumber(exec);
JSValue* PostDecLocalVarNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue** slot = &exec->localStorage()[m_index].value;
JSValue* v = (*slot)->toJSNumber(exec);
double PostDecLocalVarNode::inlineEvaluateToNumber(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue** slot = &exec->localStorage()[m_index].value;
double n = (*slot)->toNumber(exec);
JSValue* LocalVarTypeOfNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
return typeStringForValue(exec->localStorage()[m_index].value);
}
JSValue* PreIncLocalVarNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue** slot = &exec->localStorage()[m_index].value;
double n = (*slot)->toNumber(exec);
JSValue* PreDecLocalVarNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue** slot = &exec->localStorage()[m_index].value;
double n = (*slot)->toNumber(exec);
JSValue* ReadModifyLocalVarNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue** slot = &exec->localStorage()[m_index].value;
ASSERT(m_oper != OpEqual);
JSValue* AssignLocalVarNode::evaluate(ExecState* exec)
{
- ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
- ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
+ ASSERT(exec->variableObject() == exec->scopeChain().top());
JSValue* v = m_right->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
if (!m_optimizedResolveNodes)
optimizeVariableAccess();
- ASSERT(exec->variableObject()->isActivation());
- LocalStorage& localStorage = static_cast<ActivationImp*>(exec->variableObject())->localStorage();
+ LocalStorage& localStorage = exec->variableObject()->localStorage();
localStorage.reserveCapacity(m_varStack.size() + m_parameters.size() + m_functionStack.size());
int minAttributes = Internal | DontDelete;
void saveProperties(SavedProperties &p) const { _prop.save(p); }
void restoreProperties(const SavedProperties &p) { _prop.restore(p); }
- virtual bool isActivation() { return false; }
+ virtual bool isActivationObject() { return false; }
virtual bool isGlobalObject() const { return false; }
protected:
PropertyMap _prop;
+2007-12-07 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Added some namespace qualifications and a forwarding header, now that
+ KJS::Node is sometimes #included in WebCore by JavaScriptCore headers.
+
+ * ForwardingHeaders/wtf/ListRefPtr.h: Added.
+ * bindings/js/JSXSLTProcessor.cpp:
+ (KJS::JSXSLTProcessorPrototypeFunctionTransformToFragment::callAsFunction):
+ * bindings/js/kjs_binding.cpp:
+ (KJS::ScriptInterpreter::getDOMNodeForDocument):
+ (KJS::ScriptInterpreter::forgetDOMNodeForDocument):
+ (KJS::ScriptInterpreter::putDOMNodeForDocument):
+ (KJS::ScriptInterpreter::markDOMNodesForDocument):
+ (KJS::ScriptInterpreter::updateDOMNodeDocument):
+
2007-12-07 Adam Roben <aroben@apple.com>
Add SoftLinking.h for Windows and use it in a few places
--- /dev/null
+#include <JavaScriptCore/ListRefPtr.h>
JSValue *nodeVal = args[0];
JSValue *docVal = args[1];
if (nodeVal->isObject(&JSNode::info) && docVal->isObject(&JSDocument::info)) {
- Node* node = static_cast<JSNode*>(nodeVal)->impl();
+ WebCore::Node* node = static_cast<JSNode*>(nodeVal)->impl();
Document* doc = static_cast<Document*>(static_cast<JSDocument *>(docVal)->impl());
return toJS(exec, processor.transformToFragment(node, doc).get());
}
namespace KJS {
typedef HashMap<void*, DOMObject*> DOMObjectMap;
-typedef HashMap<Node*, JSNode*> NodeMap;
+typedef HashMap<WebCore::Node*, JSNode*> NodeMap;
typedef HashMap<Document*, NodeMap*> NodePerDocMap;
// For debugging, keep a set of wrappers currently registered, and check that
removeWrapper(domObjects().take(objectHandle));
}
-JSNode* ScriptInterpreter::getDOMNodeForDocument(Document* document, Node* node)
+JSNode* ScriptInterpreter::getDOMNodeForDocument(Document* document, WebCore::Node* node)
{
if (!document)
return static_cast<JSNode*>(domObjects().get(node));
return NULL;
}
-void ScriptInterpreter::forgetDOMNodeForDocument(Document* document, Node* node)
+void ScriptInterpreter::forgetDOMNodeForDocument(Document* document, WebCore::Node* node)
{
if (!document) {
removeWrapper(domObjects().take(node));
removeWrapper(documentDict->take(node));
}
-void ScriptInterpreter::putDOMNodeForDocument(Document* document, Node* node, JSNode* wrapper)
+void ScriptInterpreter::putDOMNodeForDocument(Document* document, WebCore::Node* node, JSNode* wrapper)
{
addWrapper(wrapper);
if (!document) {
NodeMap::iterator nodeEnd = nodeDict->end();
for (NodeMap::iterator nodeIt = nodeDict->begin(); nodeIt != nodeEnd; ++nodeIt) {
JSNode* jsNode = nodeIt->second;
- Node* node = jsNode->impl();
+ WebCore::Node* node = jsNode->impl();
// don't mark wrappers for nodes that are no longer in the
// document - they should not be saved if the node is not
}
}
-void ScriptInterpreter::updateDOMNodeDocument(Node* node, Document* oldDoc, Document* newDoc)
+void ScriptInterpreter::updateDOMNodeDocument(WebCore::Node* node, Document* oldDoc, Document* newDoc)
{
ASSERT(oldDoc != newDoc);
JSNode* wrapper = getDOMNodeForDocument(oldDoc, node);
+2007-12-07 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Added a forwarding header, since we now #include nodes.h through some
+ JavaScriptCore headers.
+
+ * ForwardingHeaders/wtf/ListRefPtr.h: Added.
+
2007-12-06 Brady Eidson <beidson@apple.com>
Reviewed by Oliver's rubber stamp
--- /dev/null
+#import <JavaScriptCore/ListRefPtr.h>