зеркало из https://github.com/mozilla/gecko-dev.git
Fixed increment bug. Added mPrivate member and supported native getter &
setter functions for NAME opcodes.
This commit is contained in:
Родитель
7a319c9908
Коммит
c3ec6e411e
|
@ -622,7 +622,7 @@ GenericPreXcrement:
|
|||
op = Decrement;
|
||||
goto GenericPostXcrement;
|
||||
case ExprNode::postIncrement:
|
||||
op = Decrement;
|
||||
op = Increment;
|
||||
goto GenericPostXcrement;
|
||||
GenericPostXcrement:
|
||||
{
|
||||
|
|
|
@ -968,14 +968,24 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
|||
LoadName* ln = static_cast<LoadName*>(instruction);
|
||||
JSFunction *getter = mGlobal->getter(*src1(ln));
|
||||
if (getter) {
|
||||
ASSERT(!getter->isNative());
|
||||
mLinkage = new Linkage(mLinkage, ++mPC, mActivation, mGlobal, dst(ln), mICode, mCurrentClosure);
|
||||
mICode = getter->getICode();
|
||||
mActivation = new Activation(mICode->itsMaxRegister, kNullValue);
|
||||
registers = &mActivation->mRegisters;
|
||||
mPC = mICode->its_iCode->begin();
|
||||
endPC = mICode->its_iCode->end();
|
||||
continue;
|
||||
if (getter->isNative()) {
|
||||
JSValues argv(2);
|
||||
argv[0] = kNullValue;
|
||||
argv[1] = getter;
|
||||
JSValue result = static_cast<JSNativeFunction*>(getter)->mCode(this, argv);
|
||||
if (dst(ln).first != NotARegister)
|
||||
(*registers)[dst(ln).first] = result;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
mLinkage = new Linkage(mLinkage, ++mPC, mActivation, mGlobal, dst(ln), mICode, mCurrentClosure);
|
||||
mICode = getter->getICode();
|
||||
mActivation = new Activation(mICode->itsMaxRegister, kNullValue);
|
||||
registers = &mActivation->mRegisters;
|
||||
mPC = mICode->its_iCode->begin();
|
||||
endPC = mICode->its_iCode->end();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
(*registers)[dst(ln).first] = mGlobal->getVariable(*src1(ln));
|
||||
|
@ -986,14 +996,23 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
|||
SaveName* sn = static_cast<SaveName*>(instruction);
|
||||
JSFunction *setter = mGlobal->setter(*dst(sn));
|
||||
if (setter) {
|
||||
ASSERT(!setter->isNative());
|
||||
mLinkage = new Linkage(mLinkage, ++mPC, mActivation, mGlobal, TypedRegister(NotARegister, &Null_Type), mICode, mCurrentClosure);
|
||||
mICode = setter->getICode();
|
||||
mActivation = new Activation(mICode->itsMaxRegister, (*registers)[src1(sn).first], kNullValue);
|
||||
registers = &mActivation->mRegisters;
|
||||
mPC = mICode->its_iCode->begin();
|
||||
endPC = mICode->its_iCode->end();
|
||||
continue;
|
||||
if (setter->isNative()) {
|
||||
JSValues argv(3);
|
||||
argv[0] = kNullValue;
|
||||
argv[1] = (*registers)[src1(sn).first];
|
||||
argv[2] = setter;
|
||||
JSValue result = static_cast<JSNativeFunction*>(setter)->mCode(this, argv);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
mLinkage = new Linkage(mLinkage, ++mPC, mActivation, mGlobal, TypedRegister(NotARegister, &Null_Type), mICode, mCurrentClosure);
|
||||
mICode = setter->getICode();
|
||||
mActivation = new Activation(mICode->itsMaxRegister, (*registers)[src1(sn).first], kNullValue);
|
||||
registers = &mActivation->mRegisters;
|
||||
mPC = mICode->its_iCode->begin();
|
||||
endPC = mICode->its_iCode->end();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
mGlobal->setVariable(*dst(sn), (*registers)[src1(sn).first]);
|
||||
|
@ -1102,8 +1121,9 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
|||
JSFunction *getter = value.object->getter(*src2(gp));
|
||||
if (getter) {
|
||||
if (getter->isNative()) {
|
||||
JSValues argv(1);
|
||||
JSValues argv(2);
|
||||
argv[0] = value;
|
||||
argv[1] = getter;
|
||||
JSValue result = static_cast<JSNativeFunction*>(getter)->mCode(this, argv);
|
||||
if (dst(gp).first != NotARegister)
|
||||
(*registers)[dst(gp).first] = result;
|
||||
|
@ -1116,6 +1136,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
|||
registers = &mActivation->mRegisters;
|
||||
mPC = mICode->its_iCode->begin();
|
||||
endPC = mICode->its_iCode->end();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -295,6 +295,9 @@ namespace JSTypes {
|
|||
JSType* mType;
|
||||
JSString* mClass; // this is the internal [[Class]] property
|
||||
|
||||
|
||||
void *mPrivate;
|
||||
|
||||
static JSObject *initJSObject();
|
||||
static JSString *ObjectString;
|
||||
static JSObject *ObjectPrototypeObject;
|
||||
|
@ -311,6 +314,9 @@ namespace JSTypes {
|
|||
if (mGetter) delete mGetter;
|
||||
if (mSetter) delete mSetter;
|
||||
}
|
||||
|
||||
void *getPrivate() { return mPrivate; }
|
||||
void setPrivate(void *underwear) { mPrivate = underwear; }
|
||||
|
||||
static void initObjectObject(JSScope *g);
|
||||
|
||||
|
@ -540,10 +546,8 @@ namespace JSTypes {
|
|||
static JSString* FunctionString;
|
||||
static JSObject* FunctionPrototypeObject;
|
||||
ICodeModule* mICode;
|
||||
|
||||
typedef JavaScript::gc_traits_finalizable<JSFunction> traits;
|
||||
typedef gc_allocator<JSFunction, traits> allocator;
|
||||
|
||||
typedef JavaScript::gc_traits_finalizable<JSFunction> traits;
|
||||
typedef gc_allocator<JSFunction, traits> allocator;
|
||||
public:
|
||||
static void initFunctionObject(JSScope *g);
|
||||
|
||||
|
@ -561,14 +565,13 @@ namespace JSTypes {
|
|||
virtual JSFunction *getFunky() { return this; }
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
|
||||
ICodeModule* getICode() { return mICode; }
|
||||
virtual bool isNative() { return false; }
|
||||
};
|
||||
|
||||
class JSBoundThis : public JSFunction {
|
||||
typedef JavaScript::gc_traits_finalizable<JSBoundThis> traits;
|
||||
typedef gc_allocator<JSBoundThis, traits> allocator;
|
||||
typedef JavaScript::gc_traits_finalizable<JSBoundThis> traits;
|
||||
typedef gc_allocator<JSBoundThis, traits> allocator;
|
||||
public:
|
||||
JSBoundThis(JSValue aThis, JSFunction *aFunc) : mBoundThis(aThis), mFunction(aFunc) { }
|
||||
JSValue mBoundThis;
|
||||
|
@ -577,13 +580,12 @@ namespace JSTypes {
|
|||
virtual ~JSBoundThis() { mICode = NULL; }
|
||||
virtual JSValue getThis() { return mBoundThis; }
|
||||
virtual JSFunction *getFunky() { return mFunction; }
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
};
|
||||
|
||||
class JSNativeFunction : public JSFunction {
|
||||
typedef JavaScript::gc_traits_finalizable<JSNativeFunction> traits;
|
||||
typedef gc_allocator<JSNativeFunction, traits> allocator;
|
||||
typedef JavaScript::gc_traits_finalizable<JSNativeFunction> traits;
|
||||
typedef gc_allocator<JSNativeFunction, traits> allocator;
|
||||
public:
|
||||
typedef JSValue (*JSCode)(Context *cx, const JSValues& argv);
|
||||
JSCode mCode;
|
||||
|
@ -593,8 +595,8 @@ namespace JSTypes {
|
|||
};
|
||||
|
||||
class JSUnaryOperator : public JSFunction {
|
||||
typedef JavaScript::gc_traits_finalizable<JSUnaryOperator> traits;
|
||||
typedef gc_allocator<JSUnaryOperator, traits> allocator;
|
||||
typedef JavaScript::gc_traits_finalizable<JSUnaryOperator> traits;
|
||||
typedef gc_allocator<JSUnaryOperator, traits> allocator;
|
||||
public:
|
||||
typedef JSValue (*JSUnaryCode)(Context *cx, const JSValue& arg1);
|
||||
JSUnaryCode mCode;
|
||||
|
@ -604,8 +606,8 @@ namespace JSTypes {
|
|||
};
|
||||
|
||||
class JSBinaryOperator : public JSFunction {
|
||||
typedef JavaScript::gc_traits_finalizable<JSBinaryOperator> traits;
|
||||
typedef gc_allocator<JSBinaryOperator, traits> allocator;
|
||||
typedef JavaScript::gc_traits_finalizable<JSBinaryOperator> traits;
|
||||
typedef gc_allocator<JSBinaryOperator, traits> allocator;
|
||||
public:
|
||||
typedef JSValue (*JSBinaryCode)(Context *cx, const JSValue& arg1, const JSValue& arg2);
|
||||
JSBinaryCode mCode;
|
||||
|
@ -617,15 +619,14 @@ namespace JSTypes {
|
|||
class JSClosure : public JSFunction {
|
||||
Interpreter::Activation *mActivation;
|
||||
JSClosure *mPrevious;
|
||||
typedef JavaScript::gc_traits_finalizable<JSClosure> traits;
|
||||
typedef gc_allocator<JSClosure, traits> allocator;
|
||||
typedef JavaScript::gc_traits_finalizable<JSClosure> traits;
|
||||
typedef gc_allocator<JSClosure, traits> allocator;
|
||||
public:
|
||||
JSClosure(ICodeModule* iCode, Interpreter::Activation *activation, JSClosure *previous)
|
||||
: JSFunction(iCode), mActivation(activation), mPrevious(previous) {}
|
||||
|
||||
JSClosure* getPrevious() { return mPrevious; }
|
||||
Interpreter::Activation* getActivation() { return mActivation; }
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
};
|
||||
|
||||
|
@ -736,6 +737,7 @@ namespace JSTypes {
|
|||
// The invokor is an implementation of the [[Call]] mechanism
|
||||
JSFunction *mInvokor;
|
||||
public:
|
||||
JSType() { }
|
||||
JSType(const String &name, JSType *baseType) : mName(name), mBaseType(baseType), mConstructor(NULL), mInvokor(NULL)
|
||||
{
|
||||
mType = &Type_Type;
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "../../../../../../gc/boehm/" /D "_LIB" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "DEBUG" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
@ -118,6 +118,16 @@ SOURCE=..\jsmath.cpp
|
|||
# Begin Source File
|
||||
|
||||
SOURCE=..\jstypes.cpp
|
||||
|
||||
!IF "$(CFG)" == "js2 - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "js2 - Win32 Debug"
|
||||
|
||||
# ADD CPP /I "../../../gc/boehm/"
|
||||
# SUBTRACT CPP /I "../../../../../../gc/boehm/"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче