Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BEFORE
- global sgs_evalspec_env =
- {
- array = array,
- dict = dict,
- map = map,
- vec2 = vec2,
- };
- function sgs_evalspec( file, env )
- {
- global _G;
- envbk = _G;
- pcall = _G.pcall;
- eval_file = _G.eval_file;
- sys_backtrace = _G.sys_backtrace;
- _G = get_merged( env, sgs_evalspec_env );
- errmsg = null;
- errstack = null;
- pcall(function sgs_evalspec_trycode() use( file, eval_file )
- {
- eval_file( file );
- },
- function sgs_evalspec_errhandler( code, msg ) use( errmsg, errstack, sys_backtrace )
- {
- errmsg = msg;
- errstack = sys_backtrace( true );
- });
- _G = envbk;
- return !errmsg, errmsg, errstack;
- }
- // AFTER
- function sgs_evalspec( file, env )
- {
- global _G;
- envbk = _G;
- _G = clone( env );
- metaobj_set( _G, envbk );
- errmsg = null;
- errstack = null;
- pcall(function sgs_evalspec_trycode()
- {
- eval_file( file );
- },
- function sgs_evalspec_errhandler( code, msg ) use( errmsg, errstack )
- {
- errmsg = msg;
- errstack = sys_backtrace( true );
- });
- _G = envbk;
- return !errmsg, errmsg, errstack;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement