#include <MethodEnv.h>
Inheritance diagram for avmplus::MethodEnv:

Definition at line 44 of file MethodEnv.h.
|
|
Definition at line 279 of file MethodEnv.h. 00279 { kActivation=0, kMethodTable, kActivationMethodTablePair };
|
|
||||||||||||
|
Definition at line 299 of file MethodEnv.cpp. References implV.
|
|
||||||||||||
|
Definition at line 305 of file MethodEnv.cpp. References AvmAssertMsg, avmplus::AvmCore::console, avmplus::Traits::core, core(), delegateInvoke(), avmplus::AbstractFunction::flags, impl32, kActivation, avmplus::ErrorConstants::kCorruptABCError, method, avmplus::AbstractFunction::NEED_ACTIVATION, avmplus::AvmCore::newVTable(), NULL, avmplus::VTable::resolveSignatures(), setActivationOrMCTable(), avmplus::Toplevel::throwVerifyError(), toplevel(), avmplus::VTable::traits, and vtable. 00306 : vtable(vtable) 00307 , method(method) 00308 , declTraits(method->declaringTraits) 00309 { 00310 // make the first call go to the method impl 00311 impl32 = delegateInvoke; 00312 00313 AvmCore* core = vtable->traits->core; 00314 #ifdef AVMPLUS_VERBOSE 00315 if (method->declaringTraits != vtable->traits) 00316 { 00317 core->console << "ERROR " << method->name << " " << method->declaringTraits << " " << vtable->traits << "\n"; 00318 } 00319 #endif 00320 if(method->declaringTraits != vtable->traits){ 00321 AvmAssertMsg(0, "(method->declaringTraits != vtable->traits)"); 00322 toplevel()->throwVerifyError(kCorruptABCError); 00323 } 00324 00325 if (method->flags & AbstractFunction::NEED_ACTIVATION) 00326 { 00327 // This can happen when the ABC has MethodInfo data but not MethodBody data 00328 if (!method->activationTraits) 00329 { 00330 toplevel()->throwVerifyError(kCorruptABCError); 00331 } 00332 00333 VTable *activation = core->newVTable(method->activationTraits, NULL, vtable->scope, vtable->abcEnv, toplevel()); 00334 activation->resolveSignatures(); 00335 setActivationOrMCTable(activation, kActivation); 00336 } 00337 }
|
|
|
Definition at line 64 of file MethodEnv.h. References vtable. Referenced by avmplus::AvmCore::exportDefs(), getScriptEnv(), and newfunction(). 00065 { 00066 return vtable->abcEnv; 00067 }
|
|
||||||||||||
|
same as coerce, but returns coerced undefined instead of throwing an exception Definition at line 1706 of file MethodEnv.cpp. References core(), avmplus::AvmCore::istype(), and avmplus::AtomConstants::nullObjectAtom. 01707 { 01708 return core()->istype(atom, expected) ? atom : nullObjectAtom; 01709 }
|
|
||||||||||||||||
|
same as callproperty but only considers the bindings in given vtable Definition at line 1207 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), avmplus::AtomConstants::BIND_CONST, avmplus::AtomConstants::BIND_GET, avmplus::AtomConstants::BIND_GETSET, avmplus::AtomConstants::BIND_METHOD, avmplus::AtomConstants::BIND_SET, avmplus::AtomConstants::BIND_VAR, avmplus::AvmCore::bindingToGetterId(), avmplus::AvmCore::bindingToMethodId(), avmplus::AvmCore::bindingToSlotId(), coerceEnter(), avmplus::AvmCore::console, core(), runtests::f, avmplus::Toplevel::getBinding(), avmplus::ScriptObject::getSlotAtom(), avmplus::ErrorConstants::kCallNotFoundError, avmplus::ErrorConstants::kWriteOnlyError, build::dependparser::m, method, avmplus::VTable::methods, avmplus::Multiname::name, avmplus::Toplevel::op_call(), avmplus::Toplevel::throwReferenceError(), toplevel(), and avmplus::VTable::traits. 01208 { 01209 VTable* base = vtable->base; 01210 Toplevel* toplevel = this->toplevel(); 01211 Binding b = toplevel->getBinding(base->traits, multiname); 01212 switch (b&7) 01213 { 01214 default: 01215 toplevel->throwReferenceError(kCallNotFoundError, multiname, base->traits); 01216 01217 case BIND_METHOD: 01218 { 01219 #ifdef DEBUG_EARLY_BINDING 01220 core()->console << "callsuper method " << base->traits << " " << multiname->name << "\n"; 01221 #endif 01222 MethodEnv* superenv = base->methods[AvmCore::bindingToMethodId(b)]; 01223 return superenv->coerceEnter(argc, atomv); 01224 } 01225 case BIND_VAR: 01226 case BIND_CONST: 01227 { 01228 #ifdef DEBUG_EARLY_BINDING 01229 core()->console << "callsuper slot " << base->traits << " " << multiname->name << "\n"; 01230 #endif 01231 uint32 slot = AvmCore::bindingToSlotId(b); 01232 Atom method = AvmCore::atomToScriptObject(atomv[0])->getSlotAtom(slot); 01233 return toplevel->op_call(method, argc, atomv); 01234 } 01235 case BIND_SET: 01236 { 01237 #ifdef DEBUG_EARLY_BINDING 01238 core()->console << "callsuper setter " << base->traits << " " << multiname->name << "\n"; 01239 #endif 01240 // read on write-only property 01241 toplevel->throwReferenceError(kWriteOnlyError, multiname, base->traits); 01242 } 01243 case BIND_GET: 01244 case BIND_GETSET: 01245 { 01246 #ifdef DEBUG_EARLY_BINDING 01247 core()->console << "callsuper getter " << base->traits << " " << multiname->name << "\n"; 01248 #endif 01249 // Invoke the getter 01250 int m = AvmCore::bindingToGetterId(b); 01251 MethodEnv *f = base->methods[m]; 01252 Atom atomv_out[1] = { atomv[0] }; 01253 Atom method = f->coerceEnter(0, atomv_out); 01254 return toplevel->op_call(method, argc, atomv); 01255 } 01256 } 01257 }
|
|
|
E4X filter operator Definition at line 1663 of file MethodEnv.cpp. References core(), avmplus::ErrorConstants::kFilterError, avmplus::Toplevel::throwTypeError(), and toplevel(). 01664 { 01665 if ( !toplevel()->isXmlBase(obj) ) 01666 { 01667 toplevel()->throwTypeError(kFilterError, core()->toErrorString(toplevel()->toTraits(obj))); 01668 } 01669 }
|
|
||||||||||||
|
implements ECMA implicit coersion. returns the coerced value, or throws a TypeError if coersion is not possible. Definition at line 1676 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), AvmAssert, core(), avmplus::Traits::isMachineType, avmplus::AvmCore::isNullOrUndefined(), avmplus::ErrorConstants::kCheckTypeFailedError, avmplus::AtomConstants::kObjectType, NULL, avmplus::Toplevel::throwTypeError(), and toplevel(). 01677 { 01678 AvmAssert(expected != NULL); 01679 AvmAssert(!expected->isMachineType); 01680 AvmAssert(expected != core()->traits.string_itraits); 01681 AvmAssert(expected != core()->traits.namespace_itraits); 01682 01683 if (AvmCore::isNullOrUndefined(atom)) 01684 return NULL; 01685 01686 ScriptObject *so; 01687 if ((atom&7) == kObjectType && 01688 (so=AvmCore::atomToScriptObject(atom))->traits()->containsInterface(expected)) 01689 { 01690 return so; 01691 } 01692 else 01693 { 01694 // failed 01695 #ifdef AVMPLUS_VERBOSE 01696 //core->console << "checktype failed " << expected << " <- " << atom << "\n"; 01697 #endif 01698 toplevel()->throwTypeError(kCheckTypeFailedError, core()->atomToErrorString(atom), core()->toErrorString(expected)); 01699 return NULL; 01700 } 01701 }
|
|
||||||||||||
|
Definition at line 208 of file MethodEnv.cpp. References AvmAssert, endCoerce(), method, avmplus::AbstractFunction::paramTraits(), runtests::res, avmplus::AbstractFunction::restOffset, startCoerce(), toplevel(), and unboxCoerceArgs(). 00209 { 00210 int extra = startCoerce(argc); 00211 00212 // check receiver type first 00213 // caller will coerce instance if necessary, 00214 // so make sure it was done. 00215 AvmAssert(atomv[0] == toplevel()->coerce(atomv[0], method->paramTraits(0))); 00216 00217 size_t extra_sz = method->restOffset + sizeof(Atom)*extra; 00218 uint32 *ap; 00219 ap = (uint32 *) alloca(extra_sz); 00220 00221 unboxCoerceArgs(argc, atomv, ap); 00222 Atom res = endCoerce(argc, ap); 00223 return res; 00224 }
|
|
||||||||||||||||
|
Definition at line 190 of file MethodEnv.cpp. References AvmAssert, endCoerce(), method, avmplus::AbstractFunction::paramTraits(), runtests::res, avmplus::AbstractFunction::restOffset, startCoerce(), toplevel(), and unboxCoerceArgs(). 00191 { 00192 int extra = startCoerce(argc); 00193 00194 // check receiver type first 00195 // caller will coerce instance if necessary, 00196 // so make sure it was done. 00197 AvmAssert(thisArg == toplevel()->coerce(thisArg, method->paramTraits(0))); 00198 00199 size_t extra_sz = method->restOffset + sizeof(Atom)*extra; 00200 uint32 *ap; 00201 ap = (uint32 *) alloca(extra_sz); 00202 00203 unboxCoerceArgs(thisArg, argc, argv, ap); 00204 Atom res = endCoerce(argc, ap); 00205 return res; 00206 }
|
|
||||||||||||
|
Definition at line 168 of file MethodEnv.cpp. References AvmAssert, coerceEnter(), endCoerce(), avmplus::ArrayObject::getLength(), method, avmplus::AbstractFunction::paramTraits(), runtests::res, avmplus::AbstractFunction::restOffset, startCoerce(), toplevel(), and unboxCoerceArgs(). 00169 { 00170 int argc = a->getLength(); 00171 if (argc == 0) 00172 return coerceEnter(thisArg); 00173 int extra = startCoerce(argc); 00174 00175 // check receiver type first 00176 // caller will coerce instance if necessary, 00177 // so make sure it was done. 00178 AvmAssert(thisArg == toplevel()->coerce(thisArg, method->paramTraits(0))); 00179 00180 size_t extra_sz = method->restOffset + sizeof(Atom)*extra; 00181 uint32 *ap; 00182 ap = (uint32 *) alloca(extra_sz); 00183 00184 unboxCoerceArgs(thisArg, a, ap); 00185 Atom res = endCoerce(argc, ap); 00186 // we know we have verified the method, so we can go right into it. 00187 return res; 00188 }
|
|
|
Coerces an array of actual parameters to the types required by a function's formal parameters, then invokes the method. Args are provided as an array of atoms, not an array of native types.
Definition at line 156 of file MethodEnv.cpp. References AvmAssert, core(), endCoerce(), method, avmplus::AbstractFunction::paramTraits(), startCoerce(), toplevel(), and unbox1(). Referenced by avmplus::Toplevel::callproperty(), callsuper(), coerceEnter(), finddef(), findglobalproperty(), newActivation(), and avmplus::Toplevel::setproperty_b(). 00157 { 00158 startCoerce(0); 00159 // check receiver type first 00160 // caller will coerce instance if necessary, 00161 // so make sure it was done. 00162 AvmAssert(thisArg == toplevel()->coerce(thisArg, method->paramTraits(0))); 00163 unbox1(core(), toplevel(), thisArg, method->paramTraits(0), &thisArg); 00164 00165 return endCoerce(0, (uint32*)&thisArg); 00166 }
|
|
|
Definition at line 76 of file MethodEnv.h. References avmplus::AbstractFunction::core(), and method. Referenced by astype(), callsuper(), checkfilter(), coerceAtom2SO(), coerceEnter(), createArguments(), delegateInvoke(), delproperty(), endCoerce(), getdescendants(), getdescendantslate(), getMethodClosureTable(), getpropertylate_i(), getpropertylate_u(), in(), avmplus::initMultiname(), avmplus::initMultinameNoXMLList(), internRtns(), avmplus::interp(), avmplus::interp32(), MethodEnv(), newActivation(), newcatch(), newclass(), newfunction(), op_newobject(), setActivationOrMCTable(), setpropertylate_i(), setpropertylate_u(), setsuper(), startCoerce(), stkover(), unbox1(), unboxCoerceArgs(), and avmplus::MethodInfo::verifyEnter(). 00077 { 00078 return method->pool->core; 00079 }
|
|
||||||||||||
|
Creates the arguments array Definition at line 1605 of file MethodEnv.cpp. References avmplus::ScriptObject::atom(), core(), avmplus::AbstractFunction::flags, method, avmplus::AbstractFunction::NEED_CLOSURE, avmplus::ScriptObject::setStringProperty(), avmplus::ScriptObject::setStringPropertyIsEnumerable(), and toplevel(). Referenced by avmplus::interp(). 01606 { 01607 Toplevel* toplevel = this->toplevel(); 01608 ArrayObject *arguments = toplevel->arrayClass->newarray(atomv+1,argc); 01609 ScriptObject *closure; 01610 if (method->flags & AbstractFunction::NEED_CLOSURE) 01611 { 01612 closure = toplevel->methodClosureClass->create(this, atomv[0]); 01613 } 01614 else 01615 { 01616 closure = ((FunctionEnv*)this)->closure; 01617 } 01618 arguments->setStringProperty(core()->kcallee, closure->atom()); 01619 arguments->setStringPropertyIsEnumerable(core()->kcallee, false); 01620 return arguments; 01621 }
|
|
||||||||||||
|
Definition at line 466 of file MethodEnv.cpp. References method, avmplus::AbstractFunction::param_count, and toplevel(). Referenced by avmplus::interp(). 00467 { 00468 // create arguments Array using argv[param_count..argc] 00469 Atom* extra = argv + method->param_count + 1; 00470 int extra_count = argc > method->param_count ? argc - method->param_count : 0; 00471 return toplevel()->arrayClass->newarray(extra, extra_count); 00472 }
|
|
||||||||||||||||
|
Definition at line 278 of file MethodEnv.cpp. References MMgc::GC::Alloc(), AvmAssert, core(), MMgc::GCRoot::GetGC(), avmplus::AbstractFunction::impl32, impl32, MMgc::GC::kContainsPointers, MMgc::GC::kZero, method, and NULL. Referenced by MethodEnv(). 00279 { 00280 env->impl32 = env->method->impl32; 00281 #if 0 // This is handled near the top of interp() for the moment, see comments there 00282 #ifdef AVMPLUS_WORD_CODE 00283 { 00284 // Install the lookup cache here, if the information is available to create it. 00285 // Otherwise it's done in verifyEnter, inside env->impl32() below. 00286 using namespace MMgc; 00287 MethodInfo* info = (MethodInfo*)(AbstractFunction*) env->method; 00288 int n; 00289 if ((n = info->word_code.cache_size) > 0) { 00290 AvmAssert(env->lookup_cache == NULL); 00291 env->lookup_cache = (LookupCache*)env->core()->GetGC()->Alloc(sizeof(LookupCache)*n, GC::kContainsPointers|GC::kZero); 00292 } 00293 } 00294 #endif 00295 #endif // 0 00296 return env->impl32(env, argc, ap); 00297 }
|
|
||||||||||||
|
Definition at line 1259 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), avmplus::AtomConstants::BIND_NONE, avmplus::Multiname::contains(), core(), avmplus::ScriptObject::deleteMultinameProperty(), avmplus::AtomConstants::falseAtom, avmplus::Toplevel::getBinding(), avmplus::AvmCore::isMethodBinding(), avmplus::AvmCore::isObject(), avmplus::Toplevel::isXmlBase(), toplevel(), avmplus::Toplevel::toTraits(), and avmplus::AtomConstants::trueAtom. 01260 { 01261 Toplevel* toplevel = this->toplevel(); 01262 Traits* traits = toplevel->toTraits(obj); // includes null check 01263 if (AvmCore::isObject(obj)) 01264 { 01265 Binding b = toplevel->getBinding(traits, multiname); 01266 if (b == BIND_NONE) 01267 { 01268 bool b = AvmCore::atomToScriptObject(obj)->deleteMultinameProperty(multiname); 01269 #ifdef AVMPLUS_WORD_CODE 01270 // Deleting a deletable bound property means deleting a dynamic global property, so 01271 // invalidate the lookup cache (because subsequent lookups should fail). 01272 if (b) 01273 core()->invalidateLookupCache(); 01274 #endif 01275 return b ? trueAtom : falseAtom; 01276 } 01277 else if (AvmCore::isMethodBinding(b)) 01278 { 01279 if (multiname->contains(core()->publicNamespace) && toplevel->isXmlBase(obj)) 01280 { 01281 // dynamic props should hide declared methods on delete 01282 ScriptObject* so = AvmCore::atomToScriptObject(obj); 01283 bool b = so->deleteMultinameProperty(multiname); 01284 return b ? trueAtom : falseAtom; 01285 } 01286 } 01287 } 01288 else 01289 { 01290 toplevel->throwReferenceError(kDeleteSealedError, multiname, traits); 01291 } 01292 01293 return falseAtom; 01294 }
|
|
|
Definition at line 71 of file MethodEnv.h. References vtable. Referenced by avmplus::AvmCore::exportDefs(). 00072 { 00073 return vtable->abcEnv->domainEnv; 00074 }
|
|
||||||||||||
|
Definition at line 123 of file MethodEnv.cpp. References AvmAssert, BOOLEAN_TYPE, core(), avmplus::AvmCore::doubleToAtom(), avmplus::AtomConstants::falseAtom, util::threadpool::i, avmplus::AbstractFunction::impl32, avmplus::AbstractFunction::implN, INT_TYPE, avmplus::AvmCore::intToAtom(), method, NAMESPACE_TYPE, NULL, NUMBER_TYPE, OBJECT_TYPE, avmplus::AbstractFunction::returnTraits(), STRING_TYPE, avmplus::AtomConstants::trueAtom, UINT_TYPE, avmplus::AvmCore::uintToAtom(), and VOID_TYPE. Referenced by coerceEnter(). 00124 { 00125 // we know we have verified the method, so we can go right into it. 00126 Traits* returnType = method->returnTraits(); 00127 AvmCore* core = this->core(); 00128 if (returnType == NUMBER_TYPE) 00129 { 00130 AvmAssert(method->implN != NULL); 00131 double d = method->implN(this, argc, ap); 00132 return core->doubleToAtom(d); 00133 } 00134 else 00135 { 00136 AvmAssert(method->impl32 != NULL); 00137 Atom i = method->impl32(this, argc, ap); 00138 if (returnType == INT_TYPE) 00139 return core->intToAtom((int)i); 00140 else if (returnType == UINT_TYPE) 00141 return core->uintToAtom((uint32)i); 00142 else if (returnType == BOOLEAN_TYPE) 00143 return i ? trueAtom : falseAtom; 00144 else if (!returnType || returnType == OBJECT_TYPE || returnType == VOID_TYPE) 00145 return (Atom)i; 00146 else if (returnType == STRING_TYPE) 00147 return ((Stringp)i)->atom(); 00148 else if (returnType == NAMESPACE_TYPE) 00149 return ((Namespace*)i)->atom(); 00150 else 00151 return ((ScriptObject*)i)->atom(); 00152 } 00153 }
|
|
|
used for defining and resolving imported definitions. Definition at line 764 of file MethodEnv.cpp. References avmplus::ScriptObject::atom(), avmplus::AtomConstants::BIND_AMBIGUOUS, avmplus::AtomConstants::BIND_NONE, coerceEnter(), getScriptEnv(), avmplus::ScriptEnv::initGlobal(), avmplus::ErrorConstants::kAmbiguousBindingError, avmplus::ErrorConstants::kUndefinedVarError, avmplus::Toplevel::throwReferenceError(), avmplus::ScriptObject::toplevel(), and toplevel(). Referenced by finddefNs(), and finddefNsset(). 00765 { 00766 Toplevel* toplevel = vtable->toplevel; 00767 00768 ScriptEnv* script = getScriptEnv(multiname); 00769 if (script == (ScriptEnv*)BIND_AMBIGUOUS) 00770 toplevel->throwReferenceError(kAmbiguousBindingError, multiname); 00771 00772 if (script == (ScriptEnv*)BIND_NONE) 00773 toplevel->throwReferenceError(kUndefinedVarError, multiname); 00774 00775 ScriptObject* global = script->global; 00776 if (!global) 00777 { 00778 global = script->initGlobal(); 00779 Atom argv[1] = { global->atom() }; 00780 script->coerceEnter(0, argv); 00781 } 00782 return global; 00783 }
|
|
||||||||||||
|
Definition at line 803 of file MethodEnv.cpp. References finddef(), and build::dependparser::m.
|
|
||||||||||||
|
Definition at line 796 of file MethodEnv.cpp. References finddef(), and build::dependparser::m.
|
|
||||||||||||
|
Like findproperty, but ignoring all lexical and 'this' scopes. Returns NULL if property could not be found; caller should signal strict error or return the target_global as appropriate. Definition at line 1556 of file MethodEnv.cpp. References avmplus::AtomConstants::BIND_AMBIGUOUS, avmplus::AtomConstants::BIND_NONE, coerceEnter(), getScriptEnv(), avmplus::ScriptEnv::initGlobal(), avmplus::ErrorConstants::kAmbiguousBindingError, NULL, configure::o, avmplus::Toplevel::throwReferenceError(), and toplevel(). 01557 { 01558 Toplevel* toplevel = this->toplevel(); 01559 01560 // look for imported definition (similar logic to OP_finddef). This will 01561 // find definitions in this script and in other scripts. 01562 ScriptEnv* script = getScriptEnv(multiname); 01563 if (script != (ScriptEnv*)BIND_NONE) 01564 { 01565 if (script == (ScriptEnv*)BIND_AMBIGUOUS) 01566 toplevel->throwReferenceError(kAmbiguousBindingError, multiname); 01567 01568 ScriptObject* global = script->global; 01569 if (global == NULL) 01570 { 01571 global = script->initGlobal(); 01572 Atom argv[1] = { script->global->atom() }; 01573 script->coerceEnter(0, argv); 01574 } 01575 return global; 01576 } 01577 01578 // no imported definition found. look for dynamic props 01579 // on the global object 01580 01581 ScriptObject* global = target_global; 01582 01583 // search the delegate chain for a value. The delegate 01584 // chain for the global object will only contain vanilla 01585 // objects (Object.prototype) so we can skip traits 01586 01587 ScriptObject* o = global; 01588 do 01589 { 01590 if (o->hasMultinameProperty(multiname)) 01591 return global; 01592 } 01593 while ((o = o->getDelegate()) != NULL); 01594 01595 return NULL; 01596 }
|
|
||||||||||||||||||||||||||||
|
Implementation of OP_findproperty Definition at line 1455 of file MethodEnv.cpp. References findWithProperty(), avmplus::AvmCore::isNull(), and toplevel(). 01461 { 01462 Toplevel* toplevel = this->toplevel(); 01463 01464 // look in each with frame in the current stack frame 01465 Atom* scopep = &scopes[extraScopes-1]; 01466 if (withBase) 01467 { 01468 for (; scopep >= withBase; scopep--) 01469 { 01470 Atom result = findWithProperty(*scopep, multiname); 01471 if (!AvmCore::isNull(result)) 01472 { 01473 return result; 01474 } 01475 } 01476 } 01477 01478 // if we're in global$init (outer_depth==0), don't check "this" scope just yet. 01479 int outer_depth = outer->getSize(); 01480 for (; scopep > scopes; scopep--) 01481 { 01482 Atom a = *scopep; 01483 Traits* t = toplevel->toTraits(a); 01484 Binding b = toplevel->getBinding(t, multiname); 01485 if (b != BIND_NONE) 01486 return a; 01487 } 01488 01489 ScopeTypeChain* outerTraits = outer->scopeTraits; 01490 01491 if (outer_depth > 0 && scopep >= scopes) 01492 { 01493 // consider "this" scope now, but constrain it to the declaringTraits of 01494 // the current method (verifier ensures this is safe) 01495 Atom a = *scopep; 01496 Traits *t; 01497 if (outerTraits->fullsize > outerTraits->size) 01498 { 01499 // scope traits has extra constraint for "this" scope, see OP_newclass in verifier 01500 t = outerTraits->getScopeTraitsAt(outerTraits->size); 01501 } 01502 else 01503 { 01504 // "this" scope type is the runtime type 01505 t = toplevel->toTraits(a); 01506 } 01507 01508 Binding b = toplevel->getBinding(t, multiname); 01509 if (b != BIND_NONE) 01510 return a; 01511 } 01512 01513 // now search outer scopes 01514 for (int i=outer_depth-1; i > 0; i--) 01515 { 01516 if (outerTraits->getScopeIsWithAt(i)) 01517 { 01518 Atom result = findWithProperty(outer->getScope(i), multiname); 01519 if (!AvmCore::isNull(result)) 01520 return result; 01521 } 01522 else 01523 { 01524 // only look at the properties on the captured (verify time) type, not the actual type, 01525 // of the outer scope object. 01526 Atom a = outer->getScope(i); 01527 Traits* t = outerTraits->getScopeTraitsAt(i); 01528 Binding b = toplevel->getBinding(t, multiname); 01529 if (b != BIND_NONE) 01530 return a; 01531 } 01532 } 01533 01534 // No imported definitions or global scope can have attributes. (Using filter 01535 // operator with non existent attribute will get here. 01536 if (multiname->isAttr()) 01537 { 01538 if (strict) 01539 toplevel->throwReferenceError(kUndefinedVarError, multiname); 01540 return undefinedAtom; 01541 } 01542 01543 // now we have searched all the scopes, except global 01544 { 01545 ScriptObject* global = AvmCore::atomToScriptObject(outer->getSize() > 0 ? outer->getScope(0) : *scopes); 01546 ScriptObject* obj = findglobalproperty(global, multiname); 01547 if (obj == NULL) { 01548 if (strict) 01549 toplevel->throwReferenceError(kUndefinedVarError, multiname); 01550 obj = global; 01551 } 01552 return obj->atom(); 01553 } 01554 }
|
|
||||||||||||
|
Definition at line 1394 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), avmplus::AtomConstants::BIND_NONE, avmplus::Toplevel::getBinding(), avmplus::AtomConstants::kObjectType, NULL, avmplus::AtomConstants::nullObjectAtom, configure::o, toplevel(), avmplus::Toplevel::toPrototype(), and avmplus::Toplevel::toTraits(). Referenced by findproperty(). 01395 { 01396 Toplevel* toplevel = this->toplevel(); 01397 if ((atom&7)==kObjectType) 01398 { 01399 // usually scope objects are ScriptObject's 01400 01401 ScriptObject* o = AvmCore::atomToScriptObject(atom); 01402 01403 // search the delegate chain for a value. we must look at 01404 // traits at each step along the way in case we have class 01405 // instances on the scope chain 01406 do 01407 { 01408 // ISSUE it is incorrect to return a reference to an object on the prototype 01409 // chain, we should only return the scopechain object; the next operation 01410 // could be a setproperty, and we don't want to mutate prototype objects this way. 01411 01412 // look at the traits first, stop if found. 01413 Binding b = toplevel->getBinding(o->traits(), multiname); 01414 if (b != BIND_NONE) 01415 return atom; 01416 if (o->hasMultinameProperty(multiname)) 01417 return atom; 01418 } 01419 while ((o = o->getDelegate()) != NULL); 01420 } 01421 else 01422 { 01423 // primitive value on scope chain! 01424 01425 // first iteration looks at traits only since primitive values don't have 01426 // dynamic variables 01427 01428 Binding b = toplevel->getBinding(toplevel->toTraits(atom), multiname); 01429 if (b != BIND_NONE) 01430 return atom; 01431 01432 // then we continue starting at the prototype for this primitive type 01433 ScriptObject* o = toplevel->toPrototype(atom); 01434 do 01435 { 01436 Binding b = toplevel->getBinding(o->traits(), multiname); 01437 if (b != BIND_NONE) 01438 return atom; 01439 if (o->hasMultinameProperty(multiname)) 01440 return atom; 01441 } 01442 while ((o = o->getDelegate()) != NULL); 01443 } 01444 01445 return nullObjectAtom; 01446 }
|
|
|
vtable for the activation scope inside this method Definition at line 1711 of file MethodEnv.cpp. References avmplus::MethodEnv::ActivationMethodTablePair::activation, activationOrMCTable, getPair(), getType(), kActivation, kActivationMethodTablePair, and NULL. Referenced by getMethodClosureTable(), and newActivation(). 01712 { 01713 int type = getType(); 01714 switch(type) 01715 { 01716 case kActivation: 01717 return (VTable *)(activationOrMCTable&~3); 01718 case kActivationMethodTablePair: 01719 return getPair()->activation; 01720 default: 01721 return NULL; 01722 } 01723 }
|
|
||||||||||||
|
E4X descendants operator (..) Definition at line 1623 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), core(), avmplus::ScriptObject::getDescendants(), avmplus::AvmCore::isObject(), avmplus::ErrorConstants::kDescendentsError, avmplus::Toplevel::throwTypeError(), toplevel(), and avmplus::AtomConstants::undefinedAtom. Referenced by getdescendantslate(). 01624 { 01625 if (AvmCore::isObject (obj)) 01626 { 01627 return core()->atomToScriptObject(obj)->getDescendants (multiname); 01628 } 01629 else 01630 { 01631 // Rhino simply returns undefined for other Atom types 01632 // SpiderMonkey throws TypeError. We're doing TypeError. 01633 toplevel()->throwTypeError(kDescendentsError, core()->toErrorString(toplevel()->toTraits(obj))); 01634 return undefinedAtom; // not reached 01635 } 01636 }
|
|
||||||||||||||||
|
Definition at line 1638 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), core(), getdescendants(), util::threadpool::i, avmplus::AvmCore::isObject(), avmplus::BuiltinTraits::qName_itraits, avmplus::Multiname::setAttr(), and avmplus::AvmCore::traits. 01639 { 01640 if (AvmCore::isObject(index)) 01641 { 01642 ScriptObject* i = AvmCore::atomToScriptObject(index); 01643 if (i->traits() == core()->traits.qName_itraits) 01644 { 01645 QNameObject* qname = (QNameObject*) i; 01646 Multiname n2; 01647 qname->getMultiname(n2); 01648 if (attr) 01649 n2.setAttr(attr); 01650 return getdescendants(obj, &n2); 01651 } 01652 } 01653 01654 // convert index to string 01655 01656 AvmCore* core = this->core(); 01657 Multiname name(core->publicNamespace, core->intern(index)); 01658 if (attr) 01659 name.setAttr(); 01660 return getdescendants(obj, &name); 01661 }
|
|
|
getter lazily creates table which maps SO->MC Definition at line 1738 of file MethodEnv.cpp. References activationOrMCTable, core(), getActivation(), MMgc::GCRoot::GetGC(), getPair(), getType(), kActivation, kActivationMethodTablePair, kMethodTable, avmplus::MethodEnv::ActivationMethodTablePair::methodTable, and setActivationOrMCTable(). 01739 { 01740 int type = getType(); 01741 if(!activationOrMCTable) 01742 { 01743 WeakKeyHashtable *wkh = new (core()->GetGC()) WeakKeyHashtable(core()->GetGC()); 01744 setActivationOrMCTable(wkh, kMethodTable); 01745 return wkh; 01746 } 01747 else if(type == kActivation) 01748 { 01749 WeakKeyHashtable *wkh = new (core()->GetGC()) WeakKeyHashtable(core()->GetGC()); 01750 ActivationMethodTablePair *amtp = new (core()->GetGC()) ActivationMethodTablePair(getActivation(), wkh); 01751 setActivationOrMCTable(amtp, kActivationMethodTablePair); 01752 return wkh; 01753 } 01754 else if(type == kActivationMethodTablePair) 01755 { 01756 return getPair()->methodTable; 01757 } 01758 return (WeakKeyHashtable*)(activationOrMCTable&~3); 01759 }
|
|
|
Definition at line 281 of file MethodEnv.h. References activationOrMCTable. Referenced by getActivation(), and getMethodClosureTable(). 00281 { return (ActivationMethodTablePair*)(activationOrMCTable&~3); }
|
|
||||||||||||
|
Definition at line 714 of file MethodEnv.cpp. References avmplus::String::atom(), avmplus::AvmCore::atomToScriptObject(), core(), avmplus::AbstractFunction::core(), avmplus::ScriptObject::getAtomProperty(), avmplus::ScriptObject::getUintProperty(), avmplus::AvmCore::internInt(), avmplus::AtomConstants::kObjectType, method, toplevel(), avmplus::Toplevel::toPrototype(), and avmplus::Toplevel::toTraits(). 00715 { 00716 // here we put the case for bind-none, since we know there are no bindings 00717 // with numeric names. 00718 if ((obj&7) == kObjectType) 00719 { 00720 if (index >= 0) 00721 { 00722 // try dynamic lookup on instance. even if the traits are sealed, 00723 // we might need to search the prototype chain 00724 return AvmCore::atomToScriptObject(obj)->getUintProperty(index); 00725 } 00726 else 00727 { 00728 // negative - we must intern the integer 00729 return AvmCore::atomToScriptObject(obj)->getAtomProperty(method->core()->internInt(index)->atom()); 00730 } 00731 } 00732 else 00733 { 00734 // primitive types are not dynamic, so we can go directly 00735 // to their __proto__ object 00736 AvmCore* core = method->core(); 00737 Toplevel *toplevel = this->toplevel(); 00738 ScriptObject *protoObject = toplevel->toPrototype(obj); 00739 return protoObject->ScriptObject::getStringPropertyFromProtoChain(core->internInt(index), protoObject, toplevel->toTraits(obj)); 00740 } 00741 }
|
|
||||||||||||
|
Definition at line 743 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), core(), avmplus::AbstractFunction::core(), avmplus::ScriptObject::getUintProperty(), avmplus::AvmCore::internUint32(), avmplus::AtomConstants::kObjectType, method, toplevel(), avmplus::Toplevel::toPrototype(), and avmplus::Toplevel::toTraits(). 00744 { 00745 // here we put the case for bind-none, since we know there are no bindings 00746 // with numeric names. 00747 if ((obj&7) == kObjectType) 00748 { 00749 // try dynamic lookup on instance. even if the traits are sealed, 00750 // we might need to search the prototype chain 00751 return AvmCore::atomToScriptObject(obj)->getUintProperty(index); 00752 } 00753 else 00754 { 00755 // primitive types are not dynamic, so we can go directly 00756 // to their __proto__ object 00757 AvmCore* core = method->core(); 00758 Toplevel *toplevel = this->toplevel(); 00759 ScriptObject *protoObject = toplevel->toPrototype(obj); 00760 return protoObject->ScriptObject::getStringPropertyFromProtoChain(core->internUint32(index), protoObject, toplevel->toTraits(obj)); 00761 } 00762 }
|
|
|
Definition at line 785 of file MethodEnv.cpp. References abcEnv(), avmplus::AbcEnv::domainEnv, avmplus::MultinameHashtable::getMulti(), avmplus::DomainEnv::getScriptInit(), and avmplus::AbcEnv::privateScriptEnvs. Referenced by finddef(), and findglobalproperty(). 00786 { 00787 ScriptEnv *se = (ScriptEnv*)abcEnv()->domainEnv->getScriptInit(multiname); 00788 if(!se) 00789 { 00790 // check privates 00791 se = (ScriptEnv*)abcEnv()->privateScriptEnvs.getMulti(multiname); 00792 } 00793 return se; 00794 }
|
|
||||||||||||
|
Reads a property from an object, with the property to retrieve specified by its binding. The binding was likely retrieved using getBinding.
Definition at line 1296 of file MethodEnv.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToScriptObject(), avmplus::AtomConstants::BIND_CONST, avmplus::AtomConstants::BIND_GET, avmplus::AtomConstants::BIND_GETSET, avmplus::AtomConstants::BIND_METHOD, avmplus::AtomConstants::BIND_SET, avmplus::AtomConstants::BIND_VAR, avmplus::AvmCore::bindingToGetterId(), avmplus::AvmCore::bindingToMethodId(), avmplus::AvmCore::bindingToSlotId(), runtests::f, avmplus::Toplevel::getBinding(), avmplus::ScriptObject::getSlotAtom(), avmplus::ErrorConstants::kReadSealedError, avmplus::ErrorConstants::kWriteOnlyError, build::dependparser::m, avmplus::VTable::methods, avmplus::Multiname::name, avmplus::Toplevel::throwReferenceError(), toplevel(), avmplus::VTable::traits, and vtable. 01297 { 01298 VTable* vtable = this->vtable->base; 01299 Toplevel* toplevel = this->toplevel(); 01300 Binding b = toplevel->getBinding(vtable->traits, multiname); 01301 switch (b&7) 01302 { 01303 default: 01304 toplevel->throwReferenceError(kReadSealedError, multiname, vtable->traits); 01305 01306 case BIND_METHOD: 01307 { 01308 #ifdef DEBUG_EARLY_BINDING 01309 core->console << "getsuper method " << vtable->traits << " " << multiname->name << "\n"; 01310 #endif 01311 // extracting a virtual method 01312 MethodEnv *m = vtable->methods[AvmCore::bindingToMethodId(b)]; 01313 return toplevel->methodClosureClass->create(m, obj)->atom(); 01314 } 01315 01316 case BIND_VAR: 01317 case BIND_CONST: 01318 #ifdef DEBUG_EARLY_BINDING 01319 core->console << "getsuper slot " << vtable->traits << " " << multiname->name << "\n"; 01320 #endif 01321 return AvmCore::atomToScriptObject(obj)->getSlotAtom(AvmCore::bindingToSlotId(b)); 01322 01323 case BIND_SET: 01324 { 01325 #ifdef DEBUG_EARLY_BINDING 01326 core->console << "getsuper setter " << vtable->traits << " " << multiname->name << "\n"; 01327 #endif 01328 // read on write-only property 01329 toplevel->throwReferenceError(kWriteOnlyError, multiname, vtable->traits); 01330 } 01331 case BIND_GET: 01332 case BIND_GETSET: 01333 { 01334 #ifdef DEBUG_EARLY_BINDING 01335 core->console << "getsuper getter " << vtable->traits << " " << multiname->name << "\n"; 01336 #endif 01337 // Invoke the getter 01338 int m = AvmCore::bindingToGetterId(b); 01339 MethodEnv *f = vtable->methods[m]; 01340 Atom atomv_out[1] = { obj }; 01341 return f->coerceEnter(0, atomv_out); 01342 } 01343 } 01344 }
|
|
|
Definition at line 282 of file MethodEnv.h. References activationOrMCTable. Referenced by getActivation(), and getMethodClosureTable(). 00282 { return activationOrMCTable&3; }
|
|
||||||||||||
|
Implementation of OP_hasnext Definition at line 890 of file MethodEnv.cpp. References avmplus::AvmCore::atomToNamespace(), avmplus::AvmCore::atomToScriptObject(), avmplus::AvmCore::isNullOrUndefined(), avmplus::AtomConstants::kNamespaceType, avmplus::AtomConstants::kObjectType, avmplus::Namespace::nextNameIndex(), avmplus::ScriptObject::nextNameIndex(), toplevel(), and avmplus::Toplevel::toPrototype(). 00891 { 00892 if (index < 0) 00893 return 0; 00894 00895 if (!AvmCore::isNullOrUndefined(objAtom)) 00896 { 00897 switch (objAtom&7) 00898 { 00899 case kObjectType: 00900 return AvmCore::atomToScriptObject(objAtom)->nextNameIndex(index); 00901 case kNamespaceType: 00902 return AvmCore::atomToNamespace(objAtom)->nextNameIndex(index); 00903 default: 00904 ScriptObject* proto = toplevel()->toPrototype(objAtom); 00905 int nextIndex = ( proto ? proto->nextNameIndex(index) : 0); 00906 return nextIndex; 00907 } 00908 } 00909 else 00910 { 00911 return 0; 00912 } 00913 }
|
|
||||||||||||
|
Implementation of OP_hasnext2 Definition at line 915 of file MethodEnv.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToNamespace(), avmplus::AvmCore::atomToScriptObject(), avmplus::ScriptObject::getDelegate(), avmplus::AvmCore::isNullOrUndefined(), avmplus::AtomConstants::kNamespaceType, avmplus::AtomConstants::kObjectType, avmplus::Namespace::nextNameIndex(), avmplus::ScriptObject::nextNameIndex(), NULL, avmplus::AtomConstants::nullObjectAtom, toplevel(), and avmplus::Toplevel::toPrototype(). 00916 { 00917 if (index < 0) 00918 return 0; 00919 00920 ScriptObject *delegate = NULL; 00921 00922 if (!AvmCore::isNullOrUndefined(objAtom)) 00923 { 00924 switch (objAtom&7) 00925 { 00926 case kObjectType: 00927 { 00928 ScriptObject *object = AvmCore::atomToScriptObject(objAtom); 00929 delegate = object->getDelegate(); 00930 index = object->nextNameIndex(index); 00931 } 00932 break; 00933 case kNamespaceType: 00934 { 00935 index = AvmCore::atomToNamespace(objAtom)->nextNameIndex(index); 00936 delegate = toplevel()->namespaceClass->prototype; 00937 } 00938 break; 00939 default: 00940 { 00941 ScriptObject* proto = toplevel()->toPrototype(objAtom); 00942 delegate = proto ? proto->getDelegate() : NULL; 00943 index = ( proto ? proto->nextNameIndex(index) : 0); 00944 } 00945 } 00946 } 00947 else 00948 { 00949 index = 0; 00950 } 00951 00952 while (index == 0 && delegate != NULL) 00953 { 00954 // Advance to next object on prototype chain 00955 ScriptObject *object = delegate; 00956 objAtom = object->atom(); 00957 delegate = object->getDelegate(); 00958 index = object->nextNameIndex(index); 00959 } 00960 00961 if (index == 0) 00962 { 00963 // If we're done, set object local to null 00964 objAtom = nullObjectAtom; 00965 } 00966 00967 return index != 0; 00968 }
|
|
||||||||||||
|
operator in from ES3 Definition at line 970 of file MethodEnv.cpp. References avmplus::AtomConstants::BIND_NONE, core(), avmplus::AbstractFunction::core(), avmplus::Traits::findBinding(), avmplus::AvmCore::intern(), avmplus::AvmCore::isDictionaryLookup(), method, toplevel(), avmplus::Toplevel::toTraits(), and avmplus::AtomConstants::trueAtom. 00971 { 00972 AvmCore* core = method->core(); 00973 Traits *t = toplevel()->toTraits(obj); // includes null check 00974 00975 if(!core->isDictionaryLookup(nameatom, obj)) 00976 { 00977 Stringp name = core->intern(nameatom); 00978 00979 // ISSUE should we try this on each object on the proto chain or just the first? 00980 if (t->findBinding(name, core->publicNamespace) != BIND_NONE) 00981 { 00982 return trueAtom; 00983 } 00984 00985 nameatom = name->atom(); 00986 } 00987 00988 ScriptObject* o = (obj&7)==kObjectType ? AvmCore::atomToScriptObject(obj) : 00989 toplevel()->toPrototype(obj); 00990 do 00991 { 00992 if (o->hasAtomProperty(nameatom)) 00993 return trueAtom; 00994 } 00995 while ((o = o->getDelegate()) != NULL); 00996 return falseAtom; 00997 }
|
|
||||||||||||||||||||
|
Definition at line 1151 of file MethodEnv.cpp. References avmplus::AtomConstants::BIND_CONST, avmplus::AtomConstants::BIND_VAR, avmplus::Toplevel::getBinding(), avmplus::ErrorConstants::kConstWriteError, avmplus::Toplevel::setproperty_b(), avmplus::Toplevel::throwReferenceError(), toplevel(), avmplus::VTable::traits, and vtable. 01152 { 01153 Toplevel* toplevel = this->toplevel(); 01154 Binding b = toplevel->getBinding(vtable->traits, multiname); 01155 if ((b&7) == BIND_CONST) 01156 { 01157 if (vtable->init != this) 01158 toplevel->throwReferenceError(kConstWriteError, multiname, vtable->traits); 01159 b = (b & ~7) | BIND_VAR; 01160 } 01161 toplevel->setproperty_b(obj, multiname, value, vtable, b); 01162 }
|
|
|
Definition at line 1598 of file MethodEnv.cpp. References avmplus::AvmCore::atomToNamespace(), core(), avmplus::AvmCore::internNamespace(), avmplus::AvmCore::isNull(), avmplus::ErrorConstants::kIllegalNamespaceError, avmplus::AtomConstants::kNamespaceType, avmplus::Toplevel::throwTypeError(), and toplevel(). 01599 { 01600 if (((nsAtom&7) != kNamespaceType) || AvmCore::isNull(nsAtom)) 01601 toplevel()->throwTypeError(kIllegalNamespaceError); 01602 return core()->internNamespace(AvmCore::atomToNamespace(nsAtom)); 01603 }
|
|
|
Definition at line 431 of file MethodEnv.cpp. References avmplus::Traits::core, avmplus::AvmCore::interrupt(), avmplus::VTable::traits, and vtable. 00432 { 00433 vtable->traits->core->interrupt(this); 00434 }
|
|
|
Definition at line 1725 of file MethodEnv.cpp. References avmplus::ScriptObject::atom(), coerceEnter(), core(), getActivation(), avmplus::VTable::getExtraSize(), MMgc::GCRoot::GetGC(), SAMPLE_FRAME, and vtable. 01726 { 01727 VTable *vtable = getActivation(); 01728 AvmCore *core = this->core(); 01729 MMgc::GC *gc = core->GetGC(); 01730 SAMPLE_FRAME("[activation-object]", core); 01731 ScriptObject* obj = new (gc, vtable->getExtraSize()) ScriptObject(vtable, 0/*delegate*/); 01732 MethodEnv *init = vtable->init; 01733 if (init) 01734 init->coerceEnter(obj->atom()); 01735 return obj; 01736 }
|
|
|
Definition at line 675 of file MethodEnv.cpp. References avmplus::ScriptObject::construct(), core(), avmplus::AvmCore::newObject(), avmplus::AvmCore::newVTable(), NULL, avmplus::BuiltinTraits::object_itraits, avmplus::VTable::resolveSignatures(), toplevel(), and avmplus::AvmCore::traits. 00676 { 00677 AvmCore* core = this->core(); 00678 Toplevel* toplevel = this->toplevel(); 00679 if (traits == core->traits.object_itraits) 00680 { 00681 // don't need temporary vtable. this is a scope for a finally clause 00682 // todo: asc shouldn't even call OP_newcatch in a finally clause 00683 return toplevel->objectClass->construct(); 00684 } 00685 else 00686 { 00687 VTable *vt = core->newVTable(traits, NULL, vtable->scope, vtable->abcEnv, toplevel); 00688 vt->resolveSignatures(); 00689 return core->newObject(vt, NULL); 00690 } 00691 }
|
|
||||||||||||||||||||
|
OP_newclass Definition at line 1047 of file MethodEnv.cpp. References core(), avmplus::ScopeChain::create(), avmplus::AvmCore::dxnsAddr, MMgc::GCRoot::GetGC(), avmplus::ScopeChain::getSize(), avmplus::Traits::itraits, avmplus::ClassClosure::ivtable(), avmplus::ErrorConstants::kConvertNullToObjectError, avmplus::ErrorConstants::kCorruptABCError, avmplus::ErrorConstants::kInvalidBaseClassError, NULL, avmplus::Traits::resolveSignatures(), SAMPLE_FRAME, avmplus::ScopeChain::setScope(), avmplus::ErrorClass::throwError(), avmplus::Toplevel::throwTypeError(), toplevel(), avmplus::VTable::traits, avmplus::Toplevel::typeErrorClass(), and avmplus::Toplevel::verifyErrorClass(). 01051 { 01052 AvmCore* core = this->core(); 01053 // adds clarity to what is usually just global$init() 01054 SAMPLE_FRAME("[newclass]", core); 01055 Toplevel* toplevel = this->toplevel(); 01056 01057 Traits* ctraits = cinit->declaringTraits; 01058 Traits* itraits = ctraits->itraits; 01059 01060 // finish resolving the base class 01061 if (!base && itraits->base) 01062 { 01063 // class has a base but no base object was provided 01064 ErrorClass *error = toplevel->typeErrorClass(); 01065 if( error ) 01066 error->throwError(kConvertNullToObjectError); 01067 else 01068 toplevel->throwTypeError(kCorruptABCError); 01069 } 01070 01071 // make sure the traits of the base vtable matches the base traits 01072 if (!(base == NULL && itraits->base == NULL || base != NULL && itraits->base == base->ivtable()->traits)) 01073 { 01074 ErrorClass *error = toplevel->verifyErrorClass(); 01075 if( error ) 01076 error->throwError(kInvalidBaseClassError); 01077 else 01078 toplevel->throwTypeError(kCorruptABCError); 01079 } 01080 01081 ctraits->resolveSignatures(toplevel); 01082 itraits->resolveSignatures(toplevel); 01083 01084 // class scopechain = [..., class] 01085 ScopeChain* cscope = ScopeChain::create(core->GetGC(), ctraits->scope, outer, *core->dxnsAddr); 01086 01087 int staticScopesCount = 0; 01088 01089 int i = outer->getSize(); 01090 for (int n=cscope->getSize()-staticScopesCount; i < n; i++) 01091 { 01092 cscope->setScope(i, *scopes++); 01093 } 01094 01095 ScopeChain* iscope = ScopeChain::create(core->GetGC(), itraits->scope, cscope, *core->dxnsAddr); 01096 01097 AbcEnv *abcEnv = vtable->abcEnv; 01098 VTable* cvtable = core->newVTable(ctraits, toplevel->class_vtable, cscope, abcEnv, toplevel); 01099 cvtable->resolveSignatures(); 01100 VTable* ivtable = core->newVTable(itraits, base ? base->ivtable() : NULL, iscope, abcEnv, toplevel); 01101 ivtable->resolveSignatures(); 01102 cvtable->ivtable = ivtable; 01103 01104 if (itraits == core->traits.object_itraits) { 01105 // we just defined Object 01106 toplevel->object_vtable = ivtable; 01107 } 01108 else if (itraits == core->traits.class_itraits) { 01109 // we just defined Class 01110 toplevel->class_vtable = ivtable; 01111 cvtable->base = ivtable; 01112 toplevel->objectClass->vtable->base = ivtable; 01113 } 01114 01115 NativeClassInfop nativeEntry; 01116 ClassClosure *cc; 01117 if ((nativeEntry = cvtable->traits->getNativeClassInfo()) != NULL) 01118 { 01119 cc = nativeEntry->handler(cvtable); 01120 } 01121 else 01122 { 01123 cc = new (core->GetGC(), cvtable->getExtraSize()) ClassClosure(cvtable); 01124 AvmAssert(cc->prototype == NULL); 01125 cc->createVanillaPrototype(); 01126 } 01127 01128 if (cc->prototype) 01129 { 01130 // C.prototype.__proto__ = Base.prototype 01131 if (base != NULL) 01132 cc->prototype->setDelegate( base->prototype ); 01133 01134 // C.prototype.constructor = C {DontEnum} 01135 cc->prototype->setStringProperty(core->kconstructor, cc->atom()); 01136 cc->prototype->setStringPropertyIsEnumerable(core->kconstructor, false); 01137 } 01138 01139 AvmAssert(i == iscope->getSize()-1); 01140 iscope->setScope(i, cc->atom()); 01141 if (toplevel->classClass) 01142 { 01143 cc->setDelegate( toplevel->classClass->prototype ); 01144 } 01145 01146 // Invoke the class init function. 01147 cvtable->init->coerceEnter(cc->atom()); 01148 return cc; 01149 }
|
|
||||||||||||||||
|
OP_newfunction see 13.2 creating function objects Definition at line 1000 of file MethodEnv.cpp. References abcEnv(), AvmAssert, core(), avmplus::ScopeChain::create(), avmplus::AvmCore::dxnsAddr, MMgc::GCRoot::GetGC(), avmplus::ScopeChain::getSize(), NULL, and avmplus::ScopeChain::setScope(). 01003 { 01004 AvmCore* core = this->core(); 01005 AbcEnv* abcEnv = vtable->abcEnv; 01006 01007 // TODO: if we have already created a function and the scope chain 01008 // is the same as last time, re-use the old closure? 01009 01010 // declaringTraits must have been filled in by verifier. 01011 Traits* ftraits = function->declaringTraits; 01012 AvmAssert(ftraits != NULL); 01013 AvmAssert(ftraits->scope != NULL); 01014 01015 ScopeChain* scope = ScopeChain::create(core->GetGC(), ftraits->scope, outer, *core->dxnsAddr); 01016 01017 for (int i=outer->getSize(), n=scope->getSize(); i < n; i++) 01018 { 01019 scope->setScope(i, *scopes++); 01020 } 01021 01022 FunctionClass* functionClass = toplevel()->functionClass; 01023 01024 // the vtable for the new function object 01025 VTable* fvtable = core->newVTable(ftraits, functionClass->ivtable(), scope, abcEnv, toplevel()); 01026 fvtable->resolveSignatures(); 01027 FunctionEnv *fenv = new (core->GetGC()) FunctionEnv(function, fvtable); 01028 fvtable->call = fenv; 01029 fvtable->ivtable = toplevel()->object_vtable; 01030 01031 ClassClosure* c = new (core->GetGC(), fvtable->getExtraSize()) ClassClosure(fvtable); 01032 c->setDelegate( functionClass->prototype ); 01033 01034 c->createVanillaPrototype(); 01035 c->prototype->setStringProperty(core->kconstructor, c->atom()); 01036 c->prototype->setStringPropertyIsEnumerable(core->kconstructor, false); 01037 01038 fenv->closure = c; 01039 01040 return c; 01041 }
|
|
||||||||||||
|
Implementation of OP_nextname Definition at line 856 of file MethodEnv.cpp. References avmplus::AvmCore::atomToNamespace(), avmplus::AvmCore::atomToScriptObject(), avmplus::AbstractFunction::core(), avmplus::AtomConstants::kNamespaceType, avmplus::AtomConstants::kObjectType, method, avmplus::Namespace::nextName(), avmplus::ScriptObject::nextName(), avmplus::AtomConstants::nullStringAtom, toplevel(), avmplus::Toplevel::toPrototype(), and avmplus::AtomConstants::undefinedAtom. 00857 { 00858 if (index <= 0) 00859 return nullStringAtom; 00860 00861 switch (objAtom&7) 00862 { 00863 case kObjectType: 00864 return AvmCore::atomToScriptObject(objAtom)->nextName(index); 00865 case kNamespaceType: 00866 return AvmCore::atomToNamespace(objAtom)->nextName(method->core(), index); 00867 default: 00868 ScriptObject* proto = toplevel()->toPrototype(objAtom); // cn: types like Number are sealed, but their prototype could have dynamic properties 00869 return proto ? proto->nextName(index) : undefinedAtom; 00870 } 00871 }
|
|
||||||||||||
|
Implementation of OP_nextvalue Definition at line 873 of file MethodEnv.cpp. References avmplus::AvmCore::atomToNamespace(), avmplus::AvmCore::atomToScriptObject(), avmplus::AtomConstants::kNamespaceType, avmplus::AtomConstants::kObjectType, avmplus::Namespace::nextValue(), avmplus::ScriptObject::nextValue(), toplevel(), avmplus::Toplevel::toPrototype(), and avmplus::AtomConstants::undefinedAtom. 00874 { 00875 if (index <= 0) 00876 return undefinedAtom; 00877 00878 switch (objAtom&7) 00879 { 00880 case kObjectType: 00881 return AvmCore::atomToScriptObject(objAtom)->nextValue(index); 00882 case kNamespaceType: 00883 return AvmCore::atomToNamespace(objAtom)->nextValue(index); 00884 default: 00885 ScriptObject* proto = toplevel()->toPrototype(objAtom); 00886 return (proto ? proto->nextValue(index) : undefinedAtom); 00887 } 00888 }
|
|
|
Definition at line 426 of file MethodEnv.cpp. References avmplus::ErrorConstants::kConvertNullToObjectError, avmplus::Toplevel::throwTypeError(), and toplevel(). 00427 { 00428 toplevel()->throwTypeError(kConvertNullToObjectError); 00429 }
|
|
|
null pointer check Definition at line 410 of file MethodEnv.cpp. References avmplus::AvmCore::isNullOrUndefined(), avmplus::ErrorConstants::kConvertNullToObjectError, avmplus::ErrorConstants::kConvertUndefinedToObjectError, avmplus::ErrorConstants::kCorruptABCError, avmplus::ErrorClass::throwError(), avmplus::Toplevel::throwVerifyError(), toplevel(), avmplus::Toplevel::typeErrorClass(), and avmplus::AtomConstants::undefinedAtom. 00411 { 00412 if (!AvmCore::isNullOrUndefined(atom)) 00413 return; 00414 00415 // TypeError in ECMA 00416 ErrorClass *error = toplevel()->typeErrorClass(); 00417 if( error ){ 00418 error->throwError( 00419 (atom == undefinedAtom) ? kConvertUndefinedToObjectError : 00420 kConvertNullToObjectError); 00421 } else { 00422 toplevel()->throwVerifyError(kCorruptABCError); 00423 } 00424 }
|
|
||||||||||||
|
implementation of object initializers Definition at line 832 of file MethodEnv.cpp. References avmplus::String::atom(), AvmAssert, core(), avmplus::AbstractFunction::core(), avmplus::VTable::getExtraSize(), MMgc::GCRoot::GetGC(), avmplus::AvmCore::internString(), avmplus::AvmCore::isString(), method, configure::o, and toplevel(). 00833 { 00834 // pre-size the hashtable since we know how many vars are coming 00835 VTable* object_vtable = toplevel()->object_vtable; 00836 AvmCore* core = method->core(); 00837 00838 ScriptObject* o = new (core->GetGC(), object_vtable->getExtraSize()) 00839 ScriptObject(object_vtable, toplevel()->objectClass->prototype, 00840 2*argc+1); 00841 00842 for (; argc-- > 0; sp -= 2) 00843 { 00844 Atom name = sp[-1]; 00845 //verifier should ensure names are String 00846 //todo have the verifier take care of interning too 00847 AvmAssert(AvmCore::isString(name)); 00848 00849 o->setAtomProperty(core->internString(name)->atom(), sp[0]); 00850 } 00851 return o; 00852 }
|
|
||||||||||||
|
Definition at line 283 of file MethodEnv.h. References activationOrMCTable, core(), and WB. Referenced by getMethodClosureTable(), and MethodEnv(). 00284 { 00285 WB(core()->GetGC(), this, &activationOrMCTable, (uintptr)ptr|type); 00286 }
|
|
||||||||||||||||
|
Definition at line 1164 of file MethodEnv.cpp. References avmplus::String::atom(), avmplus::AvmCore::atomToScriptObject(), core(), avmplus::AbstractFunction::core(), avmplus::AvmCore::internInt(), avmplus::AvmCore::isObject(), avmplus::ErrorConstants::kWriteSealedError, method, configure::o, avmplus::Toplevel::throwReferenceError(), and toplevel(). 01165 { 01166 if (AvmCore::isObject(obj)) 01167 { 01168 ScriptObject* o = AvmCore::atomToScriptObject(obj); 01169 if (index >= 0) 01170 { 01171 o->setUintProperty(index, value); 01172 } 01173 else 01174 { 01175 // negative index - we must intern the integer 01176 o->setAtomProperty(method->core()->internInt(index)->atom(), value); 01177 } 01178 } 01179 else 01180 { 01181 // obj represents a primitive Number, Boolean, int, or String, and primitives 01182 // are sealed and final. Cannot add dynamic vars to them. 01183 01184 // throw a ReferenceError exception Property not found and could not be created. 01185 Multiname tempname(core()->publicNamespace, core()->internInt(index)); 01186 toplevel()->throwReferenceError(kWriteSealedError, &tempname, toplevel()->toTraits(obj)); 01187 } 01188 }
|
|
||||||||||||||||
|
Definition at line 1190 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), core(), avmplus::AvmCore::isObject(), avmplus::ErrorConstants::kWriteSealedError, avmplus::ScriptObject::setUintProperty(), avmplus::Toplevel::throwReferenceError(), and toplevel(). 01191 { 01192 if (AvmCore::isObject(obj)) 01193 { 01194 AvmCore::atomToScriptObject(obj)->setUintProperty(index, value); 01195 } 01196 else 01197 { 01198 // obj represents a primitive Number, Boolean, int, or String, and primitives 01199 // are sealed and final. Cannot add dynamic vars to them. 01200 01201 // throw a ReferenceError exception Property not found and could not be created. 01202 Multiname tempname(core()->publicNamespace, core()->internUint32(index)); 01203 toplevel()->throwReferenceError(kWriteSealedError, &tempname, toplevel()->toTraits(obj)); 01204 } 01205 }
|
|
||||||||||||||||
|
Write to a property of an object, with the property to modify specified by its binding. The binding was likely retrieved using getBinding.
Definition at line 1347 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), AvmAssert, avmplus::AtomConstants::BIND_CONST, avmplus::AtomConstants::BIND_GET, avmplus::AtomConstants::BIND_GETSET, avmplus::AtomConstants::BIND_METHOD, avmplus::AtomConstants::BIND_SET, avmplus::AtomConstants::BIND_VAR, avmplus::AvmCore::bindingToSetterId(), avmplus::AvmCore::bindingToSlotId(), avmplus::AvmCore::console, core(), avmplus::Toplevel::getBinding(), avmplus::ErrorConstants::kCannotAssignToMethodError, avmplus::ErrorConstants::kConstWriteError, avmplus::ErrorConstants::kWriteSealedError, build::dependparser::m, method, avmplus::VTable::methods, avmplus::Multiname::name, avmplus::ScriptObject::setSlotAtom(), avmplus::Toplevel::throwReferenceError(), toplevel(), avmplus::VTable::traits, and vtable. 01348 { 01349 VTable* vtable = this->vtable->base; 01350 Toplevel* toplevel = this->toplevel(); 01351 Binding b = toplevel->getBinding(vtable->traits, multiname); 01352 switch (b&7) 01353 { 01354 default: 01355 toplevel->throwReferenceError(kWriteSealedError, multiname, vtable->traits); 01356 01357 case BIND_CONST: 01358 toplevel->throwReferenceError(kConstWriteError, multiname, vtable->traits); 01359 01360 case BIND_METHOD: 01361 toplevel->throwReferenceError(kCannotAssignToMethodError, multiname, vtable->traits); 01362 01363 case BIND_GET: 01364 #ifdef DEBUG_EARLY_BINDING 01365 core()->console << "setsuper getter " << vtable->traits << " " << multiname->name << "\n"; 01366 #endif 01367 toplevel->throwReferenceError(kConstWriteError, multiname, vtable->traits); 01368 01369 case BIND_VAR: 01370 #ifdef DEBUG_EARLY_BINDING 01371 core()->console << "setsuper slot " << vtable->traits << " " << multiname->name << "\n"; 01372 #endif 01373 AvmCore::atomToScriptObject(obj)->setSlotAtom(AvmCore::bindingToSlotId(b), value); 01374 return; 01375 01376 case BIND_SET: 01377 case BIND_GETSET: 01378 { 01379 #ifdef DEBUG_EARLY_BINDING 01380 core()->console << "setsuper setter " << vtable->traits << " " << multiname->name << "\n"; 01381 #endif 01382 // Invoke the setter 01383 uint32 m = AvmCore::bindingToSetterId(b); 01384 AvmAssert(m < vtable->traits->methodCount); 01385 MethodEnv* method = vtable->methods[m]; 01386 Atom atomv_out[2] = { obj, value }; 01387 // coerce value to proper type, then call enter 01388 method->coerceEnter(1, atomv_out); 01389 return; 01390 } 01391 } 01392 }
|
|
|
Definition at line 96 of file MethodEnv.cpp. References avmplus::AbstractFunction::argcOk(), avmplus::Toplevel::argumentErrorClass(), core(), avmplus::ErrorConstants::kWrongArgumentCountError, method, avmplus::AbstractFunction::requiredParamCount(), avmplus::ErrorClass::throwError(), avmplus::AvmCore::toErrorString(), toplevel(), and vtable. Referenced by coerceEnter(). 00097 { 00098 Toplevel* toplevel = vtable->toplevel; 00099 00100 if (!method->argcOk(argc)) 00101 { 00102 toplevel->argumentErrorClass()->throwError(kWrongArgumentCountError, core()->toErrorString((AbstractFunction*)method), core()->toErrorString(method->requiredParamCount()), core()->toErrorString(argc)); 00103 } 00104 00105 // Can happen with duplicate function definitions from corrupt ABC data. F1 is defined 00106 // and F2 overrides the F1 slot which is okay as long as F1's MethodEnv is never called again. 00107 if (method->declaringTraits != this->declTraits) 00108 { 00109 toplevel->throwVerifyError(kCorruptABCError); 00110 } 00111 00112 // just do enough to resolve signatures. Don't do a full verify yet. 00113 method->resolveSignature(toplevel); 00114 00115 // now unbox everything, including instance and rest args 00116 int extra = argc > method->param_count ? argc - method->param_count : 0; 00117 AvmAssert(method->restOffset > 0 && extra >= 0); 00118 00119 return extra; 00120 }
|
|
|
Definition at line 436 of file MethodEnv.cpp. References core(), and avmplus::AvmCore::stackOverflow(). 00437 { 00438 this->core()->stackOverflow(this); 00439 }
|
|
|
returns the instance traits of the factorytype of the passed atom Definition at line 441 of file MethodEnv.cpp. References avmplus::AvmCore::atomToScriptObject(), avmplus::AvmCore::isNull(), avmplus::Traits::itraits, avmplus::ErrorConstants::kConvertNullToObjectError, avmplus::ErrorConstants::kConvertUndefinedToObjectError, avmplus::ErrorConstants::kIsTypeMustBeClassError, avmplus::AtomConstants::kObjectType, NULL, avmplus::Toplevel::throwTypeError(), toplevel(), avmplus::ScriptObject::traits(), and avmplus::AtomConstants::undefinedAtom. 00442 { 00443 switch (atom&7) 00444 { 00445 case kObjectType: 00446 { 00447 if( !AvmCore::isNull(atom) ) 00448 { 00449 Traits* itraits = AvmCore::atomToScriptObject(atom)->traits()->itraits; 00450 if (itraits == NULL) 00451 toplevel()->throwTypeError(kIsTypeMustBeClassError); 00452 return itraits; 00453 } 00454 // else fall through and report an error 00455 } 00456 default: 00457 // TypeError in ECMA 00458 // ISSUE the error message should say "whatever" is not a class 00459 toplevel()->throwTypeError( 00460 (atom == undefinedAtom) ? kConvertUndefinedToObjectError : 00461 kConvertNullToObjectError); 00462 return NULL; 00463 } 00464 }
|
|
|
Definition at line 59 of file MethodEnv.h. References vtable. Referenced by callsuper(), checkfilter(), coerceAtom2SO(), coerceEnter(), createArguments(), createRest(), delproperty(), finddef(), findglobalproperty(), findproperty(), findWithProperty(), getdescendants(), getpropertylate_i(), getpropertylate_u(), getsuper(), hasnext(), hasnextproto(), in(), avmplus::ScriptEnv::initGlobal(), avmplus::initMultinameNoXMLList(), initproperty(), internRtns(), avmplus::interp(), MethodEnv(), newcatch(), newclass(), nextname(), nextvalue(), npe(), nullcheck(), op_newobject(), setpropertylate_i(), setpropertylate_u(), setsuper(), startCoerce(), toClassITraits(), unbox1(), unboxCoerceArgs(), avmplus::NativeMethod::verifyEnter(), and avmplus::MethodInfo::verifyEnter(). 00060 { 00061 return vtable->toplevel; 00062 }
|
|
||||||||||||||||||||||||
|
Definition at line 46 of file MethodEnv.cpp. References AvmAssert, avmplus::AvmCore::boolean(), BOOLEAN_TYPE, avmplus::Toplevel::coerce(), core(), INT_TYPE, avmplus::AvmCore::integer(), avmplus::AtomConstants::nullObjectAtom, avmplus::AvmCore::number(), NUMBER_TYPE, OBJECT_TYPE, toplevel(), avmplus::AvmCore::toUInt32(), UINT_TYPE, avmplus::AtomConstants::undefinedAtom, and VOID_TYPE. Referenced by coerceEnter(), and unboxCoerceArgs(). 00047 { 00048 AvmAssert(t != VOID_TYPE); 00049 00050 if (t == NUMBER_TYPE) 00051 { 00052 union { 00053 double d; 00054 uint32 l[2]; 00055 }; 00056 d = core->number(in); 00057 #ifdef AVMPLUS_64BIT 00058 AvmAssert(sizeof(Atom) == sizeof(double)); 00059 *(double *) args = d; 00060 args++; 00061 #else 00062 AvmAssert(sizeof(Atom) * 2 == sizeof(double)); 00063 *args++ = l[0]; 00064 *args++ = l[1]; 00065 #endif 00066 } 00067 else if (t == INT_TYPE) 00068 { 00069 *args++ = core->integer(in); 00070 } 00071 else if (t == UINT_TYPE) 00072 { 00073 *args++ = core->toUInt32(in); 00074 } 00075 else if (t == BOOLEAN_TYPE) 00076 { 00077 *args++ = core->boolean(in); 00078 } 00079 else if (t == OBJECT_TYPE) 00080 { 00081 *args++ = in == undefinedAtom ? nullObjectAtom : in; 00082 } 00083 else if (!t) 00084 { 00085 *args++ = in; 00086 } 00087 else 00088 { 00089 // ScriptObject, String, or Namespace, or Null 00090 *args++ = toplevel->coerce(in,t) & ~7; 00091 } 00092 return args; 00093 }
|
|
||||||||||||||||||||
|
Definition at line 263 of file MethodEnv.cpp. References runtests::args, core(), runtests::f, util::threadpool::i, method, toplevel(), and unbox1(). 00264 { 00265 AbstractFunction* f = this->method; 00266 AvmCore* core = this->core(); 00267 Toplevel* toplevel = this->toplevel(); 00268 00269 Atom *args = unbox1(core, toplevel, thisArg, f->paramTraits(0), (Atom *) argv); 00270 00271 int end = argc >= f->param_count ? f->param_count : argc; 00272 for (int i=0; i < end; i++) 00273 args = unbox1(core, toplevel, in[i], f->paramTraits(i+1), args); 00274 while (end < argc) 00275 *args++ = in[end++]; 00276 }
|
|
||||||||||||||||
|
convert atoms to native args. argc is the number of args, not counting the instance which is arg[0]. the layout is [instance][arg1..argN] Definition at line 232 of file MethodEnv.cpp. References runtests::args, core(), runtests::f, util::threadpool::i, method, toplevel(), and unbox1(). 00233 { 00234 AbstractFunction* f = this->method; 00235 AvmCore* core = this->core(); 00236 Toplevel* toplevel = this->toplevel(); 00237 00238 Atom *args = unbox1(core, toplevel, in[0], f->paramTraits(0), (Atom *) argv); 00239 00240 int end = argc >= f->param_count ? f->param_count : argc; 00241 for (int i=0; i < end; i++) 00242 args = unbox1(core, toplevel, in[i+1], f->paramTraits(i+1), args); 00243 while (end < argc) 00244 *args++ = in[++end]; 00245 }
|
|
||||||||||||||||
|
Definition at line 247 of file MethodEnv.cpp. References runtests::args, core(), runtests::f, avmplus::ArrayObject::getLength(), avmplus::ArrayObject::getUintProperty(), util::threadpool::i, method, toplevel(), and unbox1(). Referenced by coerceEnter(). 00248 { 00249 AbstractFunction* f = this->method; 00250 AvmCore* core = this->core(); 00251 Toplevel* toplevel = this->toplevel(); 00252 int argc = a->getLength(); 00253 00254 Atom *args = unbox1(core, toplevel, thisArg, f->paramTraits(0), (Atom *) argv); 00255 00256 int end = argc >= f->param_count ? f->param_count : argc; 00257 for (int i=0; i < end; i++) 00258 args = unbox1(core, toplevel, a->getUintProperty(i), f->paramTraits(i+1), args); 00259 while (end < argc) 00260 *args++ = a->getUintProperty(end++); 00261 }
|
|
|
Definition at line 299 of file MethodEnv.h. Referenced by getActivation(), getMethodClosureTable(), getPair(), getType(), and setActivationOrMCTable(). |
|
|
Definition at line 292 of file MethodEnv.h. |
|
|
Definition at line 294 of file MethodEnv.h. Referenced by delegateInvoke(), MethodEnv(), avmplus::NativeMethod::verifyEnter(), and avmplus::MethodInfo::verifyEnter(). |
|
|
Definition at line 295 of file MethodEnv.h. |
|
|
Definition at line 296 of file MethodEnv.h. Referenced by MethodEnv(). |
|
|
|
Definition at line 290 of file MethodEnv.h. Referenced by abcEnv(), avmplus::AvmCore::codeContext(), domainEnv(), getsuper(), initproperty(), avmplus::interp(), interrupt(), MethodEnv(), newActivation(), setsuper(), startCoerce(), toplevel(), avmplus::NativeMethod::verifyEnter(), and avmplus::MethodInfo::verifyEnter(). |
1.4.6