MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / handle_script

Function handle_script

src/Chain/libraries/glua/single_glua_src/main.cpp:452–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450static bool use_type_check_compile = true;
451
452static int handle_script(lua_State *L, char **argv, bool is_contract=false) {
453 int status;
454 const char *fname = argv[0];
455 if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0)
456 fname = NULL; /* stdin */
457 bool is_bytecode_file = luaL_is_bytecode_file(L, fname);
458 if (is_bytecode_file)
459 {
460 status = luaL_loadfile(L, fname);
461 if (status == LUA_OK) {
462 int n = pushargs(L); /* push arguments to script */
463 status = docall(L, n, LUA_MULTRET);
464 }
465 return report(L, status);
466 }
467 else
468 {
469 std::string out_fname = std::string(fname) + ".out";
470 char error[LUA_COMPILE_ERROR_MAX_LENGTH + 1];
471 memset(error, 0x0, sizeof(char) * (LUA_COMPILE_ERROR_MAX_LENGTH + 1));
472 // TODO: 如果is_contract,编译期开启合约语法扩展检查
473 if(!thinkyoung::lua::lib::compilefile_to_file(fname, out_fname.c_str(), error, use_type_check_compile))
474 {
475 printf("compile %s error\n", fname);
476 if (strlen(error) > 0)
477 {
478 perror(error);
479 lua_set_compile_error(L, error);
480 }
481 return LUA_ERRRUN;
482 }
483 return thinkyoung::lua::lib::run_compiledfile(L, out_fname.c_str()) ? LUA_OK : LUA_ERRRUN;
484 }
485}
486
487static int run_decompile_script(lua_State *L, char **argv, int script)
488{

Callers 1

pmainFunction · 0.70

Calls 10

luaL_is_bytecode_fileFunction · 0.85
compilefile_to_fileFunction · 0.85
printfClass · 0.85
lua_set_compile_errorFunction · 0.85
run_compiledfileFunction · 0.85
pushargsFunction · 0.70
docallFunction · 0.70
reportFunction · 0.70
stringClass · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected