Beispiel #1
0
void
_ejs_process_init(ejsval global, uint32_t argc, char **argv)
{
    _ejs_Process = _ejs_object_new (_ejs_null, &_ejs_Object_specops);
    _ejs_object_setprop (global, _ejs_atom_process, _ejs_Process);

    ejsval _argv = _ejs_array_new (argc, EJS_FALSE);
    _ejs_object_setprop (_ejs_Process, _ejs_atom_argv, _argv);

    for (int i = 0; i < argc; i ++)
        _ejs_object_setprop (_argv, NUMBER_TO_EJSVAL(i), _ejs_string_new_utf8(argv[i]));

#define OBJ_PROP(x) EJS_INSTALL_ATOM_GETTER(_ejs_Process, x, _ejs_Process_get_##x)
#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Process, x, _ejs_Process_##x)

    OBJ_PROP(env);

    OBJ_METHOD(exit);

    OBJ_METHOD(chdir);
    OBJ_METHOD(cwd);

#undef OBJ_PROP
#undef OBJ_METHOD
}
Beispiel #2
0
void
_ejs_promise_init(ejsval global)
{
    _ejs_Promise = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_Promise, (EJSClosureFunc)_ejs_Promise_impl);
    _ejs_object_setprop (global, _ejs_atom_Promise, _ejs_Promise);

    _ejs_gc_add_root (&_ejs_Promise_prototype);
    _ejs_Promise_prototype = _ejs_object_new(_ejs_null, &_ejs_Object_specops);
    _ejs_object_setprop (_ejs_Promise,       _ejs_atom_prototype,  _ejs_Promise_prototype);
    _ejs_object_define_value_property (_ejs_Promise_prototype, _ejs_atom_constructor, _ejs_Promise,
                                       EJS_PROP_NOT_ENUMERABLE | EJS_PROP_CONFIGURABLE | EJS_PROP_WRITABLE);

#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS (_ejs_Promise_prototype, x, _ejs_Promise_prototype_##x, EJS_PROP_NOT_ENUMERABLE)
#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS (_ejs_Promise, x, _ejs_Promise_##x, EJS_PROP_NOT_ENUMERABLE)

    PROTO_METHOD(catch);
    PROTO_METHOD(then);

    _ejs_object_define_value_property (_ejs_Promise_prototype, _ejs_Symbol_toStringTag, _ejs_atom_Promise, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_NOT_WRITABLE | EJS_PROP_CONFIGURABLE);

    OBJ_METHOD(all);
    OBJ_METHOD(race);
    OBJ_METHOD(reject);
    OBJ_METHOD(resolve);

#undef PROTO_METHOD

    EJS_INSTALL_SYMBOL_FUNCTION_FLAGS (_ejs_Promise, create, _ejs_Promise_create, EJS_PROP_NOT_ENUMERABLE);

    _ejs_gc_add_root(&_ejs_identity_function);
    _ejs_identity_function = _ejs_function_new_anon(_ejs_undefined, identity);
    _ejs_gc_add_root(&_ejs_thrower_function);
    _ejs_thrower_function = _ejs_function_new_anon(_ejs_undefined, thrower);
}
Beispiel #3
0
void
_ejs_symbol_init(ejsval global)
{
    _ejs_Symbol = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_Symbol, _ejs_Symbol_impl);
    _ejs_object_setprop (global, _ejs_atom_Symbol, _ejs_Symbol);

    _ejs_gc_add_root (&_ejs_Symbol_prototype);
    _ejs_Symbol_prototype = _ejs_object_new(_ejs_null, &_ejs_Object_specops); // XXX
    _ejs_object_setprop (_ejs_Symbol,       _ejs_atom_prototype,  _ejs_Symbol_prototype);

    PROTO_METHOD(toString);
    PROTO_METHOD(valueOf);

    OBJ_METHOD(for);
    OBJ_METHOD(keyFor);

    WELL_KNOWN_SYMBOL(hasInstance);
    WELL_KNOWN_SYMBOL(isConcatSpreadable);
    WELL_KNOWN_SYMBOL(species);
    WELL_KNOWN_SYMBOL(iterator);
    WELL_KNOWN_SYMBOL(toPrimitive);
    WELL_KNOWN_SYMBOL(toStringTag);
    WELL_KNOWN_SYMBOL(unscopables);
    WELL_KNOWN_SYMBOL(match);
    WELL_KNOWN_SYMBOL(replace);
    WELL_KNOWN_SYMBOL(split);
    WELL_KNOWN_SYMBOL(search);

    _ejs_object_define_value_property (_ejs_Symbol_prototype, _ejs_Symbol_toStringTag, _ejs_atom_Symbol, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_NOT_WRITABLE | EJS_PROP_CONFIGURABLE);
}
Beispiel #4
0
    void
    ArrayType_init (ejsval exports)
    {
        _ejs_ArrayType_specops = _ejs_Object_specops;
        _ejs_ArrayType_specops.class_name = "LLVMArray";
        _ejs_ArrayType_specops.Allocate = ArrayType_allocate;

        _ejs_gc_add_root (&_ejs_ArrayType_prototype);
        _ejs_ArrayType_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_ArrayType_specops);

        _ejs_ArrayType = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMArrayType", (EJSClosureFunc)ArrayType_impl, _ejs_ArrayType_prototype);

        _ejs_object_setprop_utf8 (exports,              "ArrayType", _ejs_ArrayType);


#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_ArrayType, x, ArrayType_##x)
#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_ArrayType_prototype, x, ArrayType_prototype_##x)

        OBJ_METHOD(get);

        PROTO_METHOD(dump);
        PROTO_METHOD(toString);

#undef PROTO_METHOD
#undef OBJ_METHOD
    }
Beispiel #5
0
    void
    Type_init (ejsval exports)
    {
        _ejs_gc_add_root (&_ejs_Type_prototype);
        _ejs_Type_prototype = _ejs_object_create(_ejs_Object_prototype);

        _ejs_Type = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMType", (EJSClosureFunc)Type_impl, _ejs_Type_prototype);

        _ejs_object_setprop_utf8 (exports,              "Type", _ejs_Type);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Type, x, Type_##x)
#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Type_prototype, x, Type_prototype_##x)

        OBJ_METHOD(getDoubleTy);
        OBJ_METHOD(getInt64Ty);
        OBJ_METHOD(getInt32Ty);
        OBJ_METHOD(getInt16Ty);
        OBJ_METHOD(getInt8Ty);
        OBJ_METHOD(getInt1Ty);
        OBJ_METHOD(getVoidTy);

        PROTO_METHOD(pointerTo);
        PROTO_METHOD(isVoid);
        PROTO_METHOD(dump);
        PROTO_METHOD(toString);
    }
Beispiel #6
0
    void
    Constant_init (ejsval exports)
    {
        _ejs_gc_add_root (&_ejs_Constant_prototype);
        _ejs_Constant_prototype = _ejs_object_create(_ejs_Object_prototype);

        _ejs_Constant = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMConstant", (EJSClosureFunc)Constant_impl, _ejs_Constant_prototype);

        _ejs_object_setprop_utf8 (exports,              "Constant", _ejs_Constant);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Constant, x, Constant_##x)
#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Constant_prototype, x, Constant_prototype_##x)

        OBJ_METHOD(getNull);
        OBJ_METHOD(getAggregateZero);
        OBJ_METHOD(getBoolValue);
        OBJ_METHOD(getIntegerValue);

#undef PROTO_METHOD
#undef OBJ_METHOD

    }
Beispiel #7
0
    void
    DebugLoc_init (ejsval exports)
    {
        _ejs_DebugLoc_specops = _ejs_Object_specops;
        _ejs_DebugLoc_specops.class_name = "LLVMDebugLoc";
        _ejs_DebugLoc_specops.Allocate = DebugLoc_allocate;

        _ejs_gc_add_root (&_ejs_DebugLoc_prototype);
        _ejs_DebugLoc_prototype = _ejs_object_create(_ejs_Object_prototype);

        _ejs_DebugLoc = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMDebugLoc", (EJSClosureFunc)DebugLoc_impl, _ejs_DebugLoc_prototype);

        _ejs_object_setprop_utf8 (exports,              "DebugLoc", _ejs_DebugLoc);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_DebugLoc, x, DebugLoc_##x)

        OBJ_METHOD(get);
    }
Beispiel #8
0
  void
  ConstantArray_init (ejsval exports)
  {
    _ejs_gc_add_root (&_ejs_ConstantArray_proto);
    _ejs_ConstantArray_proto = _ejs_object_create(_ejs_Object_prototype);

    _ejs_ConstantArray = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMConstantArray", (EJSClosureFunc)ConstantArray_impl, _ejs_ConstantArray_proto);

    _ejs_object_setprop_utf8 (exports,              "ConstantArray", _ejs_ConstantArray);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_ConstantArray, x, ConstantArray_##x)
#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_ConstantArray_proto, x, ConstantArray_prototype_##x)

    OBJ_METHOD(get);

#undef PROTO_METHOD
#undef OBJ_METHOD
  }
