Value Interpreter::MakeGlobal(const char * name) { int index = DefineGlobal(String(name)); Value global = NewObject(mObject, name); SetGlobal(index, global); return global; }
ALERROR CCodeChain::DefineGlobalString (const CString &sVar, const CString &sValue) { ALERROR error; ICCItem *pValue = CreateString(sValue); error = DefineGlobal(sVar, pValue); pValue->Discard(this); return error; }
void Compiler::EmitGlobals(void) { vector<Symbol>::iterator p = GlobalIDs.buckets.begin(); for (; p != GlobalIDs.buckets.end(); p++) { if ((*p)->kind == SK_Variable) { DefineGlobal(*p); } } }
void Interpreter::BindMethod(String objectName, String message, PrimitiveMethod method) { ASSERT_STRING_NOT_EMPTY(objectName); ASSERT_STRING_NOT_EMPTY(message); ASSERT_NOT_NULL(method); int globalIndex = DefineGlobal(objectName); Value object = GetGlobal(globalIndex); ASSERT(!object.IsNull(), "Must be an existing global variable."); DynamicObject* dynamicObj = object.AsDynamic(); ASSERT_NOT_NULL(dynamicObj); StringId messageId = mStrings.Add(message); dynamicObj->AddPrimitive(messageId, method); }