зеркало из https://github.com/mozilla/pjs.git
Fixing Function prototypes. Added 'dumpAt'.
This commit is contained in:
Родитель
4a0a841b62
Коммит
4387f4b6f0
|
@ -264,6 +264,9 @@ void printFrameBindings(NonWithFrame *f)
|
|||
js2val dump(JS2Metadata *meta, const js2val /* thisValue */, js2val argv[], uint32 argc)
|
||||
{
|
||||
if (argc) {
|
||||
if (JS2VAL_IS_UNDEFINED(argv[0]))
|
||||
stdOut << "Undefined\n";
|
||||
else
|
||||
if (JS2VAL_IS_OBJECT(argv[0])) {
|
||||
JS2Object *fObj = JS2VAL_TO_OBJECT(argv[0]);
|
||||
if (((fObj->kind == SimpleInstanceKind)
|
||||
|
@ -335,6 +338,16 @@ js2val dump(JS2Metadata *meta, const js2val /* thisValue */, js2val argv[], uint
|
|||
}
|
||||
return JS2VAL_UNDEFINED;
|
||||
}
|
||||
|
||||
js2val dumpAt(JS2Metadata *meta, const js2val /* thisValue */, js2val argv[], uint32 argc)
|
||||
{
|
||||
if (JS2VAL_IS_INT(argv[0])) {
|
||||
argv[0] = OBJECT_TO_JS2VAL(JS2VAL_TO_INT(argv[0]));
|
||||
return dump(meta, JS2VAL_NULL, argv, argc);
|
||||
}
|
||||
return JS2VAL_VOID;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
js2val load(JS2Metadata *meta, const js2val /* thisValue */, js2val argv[], uint32 argc)
|
||||
|
@ -386,6 +399,7 @@ int main(int argc, char **argv)
|
|||
metadata->addGlobalObjectFunction("load", load, 1);
|
||||
#ifdef DEBUG
|
||||
metadata->addGlobalObjectFunction("dump", dump, 1);
|
||||
metadata->addGlobalObjectFunction("dumpAt", dumpAt, 1);
|
||||
metadata->addGlobalObjectFunction("trees", trees, 0);
|
||||
metadata->addGlobalObjectFunction("trace", trace, 0);
|
||||
#endif
|
||||
|
|
|
@ -844,7 +844,7 @@ void initArrayObject(JS2Metadata *meta)
|
|||
/*
|
||||
Dynamic property of the prototype:
|
||||
*/
|
||||
FunctionInstance *fInst = new FunctionInstance(meta->functionClass->prototype, meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
fInst->fWrap = callInst->fWrap;
|
||||
meta->writeDynamicProperty(meta->arrayClass->prototype, new Multiname(&meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
fInst->writeProperty(meta, meta->engine->length_StringAtom, INT_TO_JS2VAL(pf->length), DynamicPropertyValue::PERMANENT | DynamicPropertyValue::READONLY);
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace MetaData {
|
|||
|
||||
js2val Boolean_Constructor(JS2Metadata *meta, const js2val thisValue, js2val argv[], uint32 argc)
|
||||
{
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new BooleanInstance(meta->booleanClass->prototype, meta->booleanClass));
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new BooleanInstance(meta, meta->booleanClass->prototype, meta->booleanClass));
|
||||
BooleanInstance *boolInst = checked_cast<BooleanInstance *>(JS2VAL_TO_OBJECT(thatValue));
|
||||
JS2Object::RootIterator ri = JS2Object::addRoot(&boolInst);
|
||||
|
||||
|
@ -119,7 +119,7 @@ namespace MetaData {
|
|||
NamespaceList publicNamespaceList;
|
||||
publicNamespaceList.push_back(meta->publicNamespace);
|
||||
|
||||
meta->booleanClass->prototype = new BooleanInstance(meta->objectClass->prototype, meta->booleanClass);
|
||||
meta->booleanClass->prototype = new BooleanInstance(meta, meta->objectClass->prototype, meta->booleanClass);
|
||||
|
||||
|
||||
// Adding "prototype" & "length" as static members of the class - not dynamic properties; XXX
|
||||
|
@ -131,7 +131,7 @@ namespace MetaData {
|
|||
meta->env->removeTopFrame();
|
||||
|
||||
// Add "constructor" as a dynamic property of the prototype
|
||||
FunctionInstance *fInst = new FunctionInstance(meta->functionClass->prototype, meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(1), RunPhase);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), Boolean_Constructor);
|
||||
meta->writeDynamicProperty(meta->booleanClass->prototype, new Multiname(&meta->world.identifiers["constructor"], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
|
@ -152,7 +152,7 @@ namespace MetaData {
|
|||
/*
|
||||
Dynamic property of the prototype:
|
||||
*/
|
||||
FunctionInstance *fInst = new FunctionInstance(meta->functionClass->prototype, meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
fInst->fWrap = callInst->fWrap;
|
||||
meta->writeDynamicProperty(meta->booleanClass->prototype, new Multiname(&meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(pf->length), RunPhase);
|
||||
|
|
|
@ -869,7 +869,7 @@ js2val Date_Call(JS2Metadata *meta, const js2val /* thisValue */, js2val *argv,
|
|||
#define MAXARGS 7
|
||||
js2val Date_Constructor(JS2Metadata *meta, const js2val /* thisValue */, js2val *argv, uint32 argc)
|
||||
{
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new DateInstance(meta->dateClass->prototype, meta->dateClass));
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new DateInstance(meta, meta->dateClass->prototype, meta->dateClass));
|
||||
DateInstance *thisInst = checked_cast<DateInstance *>(JS2VAL_TO_OBJECT(thatValue));
|
||||
JS2Object::RootIterator ri = JS2Object::addRoot(&thisInst);
|
||||
|
||||
|
@ -1489,7 +1489,7 @@ void initDateObject(JS2Metadata *meta)
|
|||
publicNamespaceList.push_back(meta->publicNamespace);
|
||||
|
||||
|
||||
meta->dateClass->prototype = new DateInstance(meta->objectClass->prototype, meta->booleanClass);
|
||||
meta->dateClass->prototype = new DateInstance(meta, meta->objectClass->prototype, meta->booleanClass);
|
||||
|
||||
// Adding "prototype" & "length" as static members of the class - not dynamic properties; XXX
|
||||
meta->env->addFrame(meta->dateClass);
|
||||
|
@ -1526,7 +1526,7 @@ XXX not static members, since those can't be accessed from the instance
|
|||
InstanceMember *m = new InstanceMethod(callInst);
|
||||
meta->defineInstanceMember(meta->dateClass, &meta->cxt, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
|
||||
|
||||
FunctionInstance *fInst = new FunctionInstance(meta->functionClass->prototype, meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
fInst->fWrap = callInst->fWrap;
|
||||
meta->writeDynamicProperty(meta->dateClass->prototype, new Multiname(&meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(pf->length), RunPhase);
|
||||
|
|
|
@ -813,7 +813,7 @@ namespace MetaData {
|
|||
ASSERT(obj->kind == ClassKind);
|
||||
JS2Class *c = checked_cast<JS2Class *>(obj);
|
||||
if (c->prototype)
|
||||
return OBJECT_TO_JS2VAL(new PrototypeInstance(c->prototype, c));
|
||||
return OBJECT_TO_JS2VAL(new PrototypeInstance(meta, c->prototype, c));
|
||||
else
|
||||
return OBJECT_TO_JS2VAL(new SimpleInstance(c));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace MetaData {
|
|||
|
||||
js2val error_ConstructorCore(JS2Metadata *meta, JS2Class *errorClass, js2val arg)
|
||||
{
|
||||
JS2Object *obj = new PrototypeInstance(errorClass->prototype, errorClass);
|
||||
JS2Object *obj = new PrototypeInstance(meta, errorClass->prototype, errorClass);
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(obj);
|
||||
|
||||
if (!JS2VAL_IS_VOID(arg)) {
|
||||
|
@ -126,7 +126,7 @@ static void initErrorClass(JS2Metadata *meta, JS2Class *c, Constructor *construc
|
|||
{
|
||||
// XXX Or make 'name' a static class member?
|
||||
c->construct = constructor;
|
||||
c->prototype = new PrototypeInstance(NULL, c);
|
||||
c->prototype = new PrototypeInstance(meta, NULL, c);
|
||||
js2val nameVal = meta->engine->allocString(c->name);
|
||||
meta->writeDynamicProperty(c->prototype, new Multiname(&meta->world.identifiers["name"], meta->publicNamespace), true, nameVal, RunPhase);
|
||||
}
|
||||
|
|
|
@ -83,19 +83,15 @@ namespace MetaData {
|
|||
return OBJECT_TO_JS2VAL(fnExpr->obj);
|
||||
}
|
||||
else { // construct an empty function wrapper
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new FunctionInstance(meta->functionClass->prototype, meta->functionClass));
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass));
|
||||
FunctionInstance *fnInst = checked_cast<FunctionInstance *>(JS2VAL_TO_OBJECT(thatValue));
|
||||
fnInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true));
|
||||
fnInst->fWrap->bCon->emitOp(eReturnVoid, meta->engine->errorPos());
|
||||
fnInst->writeProperty(meta, meta->engine->length_StringAtom, INT_TO_JS2VAL(0), DynamicPropertyValue::READONLY);
|
||||
return thatValue;
|
||||
}
|
||||
}
|
||||
|
||||
static js2val Function_Call(JS2Metadata *meta, const js2val thisValue, js2val argv[], uint32 argc)
|
||||
{
|
||||
return JS2VAL_VOID;
|
||||
}
|
||||
|
||||
|
||||
static js2val Function_toString(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
|
||||
{
|
||||
if (!JS2VAL_IS_OBJECT(thisValue)
|
||||
|
@ -119,7 +115,7 @@ namespace MetaData {
|
|||
void initFunctionObject(JS2Metadata *meta)
|
||||
{
|
||||
meta->functionClass->construct = Function_Constructor;
|
||||
meta->functionClass->call = Function_Call;
|
||||
meta->functionClass->call = Function_Constructor;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
|
@ -138,7 +134,7 @@ namespace MetaData {
|
|||
NamespaceList publicNamespaceList;
|
||||
publicNamespaceList.push_back(meta->publicNamespace);
|
||||
|
||||
meta->functionClass->prototype = new FunctionInstance(meta->objectClass->prototype, meta->functionClass);
|
||||
meta->functionClass->prototype = new FunctionInstance(meta, meta->objectClass->prototype, meta->functionClass);
|
||||
|
||||
// Adding "prototype" as a static member of the class - not a dynamic property
|
||||
meta->env->addFrame(meta->functionClass);
|
||||
|
@ -147,28 +143,31 @@ namespace MetaData {
|
|||
meta->env->removeTopFrame();
|
||||
|
||||
// Add "constructor" as a dynamic property of the prototype
|
||||
SimpleInstance *fInst = new SimpleInstance(meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(1), RunPhase);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), Function_Constructor);
|
||||
meta->writeDynamicProperty(meta->functionClass->prototype, new Multiname(&meta->world.identifiers["constructor"], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
|
||||
|
||||
PrototypeFunction *pf = &prototypeFunctions[0];
|
||||
while (pf->name) {
|
||||
fInst = new SimpleInstance(meta->functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code);
|
||||
SimpleInstance *callInst = new SimpleInstance(meta->functionClass);
|
||||
callInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code);
|
||||
/*
|
||||
XXX not static members, since those can't be accessed from the instance
|
||||
Variable *v = new Variable(meta->functionClass, OBJECT_TO_JS2VAL(fInst), true);
|
||||
meta->defineLocalMember(&meta->env, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
|
||||
*/
|
||||
InstanceMember *m = new InstanceMethod(fInst);
|
||||
InstanceMember *m = new InstanceMethod(callInst);
|
||||
meta->defineInstanceMember(meta->functionClass, &meta->cxt, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
|
||||
|
||||
/*
|
||||
Dynamic property of the prototype:
|
||||
*/
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
fInst->fWrap = callInst->fWrap;
|
||||
meta->writeDynamicProperty(meta->functionClass->prototype, new Multiname(&meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(pf->length), RunPhase);
|
||||
|
||||
pf++;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace MetaData {
|
|||
JS2Object *result;
|
||||
|
||||
if (prototype) {
|
||||
FunctionInstance *fInst = new FunctionInstance(functionClass->prototype, functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(unchecked, compileFrame);
|
||||
fnDef->fWrap = fInst->fWrap;
|
||||
result = fInst;
|
||||
|
@ -3259,7 +3259,7 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
|
|||
v = new Variable(classClass, OBJECT_TO_JS2VAL(objectClass), true);
|
||||
defineLocalMember(env, &world.identifiers["Object"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
|
||||
// Function properties of the Object prototype object
|
||||
objectClass->prototype = new PrototypeInstance(NULL, objectClass);
|
||||
objectClass->prototype = new PrototypeInstance(this, NULL, objectClass);
|
||||
// Adding "prototype" as a static member of the class - not a dynamic property
|
||||
env->addFrame(objectClass);
|
||||
v = new Variable(objectClass, OBJECT_TO_JS2VAL(objectClass->prototype), true);
|
||||
|
@ -3273,7 +3273,7 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
|
|||
initFunctionObject(this);
|
||||
|
||||
// Adding 'toString' to the Object.prototype XXX Or make this a static class member?
|
||||
FunctionInstance *fInst = new FunctionInstance(functionClass->prototype, functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), Object_toString);
|
||||
objectClass->prototype->writeProperty(this, engine->toString_StringAtom, OBJECT_TO_JS2VAL(fInst), 0);
|
||||
fInst->writeProperty(this, engine->length_StringAtom, INT_TO_JS2VAL(0), DynamicPropertyValue::READONLY);
|
||||
|
@ -4467,6 +4467,14 @@ deleteClassProperty:
|
|||
*
|
||||
************************************************************************************/
|
||||
|
||||
PrototypeInstance::PrototypeInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type)
|
||||
: JS2Object(PrototypeInstanceKind), parent(parent), type(type)
|
||||
{
|
||||
// Add prototype property
|
||||
writeProperty(meta, meta->engine->prototype_StringAtom, OBJECT_TO_JS2VAL(parent), 0);
|
||||
}
|
||||
|
||||
|
||||
// gc-mark all contained JS2Objects and visit contained structures to do likewise
|
||||
void PrototypeInstance::markChildren()
|
||||
{
|
||||
|
@ -4483,8 +4491,8 @@ deleteClassProperty:
|
|||
*
|
||||
************************************************************************************/
|
||||
|
||||
FunctionInstance::FunctionInstance(JS2Object *parent, JS2Class *type)
|
||||
: PrototypeInstance(parent, type), fWrap(NULL)
|
||||
FunctionInstance::FunctionInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type)
|
||||
: PrototypeInstance(meta, parent, type), fWrap(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4589,7 +4597,7 @@ deleteClassProperty:
|
|||
ParameterFrame *plural = checked_cast<ParameterFrame *>(pluralFrame);
|
||||
ASSERT((plural->positionalCount == 0) || (plural->positional != NULL));
|
||||
|
||||
PrototypeInstance *argsObj = new PrototypeInstance(meta->objectClass->prototype, meta->objectClass);
|
||||
PrototypeInstance *argsObj = new PrototypeInstance(meta, meta->objectClass->prototype, meta->objectClass);
|
||||
|
||||
// Add the 'arguments' property
|
||||
QualifiedName qn(meta->publicNamespace, &meta->world.identifiers["arguments"]);
|
||||
|
|
|
@ -614,8 +614,7 @@ public:
|
|||
// contain no fixed properties.
|
||||
class PrototypeInstance : public JS2Object {
|
||||
public:
|
||||
PrototypeInstance(JS2Object *parent, JS2Class *type) : JS2Object(PrototypeInstanceKind), parent(parent), type(type) { }
|
||||
|
||||
PrototypeInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type);
|
||||
|
||||
JS2Object *parent; // If this instance was created by calling new on a prototype function,
|
||||
// the value of the function’s prototype property at the time of the call;
|
||||
|
@ -633,7 +632,7 @@ public:
|
|||
// that contains the millisecond count
|
||||
class DateInstance : public PrototypeInstance {
|
||||
public:
|
||||
DateInstance(JS2Object *parent, JS2Class *type) : PrototypeInstance(parent, type) { }
|
||||
DateInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type) : PrototypeInstance(meta, parent, type) { }
|
||||
|
||||
float64 ms;
|
||||
};
|
||||
|
@ -642,7 +641,7 @@ public:
|
|||
// that contains the string data
|
||||
class StringInstance : public PrototypeInstance {
|
||||
public:
|
||||
StringInstance(JS2Object *parent, JS2Class *type) : PrototypeInstance(parent, type), mValue(NULL) { }
|
||||
StringInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type) : PrototypeInstance(meta, parent, type), mValue(NULL) { }
|
||||
|
||||
String *mValue; // has been allocated by engine in the GC'able Pond
|
||||
|
||||
|
@ -654,7 +653,7 @@ public:
|
|||
// that contains the float64 data
|
||||
class NumberInstance : public PrototypeInstance {
|
||||
public:
|
||||
NumberInstance(JS2Object *parent, JS2Class *type) : PrototypeInstance(parent, type), mValue(0.0) { }
|
||||
NumberInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type) : PrototypeInstance(meta, parent, type), mValue(0.0) { }
|
||||
|
||||
float64 mValue;
|
||||
virtual ~NumberInstance() { }
|
||||
|
@ -664,7 +663,7 @@ public:
|
|||
// that contains the bool data
|
||||
class BooleanInstance : public PrototypeInstance {
|
||||
public:
|
||||
BooleanInstance(JS2Object *parent, JS2Class *type) : PrototypeInstance(parent, type), mValue(false) { }
|
||||
BooleanInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type) : PrototypeInstance(meta, parent, type), mValue(false) { }
|
||||
|
||||
bool mValue;
|
||||
virtual ~BooleanInstance() { }
|
||||
|
@ -674,7 +673,7 @@ public:
|
|||
// that contains a pointer to the function implementation
|
||||
class FunctionInstance : public PrototypeInstance {
|
||||
public:
|
||||
FunctionInstance(JS2Object *parent, JS2Class *type);
|
||||
FunctionInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type);
|
||||
|
||||
FunctionWrapper *fWrap;
|
||||
|
||||
|
@ -687,7 +686,7 @@ public:
|
|||
// are added.
|
||||
class ArrayInstance : public PrototypeInstance {
|
||||
public:
|
||||
ArrayInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type) : PrototypeInstance(parent, type) { setLength(meta, this, 0); }
|
||||
ArrayInstance(JS2Metadata *meta, JS2Object *parent, JS2Class *type) : PrototypeInstance(meta, parent, type) { setLength(meta, this, 0); }
|
||||
|
||||
virtual void writeProperty(JS2Metadata *meta, const String *name, js2val newValue, uint32 flags);
|
||||
virtual ~ArrayInstance() { }
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace MetaData {
|
|||
|
||||
js2val Number_Constructor(JS2Metadata *meta, const js2val thisValue, js2val argv[], uint32 argc)
|
||||
{
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new NumberInstance(meta->numberClass->prototype, meta->numberClass));
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new NumberInstance(meta, meta->numberClass->prototype, meta->numberClass));
|
||||
NumberInstance *numInst = checked_cast<NumberInstance *>(JS2VAL_TO_OBJECT(thatValue));
|
||||
|
||||
if (argc > 0)
|
||||
|
@ -139,7 +139,7 @@ namespace MetaData {
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
meta->numberClass->prototype = new NumberInstance(meta->objectClass->prototype, meta->numberClass);
|
||||
meta->numberClass->prototype = new NumberInstance(meta, meta->objectClass->prototype, meta->numberClass);
|
||||
|
||||
// Adding "prototype" & "length" as static members of the class - not dynamic properties; XXX
|
||||
meta->env->addFrame(meta->numberClass);
|
||||
|
@ -165,7 +165,7 @@ namespace MetaData {
|
|||
/*
|
||||
Dynamic property of the prototype:
|
||||
*/
|
||||
FunctionInstance *fInst = new FunctionInstance(meta->functionClass->prototype, meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
fInst->fWrap = callInst->fWrap;
|
||||
meta->writeDynamicProperty(meta->numberClass->prototype, new Multiname(&meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(pf->length), RunPhase);
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
else {
|
||||
pFrame = new ParameterFrame(fWrap->compileFrame);
|
||||
pFrame->instantiate(meta->env);
|
||||
PrototypeInstance *pInst = new PrototypeInstance(protoObj, meta->objectClass);
|
||||
PrototypeInstance *pInst = new PrototypeInstance(meta, protoObj, meta->objectClass);
|
||||
baseVal = OBJECT_TO_JS2VAL(pInst);
|
||||
pFrame->thisObject = baseVal;
|
||||
pFrame->assignArguments(meta, obj, base(argCount), argCount);
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
{
|
||||
uint16 argCount = BytecodeContainer::getShort(pc);
|
||||
pc += sizeof(uint16);
|
||||
PrototypeInstance *pInst = new PrototypeInstance(meta->objectClass->prototype, meta->objectClass);
|
||||
PrototypeInstance *pInst = new PrototypeInstance(meta, meta->objectClass->prototype, meta->objectClass);
|
||||
baseVal = OBJECT_TO_JS2VAL(pInst);
|
||||
for (uint16 i = 0; i < argCount; i++) {
|
||||
a = pop();
|
||||
|
|
|
@ -59,7 +59,7 @@ js2val String_Constructor(JS2Metadata *meta, const js2val /*thisValue*/, js2val
|
|||
{
|
||||
// XXX GC might happen after the new StringInstance, but before the
|
||||
// object gets rooted somewhere - this is a general problem...
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new StringInstance(meta->stringClass->prototype, meta->stringClass));
|
||||
js2val thatValue = OBJECT_TO_JS2VAL(new StringInstance(meta, meta->stringClass->prototype, meta->stringClass));
|
||||
StringInstance *strInst = checked_cast<StringInstance *>(JS2VAL_TO_OBJECT(thatValue));
|
||||
JS2Object::RootIterator ri = JS2Object::addRoot(&strInst);
|
||||
if (argc > 0)
|
||||
|
@ -798,7 +798,7 @@ void initStringObject(JS2Metadata *meta)
|
|||
meta->stringClass->construct = String_Constructor;
|
||||
meta->stringClass->call = String_Call;
|
||||
|
||||
meta->stringClass->prototype = new StringInstance(meta->objectClass->prototype, meta->booleanClass);
|
||||
meta->stringClass->prototype = new StringInstance(meta, meta->objectClass->prototype, meta->booleanClass);
|
||||
|
||||
// Adding "prototype" & "length" as static members of the class - not dynamic properties; XXX
|
||||
meta->env->addFrame(meta->stringClass);
|
||||
|
@ -824,7 +824,7 @@ XXX not prototype object function properties, like ECMA3, but members of the Str
|
|||
InstanceMember *m = new InstanceMethod(callInst);
|
||||
meta->defineInstanceMember(meta->stringClass, &meta->cxt, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
|
||||
|
||||
FunctionInstance *fInst = new FunctionInstance(meta->functionClass->prototype, meta->functionClass);
|
||||
FunctionInstance *fInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
fInst->fWrap = callInst->fWrap;
|
||||
meta->writeDynamicProperty(meta->stringClass->prototype, new Multiname(&meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
|
||||
meta->writeDynamicProperty(fInst, new Multiname(meta->engine->length_StringAtom, meta->publicNamespace), true, INT_TO_JS2VAL(pf->length), RunPhase);
|
||||
|
|
Загрузка…
Ссылка в новой задаче