changed Context constructor to take JSObject* not JSObject&, to be able to control lifetime a little more carefully.

This commit is contained in:
beard%netscape.com 2000-04-25 03:32:53 +00:00
parent 02525db2ed
commit b33c70b006
6 changed files with 24 additions and 24 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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;