Ejemplo n.º 1
0
static void errquit(lua_State * L, const char *fmt, ...) {
    if (fmt) {
        va_list args;
        va_start(args, fmt);
        vfprintf(stderr, fmt, args);
        fflush(stderr);
        va_end(args);
    }
    lua_close(L);
    terra_llvmshutdown();
    exit(1);
}
Ejemplo n.º 2
0
int main(int argc, char ** argv) {
    progname = argv[0];
    lua_State * L = luaL_newstate();
    luaL_openlibs(L);
    
    terra_Options terra_options;
    memset(&terra_options, 0, sizeof(terra_Options));

    ebb_Options ebboptions;
    memset(&ebboptions, 0, sizeof(ebb_Options));
    char additional_args[ADDITIONAL_ARG_LEN] = "";
    ebboptions.additional = additional_args;
    
    bool interactive = false;
    int scriptidx;

    parse_args(L,argc,argv,&terra_options,&ebboptions,&interactive,&scriptidx);
    // set some arguments by default
    terra_options.usemcjit = 1;
    // check other arguments
    check_legion_arg_consistency(&ebboptions);
    
    if(terra_initwithoptions(L, &terra_options))
        doerror(L);
    
    setupcrashsignal(L);
    setupebb(L, &ebboptions);
    
    if(scriptidx < argc) {
      const char * filename = argv[scriptidx];
      if(strcmp(filename,"-")) { // if not equal, then launch
        int narg = getargs(L, argv, scriptidx);
        lua_setglobal(L, "arg");
        if(load_launchscript(L,&ebboptions))
          doerror(L);
        lua_insert(L, -(narg + 1));
        if(docall(L,narg,0))
          doerror(L);
      }
    }
    
    if(isatty(0) && (interactive || scriptidx == argc)) {
        progname = NULL;
        dotty(L);
    }
    
    lua_close(L);
    terra_llvmshutdown();
    
    return 0;
}
Ejemplo n.º 3
0
int main(int argc, char ** argv) {
    progname = argv[0];
    lua_State * L = luaL_newstate();
    luaL_openlibs(L);
    
    terra_Options options;
    memset(&options, 0, sizeof(terra_Options));
    
    bool interactive = false;
    int scriptidx;

    parse_args(L,argc,argv,&options,&interactive,&scriptidx);
    
    if(terra_initwithoptions(L, &options))
        doerror(L);
    
    setupsigsegv(L);
    
    if(scriptidx < argc) {
      int narg = getargs(L, argv, scriptidx);  
      lua_setglobal(L, "arg");
      const char * filename = argv[scriptidx];
      if(!strcmp(filename,"-"))
        filename = NULL;
      if(terra_loadfile(L,filename))
        doerror(L);
      lua_insert(L, -(narg + 1));
      if(lua_pcall(L, narg, LUA_MULTRET, 0))
        doerror(L);
    }
    
    if(isatty(0) && (interactive || scriptidx == argc)) {
        progname = NULL;
        dotty(L);
    }
    
    lua_close(L);
    terra_llvmshutdown();
    
    return 0;
}
Ejemplo n.º 4
0
static void doerror(lua_State * L) {
    printf("%s\n",luaL_checkstring(L,-1));
    lua_close(L);
    terra_llvmshutdown();
    exit(1);
}