Esempio n. 1
0
ejsval
_ejs_child_process_module_func (ejsval env, ejsval _this, uint32_t argc, ejsval* args)
{
    ejsval exports = args[0];

    EJS_INSTALL_FUNCTION(exports, "spawn", _ejs_child_process_spawn);

    _ejs_object_setprop_utf8 (exports, "stdout", _ejs_wrapFdWithStream(1));
    _ejs_object_setprop_utf8 (exports, "stderr", _ejs_wrapFdWithStream(2));

    return _ejs_undefined;
}
Esempio n. 2
0
    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);
    }
Esempio n. 3
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
    }
Esempio n. 4
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);
    }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
    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

    }
Esempio n. 7
0
    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);
    }
Esempio n. 8
0
    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

    }
Esempio n. 9
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
    }
Esempio n. 10
0
static EJSBool
json_value_to_ejsval(JSON_Value *v, ejsval *rv)
{
    switch (json_value_get_type (v)) {
    case JSONNull:
        *rv = _ejs_null;
        return EJS_TRUE;

    case JSONString:
        *rv = _ejs_string_new_utf8 (json_value_get_string(v));
        return EJS_TRUE;

    case JSONNumber:
        *rv = NUMBER_TO_EJSVAL(json_value_get_number(v));
        return EJS_TRUE;

    case JSONObject: {
        JSON_Object *obj = json_value_get_object (v);
        *rv = _ejs_object_create (_ejs_null);

        int count = json_object_get_count (obj);
        for (int i = 0; i < count; i ++) {
            const char *propkey = json_object_get_name (obj, i);
            ejsval propval;
            if (!json_value_to_ejsval (json_object_get_value (obj, propkey), &propval))
                return EJS_FALSE;
            _ejs_object_setprop_utf8 (*rv, propkey, propval);
        }

        return EJS_TRUE;
    }
        
    case JSONArray: {
        JSON_Array *arr = json_value_get_array (v);
        int count = json_array_get_count (arr);

        *rv = _ejs_array_new (count, EJS_FALSE);

        for (int i = 0; i < count; i ++) {
            ejsval propkey = _ejs_number_new (i);
            ejsval propval;
            if (!json_value_to_ejsval (json_array_get_value (arr, i), &propval))
                return EJS_FALSE;
            _ejs_object_setprop (*rv, propkey, propval);
        }

        return EJS_TRUE;
    }
    case JSONBoolean:
        *rv = BOOLEAN_TO_EJSVAL(json_value_get_boolean(v));
        return EJS_TRUE;


    case JSONError:
        EJS_NOT_IMPLEMENTED();
        return EJS_FALSE;
    }
}
Esempio n. 11
0
static ejsval
_ejs_wrapFdWithStream (int fd)
{
    ejsval stream = _ejs_object_create(_ejs_null);

    EJS_INSTALL_FUNCTION (stream, "write", _ejs_stream_write);
    EJS_INSTALL_FUNCTION (stream, "end", _ejs_stream_end);

    _ejs_object_setprop_utf8 (stream, "%internal_fd", NUMBER_TO_EJSVAL(fd));

    return stream;
}
Esempio n. 12
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
  }
Esempio n. 13
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);
    }
Esempio n. 14
0
    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
    }
Esempio n. 15
0
    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
    }
Esempio n. 16
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
    }
Esempio n. 17
0
    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
    }
Esempio n. 18
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
    }
Esempio n. 19
0
    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
    }
Esempio n. 20
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

    }
Esempio n. 21
0
ejsval
_ejs_fs_createWriteStream (ejsval env, ejsval _this, uint32_t argc, ejsval* args)
{
    ejsval stream = _ejs_object_create(_ejs_null);

    EJS_INSTALL_FUNCTION (stream, "write", _ejs_stream_write);
    EJS_INSTALL_FUNCTION (stream, "end", _ejs_stream_end);

    char *utf8_path = ucs2_to_utf8(EJSVAL_TO_FLAT_STRING(args[0]));

    int fd = open (utf8_path, O_CREAT | O_TRUNC | O_WRONLY, 0777);
    free (utf8_path);
    if (fd == -1) {
        perror ("open");
        printf ("we should totally throw an exception here\n");
        return _ejs_undefined;
    }

    _ejs_object_setprop_utf8 (stream, "%internal_fd", NUMBER_TO_EJSVAL(fd));

    return stream;
}
Esempio n. 22
0
    void
    LandingPad_init (ejsval exports)
    {
        _ejs_LandingPad_specops = _ejs_Object_specops;
        _ejs_LandingPad_specops.class_name = "LLVMLandingPad";
        _ejs_LandingPad_specops.allocate = LandingPad_allocate;

        _ejs_gc_add_root (&_ejs_LandingPad_prototype);
        _ejs_LandingPad_prototype = _ejs_object_new(_ejs_Object_prototype, &_ejs_LandingPad_specops);

        _ejs_LandingPad = _ejs_function_new_utf8_with_proto  (_ejs_null, "LLVMLandingPad", (EJSClosureFunc)LandingPad_impl, _ejs_LandingPad_prototype);

        _ejs_object_setprop_utf8 (exports,              "LandingPad", _ejs_LandingPad);

#define PROTO_METHOD(x) EJS_INSTALL_ATOM_FUNCTION(_ejs_LandingPad_prototype, x, LandingPad_prototype_##x)

        PROTO_METHOD(dump);
        PROTO_METHOD(toString);
        PROTO_METHOD(setCleanup);
        PROTO_METHOD(addClause);

#undef PROTO_METHOD
    }
