mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
changed Context constructor to take JSObject* not JSObject&, to be able to control lifetime a little more carefully.
This commit is contained in:
parent
02525db2ed
commit
b33c70b006
@ -123,13 +123,13 @@ namespace JavaScript {
|
||||
case LOAD_NAME:
|
||||
{
|
||||
LoadName* ln = static_cast<LoadName*>(instruction);
|
||||
(*registers)[dst(ln)] = mGlobal[*src1(ln)];
|
||||
(*registers)[dst(ln)] = (*mGlobal)[*src1(ln)];
|
||||
}
|
||||
break;
|
||||
case SAVE_NAME:
|
||||
{
|
||||
SaveName* sn = static_cast<SaveName*>(instruction);
|
||||
mGlobal[*dst(sn)] = (*registers)[src1(sn)];
|
||||
(*mGlobal)[*dst(sn)] = (*registers)[src1(sn)];
|
||||
}
|
||||
break;
|
||||
case NEW_OBJECT:
|
||||
@ -296,7 +296,7 @@ namespace JavaScript {
|
||||
break;
|
||||
case NOT:
|
||||
{
|
||||
Move* nt = static_cast<Move*>(instruction);
|
||||
Not* nt = static_cast<Not*>(instruction);
|
||||
(*registers)[dst(nt)].i32 = !(*registers)[src1(nt)].i32;
|
||||
}
|
||||
break;
|
||||
|
@ -31,26 +31,26 @@ namespace JavaScript {
|
||||
|
||||
class Context : public gc_base {
|
||||
public:
|
||||
explicit Context(World& /*world */, JSObject& aGlobal) :
|
||||
mGlobal(aGlobal) {};
|
||||
explicit Context(World& /*world */, JSObject* aGlobal) :
|
||||
mGlobal(aGlobal) {}
|
||||
|
||||
JSValue interpret(ICodeModule* iCode, const JSValues& args);
|
||||
|
||||
JSObject& setGlobalObject(JSObject& aGlobal)
|
||||
JSObject* setGlobalObject(JSObject* aGlobal)
|
||||
{
|
||||
JSObject &t = mGlobal;
|
||||
JSObject* t = mGlobal;
|
||||
mGlobal = aGlobal;
|
||||
return t;
|
||||
}
|
||||
|
||||
JSObject& getGlobalObject()
|
||||
JSObject* getGlobalObject()
|
||||
{
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
private:
|
||||
/* World mWorld; */
|
||||
JSObject& mGlobal;
|
||||
JSObject* mGlobal;
|
||||
|
||||
}; /* class Interpreter */
|
||||
} /* namespace JavaScript */
|
||||
|
@ -216,7 +216,7 @@ namespace Shell {
|
||||
static float64 testFunctionCall(World &world, float64 n)
|
||||
{
|
||||
JSObject glob;
|
||||
Context cx(world, glob);
|
||||
Context cx(world, &glob);
|
||||
uint32 position = 0;
|
||||
//StringAtom& global = world.identifiers[widenCString("global")];
|
||||
StringAtom& sum = world.identifiers[widenCString("sum")];
|
||||
@ -266,7 +266,7 @@ namespace Shell {
|
||||
static float64 testFactorial(World &world, float64 n)
|
||||
{
|
||||
JSObject glob;
|
||||
Context cx(world, glob);
|
||||
Context cx(world, &glob);
|
||||
// generate code for factorial, and interpret it.
|
||||
uint32 position = 0;
|
||||
ICodeGenerator icg;
|
||||
@ -327,7 +327,7 @@ namespace Shell {
|
||||
static float64 testObjects(World &world, int32 n)
|
||||
{
|
||||
JSObject glob;
|
||||
Context cx(world, glob);
|
||||
Context cx(world, &glob);
|
||||
// create some objects, put some properties, and retrieve them.
|
||||
uint32 position = 0;
|
||||
ICodeGenerator initCG;
|
||||
|
@ -123,13 +123,13 @@ namespace JavaScript {
|
||||
case LOAD_NAME:
|
||||
{
|
||||
LoadName* ln = static_cast<LoadName*>(instruction);
|
||||
(*registers)[dst(ln)] = mGlobal[*src1(ln)];
|
||||
(*registers)[dst(ln)] = (*mGlobal)[*src1(ln)];
|
||||
}
|
||||
break;
|
||||
case SAVE_NAME:
|
||||
{
|
||||
SaveName* sn = static_cast<SaveName*>(instruction);
|
||||
mGlobal[*dst(sn)] = (*registers)[src1(sn)];
|
||||
(*mGlobal)[*dst(sn)] = (*registers)[src1(sn)];
|
||||
}
|
||||
break;
|
||||
case NEW_OBJECT:
|
||||
@ -296,7 +296,7 @@ namespace JavaScript {
|
||||
break;
|
||||
case NOT:
|
||||
{
|
||||
Move* nt = static_cast<Move*>(instruction);
|
||||
Not* nt = static_cast<Not*>(instruction);
|
||||
(*registers)[dst(nt)].i32 = !(*registers)[src1(nt)].i32;
|
||||
}
|
||||
break;
|
||||
|
@ -31,26 +31,26 @@ namespace JavaScript {
|
||||
|
||||
class Context : public gc_base {
|
||||
public:
|
||||
explicit Context(World& /*world */, JSObject& aGlobal) :
|
||||
mGlobal(aGlobal) {};
|
||||
explicit Context(World& /*world */, JSObject* aGlobal) :
|
||||
mGlobal(aGlobal) {}
|
||||
|
||||
JSValue interpret(ICodeModule* iCode, const JSValues& args);
|
||||
|
||||
JSObject& setGlobalObject(JSObject& aGlobal)
|
||||
JSObject* setGlobalObject(JSObject* aGlobal)
|
||||
{
|
||||
JSObject &t = mGlobal;
|
||||
JSObject* t = mGlobal;
|
||||
mGlobal = aGlobal;
|
||||
return t;
|
||||
}
|
||||
|
||||
JSObject& getGlobalObject()
|
||||
JSObject* getGlobalObject()
|
||||
{
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
private:
|
||||
/* World mWorld; */
|
||||
JSObject& mGlobal;
|
||||
JSObject* mGlobal;
|
||||
|
||||
}; /* class Interpreter */
|
||||
} /* namespace JavaScript */
|
||||
|
@ -216,7 +216,7 @@ namespace Shell {
|
||||
static float64 testFunctionCall(World &world, float64 n)
|
||||
{
|
||||
JSObject glob;
|
||||
Context cx(world, glob);
|
||||
Context cx(world, &glob);
|
||||
uint32 position = 0;
|
||||
//StringAtom& global = world.identifiers[widenCString("global")];
|
||||
StringAtom& sum = world.identifiers[widenCString("sum")];
|
||||
@ -266,7 +266,7 @@ namespace Shell {
|
||||
static float64 testFactorial(World &world, float64 n)
|
||||
{
|
||||
JSObject glob;
|
||||
Context cx(world, glob);
|
||||
Context cx(world, &glob);
|
||||
// generate code for factorial, and interpret it.
|
||||
uint32 position = 0;
|
||||
ICodeGenerator icg;
|
||||
@ -327,7 +327,7 @@ namespace Shell {
|
||||
static float64 testObjects(World &world, int32 n)
|
||||
{
|
||||
JSObject glob;
|
||||
Context cx(world, glob);
|
||||
Context cx(world, &glob);
|
||||
// create some objects, put some properties, and retrieve them.
|
||||
uint32 position = 0;
|
||||
ICodeGenerator initCG;
|
||||
|
Loading…
Reference in New Issue
Block a user