Commit f5ab0692 authored by ggaren@apple.com's avatar ggaren@apple.com

JavaScriptCore:

        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.

WebCore:

        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):

WebKit/mac:

        Reviewed by Sam Weinig.
        
        Added a forwarding header, since we now #include nodes.h through some
        JavaScriptCore headers.

        * ForwardingHeaders/wtf/ListRefPtr.h: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28527 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ee5a5d14
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.
......
......@@ -149,6 +149,8 @@ __ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
__ZN3KJS15JSWrapperObject4markEv
__ZN3KJS15SavedPropertiesC1Ev
__ZN3KJS15SavedPropertiesD1Ev
__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS16RuntimeObjectImp4infoE
__ZN3KJS16RuntimeObjectImpC1EPNS_8Bindings8InstanceE
__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
......@@ -223,6 +225,7 @@ __ZN3KJS9Collector4sizeEv
__ZN3KJS9Collector7collectEv
__ZN3KJS9Collector7protectEPNS_7JSValueE
__ZN3KJS9Collector9unprotectEPNS_7JSValueE
__ZN3KJS9ExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectEPNS_16FunctionBodyNodeENS_8CodeTypeEPS0_S8_PNS_11FunctionImpEPKNS_4ListE
__ZN3KJS9ExecStateD1Ev
__ZN3KJSeqERKNS_7UStringEPKc
__ZN3WTF10fastCallocEmm
......@@ -277,6 +280,7 @@ __ZNK3KJS9ExecState19lexicalGlobalObjectEv
__ZTVN3KJS14JSGlobalObjectE
__ZTVN3KJS14StringInstanceE
__ZTVN3KJS15JSWrapperObjectE
__ZTVN3KJS16JSVariableObjectE
__ZTVN3KJS19InternalFunctionImpE
__ZTVN3KJS8JSObjectE
_jscore_collector_introspection
......
......@@ -318,6 +318,14 @@
RelativePath="..\..\kjs\JSGlobalObject.cpp"
>
</File>
<File
RelativePath="..\..\kjs\JSVariableObject.cpp"
>
</File>
<File
RelativePath="..\..\kjs\JSVariableObject.h"
>
</File>
<File
RelativePath="..\..\kjs\JSImmediate.cpp"
>
......
......@@ -66,7 +66,7 @@
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, ); }; };
......@@ -81,6 +81,8 @@
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, ); }; };
......@@ -142,7 +144,7 @@
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, ); }; };
......@@ -228,7 +230,7 @@
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, ); }; };
......@@ -439,6 +441,8 @@
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>"; };
......@@ -952,6 +956,7 @@
65417200039E01BA0058BFEB /* kjs */ = {
isa = PBXGroup;
children = (
14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
93ADFCE60CCBD7AC00D30B08 /* array_instance.cpp */,
938772E5038BFE19008635CE /* array_instance.h */,
......@@ -1000,6 +1005,7 @@
65EA4C9A092AF9E20093D800 /* JSLock.h */,
14ABB454099C2A0F00E2A24F /* JSType.h */,
1482B6EA0A4300B300517CFC /* JSValueRef.h */,
14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
93F1981A08245AAE001E9ABC /* keywords.table */,
......@@ -1268,6 +1274,7 @@
E1EF79AB0CE97BA60088D500 /* UTF8.h in Headers */,
1419D32D0CEA7CDE00FF507A /* RefCounted.h in Headers */,
5DA479660CFBCF56009328A0 /* TCPackedCache.h in Headers */,
14F252570D08DD8D004ECFFF /* JSVariableObject.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1557,6 +1564,7 @@
932F5BC50822A1C700736975 /* runtime_root.cpp in Sources */,
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */,
14F252610D08DF2F004ECFFF /* JSVariableObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -75,6 +75,7 @@ Source files for JSCore.
kjs/internal.cpp
kjs/interpreter.cpp
kjs/JSGlobalObject.cpp
kjs/JSVariableObject.cpp
kjs/JSImmediate.cpp
kjs/JSLock.cpp
kjs/JSWrapperObject.cpp
......
......@@ -50,10 +50,10 @@ ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisV,
// 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
......@@ -61,7 +61,7 @@ ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisV,
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
......@@ -72,7 +72,7 @@ ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisV,
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;
}
......@@ -106,7 +106,7 @@ JSGlobalObject* ExecState::lexicalGlobalObject() const
void ExecState::updateLocalStorage()
{
m_localStorageBuffer = static_cast<ActivationImp*>(m_activation)->localStorage().data();
m_localStorageBuffer = m_activation->localStorage().data();
}
} // namespace KJS
......@@ -38,12 +38,14 @@ 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;
/**
......@@ -73,14 +75,14 @@ namespace KJS {
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; }
......@@ -128,11 +130,11 @@ namespace KJS {
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;
......
This diff is collapsed.
......@@ -23,7 +23,7 @@
#ifndef KJS_GlobalObject_h
#define KJS_GlobalObject_h
#include "object.h"
#include "JSVariableObject.h"
namespace KJS {
......@@ -67,11 +67,14 @@ 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)
{
}
......@@ -80,7 +83,7 @@ namespace KJS {
Debugger* debugger;
CompatMode compatMode;
ExecState globalExec;
ExecState* currentExec;
int recursion;
......@@ -123,17 +126,20 @@ namespace KJS {
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();
}
......@@ -143,7 +149,7 @@ namespace KJS {
// 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
......@@ -154,59 +160,59 @@ namespace KJS {
// 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();
......@@ -218,11 +224,10 @@ namespace KJS {
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();
......@@ -232,9 +237,9 @@ namespace KJS {
inline bool JSGlobalObject::timedOut()
{
d->tickCount++;
d()->tickCount++;
if (d->tickCount != d->ticksUntilNextTimeoutCheck)
if (d()->tickCount != d()->ticksUntilNextTimeoutCheck)
return false;
return checkTimeout();
......
/*
* 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
/*
* 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
......@@ -96,7 +96,7 @@ JSValue* FunctionImp::argumentsGetter(ExecState* exec, JSObject*, const Identifi
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();
......@@ -358,21 +358,14 @@ bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
const ClassInfo ActivationImp::info = <