const variable* ASObject::findVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt, Class_base* cls) { //Get from the current object without considering borrowed properties const variable* var=findGettable(name); if(!var && cls) { //Look for borrowed traits before var=cls->findBorrowedGettable(name); } if(!var && cls) { //Check prototype chain Prototype* proto = cls->prototype.getPtr(); while(proto) { var = proto->getObj()->findGettable(name); if(var) break; proto = proto->prevPrototype.getPtr(); } } return var; }
bool ASObject::hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype) { //We look in all the object's levels uint32_t validTraits=DECLARED_TRAIT; if(considerDynamic) validTraits|=DYNAMIC_TRAIT; if(Variables.findObjVar(name, NO_CREATE_TRAIT, validTraits)!=NULL) return true; if(classdef && classdef->borrowedVariables.findObjVar(name, NO_CREATE_TRAIT, DECLARED_TRAIT)!=NULL) return true; //Check prototype inheritance chain if(getClass() && considerPrototype) { Prototype* proto = getClass()->prototype.getPtr(); while(proto) { if(proto->getObj()->findGettable(name) != NULL) return true; proto=proto->prevPrototype.getPtr(); } } //Must not ask for non borrowed traits as static class member are not valid return false; }