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); }
void _ejs_weakset_init(ejsval global) { _ejs_gc_add_root (&_ejs_WeakSetData_symbol); _ejs_WeakSetData_symbol = _ejs_symbol_new(_ejs_atom_WeakSetData); _ejs_WeakSet = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_WeakSet, _ejs_WeakSet_impl); _ejs_object_setprop (global, _ejs_atom_WeakSet, _ejs_WeakSet); _ejs_gc_add_root (&_ejs_WeakSet_prototype); _ejs_WeakSet_prototype = _ejs_object_new (_ejs_Object_prototype, &_ejs_Object_specops); _ejs_object_setprop (_ejs_WeakSet, _ejs_atom_prototype, _ejs_WeakSet_prototype); #define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_WeakSet, x, _ejs_WeakSet_##x) #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS(_ejs_WeakSet_prototype, x, _ejs_WeakSet_prototype_##x, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_WRITABLE | EJS_PROP_CONFIGURABLE) #define PROTO_GETTER(x) EJS_INSTALL_ATOM_GETTER(_ejs_WeakSet_prototype, x, _ejs_WeakSet_prototype_get_##x) PROTO_METHOD(add); // XXX (ES6 23.4.3.2) WeakSet.prototype.constructor PROTO_METHOD(delete); PROTO_METHOD(has); _ejs_object_define_value_property (_ejs_WeakSet_prototype, _ejs_Symbol_toStringTag, _ejs_atom_WeakSet, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_NOT_WRITABLE | EJS_PROP_CONFIGURABLE); #undef OBJ_METHOD #undef PROTO_METHOD }
static void EnqueuePromiseReactionTask (EJSPromiseReaction* reaction, ejsval value) { ReactionTaskArg *arg = malloc(sizeof(ReactionTaskArg)); arg->reaction = reaction; arg->arg = value; /* root the ejsvals in EJSPromiseReaction and our value here */ _ejs_gc_add_root(&arg->reaction->handler); _ejs_gc_add_root(&arg->reaction->capabilities); _ejs_gc_add_root(&arg->arg); _ejs_runloop_add_task(call_promise_reaction_task, arg, reaction_arg_dtor); }
static void EnqueuePromiseResolveThenableTask (ejsval promiseToResolve, ejsval thenable, ejsval then) { ResolveThenableTaskArg *arg = malloc(sizeof(ResolveThenableTaskArg)); arg->promiseToResolve = promiseToResolve; arg->thenable = thenable; arg->then = then; /* root the ejsvals */ _ejs_gc_add_root(&arg->promiseToResolve); _ejs_gc_add_root(&arg->thenable); _ejs_gc_add_root(&arg->then); _ejs_runloop_add_task(call_promise_resolve_thenable_task, arg, resolve_thenable_arg_dtor); }
void _ejs_set_init(ejsval global) { _ejs_Set = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_Set, (EJSClosureFunc)_ejs_Set_impl); _ejs_object_setprop (global, _ejs_atom_Set, _ejs_Set); _ejs_gc_add_root (&_ejs_Set_prototype); _ejs_Set_prototype = _ejs_set_new (); _ejs_object_setprop (_ejs_Set, _ejs_atom_prototype, _ejs_Set_prototype); #define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Set, x, _ejs_Set_##x) #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS(_ejs_Set_prototype, x, _ejs_Set_prototype_##x, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_WRITABLE | EJS_PROP_CONFIGURABLE) #define PROTO_GETTER(x) EJS_INSTALL_ATOM_GETTER(_ejs_Set_prototype, x, _ejs_Set_prototype_get_##x) PROTO_METHOD(add); PROTO_METHOD(clear); PROTO_METHOD(delete); PROTO_METHOD(entries); PROTO_METHOD(forEach); PROTO_METHOD(has); PROTO_GETTER(size); // expand PROTO_METHOD(values) here so that we can install the function for both keys and @@iterator below ejsval _values = _ejs_function_new_native (_ejs_null, _ejs_atom_values, (EJSClosureFunc)_ejs_Set_prototype_values); _ejs_object_define_value_property (_ejs_Set_prototype, _ejs_atom_values, _values, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_FLAGS_WRITABLE | EJS_PROP_CONFIGURABLE); _ejs_object_define_value_property (_ejs_Set_prototype, _ejs_atom_keys, _values, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_WRITABLE | EJS_PROP_CONFIGURABLE); _ejs_object_define_value_property (_ejs_Set_prototype, _ejs_Symbol_iterator, _values, EJS_PROP_NOT_ENUMERABLE); _ejs_object_define_value_property (_ejs_Set_prototype, _ejs_Symbol_toStringTag, _ejs_atom_Set, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_NOT_WRITABLE | EJS_PROP_CONFIGURABLE); EJS_INSTALL_SYMBOL_FUNCTION_FLAGS (_ejs_Set, create, _ejs_Set_create, EJS_PROP_NOT_ENUMERABLE); #undef OBJ_METHOD #undef PROTO_METHOD _ejs_SetIterator = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_Set, (EJSClosureFunc)_ejs_SetIterator_impl); _ejs_gc_add_root (&_ejs_SetIterator_prototype); _ejs_SetIterator_prototype = _ejs_set_iterator_new(_ejs_Set_prototype, EJS_SET_ITER_KIND_VALUE); EJSVAL_TO_OBJECT(_ejs_SetIterator_prototype)->proto = _ejs_Object_prototype; _ejs_object_define_value_property (_ejs_SetIterator, _ejs_atom_prototype, _ejs_SetIterator_prototype, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_NOT_CONFIGURABLE | EJS_PROP_NOT_WRITABLE); _ejs_object_define_value_property (_ejs_SetIterator_prototype, _ejs_atom_constructor, _ejs_SetIterator, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_CONFIGURABLE | EJS_PROP_WRITABLE); #define PROTO_ITER_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS (_ejs_SetIterator_prototype, x, _ejs_SetIterator_prototype_##x, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_WRITABLE | EJS_PROP_CONFIGURABLE) PROTO_ITER_METHOD(next); #undef PROTO_ITER_METHOD }
void DIBuilder_init (ejsval exports) { _ejs_DIBuilder_specops = _ejs_Object_specops; _ejs_DIBuilder_specops.class_name = "LLVMDIBuilder"; _ejs_DIBuilder_specops.Allocate = DIBuilder_allocate; _ejs_gc_add_root (&_ejs_DIBuilder_prototype); _ejs_DIBuilder_prototype = _ejs_object_create(_ejs_Object_prototype); _ejs_DIBuilder = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMDIBuilder", (EJSClosureFunc)DIBuilder_impl, _ejs_DIBuilder_prototype); _ejs_object_setprop_utf8 (exports, "DIBuilder", _ejs_DIBuilder); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_DIBuilder_prototype, x, DIBuilder_prototype_##x) PROTO_METHOD(createCompileUnit); PROTO_METHOD(createFile); PROTO_METHOD(createFunction); PROTO_METHOD(createLexicalBlock); PROTO_METHOD(finalize); #undef PROTO_METHOD EJS_INSTALL_SYMBOL_FUNCTION_FLAGS (_ejs_DIBuilder, create, DIBuilder_create, EJS_PROP_NOT_ENUMERABLE); }
void BasicBlock_init (ejsval exports) { basicblock_specops = _ejs_Object_specops; basicblock_specops.class_name = "LLVMBasicBlock"; basicblock_specops.allocate = BasicBlock_allocate; _ejs_gc_add_root (&_ejs_BasicBlock_proto); _ejs_BasicBlock_proto = _ejs_object_new(_ejs_Object_prototype, &basicblock_specops); _ejs_BasicBlock = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMBasicBlock", (EJSClosureFunc)BasicBlock_impl, _ejs_BasicBlock_proto); _ejs_object_setprop_utf8 (exports, "BasicBlock", _ejs_BasicBlock); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_BasicBlock_proto, x, BasicBlock_prototype_##x) #define PROTO_ACCESSOR(x) EJS_INSTALL_ATOM_GETTER(_ejs_BasicBlock_proto, x, BasicBlock_prototype_get_##x) PROTO_ACCESSOR(name); PROTO_ACCESSOR(parent); PROTO_METHOD(dump); PROTO_METHOD(toString); #undef PROTO_METHOD #undef PROTO_ACCESSOR }
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); }
void Invoke_init (ejsval exports) { _ejs_Invoke_specops = _ejs_Object_specops; _ejs_Invoke_specops.class_name = "LLVMInvoke"; _ejs_Invoke_specops.Allocate = Invoke_allocate; _ejs_gc_add_root (&_ejs_Invoke_prototype); _ejs_Invoke_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_Invoke_specops); _ejs_Invoke = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMInvoke", (EJSClosureFunc)Invoke_impl, _ejs_Invoke_prototype); _ejs_object_setprop_utf8 (exports, "Invoke", _ejs_Invoke); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Invoke_prototype, x, Invoke_prototype_##x) PROTO_METHOD(setOnlyReadsMemory); PROTO_METHOD(setDoesNotAccessMemory); PROTO_METHOD(setDoesNotThrow); PROTO_METHOD(setStructRet); PROTO_METHOD(dump); PROTO_METHOD(toString); #undef PROTO_METHOD }
void _ejs_error_init(ejsval global) { ejsval toString = _ejs_function_new_native (_ejs_null, _ejs_atom_toString, (EJSClosureFunc)_ejs_Error_prototype_toString); _ejs_gc_add_root (&toString); #define EJS_ADD_NATIVE_ERROR_TYPE(err) EJS_MACRO_START \ _ejs_##err = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_##err, (EJSClosureFunc)_ejs_##err##_impl); \ _ejs_object_setprop (global, _ejs_atom_##err, _ejs_##err); \ _ejs_##err##_prototype = _ejs_object_new(_ejs_null, &_ejs_Object_specops); \ _ejs_object_setprop (_ejs_##err, _ejs_atom_prototype, _ejs_##err##_prototype); \ _ejs_object_define_value_property (_ejs_##err##_prototype, _ejs_atom_constructor, _ejs_##err,\ EJS_PROP_NOT_ENUMERABLE | EJS_PROP_CONFIGURABLE | EJS_PROP_WRITABLE); \ \ _ejs_object_setprop (_ejs_##err##_prototype, _ejs_atom_name, _ejs_atom_##err); \ _ejs_object_setprop (_ejs_##err##_prototype, _ejs_atom_toString, toString); \ \ EJS_INSTALL_SYMBOL_FUNCTION_FLAGS (_ejs_##err, create, _ejs_Error_create, EJS_PROP_NOT_ENUMERABLE); \ EJS_MACRO_END EJS_ADD_NATIVE_ERROR_TYPE(Error); EJS_ADD_NATIVE_ERROR_TYPE(EvalError); EJS_ADD_NATIVE_ERROR_TYPE(RangeError); EJS_ADD_NATIVE_ERROR_TYPE(ReferenceError); EJS_ADD_NATIVE_ERROR_TYPE(SyntaxError); EJS_ADD_NATIVE_ERROR_TYPE(TypeError); EJS_ADD_NATIVE_ERROR_TYPE(URIError); _ejs_gc_remove_root (&toString); }
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 }
void Module_init (ejsval exports) { _ejs_Module_specops = _ejs_Object_specops; _ejs_Module_specops.class_name = "LLVMModule"; _ejs_Module_specops.Allocate = Module_allocate; _ejs_Module_specops.Finalize = Module_finalize; _ejs_gc_add_root (&_ejs_Module_prototype); _ejs_Module_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_Module_specops); _ejs_Module = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMModule", (EJSClosureFunc)Module_impl, _ejs_Module_prototype); _ejs_object_setprop_utf8 (exports, "Module", _ejs_Module); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Module_prototype, x, Module_prototype_##x) PROTO_METHOD(getGlobalVariable); PROTO_METHOD(getOrInsertIntrinsic); PROTO_METHOD(getOrInsertFunction); PROTO_METHOD(getOrInsertGlobal); PROTO_METHOD(getOrInsertExternalFunction); PROTO_METHOD(getFunction); PROTO_METHOD(dump); PROTO_METHOD(toString); PROTO_METHOD(writeToFile); PROTO_METHOD(writeBitcodeToFile); PROTO_METHOD(setDataLayout); PROTO_METHOD(setTriple); #undef PROTO_METHOD EJS_INSTALL_SYMBOL_FUNCTION_FLAGS (_ejs_Module, create, Module_create, EJS_PROP_NOT_ENUMERABLE); }
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); }
void Call_init (ejsval exports) { _ejs_Call_specops = _ejs_Object_specops; _ejs_Call_specops.class_name = "LLVMCall"; _ejs_Call_specops.Allocate = Call_allocate; _ejs_gc_add_root (&_ejs_Call_prototype); _ejs_Call_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_Call_specops); ejsval tmpobj = _ejs_function_new_utf8 (_ejs_null, "LLVMCall", (EJSClosureFunc)Call_impl); _ejs_Call = tmpobj; #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Call_prototype, x, Call_prototype_##x) _ejs_object_setprop (_ejs_Call, _ejs_atom_prototype, _ejs_Call_prototype); PROTO_METHOD(setOnlyReadsMemory); PROTO_METHOD(setDoesNotAccessMemory); PROTO_METHOD(setDoesNotThrow); PROTO_METHOD(setStructRet); PROTO_METHOD(dump); PROTO_METHOD(toString); #undef PROTO_METHOD _ejs_object_setprop_utf8 (exports, "Call", _ejs_Call); }
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 }
void _ejs_iterator_init_proto() { _ejs_gc_add_root (&_ejs_Generator_prototype); _ejs_Iterator_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_Object_specops); ejsval _iterator = _ejs_function_new_native (_ejs_null, _ejs_Symbol_iterator, _ejs_Iterator_prototype_iterator); _ejs_object_define_value_property (_ejs_Iterator_prototype, _ejs_Symbol_iterator, _iterator, EJS_PROP_NOT_ENUMERABLE); }
void _ejs_generator_init(ejsval global) { _ejs_gc_add_root (&_ejs_Generator_prototype); _ejs_Generator_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_Generator_specops); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS (_ejs_Generator_prototype, x, _ejs_Generator_prototype_##x, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_WRITABLE | EJS_PROP_CONFIGURABLE) PROTO_METHOD(next); PROTO_METHOD(return); PROTO_METHOD(throw); }
void _ejs_iterator_wrapper_init (ejsval global) { _ejs_gc_add_root (&_ejs_IteratorWrapper_prototype); _ejs_IteratorWrapper_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_Object_specops); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION_FLAGS (_ejs_IteratorWrapper_prototype, x, _ejs_IteratorWrapper_prototype_##x, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_WRITABLE | EJS_PROP_CONFIGURABLE) PROTO_METHOD(getNextValue); PROTO_METHOD(getRest); #undef PROTO_METHOD }
void _ejs_regexp_init(ejsval global) { _ejs_RegExp = _ejs_function_new_without_proto (_ejs_null, _ejs_atom_RegExp, (EJSClosureFunc)_ejs_RegExp_impl); _ejs_object_setprop (global, _ejs_atom_RegExp, _ejs_RegExp); _ejs_gc_add_root (&_ejs_RegExp_prototype); _ejs_RegExp_prototype = _ejs_object_new(_ejs_null, &_ejs_RegExp_specops); EJSRegExp* re_proto = (EJSRegExp*)EJSVAL_TO_OBJECT(_ejs_RegExp_prototype); re_proto->pattern = _ejs_string_new_utf8("(?:)"); re_proto->flags = _ejs_atom_empty; _ejs_object_setprop (_ejs_RegExp, _ejs_atom_prototype, _ejs_RegExp_prototype); #define OBJ_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_RegExp, x, _ejs_RegExp_##x) #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_RegExp_prototype, x, _ejs_RegExp_prototype_##x) #define PROTO_METHOD_VAL(x) EJS_INSTALL_ATOM_FUNCTION_VAL(_ejs_RegExp_prototype, x, _ejs_RegExp_prototype_##x) #define PROTO_GETTER(x) EJS_INSTALL_ATOM_GETTER(_ejs_RegExp_prototype, x, _ejs_RegExp_prototype_get_##x) _ejs_gc_add_root (&_ejs_RegExp_prototype_exec_closure); _ejs_RegExp_prototype_exec_closure = PROTO_METHOD_VAL(exec); PROTO_METHOD(test); PROTO_METHOD(toString); PROTO_GETTER(global); PROTO_GETTER(ignoreCase); PROTO_GETTER(lastIndex); PROTO_GETTER(multiline); PROTO_GETTER(source); PROTO_GETTER(sticky); PROTO_GETTER(unicode); #undef OBJ_METHOD #undef PROTO_METHOD EJS_INSTALL_SYMBOL_FUNCTION_FLAGS (_ejs_RegExp, create, _ejs_RegExp_create, EJS_PROP_NOT_ENUMERABLE); }
static void _ejs_function_init_proto() { _ejs_gc_add_root (&_ejs_Function_prototype); // Function.prototype = function () { return undefined; } EJSFunction* proto = _ejs_gc_new(EJSFunction); _ejs_Function_prototype = OBJECT_TO_EJSVAL(proto); _ejs_init_object ((EJSObject*)proto, _ejs_Object_prototype, &_ejs_Function_specops); proto->func = _ejs_Function_empty; proto->env = _ejs_null; _ejs_object_define_value_property (OBJECT_TO_EJSVAL(proto), _ejs_atom_name, _ejs_atom_empty, EJS_PROP_NOT_ENUMERABLE | EJS_PROP_NOT_CONFIGURABLE | EJS_PROP_NOT_WRITABLE); }
void _ejs_exception_throw(ejsval val) { struct ejs_exception *exc = (struct ejs_exception*)__cxa_allocate_exception(sizeof(struct ejs_exception)); exc->val = val; // need to root the exception until it's caught _ejs_gc_add_root(&exc->val); exc->tinfo = EJS_EHTYPE_ejsvalue; SPEW({ _ejs_log ("EXCEPTIONS: throwing %p\n", exc); _ejs_dump_value (val); });
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 }
void DILexicalBlock_init (ejsval exports) { _ejs_DILexicalBlock_specops = _ejs_Object_specops; _ejs_DILexicalBlock_specops.class_name = "LLVMDILexicalBlock"; _ejs_DILexicalBlock_specops.Allocate = DILexicalBlock_allocate; _ejs_gc_add_root (&_ejs_DILexicalBlock_prototype); _ejs_DILexicalBlock_prototype = _ejs_object_create(_ejs_Object_prototype); _ejs_DILexicalBlock = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMDILexicalBlock", (EJSClosureFunc)DILexicalBlock_impl, _ejs_DILexicalBlock_prototype); _ejs_object_setprop_utf8 (exports, "DILexicalBlock", _ejs_DILexicalBlock); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_DILexicalBlock_prototype, x, DILexicalBlock_prototype_##x) #undef PROTO_METHOD }
EJSBool require_builtin_module (const char* name, ejsval *module) { int i; for (i = 0; i < num_builtin_modules; i ++) { if (!strcmp (builtin_module_map[i].name, name)) { if (EJSVAL_IS_NULL(builtin_module_map[i].cached_exports)) { // printf ("require'ing %s.\n", EJSVAL_TO_FLAT_STRING(arg)); _ejs_gc_add_root (&builtin_module_map[i].cached_exports); builtin_module_map[i].cached_exports = _ejs_object_new(_ejs_null, &_ejs_Object_specops); builtin_module_map[i].func(_ejs_null, _ejs_undefined, 1, &builtin_module_map[i].cached_exports); } *module = builtin_module_map[i].cached_exports; return EJS_TRUE; } } return EJS_FALSE; }
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); }
void GlobalVariable_init (ejsval exports) { _ejs_gc_add_root (&_ejs_GlobalVariable_proto); _ejs_GlobalVariable_proto = _ejs_object_new(_ejs_Object_prototype, &_ejs_Object_specops); _ejs_GlobalVariable = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMGlobalVariable", (EJSClosureFunc)GlobalVariable_impl, _ejs_GlobalVariable_proto); _ejs_object_setprop_utf8 (exports, "GlobalVariable", _ejs_GlobalVariable); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_GlobalVariable_proto, x, GlobalVariable_prototype_##x) PROTO_METHOD(setAlignment); PROTO_METHOD(setInitializer); PROTO_METHOD(dump); PROTO_METHOD(toString); #undef PROTO_METHOD }
void Function_init (ejsval exports) { function_specops = _ejs_Object_specops; function_specops.class_name = "LLVMFunction"; function_specops.allocate = Function_allocate; _ejs_gc_add_root (&_ejs_Function_proto); _ejs_Function_proto = _ejs_object_new(_ejs_Object_prototype, &function_specops); _ejs_Function = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMFunction", (EJSClosureFunc)Function_impl, _ejs_Function_proto); _ejs_object_setprop_utf8 (exports, "Function", _ejs_Function); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_Function_proto, x, Function_prototype_##x) #define PROTO_ACCESSOR(x) EJS_INSTALL_ATOM_GETTER(_ejs_Function_proto, x, Function_prototype_get_##x) PROTO_ACCESSOR(args); PROTO_ACCESSOR(argSize); PROTO_ACCESSOR(name); PROTO_ACCESSOR(returnType); PROTO_ACCESSOR(type); PROTO_ACCESSOR(doesNotThrow); PROTO_ACCESSOR(onlyReadsMemory); PROTO_ACCESSOR(doesNotAccessMemory); PROTO_METHOD(dump); PROTO_METHOD(setOnlyReadsMemory); PROTO_METHOD(setDoesNotAccessMemory); PROTO_METHOD(setDoesNotThrow); PROTO_METHOD(setGC); PROTO_METHOD(setExternalLinkage); PROTO_METHOD(setInternalLinkage); PROTO_METHOD(toString); PROTO_METHOD(hasStructRetAttr); PROTO_METHOD(setStructRet); #undef PROTO_METHOD #undef PROTO_ACCESSOR }
EJSBool require_external_module (const char* name, ejsval *module) { int i = 0; while (1) { if (!_ejs_external_module_require_map[i].name) { return EJS_FALSE; } if (!strcmp (_ejs_external_module_require_map[i].name, name)) { if (EJSVAL_IS_NULL(_ejs_external_module_require_map[i].cached_exports)) { _ejs_gc_add_root (&_ejs_external_module_require_map[i].cached_exports); _ejs_external_module_require_map[i].cached_exports = _ejs_object_new(_ejs_null, &_ejs_Object_specops); _ejs_external_module_require_map[i].func(_ejs_external_module_require_map[i].cached_exports); } *module = _ejs_external_module_require_map[i].cached_exports; return EJS_TRUE; } i++; } }
EJSBool require_user_module (const char* name, ejsval *module) { int i = 0; while (1) { EJSRequire* map = &_ejs_require_map[i]; if (!map->name) { return EJS_FALSE; } if (!strcmp (map->name, name)) { if (EJSVAL_IS_NULL(map->cached_exports)) { _ejs_gc_add_root (&map->cached_exports); map->cached_exports = _ejs_object_new(_ejs_null, &_ejs_Object_specops); map->func (_ejs_null, _ejs_undefined, 1, &map->cached_exports); } *module = map->cached_exports; return EJS_TRUE; } i++; } }
void AllocaInst_init (ejsval exports) { allocainst_specops = _ejs_Object_specops; allocainst_specops.class_name = "LLVMAllocaInst"; allocainst_specops.allocate = AllocaInst_allocate; _ejs_gc_add_root (&_ejs_AllocaInst_proto); _ejs_AllocaInst_proto = _ejs_object_new(_ejs_Object_prototype, &allocainst_specops); _ejs_AllocaInst = _ejs_function_new_utf8_with_proto (_ejs_null, "LLVMAllocaInst", (EJSClosureFunc)AllocaInst_impl, _ejs_AllocaInst_proto); _ejs_object_setprop_utf8 (exports, "AllocaInst", _ejs_AllocaInst); #define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_AllocaInst_proto, x, AllocaInst_prototype_##x) PROTO_METHOD(dump); PROTO_METHOD(toString); PROTO_METHOD(setAlignment); #undef PROTO_METHOD }