More long/ulong changes - moved to String for name storage, added string

to GC handling. Removing reference assign ops.
This commit is contained in:
rogerl%netscape.com 2002-10-10 05:32:21 +00:00
Родитель 09cf60a607
Коммит ccf304be55
13 изменённых файлов: 267 добавлений и 232 удалений

Просмотреть файл

@ -140,7 +140,7 @@ public:
void setOffset(uint32 index, int32 v) { *((int32 *)(mBuffer.begin() + index)) = v; }
static int32 getOffset(void *pc) { return *((int32 *)pc); }
void addString(const StringAtom &x, size_t pos) { emitOp(eString, pos); addPointer(&x); }
void addString(const StringAtom *x, size_t pos) { emitOp(eString, pos); addPointer(x); }
void addString(String &x, size_t pos) { emitOp(eString, pos); addPointer(&x); }
void addString(String *x, size_t pos) { emitOp(eString, pos); addPointer(x); }
static String *getString(void *pc) { return (String *)getPointer(pc); }

Просмотреть файл

@ -745,7 +745,7 @@ static void new_explode(float64 timeval, PRMJTime *split, bool findEquivalent)
}
/* helper function */
static js2val Date_format(float64 date, formatspec format)
static js2val Date_format(JS2Metadata *meta, float64 date, formatspec format)
{
StringFormatter outf;
char tzbuf[100];
@ -848,7 +848,7 @@ static js2val Date_format(float64 date, formatspec format)
}
}
return STRING_TO_JS2VAL(new String(outf.getString()));
return meta->engine->allocString(outf.getString());
}
@ -983,7 +983,7 @@ static js2val Date_toGMTString(JS2Metadata *meta, const js2val thisValue, js2val
MinFromTime(temp),
SecFromTime(temp));
}
return STRING_TO_JS2VAL(new String(buf.getString()));
return meta->engine->allocString(buf.getString());
}
static js2val Date_toLocaleHelper(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/, char *format)
@ -1006,7 +1006,7 @@ static js2val Date_toLocaleHelper(JS2Metadata *meta, const js2val thisValue, js2
/* If it failed, default to toString. */
if (result_len == 0)
return Date_format(*date, FORMATSPEC_FULL);
return Date_format(meta, *date, FORMATSPEC_FULL);
/* Hacked check against undesired 2-digit year 00/00/00 form. */
if ((buf[result_len - 3] == '/')
@ -1018,7 +1018,7 @@ static js2val Date_toLocaleHelper(JS2Metadata *meta, const js2val thisValue, js2
outf << buf;
}
return STRING_TO_JS2VAL(new String(outf.getString()));
return meta->engine->allocString(outf.getString());
}
static js2val Date_toLocaleString(JS2Metadata *meta, const js2val thisValue, js2val *argv, uint32 argc)
@ -1059,19 +1059,19 @@ static js2val Date_toLocaleTimeString(JS2Metadata *meta, const js2val thisValue,
static js2val Date_toTimeString(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
{
float64 *date = Date_getProlog(meta, thisValue);
return Date_format(*date, FORMATSPEC_TIME);
return Date_format(meta, *date, FORMATSPEC_TIME);
}
static js2val Date_toDateString(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
{
float64 *date = Date_getProlog(meta, thisValue);
return Date_format(*date, FORMATSPEC_DATE);
return Date_format(meta, *date, FORMATSPEC_DATE);
}
static js2val Date_toString(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
{
float64 *date = Date_getProlog(meta, thisValue);
return Date_format(*date, FORMATSPEC_FULL);
return Date_format(meta, *date, FORMATSPEC_FULL);
}
static js2val Date_toSource(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
@ -1079,7 +1079,7 @@ static js2val Date_toSource(JS2Metadata *meta, const js2val thisValue, js2val *
StringFormatter buf;
float64 *date = Date_getProlog(meta, thisValue);
buf << "(new Date(" << *numberToString(date) << "))";
return STRING_TO_JS2VAL(new String(buf.getString()));
return meta->engine->allocString(buf.getString());
}
static js2val Date_getTime(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
@ -1479,7 +1479,7 @@ XXX not prototype object function properties, like ECMA3, but members of the Dat
meta->writeDynamicProperty(meta->dateClass->prototype, new Multiname(meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
*/
InstanceMember *m = new InstanceMethod(fInst);
meta->defineInstanceMember(meta->dateClass, &meta->cxt, meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
meta->defineInstanceMember(meta->dateClass, &meta->cxt, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
pf++;
}

Просмотреть файл

@ -123,6 +123,12 @@ namespace MetaData {
}
}
String *JS2Engine::allocStringPtr(const String *s)
{
String *p = (String *)(JS2Object::alloc(sizeof(String)));
return new (p) String(*s);
}
// if the argument can be stored as an integer value, do so
// otherwise get a double value
js2val JS2Engine::allocNumber(float64 x)
@ -181,14 +187,14 @@ namespace MetaData {
}
// x is not a String
String *JS2Engine::convertValueToString(js2val x)
const String *JS2Engine::convertValueToString(js2val x)
{
if (JS2VAL_IS_UNDEFINED(x))
return &undefined_StringAtom;
return undefined_StringAtom;
if (JS2VAL_IS_NULL(x))
return &null_StringAtom;
return null_StringAtom;
if (JS2VAL_IS_BOOLEAN(x))
return (JS2VAL_TO_BOOLEAN(x)) ? &true_StringAtom : &false_StringAtom;
return (JS2VAL_TO_BOOLEAN(x)) ? true_StringAtom : false_StringAtom;
if (JS2VAL_IS_INT(x))
return numberToString(JS2VAL_TO_INT(x));
if (JS2VAL_IS_LONG(x)) {
@ -217,7 +223,7 @@ namespace MetaData {
// if not available or result is not primitive then try property 'valueOf'
// if that's not available or returns a non primitive, throw a TypeError
return STRING_TO_JS2VAL(&object_StringAtom);
return STRING_TO_JS2VAL(object_StringAtom);
ASSERT(false);
return JS2VAL_VOID;
@ -397,7 +403,7 @@ namespace MetaData {
#define INIT_STRINGATOM(n) n##_StringAtom(world.identifiers[#n])
#define INIT_STRINGATOM(n) n##_StringAtom(allocStringPtr(#n))
JS2Engine::JS2Engine(World &world)
: pc(NULL),
@ -412,8 +418,8 @@ namespace MetaData {
INIT_STRINGATOM(private),
INIT_STRINGATOM(function),
INIT_STRINGATOM(object),
Empty_StringAtom(world.identifiers[""]),
Dollar_StringAtom(world.identifiers["$"])
Empty_StringAtom(&world.identifiers[""]),
Dollar_StringAtom(&world.identifiers["$"])
{
for (int i = 0; i < 256; i++)
float64Table[i] = NULL;
@ -640,6 +646,16 @@ namespace MetaData {
GCMARKVALUE(b);
GCMARKVALUE(baseVal);
GCMARKVALUE(indexVal);
JS2Object::mark(true_StringAtom);
JS2Object::mark(false_StringAtom);
JS2Object::mark(null_StringAtom);
JS2Object::mark(undefined_StringAtom);
JS2Object::mark(public_StringAtom);
JS2Object::mark(private_StringAtom);
JS2Object::mark(function_StringAtom);
JS2Object::mark(object_StringAtom);
JS2Object::mark(Empty_StringAtom);
JS2Object::mark(Dollar_StringAtom);
}
}

Просмотреть файл

@ -152,14 +152,14 @@ public:
uint16 toUInt16(float64 f);
String *convertValueToString(js2val x);
const String *convertValueToString(js2val x);
js2val convertValueToPrimitive(js2val x);
float64 convertValueToDouble(js2val x);
bool convertValueToBoolean(js2val x);
int32 convertValueToInteger(js2val x);
js2val convertValueToGeneralNumber(js2val x);
String *toString(js2val x) { if (JS2VAL_IS_STRING(x)) return JS2VAL_TO_STRING(x); else return convertValueToString(x); }
const String *toString(js2val x){ if (JS2VAL_IS_STRING(x)) return JS2VAL_TO_STRING(x); else return convertValueToString(x); }
js2val toPrimitive(js2val x) { if (JS2VAL_IS_PRIMITIVE(x)) return x; else return convertValueToPrimitive(x); }
float64 toFloat64(js2val x);
js2val toGeneralNumber(js2val x){ if (JS2VAL_IS_NUMBER(x)) return x; else return convertValueToGeneralNumber(x); }
@ -182,6 +182,12 @@ public:
js2val posInfValue;
js2val negInfValue;
js2val allocString(const String *s) { return STRING_TO_JS2VAL(allocStringPtr(s)); }
js2val allocString(const String &s) { return allocString(&s); }
js2val allocString(const char *s) { return STRING_TO_JS2VAL(allocStringPtr(s)); }
String *allocStringPtr(const String *s);
String *allocStringPtr(const char *s) { return allocStringPtr(&widenCString(s)); }
js2val allocFloat(float32 x);
js2val pushFloat(float32 x) { js2val retval = allocFloat(x); push(retval); return retval; }
@ -208,16 +214,16 @@ public:
// Cached StringAtoms for handy access
StringAtom &true_StringAtom;
StringAtom &false_StringAtom;
StringAtom &null_StringAtom;
StringAtom &undefined_StringAtom;
StringAtom &public_StringAtom;
StringAtom &private_StringAtom;
StringAtom &function_StringAtom;
StringAtom &object_StringAtom;
StringAtom &Empty_StringAtom;
StringAtom &Dollar_StringAtom;
const String *true_StringAtom;
const String *false_StringAtom;
const String *null_StringAtom;
const String *undefined_StringAtom;
const String *public_StringAtom;
const String *private_StringAtom;
const String *function_StringAtom;
const String *object_StringAtom;
const String *Empty_StringAtom;
const String *Dollar_StringAtom;
// The activation stack, when it's empty and a return is executed, the
// interpreter quits

Просмотреть файл

@ -312,7 +312,7 @@ void initMathObject(JS2Metadata *meta)
for (i = 0; i < M_CONSTANTS_COUNT; i++)
{
Variable *v = new Variable(meta->numberClass, meta->engine->allocNumber(MathObjectConstants[i].value), true);
meta->defineStaticMember(&meta->env, meta->world.identifiers[MathObjectConstants[i].name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
meta->defineStaticMember(&meta->env, &meta->world.identifiers[MathObjectConstants[i].name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
}
meta->env.removeTopFrame();
@ -351,7 +351,7 @@ void initMathObject(JS2Metadata *meta)
FixedInstance *fInst = new FixedInstance(meta->functionClass);
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code);
Variable *v = new Variable(meta->functionClass, OBJECT_TO_JS2VAL(fInst), true);
meta->defineStaticMember(&meta->env, meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
meta->defineStaticMember(&meta->env, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
pf++;
}
meta->env.removeTopFrame();

Просмотреть файл

@ -324,7 +324,7 @@ namespace MetaData {
&& ((topFrame->kind == GlobalObjectKind)
|| (topFrame->kind == ParameterKind))
&& (f->attributes == NULL)) {
defineHoistedVar(env, *f->function.name, p);
defineHoistedVar(env, f->function.name, p);
}
else {
FixedInstance *fInst = new FixedInstance(functionClass);
@ -335,7 +335,7 @@ namespace MetaData {
case Attribute::Static:
{
Variable *v = new Variable(functionClass, OBJECT_TO_JS2VAL(fInst), true);
defineStaticMember(env, *f->function.name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
defineStaticMember(env, f->function.name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
}
break;
case Attribute::Virtual:
@ -343,7 +343,7 @@ namespace MetaData {
{
JS2Class *c = checked_cast<JS2Class *>(env->getTopFrame());
InstanceMember *m = new InstanceMethod(fInst);
defineInstanceMember(c, cxt, *f->function.name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, m, p->pos);
defineInstanceMember(c, cxt, f->function.name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, m, p->pos);
}
break;
case Attribute::Constructor:
@ -380,7 +380,7 @@ namespace MetaData {
&& !immutable
&& (vs->attributes == NULL)
&& (vb->type == NULL)) {
defineHoistedVar(env, *name, p);
defineHoistedVar(env, name, p);
}
else {
a = Attribute::toCompoundAttribute(attr);
@ -400,7 +400,7 @@ namespace MetaData {
Variable *v = new Variable(FUTURE_TYPE, immutable ? JS2VAL_FUTUREVALUE : JS2VAL_INACCESSIBLE, immutable);
vb->member = v;
v->vb = vb;
vb->mn = defineStaticMember(env, *name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
vb->mn = defineStaticMember(env, name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
}
break;
case Attribute::Virtual:
@ -409,7 +409,7 @@ namespace MetaData {
JS2Class *c = checked_cast<JS2Class *>(env->getTopFrame());
InstanceMember *m = new InstanceVariable(FUTURE_TYPE, immutable, (memberMod == Attribute::Final), c->slotCount++);
vb->member = m;
vb->osp = defineInstanceMember(c, cxt, *name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, m, p->pos);
vb->osp = defineInstanceMember(c, cxt, name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, m, p->pos);
}
break;
default:
@ -440,8 +440,8 @@ namespace MetaData {
reportError(Exception::definitionError, "Illegal attribute", p->pos);
if ( ! ((a->memberMod == Attribute::NoModifier) || ((a->memberMod == Attribute::Static) && (env->getTopFrame()->kind == ClassKind))) )
reportError(Exception::definitionError, "Illegal attribute", p->pos);
Variable *v = new Variable(namespaceClass, OBJECT_TO_JS2VAL(new Namespace(ns->name)), true);
defineStaticMember(env, ns->name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
Variable *v = new Variable(namespaceClass, OBJECT_TO_JS2VAL(new Namespace(&ns->name)), true);
defineStaticMember(env, &ns->name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
}
break;
case StmtNode::Use:
@ -500,10 +500,10 @@ namespace MetaData {
reportError(Exception::definitionError, "Illegal modifier for class definition", p->pos);
break;
}
JS2Class *c = new JS2Class(superClass, proto, new Namespace(engine->private_StringAtom), (a->dynamic || superClass->dynamic), true, final, classStmt->name);
JS2Class *c = new JS2Class(superClass, proto, new Namespace(engine->private_StringAtom), (a->dynamic || superClass->dynamic), true, final, &classStmt->name);
classStmt->c = c;
Variable *v = new Variable(classClass, OBJECT_TO_JS2VAL(c), true);
defineStaticMember(env, classStmt->name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
defineStaticMember(env, &classStmt->name, a->namespaces, a->overrideMod, a->xplicit, ReadWriteAccess, v, p->pos);
if (classStmt->body) {
env->addFrame(c);
ValidateStmtList(cxt, env, classStmt->body->statements);
@ -778,7 +778,7 @@ namespace MetaData {
if (vb->initializer) {
Reference *r = EvalExprNode(env, phase, vb->initializer);
if (r) r->emitReadBytecode(bCon, p->pos);
LexicalReference *lVal = new LexicalReference(*vb->name, cxt.strict);
LexicalReference *lVal = new LexicalReference(vb->name, cxt.strict);
lVal->variableMultiname->addNamespace(publicNamespace);
lVal->emitWriteBytecode(bCon, p->pos);
}
@ -1307,12 +1307,14 @@ doAssignBinary:
BinaryExprNode *b = checked_cast<BinaryExprNode *>(p);
Reference *lVal = EvalExprNode(env, phase, b->op1);
if (lVal) {
lVal->emitReadForWriteBackBytecode(bCon, p->pos);
Reference *rVal = EvalExprNode(env, phase, b->op2);
if (rVal) rVal->emitReadBytecode(bCon, p->pos);
lVal->emitAssignOpBytecode(bCon, op, p->pos);
}
else
reportError(Exception::semanticError, "Assignment needs an lValue", p->pos);
bCon->emitOp(op, p->pos);
lVal->emitWriteBackBytecode(bCon, p->pos);
}
break;
case ExprNode::lessThan:
@ -1523,13 +1525,13 @@ doUnary:
reportError(Exception::badValueError, "Namespace expected in qualifier", p->pos);
Namespace *ns = checked_cast<Namespace *>(obj);
returnRef = new LexicalReference(name, ns, cxt.strict);
returnRef = new LexicalReference(&name, ns, cxt.strict);
}
break;
case ExprNode::identifier:
{
IdentifierExprNode *i = checked_cast<IdentifierExprNode *>(p);
returnRef = new LexicalReference(i->name, cxt.strict);
returnRef = new LexicalReference(&i->name, cxt.strict);
((LexicalReference *)returnRef)->variableMultiname->addNamespace(cxt);
}
break;
@ -1605,7 +1607,7 @@ doUnary:
if (b->op2->getKind() == ExprNode::identifier) {
IdentifierExprNode *i = checked_cast<IdentifierExprNode *>(b->op2);
returnRef = new DotReference(i->name);
returnRef = new DotReference(&i->name);
}
else {
if (b->op2->getKind() == ExprNode::qualify) {
@ -1634,7 +1636,7 @@ doUnary:
if (rVal) rVal->emitReadBytecode(bCon, p->pos);
switch (e->field->getKind()) {
case ExprNode::identifier:
bCon->addString(checked_cast<IdentifierExprNode *>(e->field)->name, p->pos);
bCon->addString(&checked_cast<IdentifierExprNode *>(e->field)->name, p->pos);
break;
case ExprNode::string:
bCon->addString(checked_cast<StringExprNode *>(e->field)->str, p->pos);
@ -1922,7 +1924,7 @@ doUnary:
// - If the binding exists (not forbidden) in lower frames in the regional environment, it's an error.
// - Define a forbidden binding in all the lower frames.
//
Multiname *JS2Metadata::defineStaticMember(Environment *env, const StringAtom &id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, StaticMember *m, size_t pos)
Multiname *JS2Metadata::defineStaticMember(Environment *env, const StringAtom *id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, StaticMember *m, size_t pos)
{
NamespaceList publicNamespaceList;
@ -1936,8 +1938,8 @@ doUnary:
Multiname *mn = new Multiname(id);
mn->addNamespace(namespaces);
for (StaticBindingIterator b = localFrame->staticReadBindings.lower_bound(id),
end = localFrame->staticReadBindings.upper_bound(id); (b != end); b++) {
for (StaticBindingIterator b = localFrame->staticReadBindings.lower_bound(*id),
end = localFrame->staticReadBindings.upper_bound(*id); (b != end); b++) {
if (mn->matches(b->second->qname))
reportError(Exception::definitionError, "Duplicate definition {0}", pos, id);
}
@ -1948,8 +1950,8 @@ doUnary:
if (localFrame != regionalFrame) {
Frame *fr = localFrame->nextFrame;
while (fr != regionalFrame) {
for (b = fr->staticReadBindings.lower_bound(id),
end = fr->staticReadBindings.upper_bound(id); (b != end); b++) {
for (b = fr->staticReadBindings.lower_bound(*id),
end = fr->staticReadBindings.upper_bound(*id); (b != end); b++) {
if (mn->matches(b->second->qname) && (b->second->content->kind == StaticMember::Forbidden))
reportError(Exception::definitionError, "Duplicate definition {0}", pos, id);
}
@ -1958,15 +1960,15 @@ doUnary:
}
if (regionalFrame->kind == GlobalObjectKind) {
GlobalObject *gObj = checked_cast<GlobalObject *>(regionalFrame);
DynamicPropertyIterator dp = gObj->dynamicProperties.find(id);
DynamicPropertyIterator dp = gObj->dynamicProperties.find(*id);
if (dp != gObj->dynamicProperties.end())
reportError(Exception::definitionError, "Duplicate definition {0}", pos, id);
}
for (NamespaceListIterator nli = mn->nsList.begin(), nlend = mn->nsList.end(); (nli != nlend); nli++) {
QualifiedName qName(*nli, id);
QualifiedName qName(*nli, *id);
StaticBinding *sb = new StaticBinding(qName, m);
const StaticBindingMap::value_type e(id, sb);
const StaticBindingMap::value_type e(*id, sb);
if (access & ReadAccess)
regionalFrame->staticReadBindings.insert(e);
if (access & WriteAccess)
@ -1977,9 +1979,9 @@ doUnary:
Frame *fr = localFrame->nextFrame;
while (fr != regionalFrame) {
for (NamespaceListIterator nli = mn->nsList.begin(), nlend = mn->nsList.end(); (nli != nlend); nli++) {
QualifiedName qName(*nli, id);
QualifiedName qName(*nli, *id);
StaticBinding *sb = new StaticBinding(qName, forbiddenMember);
const StaticBindingMap::value_type e(id, sb);
const StaticBindingMap::value_type e(*id, sb);
if (access & ReadAccess)
fr->staticReadBindings.insert(e);
if (access & WriteAccess)
@ -2020,11 +2022,11 @@ doUnary:
// Examine class 'c' and find all instance members that would be overridden
// by 'id' in any of the given namespaces.
OverrideStatus *JS2Metadata::searchForOverrides(JS2Class *c, const StringAtom &id, NamespaceList *namespaces, Access access, size_t pos)
OverrideStatus *JS2Metadata::searchForOverrides(JS2Class *c, const StringAtom *id, NamespaceList *namespaces, Access access, size_t pos)
{
OverrideStatus *os = new OverrideStatus(NULL, id);
for (NamespaceListIterator ns = namespaces->begin(), end = namespaces->end(); (ns != end); ns++) {
QualifiedName qname(*ns, id);
QualifiedName qname(*ns, *id);
InstanceMember *m = findInstanceMember(c, &qname, access);
if (m) {
os->multiname.addNamespace(*ns);
@ -2040,7 +2042,7 @@ doUnary:
// Find the possible override conflicts that arise from the given id and namespaces
// Fall back on the currently open namespace list if no others are specified.
OverrideStatus *JS2Metadata::resolveOverrides(JS2Class *c, Context *cxt, const StringAtom &id, NamespaceList *namespaces, Access access, bool expectMethod, size_t pos)
OverrideStatus *JS2Metadata::resolveOverrides(JS2Class *c, Context *cxt, const StringAtom *id, NamespaceList *namespaces, Access access, bool expectMethod, size_t pos)
{
OverrideStatus *os = NULL;
if ((namespaces == NULL) || namespaces->empty()) {
@ -2074,17 +2076,17 @@ doUnary:
}
// For all the discovered possible overrides, make sure the member doesn't already exist in the class
for (NamespaceListIterator nli = os->multiname.nsList.begin(), nlend = os->multiname.nsList.end(); (nli != nlend); nli++) {
QualifiedName qname(*nli, id);
QualifiedName qname(*nli, *id);
if (access & ReadAccess) {
for (InstanceBindingIterator b = c->instanceReadBindings.lower_bound(id),
end = c->instanceReadBindings.upper_bound(id); (b != end); b++) {
for (InstanceBindingIterator b = c->instanceReadBindings.lower_bound(*id),
end = c->instanceReadBindings.upper_bound(*id); (b != end); b++) {
if (qname == b->second->qname)
reportError(Exception::definitionError, "Illegal override", pos);
}
}
if (access & WriteAccess) {
for (InstanceBindingIterator b = c->instanceWriteBindings.lower_bound(id),
end = c->instanceWriteBindings.upper_bound(id); (b != end); b++) {
for (InstanceBindingIterator b = c->instanceWriteBindings.lower_bound(*id),
end = c->instanceWriteBindings.upper_bound(*id); (b != end); b++) {
if (qname == b->second->qname)
reportError(Exception::definitionError, "Illegal override", pos);
}
@ -2105,7 +2107,7 @@ doUnary:
// Define an instance member in the class. Verify that, if any overriding is happening, it's legal. The result pair indicates
// the members being overridden.
OverrideStatusPair *JS2Metadata::defineInstanceMember(JS2Class *c, Context *cxt, const StringAtom &id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, InstanceMember *m, size_t pos)
OverrideStatusPair *JS2Metadata::defineInstanceMember(JS2Class *c, Context *cxt, const StringAtom *id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, InstanceMember *m, size_t pos)
{
OverrideStatus *readStatus;
OverrideStatus *writeStatus;
@ -2136,16 +2138,16 @@ doUnary:
NamespaceListIterator nli, nlend;
for (nli = readStatus->multiname.nsList.begin(), nlend = readStatus->multiname.nsList.end(); (nli != nlend); nli++) {
QualifiedName qName(*nli, id);
QualifiedName qName(*nli, *id);
InstanceBinding *ib = new InstanceBinding(qName, m);
const InstanceBindingMap::value_type e(id, ib);
const InstanceBindingMap::value_type e(*id, ib);
c->instanceReadBindings.insert(e);
}
for (nli = writeStatus->multiname.nsList.begin(), nlend = writeStatus->multiname.nsList.end(); (nli != nlend); nli++) {
QualifiedName qName(*nli, id);
QualifiedName qName(*nli, *id);
InstanceBinding *ib = new InstanceBinding(qName, m);
const InstanceBindingMap::value_type e(id, ib);
const InstanceBindingMap::value_type e(*id, ib);
c->instanceWriteBindings.insert(e);
}
@ -2153,9 +2155,9 @@ doUnary:
}
// Define a hoisted var in the current frame (either Global or a Function)
void JS2Metadata::defineHoistedVar(Environment *env, const StringAtom &id, StmtNode *p)
void JS2Metadata::defineHoistedVar(Environment *env, const StringAtom *id, StmtNode *p)
{
QualifiedName qName(publicNamespace, id);
QualifiedName qName(publicNamespace, *id);
Frame *regionalFrame = env->getRegionalFrame();
ASSERT((env->getTopFrame()->kind == GlobalObjectKind) || (env->getTopFrame()->kind == ParameterKind));
@ -2163,8 +2165,8 @@ doUnary:
// variable already exists.
StaticBindingIterator b, end;
bool existing = false;
for (b = regionalFrame->staticReadBindings.lower_bound(id),
end = regionalFrame->staticReadBindings.upper_bound(id); (b != end); b++) {
for (b = regionalFrame->staticReadBindings.lower_bound(*id),
end = regionalFrame->staticReadBindings.upper_bound(*id); (b != end); b++) {
if (b->second->qname == qName) {
if (b->second->content->kind != StaticMember::HoistedVariable)
reportError(Exception::definitionError, "Duplicate definition {0}", p->pos, id);
@ -2174,8 +2176,8 @@ doUnary:
}
}
}
for (b = regionalFrame->staticWriteBindings.lower_bound(id),
end = regionalFrame->staticWriteBindings.upper_bound(id); (b != end); b++) {
for (b = regionalFrame->staticWriteBindings.lower_bound(*id),
end = regionalFrame->staticWriteBindings.upper_bound(*id); (b != end); b++) {
if (b->second->qname == qName) {
if (b->second->content->kind != StaticMember::HoistedVariable)
reportError(Exception::definitionError, "Duplicate definition {0}", p->pos, id);
@ -2188,13 +2190,13 @@ doUnary:
if (!existing) {
if (regionalFrame->kind == GlobalObjectKind) {
GlobalObject *gObj = checked_cast<GlobalObject *>(regionalFrame);
DynamicPropertyIterator dp = gObj->dynamicProperties.find(id);
DynamicPropertyIterator dp = gObj->dynamicProperties.find(*id);
if (dp != gObj->dynamicProperties.end())
reportError(Exception::definitionError, "Duplicate definition {0}", p->pos, id);
}
// XXX ok to use same binding in read & write maps?
StaticBinding *sb = new StaticBinding(qName, new HoistedVar());
const StaticBindingMap::value_type e(id, sb);
const StaticBindingMap::value_type e(*id, sb);
// XXX ok to use same value_type in different multimaps?
regionalFrame->staticReadBindings.insert(e);
@ -2205,7 +2207,7 @@ doUnary:
js2val Object_toString(JS2Metadata *meta, const js2val thisValue, js2val argv[], uint32 argc)
{
return STRING_TO_JS2VAL(&meta->engine->object_StringAtom);
return STRING_TO_JS2VAL(meta->engine->object_StringAtom);
}
js2val RegExp_Constructor(JS2Metadata *meta, const js2val thisValue, js2val *argv, uint32 argc)
@ -2215,8 +2217,8 @@ doUnary:
js2val thatValue = OBJECT_TO_JS2VAL(thisInst);
REuint32 flags = 0;
const String *regexpStr = &meta->engine->Empty_StringAtom;
const String *flagStr = &meta->engine->Empty_StringAtom;
const String *regexpStr = meta->engine->Empty_StringAtom;
const String *flagStr = meta->engine->Empty_StringAtom;
if (argc > 0) {
if (meta->objectType(argv[0]) == meta->regexpClass) {
if ((argc == 1) || JS2VAL_IS_UNDEFINED(argv[1])) {
@ -2271,17 +2273,17 @@ doUnary:
MAKEBUILTINCLASS(objectClass, NULL, false, true, false, engine->object_StringAtom);
MAKEBUILTINCLASS(undefinedClass, objectClass, false, false, true, engine->undefined_StringAtom);
MAKEBUILTINCLASS(nullClass, objectClass, false, true, true, engine->null_StringAtom);
MAKEBUILTINCLASS(booleanClass, objectClass, false, false, true, world.identifiers["boolean"]);
MAKEBUILTINCLASS(generalNumberClass, objectClass, false, false, false, world.identifiers["general number"]);
MAKEBUILTINCLASS(numberClass, generalNumberClass, false, false, true, world.identifiers["number"]);
MAKEBUILTINCLASS(characterClass, objectClass, false, false, true, world.identifiers["character"]);
MAKEBUILTINCLASS(stringClass, objectClass, false, false, true, world.identifiers["string"]);
MAKEBUILTINCLASS(namespaceClass, objectClass, false, true, true, world.identifiers["namespace"]);
MAKEBUILTINCLASS(attributeClass, objectClass, false, true, true, world.identifiers["attribute"]);
MAKEBUILTINCLASS(classClass, objectClass, false, true, true, world.identifiers["class"]);
MAKEBUILTINCLASS(booleanClass, objectClass, false, false, true, &world.identifiers["boolean"]);
MAKEBUILTINCLASS(generalNumberClass, objectClass, false, false, false, &world.identifiers["general number"]);
MAKEBUILTINCLASS(numberClass, generalNumberClass, false, false, true, &world.identifiers["number"]);
MAKEBUILTINCLASS(characterClass, objectClass, false, false, true, &world.identifiers["character"]);
MAKEBUILTINCLASS(stringClass, objectClass, false, false, true, &world.identifiers["string"]);
MAKEBUILTINCLASS(namespaceClass, objectClass, false, true, true, &world.identifiers["namespace"]);
MAKEBUILTINCLASS(attributeClass, objectClass, false, true, true, &world.identifiers["attribute"]);
MAKEBUILTINCLASS(classClass, objectClass, false, true, true, &world.identifiers["class"]);
MAKEBUILTINCLASS(functionClass, objectClass, false, true, true, engine->function_StringAtom);
MAKEBUILTINCLASS(prototypeClass, objectClass, true, true, true, world.identifiers["prototype"]);
MAKEBUILTINCLASS(packageClass, objectClass, true, true, true, world.identifiers["package"]);
MAKEBUILTINCLASS(prototypeClass, objectClass, true, true, true, &world.identifiers["prototype"]);
MAKEBUILTINCLASS(packageClass, objectClass, true, true, true, &world.identifiers["package"]);
// A 'forbidden' member, used to mark hidden bindings
forbiddenMember = new StaticMember(Member::Forbidden);
@ -2289,39 +2291,39 @@ doUnary:
// Non-function properties of the global object : 'undefined', 'NaN' and 'Infinity'
// XXX Or are these fixed properties?
writeDynamicProperty(glob, new Multiname(engine->undefined_StringAtom, publicNamespace), true, JS2VAL_UNDEFINED, RunPhase);
writeDynamicProperty(glob, new Multiname(world.identifiers["NaN"], publicNamespace), true, engine->nanValue, RunPhase);
writeDynamicProperty(glob, new Multiname(world.identifiers["Infinity"], publicNamespace), true, engine->posInfValue, RunPhase);
writeDynamicProperty(glob, new Multiname(&world.identifiers["NaN"], publicNamespace), true, engine->nanValue, RunPhase);
writeDynamicProperty(glob, new Multiname(&world.identifiers["Infinity"], publicNamespace), true, engine->posInfValue, RunPhase);
// Function properties of the Object prototype object
objectClass->prototype = new PrototypeInstance(NULL, objectClass);
// XXX Or make this a static class members?
FixedInstance *fInst = new FixedInstance(functionClass);
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), Object_toString);
writeDynamicProperty(objectClass->prototype, new Multiname(world.identifiers["toString"], publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
writeDynamicProperty(objectClass->prototype, new Multiname(&world.identifiers["toString"], publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
NamespaceList publicNamespaceList;
publicNamespaceList.push_back(publicNamespace);
Variable *v;
MAKEBUILTINCLASS(dateClass, objectClass, true, true, true, world.identifiers["Date"]);
MAKEBUILTINCLASS(dateClass, objectClass, true, true, true, &world.identifiers["Date"]);
v = new Variable(classClass, OBJECT_TO_JS2VAL(dateClass), true);
defineStaticMember(&env, world.identifiers["Date"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
defineStaticMember(&env, &world.identifiers["Date"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
// dateClass->prototype = new PrototypeInstance(NULL, dateClass);
initDateObject(this);
MAKEBUILTINCLASS(regexpClass, objectClass, true, true, true, world.identifiers["RegExp"]);
MAKEBUILTINCLASS(regexpClass, objectClass, true, true, true, &world.identifiers["RegExp"]);
v = new Variable(classClass, OBJECT_TO_JS2VAL(regexpClass), true);
defineStaticMember(&env, world.identifiers["RegExp"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
defineStaticMember(&env, &world.identifiers["RegExp"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
regexpClass->construct = RegExp_Constructor;
v = new Variable(classClass, OBJECT_TO_JS2VAL(stringClass), true);
defineStaticMember(&env, world.identifiers["String"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
defineStaticMember(&env, &world.identifiers["String"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
// stringClass->prototype = new PrototypeInstance(NULL, stringClass);
initStringObject(this);
MAKEBUILTINCLASS(mathClass, objectClass, true, true, true, world.identifiers["Math"]);
MAKEBUILTINCLASS(mathClass, objectClass, true, true, true, &world.identifiers["Math"]);
v = new Variable(classClass, OBJECT_TO_JS2VAL(mathClass), true);
defineStaticMember(&env, world.identifiers["Math"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
defineStaticMember(&env, &world.identifiers["Math"], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, 0);
initMathObject(this);
@ -2386,7 +2388,7 @@ doUnary:
|| (container->kind == PrototypeInstanceKind)));
if (!multiname->onList(publicNamespace))
return false;
const StringAtom &name = multiname->name;
const String *name = multiname->name;
if (phase == CompilePhase)
reportError(Exception::compileExpressionError, "Inappropriate compile time expression", engine->errorPos());
DynamicPropertyMap *dMap = NULL;
@ -2401,13 +2403,15 @@ doUnary:
dMap = &(checked_cast<PrototypeInstance *>(container))->dynamicProperties;
}
for (DynamicPropertyIterator i = dMap->begin(), end = dMap->end(); (i != end); i++) {
if (i->first == name) {
if (i->first == *name) {
*rval = i->second;
return true;
}
}
if (isPrototypeInstance) {
return readDynamicProperty((checked_cast<PrototypeInstance *>(container))->parent, multiname, lookupKind, phase, rval);
PrototypeInstance *pInst = checked_cast<PrototypeInstance *>(container);
if (pInst->parent)
return readDynamicProperty(pInst->parent, multiname, lookupKind, phase, rval);
}
if (lookupKind->isPropertyLookup()) {
*rval = JS2VAL_UNDEFINED;
@ -2424,7 +2428,7 @@ doUnary:
|| (container->kind == PrototypeInstanceKind)));
if (!multiname->onList(publicNamespace))
return false;
const StringAtom &name = multiname->name;
const String *name = multiname->name;
DynamicPropertyMap *dMap = NULL;
if (container->kind == DynamicInstanceKind)
dMap = &(checked_cast<DynamicInstance *>(container))->dynamicProperties;
@ -2434,7 +2438,7 @@ doUnary:
else
dMap = &(checked_cast<PrototypeInstance *>(container))->dynamicProperties;
for (DynamicPropertyIterator i = dMap->begin(), end = dMap->end(); (i != end); i++) {
if (i->first == name) {
if (i->first == *name) {
i->second = newValue;
return true;
}
@ -2445,7 +2449,7 @@ doUnary:
DynamicInstance *dynInst = checked_cast<DynamicInstance *>(container);
InstanceBinding *ib = resolveInstanceMemberName(dynInst->type, multiname, ReadAccess, phase);
if (ib == NULL) {
const DynamicPropertyMap::value_type e(name, newValue);
const DynamicPropertyMap::value_type e(*name, newValue);
dynInst->dynamicProperties.insert(e);
return true;
}
@ -2455,14 +2459,14 @@ doUnary:
GlobalObject *glob = checked_cast<GlobalObject *>(container);
StaticMember *m = findFlatMember(glob, multiname, ReadAccess, phase);
if (m == NULL) {
const DynamicPropertyMap::value_type e(name, newValue);
const DynamicPropertyMap::value_type e(*name, newValue);
glob->dynamicProperties.insert(e);
return true;
}
}
else {
PrototypeInstance *pInst = checked_cast<PrototypeInstance *>(container);
const DynamicPropertyMap::value_type e(name, newValue);
const DynamicPropertyMap::value_type e(*name, newValue);
pInst->dynamicProperties.insert(e);
return true;
}
@ -2835,7 +2839,7 @@ deleteClassProperty:
|| (container->kind == PrototypeInstanceKind)));
if (!multiname->onList(publicNamespace))
return false;
const StringAtom &name = multiname->name;
const String *name = multiname->name;
DynamicPropertyMap *dMap = NULL;
if (container->kind == DynamicInstanceKind)
dMap = &(checked_cast<DynamicInstance *>(container))->dynamicProperties;
@ -2846,7 +2850,7 @@ deleteClassProperty:
dMap = &(checked_cast<PrototypeInstance *>(container))->dynamicProperties;
}
for (DynamicPropertyIterator i = dMap->begin(), end = dMap->end(); (i != end); i++) {
if (i->first == name) {
if (i->first == *name) {
dMap->erase(i);
*result = true;
return true;
@ -2890,19 +2894,19 @@ deleteClassProperty:
StaticMember *found = NULL;
StaticBindingIterator b, end;
if (access & ReadAccess) {
b = container->staticReadBindings.lower_bound(multiname->name);
end = container->staticReadBindings.upper_bound(multiname->name);
b = container->staticReadBindings.lower_bound(*multiname->name);
end = container->staticReadBindings.upper_bound(*multiname->name);
}
else {
b = container->staticWriteBindings.lower_bound(multiname->name);
end = container->staticWriteBindings.upper_bound(multiname->name);
b = container->staticWriteBindings.lower_bound(*multiname->name);
end = container->staticWriteBindings.upper_bound(*multiname->name);
}
while (true) {
if (b == end) {
if (access == ReadWriteAccess) {
access = WriteAccess;
b = container->staticWriteBindings.lower_bound(multiname->name);
end = container->staticWriteBindings.upper_bound(multiname->name);
b = container->staticWriteBindings.lower_bound(*multiname->name);
end = container->staticWriteBindings.upper_bound(*multiname->name);
continue;
}
else
@ -2927,12 +2931,12 @@ deleteClassProperty:
while (s) {
StaticBindingIterator b, end;
if (access & ReadAccess) {
b = s->staticReadBindings.lower_bound(multiname->name);
end = s->staticReadBindings.upper_bound(multiname->name);
b = s->staticReadBindings.lower_bound(*multiname->name);
end = s->staticReadBindings.upper_bound(*multiname->name);
}
else {
b = s->staticWriteBindings.lower_bound(multiname->name);
end = s->staticWriteBindings.upper_bound(multiname->name);
b = s->staticWriteBindings.lower_bound(*multiname->name);
end = s->staticWriteBindings.upper_bound(*multiname->name);
}
StaticMember *found = NULL;
while (b != end) {
@ -2953,12 +2957,12 @@ deleteClassProperty:
InstanceBinding *iFound = NULL;
InstanceBindingIterator ib, iend;
if (access & ReadAccess) {
ib = s->instanceReadBindings.lower_bound(multiname->name);
iend = s->instanceReadBindings.upper_bound(multiname->name);
ib = s->instanceReadBindings.lower_bound(*multiname->name);
iend = s->instanceReadBindings.upper_bound(*multiname->name);
}
else {
ib = s->instanceWriteBindings.lower_bound(multiname->name);
iend = s->instanceWriteBindings.upper_bound(multiname->name);
ib = s->instanceWriteBindings.lower_bound(*multiname->name);
iend = s->instanceWriteBindings.upper_bound(*multiname->name);
}
while (ib != iend) {
if (multiname->matches(ib->second->qname)) {
@ -2993,19 +2997,19 @@ deleteClassProperty:
}
InstanceBindingIterator b, end;
if (access & ReadAccess) {
b = c->instanceReadBindings.lower_bound(multiname->name);
end = c->instanceReadBindings.upper_bound(multiname->name);
b = c->instanceReadBindings.lower_bound(*multiname->name);
end = c->instanceReadBindings.upper_bound(*multiname->name);
}
else {
b = c->instanceWriteBindings.lower_bound(multiname->name);
end = c->instanceWriteBindings.upper_bound(multiname->name);
b = c->instanceWriteBindings.lower_bound(*multiname->name);
end = c->instanceWriteBindings.upper_bound(*multiname->name);
}
while (true) {
if (b == end) {
if (access == ReadWriteAccess) {
access = WriteAccess;
b = c->instanceWriteBindings.lower_bound(multiname->name);
end = c->instanceWriteBindings.upper_bound(multiname->name);
b = c->instanceWriteBindings.lower_bound(*multiname->name);
end = c->instanceWriteBindings.upper_bound(*multiname->name);
continue;
}
else
@ -3085,13 +3089,21 @@ deleteClassProperty:
inline char narrow(char16 ch) { return char(ch); }
// Accepts a String as the error argument and converts to char *
void JS2Metadata::reportError(Exception::Kind kind, const char *message, size_t pos, const String& name)
void JS2Metadata::reportError(Exception::Kind kind, const char *message, size_t pos, const String &name)
{
std::string str(name.length(), char());
std::transform(name.begin(), name.end(), str.begin(), narrow);
reportError(kind, message, pos, str.c_str());
}
// Accepts a String * as the error argument and converts to char *
void JS2Metadata::reportError(Exception::Kind kind, const char *message, size_t pos, const String *name)
{
std::string str(name->length(), char());
std::transform(name->begin(), name->end(), str.begin(), narrow);
reportError(kind, message, pos, str.c_str());
}
/************************************************************************************
*
* JS2Class
@ -3099,7 +3111,7 @@ deleteClassProperty:
************************************************************************************/
JS2Class::JS2Class(JS2Class *super, JS2Object *proto, Namespace *privateNamespace, bool dynamic, bool allowNull, bool final, const StringAtom &name)
JS2Class::JS2Class(JS2Class *super, JS2Object *proto, Namespace *privateNamespace, bool dynamic, bool allowNull, bool final, const String *name)
: Frame(ClassKind),
instanceInitOrder(NULL),
complete(false),
@ -3458,6 +3470,9 @@ deleteClassProperty:
GCMARKOBJECT(obj);
}
else
if (JS2VAL_IS_STRING(v))
JS2Object::mark(JS2VAL_TO_STRING(v));
else
if (JS2VAL_IS_DOUBLE(v))
JS2Object::mark(JS2VAL_TO_DOUBLE(v));
else

Просмотреть файл

@ -158,7 +158,7 @@ public:
bool isMarked() { return ((PondScum *)this)[-1].isMarked(); }
void mark() { ((PondScum *)this)[-1].mark(); }
static void mark(void *p) { ((PondScum *)p)[-1].mark(); }
static void mark(const void *p) { ((PondScum *)p)[-1].mark(); }
static void markJS2Value(js2val v);
};
@ -183,11 +183,11 @@ public:
// A Namespace (is also an attribute)
class Namespace : public Attribute {
public:
Namespace(const StringAtom &name) : Attribute(NamespaceAttr), name(name) { }
Namespace(const String *name) : Attribute(NamespaceAttr), name(name) { }
virtual CompoundAttribute *toCompoundAttribute();
const StringAtom &name; // The namespace's name used by toString
const String *name; // The namespace's name used by toString
};
// A QualifiedName is the combination of an identifier and a namespace
@ -208,18 +208,18 @@ typedef std::vector<Namespace *> NamespaceList;
typedef NamespaceList::iterator NamespaceListIterator;
class Multiname : public JS2Object {
public:
Multiname(const StringAtom &name) : JS2Object(MultinameKind), name(name) { }
Multiname(const StringAtom &name, Namespace *ns) : JS2Object(MultinameKind), name(name) { addNamespace(ns); }
Multiname(const String *name) : JS2Object(MultinameKind), name(name) { }
Multiname(const String *name, Namespace *ns) : JS2Object(MultinameKind), name(name) { addNamespace(ns); }
void addNamespace(Namespace *ns) { nsList.push_back(ns); }
void addNamespace(NamespaceList *ns);
void addNamespace(Context &cxt);
bool matches(QualifiedName &q) { return (name == q.id) && onList(q.nameSpace); }
bool matches(QualifiedName &q) { return (*name == q.id) && onList(q.nameSpace); }
bool onList(Namespace *nameSpace);
NamespaceList nsList;
const StringAtom &name;
const String *name;
virtual void markChildren();
};
@ -388,7 +388,7 @@ public:
#define POTENTIAL_CONFLICT ((InstanceMember *)(-1))
class OverrideStatus {
public:
OverrideStatus(InstanceMember *overriddenMember, const StringAtom &name)
OverrideStatus(InstanceMember *overriddenMember, const StringAtom *name)
: overriddenMember(overriddenMember), multiname(name) { }
InstanceMember *overriddenMember; // NULL for none
@ -432,9 +432,9 @@ public:
class JS2Class : public Frame {
public:
JS2Class(JS2Class *super, JS2Object *proto, Namespace *privateNamespace, bool dynamic, bool allowNull, bool final, const StringAtom &name);
JS2Class(JS2Class *super, JS2Object *proto, Namespace *privateNamespace, bool dynamic, bool allowNull, bool final, const String *name);
const StringAtom &getName() { return name; }
const String *getName() { return name; }
InstanceBindingMap instanceReadBindings; // Map of qualified names to readable instance members defined in this class
InstanceBindingMap instanceWriteBindings; // Map of qualified names to writable instance members defined in this class
@ -457,7 +457,7 @@ public:
uint32 slotCount;
const StringAtom &name;
const String *name;
virtual void instantiate(Environment * /* env */) { } // nothing to do
virtual void markChildren();
@ -466,7 +466,7 @@ public:
class GlobalObject : public Frame {
public:
GlobalObject(World &world) : Frame(GlobalObjectKind), internalNamespace(new Namespace(world.identifiers["internal"])) { }
GlobalObject(World &world) : Frame(GlobalObjectKind), internalNamespace(new Namespace(&world.identifiers["internal"])) { }
Namespace *internalNamespace; // This global object's internal namespace
DynamicPropertyMap dynamicProperties; // A set of this global object's dynamic properties
@ -492,7 +492,7 @@ public:
Invokable *call; // A procedure to call when this instance is used in a call expression
Invokable *construct; // A procedure to call when this instance is used in a new expression
Environment *env; // The environment to pass to the call or construct procedure
const StringAtom &typeofString; // A string to return if typeof is invoked on this instance
const String *typeofString; // A string to return if typeof is invoked on this instance
Slot *slots; // A set of slots that hold this instance's fixed property values
virtual void markChildren();
};
@ -506,7 +506,7 @@ public:
Invokable *call; // A procedure to call when this instance is used in a call expression
Invokable *construct; // A procedure to call when this instance is used in a new expression
Environment *env; // The environment to pass to the call or construct procedure
const StringAtom &typeofString; // A string to return if typeof is invoked on this instance
const String *typeofString; // A string to return if typeof is invoked on this instance
Slot *slots; // A set of slots that hold this instance's fixed property values
DynamicPropertyMap dynamicProperties; // A set of this instance's dynamic properties
virtual void markChildren();
@ -604,8 +604,8 @@ class LexicalReference : public Reference {
// of a given set of qualified names. LEXICALREFERENCE tuples arise from evaluating identifiers a and qualified identifiers
// q::a.
public:
LexicalReference(const StringAtom &name, bool strict) : variableMultiname(new Multiname(name)), env(NULL), strict(strict) { }
LexicalReference(const StringAtom &name, Namespace *nameSpace, bool strict) : variableMultiname(new Multiname(name, nameSpace)), env(NULL), strict(strict) { }
LexicalReference(const StringAtom *name, bool strict) : variableMultiname(new Multiname(name)), env(NULL), strict(strict) { }
LexicalReference(const StringAtom *name, Namespace *nameSpace, bool strict) : variableMultiname(new Multiname(name, nameSpace)), env(NULL), strict(strict) { }
Multiname *variableMultiname; // A nonempty set of qualified names to which this reference can refer
@ -634,7 +634,7 @@ class DotReference : public Reference {
// object with one of a given set of qualified names. DOTREFERENCE tuples arise from evaluating subexpressions such as a.b or
// a.q::b.
public:
DotReference(const StringAtom &name) : propertyMultiname(new Multiname(name)) { }
DotReference(const StringAtom *name) : propertyMultiname(new Multiname(name)) { }
DotReference(Multiname *mn) : propertyMultiname(mn) { }
// In this implementation, the base is established by the execution of the preceding expression and
@ -883,11 +883,11 @@ public:
StaticMember *findFlatMember(Frame *container, Multiname *multiname, Access access, Phase phase);
InstanceBinding *resolveInstanceMemberName(JS2Class *js2class, Multiname *multiname, Access access, Phase phase);
void defineHoistedVar(Environment *env, const StringAtom &id, StmtNode *p);
Multiname *defineStaticMember(Environment *env, const StringAtom &id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, StaticMember *m, size_t pos);
OverrideStatusPair *defineInstanceMember(JS2Class *c, Context *cxt, const StringAtom &id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, InstanceMember *m, size_t pos);
OverrideStatus *resolveOverrides(JS2Class *c, Context *cxt, const StringAtom &id, NamespaceList *namespaces, Access access, bool expectMethod, size_t pos);
OverrideStatus *searchForOverrides(JS2Class *c, const StringAtom &id, NamespaceList *namespaces, Access access, size_t pos);
void defineHoistedVar(Environment *env, const StringAtom *id, StmtNode *p);
Multiname *defineStaticMember(Environment *env, const StringAtom *id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, StaticMember *m, size_t pos);
OverrideStatusPair *defineInstanceMember(JS2Class *c, Context *cxt, const StringAtom *id, NamespaceList *namespaces, Attribute::OverrideModifier overrideMod, bool xplicit, Access access, InstanceMember *m, size_t pos);
OverrideStatus *resolveOverrides(JS2Class *c, Context *cxt, const StringAtom *id, NamespaceList *namespaces, Access access, bool expectMethod, size_t pos);
OverrideStatus *searchForOverrides(JS2Class *c, const StringAtom *id, NamespaceList *namespaces, Access access, size_t pos);
InstanceMember *findInstanceMember(JS2Class *c, QualifiedName *qname, Access access);
Slot *findSlot(js2val thisObjVal, InstanceVariable *id);
bool findStaticMember(JS2Class *c, Multiname *multiname, Access access, Phase phase, MemberDescriptor *result);
@ -913,7 +913,8 @@ public:
bool deleteInstanceMember(JS2Class *c, QualifiedName *qname, bool *result);
void reportError(Exception::Kind kind, const char *message, size_t pos, const char *arg = NULL);
void reportError(Exception::Kind kind, const char *message, size_t pos, const String& name);
void reportError(Exception::Kind kind, const char *message, size_t pos, const String &name);
void reportError(Exception::Kind kind, const char *message, size_t pos, const String *name);
// Used for interning strings

Просмотреть файл

@ -108,8 +108,8 @@
LookupKind lookup(false, NULL);
indexVal = pop();
b = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(b, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
push(a);
@ -125,8 +125,8 @@
a = pop();
indexVal = pop();
b = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
meta->writeProperty(b, &mn, &lookup, true, a, RunPhase);
push(a);
indexVal = JS2VAL_VOID;
@ -139,8 +139,8 @@
LookupKind lookup(false, NULL);
indexVal = pop();
b = top();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(b, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
push(a);
@ -154,9 +154,9 @@
LookupKind lookup(false, NULL);
indexVal = pop();
b = top();
String *indexStr = toString(indexVal);
const String *indexStr = toString(indexVal);
push(STRING_TO_JS2VAL(indexStr));
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(b, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
push(a);
@ -172,7 +172,7 @@
indexVal = pop();
ASSERT(JS2VAL_IS_STRING(indexVal));
b = pop();
Multiname mn(meta->world.identifiers[*JS2VAL_TO_STRING(indexVal)], meta->publicNamespace);
Multiname mn(&meta->world.identifiers[*JS2VAL_TO_STRING(indexVal)], meta->publicNamespace);
meta->writeProperty(b, &mn, &lookup, true, a, RunPhase);
push(a);
indexVal = JS2VAL_VOID;

Просмотреть файл

@ -182,9 +182,9 @@
a = toPrimitive(a);
b = toPrimitive(b);
if (JS2VAL_IS_STRING(a) || JS2VAL_IS_STRING(b)) {
String *astr = toString(a);
String *bstr = toString(b);
String *c = new String(*astr);
const String *astr = toString(a);
const String *bstr = toString(b);
String *c = allocStringPtr(astr);
*c += *bstr;
push(STRING_TO_JS2VAL(c));
}
@ -461,9 +461,9 @@
a = toPrimitive(a);
b = toPrimitive(b);
if (JS2VAL_IS_STRING(a) || JS2VAL_IS_STRING(b)) {
String *astr = toString(a);
String *bstr = toString(b);
String *c = new String(*astr);
const String *astr = toString(a);
const String *bstr = toString(b);
String *c = allocStringPtr(astr);
*c += *bstr;
a = STRING_TO_JS2VAL(c);
}
@ -612,9 +612,9 @@
a = toPrimitive(a);
b = toPrimitive(b);
if (JS2VAL_IS_STRING(a) || JS2VAL_IS_STRING(b)) {
String *astr = toString(a);
String *bstr = toString(b);
String *c = new String(*astr);
const String *astr = toString(a);
const String *bstr = toString(b);
String *c = allocStringPtr(astr);
*c += *bstr;
a = STRING_TO_JS2VAL(c);
}
@ -771,8 +771,8 @@
b = pop();
indexVal = pop();
baseVal = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
switch (op) {
@ -781,9 +781,9 @@
a = toPrimitive(a);
b = toPrimitive(b);
if (JS2VAL_IS_STRING(a) || JS2VAL_IS_STRING(b)) {
String *astr = toString(a);
String *bstr = toString(b);
String *c = new String(*astr);
const String *astr = toString(a);
const String *bstr = toString(b);
String *c = allocStringPtr(astr);
*c += *bstr;
a = STRING_TO_JS2VAL(c);
}
@ -882,8 +882,8 @@ case eBracketPostInc:
LookupKind lookup(false, NULL);
indexVal = pop();
baseVal = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
float64 num = toFloat64(a);
@ -898,8 +898,8 @@ case eBracketPostInc:
LookupKind lookup(false, NULL);
indexVal = pop();
baseVal = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
float64 num = toFloat64(a);
@ -914,8 +914,8 @@ case eBracketPostInc:
LookupKind lookup(false, NULL);
indexVal = pop();
baseVal = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
float64 num = toFloat64(a);
@ -930,8 +930,8 @@ case eBracketPostInc:
LookupKind lookup(false, NULL);
indexVal = pop();
baseVal = pop();
String *indexStr = toString(indexVal);
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
const String *indexStr = toString(indexVal);
Multiname mn(&meta->world.identifiers[*indexStr], meta->publicNamespace);
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
float64 num = toFloat64(a);

Просмотреть файл

@ -163,42 +163,42 @@
{
a = pop();
if (JS2VAL_IS_UNDEFINED(a))
a = STRING_TO_JS2VAL(&undefined_StringAtom);
a = STRING_TO_JS2VAL(undefined_StringAtom);
else
if (JS2VAL_IS_BOOLEAN(a))
a = STRING_TO_JS2VAL(&meta->world.identifiers["boolean"]);
a = allocString("boolean");
else
if (JS2VAL_IS_NUMBER(a))
a = STRING_TO_JS2VAL(&meta->world.identifiers["number"]);
a = allocString("number");
else
if (JS2VAL_IS_STRING(a))
a = STRING_TO_JS2VAL(&meta->world.identifiers["string"]);
a = allocString("string");
else {
ASSERT(JS2VAL_IS_OBJECT(a));
if (JS2VAL_IS_NULL(a))
a = STRING_TO_JS2VAL(&object_StringAtom);
a = STRING_TO_JS2VAL(object_StringAtom);
JS2Object *obj = JS2VAL_TO_OBJECT(a);
switch (obj->kind) {
case MultinameKind:
a = STRING_TO_JS2VAL(&meta->world.identifiers["namespace"]);
a = allocString("namespace");
break;
case AttributeObjectKind:
a = STRING_TO_JS2VAL(&meta->world.identifiers["attribute"]);
a = allocString("attribute");
break;
case ClassKind:
case MethodClosureKind:
a = STRING_TO_JS2VAL(&function_StringAtom);
a = STRING_TO_JS2VAL(function_StringAtom);
break;
case PrototypeInstanceKind:
case PackageKind:
case GlobalObjectKind:
a = STRING_TO_JS2VAL(&object_StringAtom);
a = STRING_TO_JS2VAL(object_StringAtom);
break;
case FixedInstanceKind:
a = STRING_TO_JS2VAL(&checked_cast<FixedInstance *>(obj)->typeofString);
a = STRING_TO_JS2VAL(checked_cast<FixedInstance *>(obj)->typeofString);
break;
case DynamicInstanceKind:
a = STRING_TO_JS2VAL(&checked_cast<DynamicInstance *>(obj)->typeofString);
a = STRING_TO_JS2VAL(checked_cast<DynamicInstance *>(obj)->typeofString);
break;
}
}

Просмотреть файл

@ -68,7 +68,7 @@
case eString:
{
push(STRING_TO_JS2VAL(BytecodeContainer::getString(pc)));
push(STRING_TO_JS2VAL(allocString(BytecodeContainer::getString(pc))));
pc += sizeof(String *);
}
break;

Просмотреть файл

@ -146,15 +146,14 @@ namespace MetaData {
if (match) {
PrototypeInstance *A = new PrototypeInstance(meta->objectClass->prototype, meta->objectClass);
result = OBJECT_TO_JS2VAL(A);
String *matchStr = new String(str->substr((uint32)match->startIndex, (uint32)match->endIndex - match->startIndex));
Multiname mname(meta->world.identifiers[*numberToString((long)0)], meta->publicNamespace);
meta->writeDynamicProperty(A, &mname, true, STRING_TO_JS2VAL(matchStr), RunPhase);
String *parenStr = &meta->engine->Empty_StringAtom;
js2val matchStr = meta->engine->allocString(str->substr((uint32)match->startIndex, (uint32)match->endIndex - match->startIndex));
Multiname mname(&meta->world.identifiers[*numberToString((long)0)], meta->publicNamespace);
meta->writeDynamicProperty(A, &mname, true, matchStr, RunPhase);
for (int32 i = 0; i < match->parenCount; i++) {
Multiname mname(meta->world.identifiers[*numberToString(i + 1)], meta->publicNamespace);
Multiname mname(&meta->world.identifiers[*numberToString(i + 1)], meta->publicNamespace);
if (match->parens[i].index != -1) {
String *parenStr = new String(str->substr((uint32)(match->parens[i].index), (uint32)(match->parens[i].length)));
meta->writeDynamicProperty(A, &mname, true, STRING_TO_JS2VAL(parenStr), RunPhase);
js2val parenStr = meta->engine->allocString(str->substr((uint32)(match->parens[i].index), (uint32)(match->parens[i].length)));
meta->writeDynamicProperty(A, &mname, true, parenStr, RunPhase);
}
else
meta->writeDynamicProperty(A, &mname, true, JS2VAL_UNDEFINED, RunPhase);

Просмотреть файл

@ -63,15 +63,15 @@ js2val String_Constructor(JS2Metadata *meta, const js2val thisValue, js2val *arg
StringInstance *strInst = checked_cast<StringInstance *>(JS2VAL_TO_OBJECT(thatValue));
if (argc > 0)
strInst->mValue = new String(*meta->engine->toString(argv[0]));
strInst->mValue = meta->engine->allocStringPtr(meta->engine->toString(argv[0]));
else
strInst->mValue = &meta->engine->Empty_StringAtom;
strInst->mValue = meta->engine->allocStringPtr((String *)NULL);
return thatValue;
}
js2val String_fromCharCode(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
{
String *resultStr = new String(); // can't use Empty_StringAtom; because we're modifying this below
String *resultStr = meta->engine->allocStringPtr((String *)NULL); // can't use Empty_StringAtom; because we're modifying this below
resultStr->reserve(argc);
for (uint32 i = 0; i < argc; i++)
*resultStr += (char16)(meta->engine->toUInt16(argv[i]));
@ -167,10 +167,10 @@ static js2val String_match(JS2Metadata *meta, const js2val thisValue, js2val *ar
lastIndex++;
else
lastIndex = match->endIndex;
String *matchStr = new String(JS2VAL_TO_STRING(S)->substr(toUInt32(match->startIndex), toUInt32(match->endIndex) - match->startIndex));
Multiname mname(meta->world.identifiers[*numberToString(index)], meta->publicNamespace);
js2val matchStr = meta->engine->allocString(JS2VAL_TO_STRING(S)->substr(toUInt32(match->startIndex), toUInt32(match->endIndex) - match->startIndex));
Multiname mname(&meta->world.identifiers[*numberToString(index)], meta->publicNamespace);
index++;
meta->writeDynamicProperty(A, &mname, true, STRING_TO_JS2VAL(matchStr), RunPhase);
meta->writeDynamicProperty(A, &mname, true, matchStr, RunPhase);
}
thisInst->setLastIndex(meta, meta->engine->allocNumber((float64)lastIndex));
return OBJECT_TO_JS2VAL(A);
@ -303,7 +303,7 @@ static js2val String_replace(JS2Metadata *meta, const js2val thisValue, js2val *
newString += S->substr(toUInt32(lastIndex), toUInt32(S->length()) - lastIndex);
if ((pState->flags & RE_GLOBAL) == 0)
JS2VAL_TO_OBJECT(searchValue)->setProperty(cx, cx->LastIndex_StringAtom, NULL, JSValue::newNumber((float64)lastIndex));
return STRING_TO_JS2VAL(new String(newString));
return meta->engine->allocString(newString);
}
else {
const String *searchStr = JSValue::string(JSValue::toString(cx, searchValue));
@ -334,7 +334,7 @@ static js2val String_replace(JS2Metadata *meta, const js2val thisValue, js2val *
newString += insertString;
uint32 index = (uint32)match.endIndex;
newString += S->substr(index, S->length() - index);
return STRING_TO_JS2VAL(new String(newString));
return meta->engine->allocString(newString);
}
}
@ -377,11 +377,9 @@ static void regexpSplitMatch(const String *S, uint32 q, REState *RE, MatchResult
if (match->parenCount) {
result.captures = new js2val[match->parenCount];
for (int32 i = 0; i < match->parenCount; i++) {
if (match->parens[i].index != -1) {
String *parenStr = new String(S->substr((uint32)(match->parens[i].index + q),
(uint32)(match->parens[i].length)));
result.captures[i] = STRING_TO_JS2VAL(parenStr);
}
if (match->parens[i].index != -1)
result.captures[i] = meta->engine->allocString(S->substr((uint32)(match->parens[i].index + q),
(uint32)(match->parens[i].length)));
else
result.captures[i] = JS2VAL_UNDEFINED;
}
@ -441,7 +439,7 @@ static js2val String_split(JS2Metadata *meta, const js2val thisValue, js2val *ar
uint32 q = p;
step11:
if (q == s) {
String *T = new String(*S, p, (s - p));
String *T = meta->engine->allocString(*S, p, (s - p));
js2val v = STRING_TO_JS2VAL(T);
A->setProperty(cx, *numberToString(A->mLength), NULL, v);
return result;
@ -460,7 +458,7 @@ step11:
q = q + 1;
goto step11;
}
String *T = new String(*S, p, (q - p));
String *T = meta->engine->allocStringPtr(new String(*S, p, (q - p))); // XXX
js2val v = STRING_TO_JS2VAL(T);
A->setProperty(cx, *numberToString(A->mLength), NULL, v);
if (A->mLength == lim)
@ -485,9 +483,9 @@ static js2val String_charAt(JS2Metadata *meta, const js2val thisValue, js2val *a
pos = toUInt32(meta->engine->toInteger(argv[0]));
if ((pos < 0) || (pos >= str->size()))
return STRING_TO_JS2VAL(&meta->engine->Empty_StringAtom);
return STRING_TO_JS2VAL(meta->engine->Empty_StringAtom);
else
return STRING_TO_JS2VAL(new String(1, (*str)[pos]));
return meta->engine->allocString(new String(1, (*str)[pos])); // XXX
}
@ -508,7 +506,7 @@ static js2val String_charCodeAt(JS2Metadata *meta, const js2val thisValue, js2va
static js2val String_concat(JS2Metadata *meta, const js2val thisValue, js2val *argv, uint32 argc)
{
const String *str = meta->engine->toString(thisValue);
String *result = new String(*str);
String *result = meta->engine->allocStringPtr(str);
for (uint32 i = 0; i < argc; i++) {
*result += *meta->engine->toString(argv[i]);
@ -582,7 +580,7 @@ static js2val String_toLowerCase(JS2Metadata *meta, const js2val thisValue, js2v
{
js2val S = STRING_TO_JS2VAL(meta->engine->toString(thisValue));
String *result = new String(*JS2VAL_TO_STRING(S));
String *result = meta->engine->allocStringPtr(JS2VAL_TO_STRING(S));
for (String::iterator i = result->begin(), end = result->end(); i != end; i++)
*i = toLower(*i);
@ -593,7 +591,7 @@ static js2val String_toUpperCase(JS2Metadata *meta, const js2val thisValue, js2v
{
js2val S = STRING_TO_JS2VAL(meta->engine->toString(thisValue));
String *result = new String(*JS2VAL_TO_STRING(S));
String *result = meta->engine->allocStringPtr(JS2VAL_TO_STRING(S));
for (String::iterator i = result->begin(), end = result->end(); i != end; i++)
*i = toUpper(*i);
@ -667,8 +665,8 @@ static js2val String_slice(JS2Metadata *meta, const js2val thisValue, js2val *ar
end = sourceLength;
if (start > end)
return STRING_TO_JS2VAL(&meta->engine->Empty_StringAtom);
return STRING_TO_JS2VAL(new String(sourceString->substr(start, end - start)));
return STRING_TO_JS2VAL(meta->engine->Empty_StringAtom);
return meta->engine->allocString(sourceString->substr(start, end - start));
}
/*
@ -740,7 +738,7 @@ static js2val String_substring(JS2Metadata *meta, const js2val thisValue, js2val
end = t;
}
return STRING_TO_JS2VAL(new String(sourceString->substr(start, end - start)));
return meta->engine->allocString(sourceString->substr(start, end - start));
}
void initStringObject(JS2Metadata *meta)
@ -792,7 +790,7 @@ XXX not prototype object function properties, like ECMA3, but members of the Str
meta->writeDynamicProperty(meta->stringClass->prototype, new Multiname(meta->world.identifiers[pf->name], meta->publicNamespace), true, OBJECT_TO_JS2VAL(fInst), RunPhase);
*/
InstanceMember *m = new InstanceMethod(fInst);
meta->defineInstanceMember(meta->stringClass, &meta->cxt, meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
meta->defineInstanceMember(meta->stringClass, &meta->cxt, &meta->world.identifiers[pf->name], &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, m, 0);
pf++;
}