Beispiel #9
0
    void
    StructType_init (ejsval exports)
    {
        _ejs_StructType_proto = _ejs_object_create (Type_get_prototype());
        _ejs_StructType = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMStructType", (EJSClosureFunc)StructType_impl, _ejs_StructType_proto);

        _ejs_object_setprop_utf8 (exports,              "StructType", _ejs_StructType);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_StructType, x, StructType_##x)
#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_StructType_proto, x, StructType_prototype_##x)

        OBJ_METHOD(create);

        PROTO_METHOD(dump);
        PROTO_METHOD(toString);

#undef OBJ_METHOD
#undef PROTO_METHOD
    }
Beispiel #10
0
    void
    FunctionType_init (ejsval exports)
    {
        _ejs_gc_add_root (&_ejs_FunctionType_proto);
        _ejs_FunctionType_proto = _ejs_object_create (Type_get_prototype());

        _ejs_FunctionType = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMFunctionType", (EJSClosureFunc)FunctionType_impl, _ejs_FunctionType_proto);

        _ejs_object_setprop_utf8 (exports,              "FunctionType", _ejs_FunctionType);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_FunctionType, x, FunctionType_##x)
#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_FunctionType_proto, x, FunctionType_prototype_##x)

        OBJ_METHOD(get);
        PROTO_METHOD(getReturnType);
        PROTO_METHOD(getParamType);
        PROTO_METHOD(dump);
        PROTO_METHOD(toString);

#undef OBJ_METHOD
#undef PROTO_METHOD
    }
Beispiel #11
0
void
_ejs_reflect_init(ejsval global)
{
    _ejs_Reflect = _ejs_object_new (_ejs_Object_prototype, &_ejs_Object_specops);
    _ejs_object_setprop (global, _ejs_atom_Reflect, _ejs_Reflect);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Reflect, x, _ejs_Reflect_##x)

    OBJ_METHOD(apply);
    OBJ_METHOD(construct);
    OBJ_METHOD(defineProperty);
    OBJ_METHOD(deleteProperty);
    OBJ_METHOD(enumerate);
    OBJ_METHOD(get);
    OBJ_METHOD(getOwnPropertyDescriptor);
    OBJ_METHOD(getPrototypeOf);
    OBJ_METHOD(has);
    OBJ_METHOD(isExtensible);
    OBJ_METHOD(ownKeys);
    OBJ_METHOD(preventExtensions);
    OBJ_METHOD(set);
    OBJ_METHOD(setPrototypeOf);

#undef OBJ_METHOD
}
Beispiel #12
0
    void
    IRBuilder_init (ejsval exports)
    {
        _ejs_gc_add_root (&_ejs_IRBuilder_prototype);
        _ejs_IRBuilder_prototype = _ejs_object_create(_ejs_Object_prototype);

        _ejs_IRBuilder = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMIRBuilder", (EJSClosureFunc)IRBuilder_impl, _ejs_IRBuilder_prototype);

        _ejs_object_setprop_utf8 (exports,              "IRBuilder", _ejs_IRBuilder);

#define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_IRBuilder, x, IRBuilder_##x)

        OBJ_METHOD(setInsertPoint);
        OBJ_METHOD(setInsertPointStartBB);
        OBJ_METHOD(getInsertBlock);
        OBJ_METHOD(createRet);
        OBJ_METHOD(createRetVoid);
        OBJ_METHOD(createPointerCast);
        OBJ_METHOD(createFPCast);
        OBJ_METHOD(createCall);
        OBJ_METHOD(createInvoke);
        OBJ_METHOD(createFAdd);
        OBJ_METHOD(createAlloca);
        OBJ_METHOD(createLoad);
        OBJ_METHOD(createStore);
        OBJ_METHOD(createExtractElement);
        OBJ_METHOD(createExtractValue);
        OBJ_METHOD(createGetElementPointer);
        OBJ_METHOD(createInBoundsGetElementPointer);
        OBJ_METHOD(createStructGetElementPointer);
        OBJ_METHOD(createICmpEq);
        OBJ_METHOD(createICmpSGt);
        OBJ_METHOD(createICmpUGE);
        OBJ_METHOD(createICmpUGt);
        OBJ_METHOD(createICmpULt);
        OBJ_METHOD(createBr);
        OBJ_METHOD(createCondBr);
        OBJ_METHOD(createPhi);
        OBJ_METHOD(createGlobalStringPtr);
        OBJ_METHOD(createUnreachable);
        OBJ_METHOD(createAnd);
        OBJ_METHOD(createOr);
        OBJ_METHOD(createZExt);
        OBJ_METHOD(createIntToPtr);
        OBJ_METHOD(createPtrToInt);
        OBJ_METHOD(createBitCast);

        OBJ_METHOD(createSwitch);
        OBJ_METHOD(createSelect);

        OBJ_METHOD(createNswSub);
    
        OBJ_METHOD(createLandingPad);
        OBJ_METHOD(createResume);

        OBJ_METHOD(setCurrentDebugLocation);

#undef OBJ_METHOD
    }