Value* get(Value* self, const std::string& name)
 {
     Register<ListValue> list = new ListValue;
     Register<StringValue> ident = new StringValue(name);
     list->push(ident);
     return invoke(iid, number, static_cast<InterfacePointerValue*>(self), list);
 }
 // Setter
 virtual bool put(Value* self, Value* value)
 {
     if (dynamic_cast<InterfacePointerValue*>(self) && !readOnly)
     {
         Register<ListValue> list = new ListValue;
         list->push(value);
         invoke(iid, setter, static_cast<InterfacePointerValue*>(self), list);
     }
     return true;
 }
Ejemplo n.º 3
0
ObjectValue*
StringValue::toObject()
{
    // Create a new String object
    ObjectValue* string = dynamic_cast<ObjectValue*>(getGlobal()->get("String"));
    if (!string || !string->getCode())
    {
        throw getErrorInstance("TypeError");
    }
    Register<ListValue> list = new ListValue;
    list->push(this);
    return string->construct(list);
};
Ejemplo n.º 4
0
// TODO(ishibashi.kenichi): remove later. Temporary test code.
Value* createOrderedMap()
{
    es::OrderedMap* map = new OrderedMap;
    Register<Value> value = new InterfacePointerValue(map);
    Register<ListValue> list = new ListValue;
    list->push(value);

    Register<ObjectValue> function = dynamic_cast<ObjectValue*>(global->get("OrderedMap"));
    if (!function || !function->getCode())
    {
        return UndefinedValue::getInstance();
    }
    return function->call(NullValue::getInstance(), list);
}
Ejemplo n.º 5
0
Value* getErrorInstance(const char* name, const char* message)
{
    Register<Value> error = global->get(name);
    Register<ListValue> list = new ListValue;
    if (message)
    {
        Register<Value> value = new StringValue(message);
        list->push(value);
    }
    Register<ObjectValue> function = dynamic_cast<ObjectValue*>(error->getValue());
    if (!function || !function->getCode())
    {
        return UndefinedValue::getInstance();
    }
    return function->call(NullValue::getInstance(), list);
}