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); }
void Interpreter::AddPrimitive(const Value & object, String message, PrimitiveMethod primitive) { StringId id = mStrings.Add(message); object.AsDynamic()->AddPrimitive(id, primitive); }