Пример #1
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;
}
Пример #2
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;
}
Пример #3
0
int terra_init(lua_State * L) {
    terra_Options options;
    memset(&options,0, sizeof(terra_Options));
    return terra_initwithoptions(L, &options);
}