Esempio n. 23
0
void allinone_for_load_just_ensure_these_functions_and_variables_are_included_please_do_not_call()
{
    JSValueHash(_ejs_nan);
    JSValueHash(jsPositiveInfinity);
    JSValueHash(jsNegativeInfinity);
    JSValueHash(jsMax);
    JSValueHash(jsMin);
    JSValueHash(_ejs_null);
    JSValueHash(_ejs_undefined);
    JSValueHash(_ejs_true);
    JSValueHash(_ejs_false);
    JSValueHash(_ejs_one);
    JSValueHash(_ejs_zero);
    JSValueHash(_ejs_global);
    JSValueHash(_ejs_console);
    JSValueHash(_ejs_Object);
    JSValueHash(_ejs_Boolean);
    JSValueHash(_ejs_Number);
    JSValueHash(_ejs_String);
    JSValueHash(_ejs_Array);
    JSValueHash(_ejs_Function);
    JSValueHash(_ejs_Process);
    JSValueHash(_ejs_Symbol_create);
    JSValueHash(_ejs_Math);
    JSValueHash(_ejs_JSON);

    jsextern_print_tick();
    jsextern_os_msleep(0);
    jsextern_os_swap(NULL, 0, 0);
    jsextern_pcre_compile(NULL);
    jsextern_pcre_study(NULL);
    jsextern_pcre_bracketcount(NULL);
    jsextern_pcre_exec(NULL, NULL, NULL, 0, 0, NULL, 0);
    jsextern_pcre_free(NULL);
    jsextern_thread_create((void *(*)(void *))NULL, NULL);
    jsextern_thread_destroy(0);
    jsextern_mutex_create();
    jsextern_mutex_destroy(0);
    jsextern_mutex_lock(0);
    jsextern_mutex_unlock(0);
    jsextern_signal_create();
    jsextern_signal_destroy(0);
    jsextern_signal_wait(0);
    jsextern_signal_send(0);

    JSValueHash(_ejs_undefined);
    
    _ejs_eval(_ejs_undefined, _ejs_undefined, 0, NULL);

    //Object
    _ejs_object_getprop_utf8(_ejs_undefined, NULL);
    _ejs_object_setprop_utf8(_ejs_global, NULL, _ejs_undefined);
    _ejs_object_define_value_property(_ejs_undefined, _ejs_undefined, _ejs_undefined, 0);
    _ejs_object_define_getter_property(_ejs_undefined, _ejs_undefined, _ejs_undefined, 0);
    _ejs_object_define_setter_property(_ejs_undefined, _ejs_undefined, _ejs_undefined, 0);
    _ejs_Object_create(_ejs_undefined, _ejs_undefined, 0, NULL);
    _ejs_Object_getOwnPropertyNames(_ejs_undefined, _ejs_undefined, 0, NULL);
    //vtable
    _ejs_specop_get(_ejs_undefined, _ejs_undefined, _ejs_undefined);
    _ejs_specop_set(_ejs_undefined, _ejs_undefined, _ejs_undefined, _ejs_undefined);
    //option
    ToEJSBool(_ejs_undefined);
    ToDouble(_ejs_undefined);
    ToUint32(_ejs_undefined);
    _ejs_op_typeof(_ejs_undefined);
    _ejs_op_instanceof(_ejs_undefined, _ejs_undefined);
    _ejs_op_typeof_is_array(_ejs_undefined);
    _ejs_op_plusplus(_ejs_undefined, EJS_FALSE);
    _ejs_op_minusminus(_ejs_undefined, EJS_FALSE);
    _ejs_op_bitwise_xor(_ejs_undefined, _ejs_undefined);
    _ejs_op_bitwise_and(_ejs_undefined, _ejs_undefined);
    _ejs_op_bitwise_or(_ejs_undefined, _ejs_undefined);
    _ejs_op_rsh(_ejs_undefined, _ejs_undefined);
    _ejs_op_ursh(_ejs_undefined, _ejs_undefined);
    _ejs_op_lsh(_ejs_undefined, _ejs_undefined);
    _ejs_op_ulsh(_ejs_undefined, _ejs_undefined);
    _ejs_op_mod(_ejs_undefined, _ejs_undefined);
    _ejs_op_add(_ejs_undefined, _ejs_undefined);
    _ejs_op_sub(_ejs_undefined, _ejs_undefined);
    _ejs_op_mult(_ejs_undefined, _ejs_undefined);
    _ejs_op_div(_ejs_undefined, _ejs_undefined);
    _ejs_op_lt(_ejs_undefined, _ejs_undefined);
    _ejs_op_le(_ejs_undefined, _ejs_undefined);
    _ejs_op_gt(_ejs_undefined, _ejs_undefined);
    _ejs_op_ge(_ejs_undefined, _ejs_undefined);
    _ejs_op_strict_eq(_ejs_undefined, _ejs_undefined);
    _ejs_op_strict_neq(_ejs_undefined, _ejs_undefined);
    _ejs_op_eq(_ejs_undefined, _ejs_undefined);
    _ejs_op_neq(_ejs_undefined, _ejs_undefined);
    //arguments
    _ejs_arguments_new(0, NULL);

    //Array
    _ejs_array_new(jsValue32Size, false);
    //String
    _ejs_string_new_utf8_len(NULL, 0);
    //Function
    _ejs_function_new_utf8(_ejs_undefined, NULL, (EJSClosureFunc)NULL);
    _ejs_invoke_closure(_ejs_undefined, _ejs_undefined, 0, NULL);
    //RegExp
    _ejs_regexp_new_utf8(NULL, NULL);
}