|
|
@ -981,7 +981,6 @@ static Proto *addprototype (LexState *ls) { |
|
|
|
** so that, if it invokes the GC, the GC knows which registers |
|
|
|
** are in use at that time. |
|
|
|
*/ |
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
static void codeclosure (LexState *ls, expdesc *v, int deferred) { |
|
|
|
FuncState *fs = ls->fs->prev; |
|
|
|
int pc = -1; |
|
|
@ -995,14 +994,6 @@ static void codeclosure (LexState *ls, expdesc *v, int deferred) { |
|
|
|
} |
|
|
|
DEBUG_VARS(raviY_printf(ls->fs, "codeclosure -> closure created %e\n", v)); |
|
|
|
} |
|
|
|
#else |
|
|
|
static void codeclosure (LexState *ls, expdesc *v) { |
|
|
|
FuncState *fs = ls->fs->prev; |
|
|
|
init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1), RAVI_TM_FUNCTION, NULL); |
|
|
|
luaK_exp2nextreg(fs, v); /* fix it at the last register */ |
|
|
|
DEBUG_VARS(raviY_printf(ls->fs, "codeclosure -> closure created %e\n", v)); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { |
|
|
@ -1363,7 +1354,6 @@ static void parlist (LexState *ls) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
static void body (LexState *ls, expdesc *e, int ismethod, int line, int deferred) { |
|
|
|
/* body -> '(' parlist ')' block END */ |
|
|
|
FuncState new_fs; |
|
|
@ -1386,28 +1376,6 @@ static void body (LexState *ls, expdesc *e, int ismethod, int line, int deferred |
|
|
|
codeclosure(ls, e, deferred); |
|
|
|
close_func(ls); |
|
|
|
} |
|
|
|
#else |
|
|
|
static void body (LexState *ls, expdesc *e, int ismethod, int line) { |
|
|
|
/* body -> '(' parlist ')' block END */ |
|
|
|
FuncState new_fs; |
|
|
|
BlockCnt bl; |
|
|
|
new_fs.f = addprototype(ls); |
|
|
|
new_fs.f->linedefined = line; |
|
|
|
open_func(ls, &new_fs, &bl); |
|
|
|
checknext(ls, '('); |
|
|
|
if (ismethod) { |
|
|
|
new_localvarliteral(ls, "self"); /* create 'self' parameter */ |
|
|
|
adjustlocalvars(ls, 1); |
|
|
|
} |
|
|
|
parlist(ls); |
|
|
|
checknext(ls, ')'); |
|
|
|
statlist(ls); |
|
|
|
new_fs.f->lastlinedefined = ls->linenumber; |
|
|
|
check_match(ls, TK_END, TK_FUNCTION, line); |
|
|
|
codeclosure(ls, e); |
|
|
|
close_func(ls); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
/* parse expression list */ |
|
|
|
static int explist (LexState *ls, expdesc *v) { |
|
|
@ -1699,11 +1667,7 @@ static void simpleexp (LexState *ls, expdesc *v) { |
|
|
|
} |
|
|
|
case TK_FUNCTION: { |
|
|
|
luaX_next(ls); |
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
body(ls, v, 0, ls->linenumber, 0); |
|
|
|
#else |
|
|
|
body(ls, v, 0, ls->linenumber); |
|
|
|
#endif |
|
|
|
return; |
|
|
|
} |
|
|
|
default: { |
|
|
@ -2277,7 +2241,6 @@ static void ifstat (LexState *ls, int line) { |
|
|
|
} |
|
|
|
|
|
|
|
/* parse a local function statement - called from statement() */ |
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
static void localfunc (LexState *ls, int defer) { |
|
|
|
expdesc b = {.ravi_type_map = RAVI_TM_ANY, .pc = -1}; |
|
|
|
FuncState *fs = ls->fs; |
|
|
@ -2295,18 +2258,6 @@ static void localfunc (LexState *ls, int defer) { |
|
|
|
/* debug information will only see the variable after this point! */ |
|
|
|
getlocvar(fs, b.u.info)->startpc = fs->pc; |
|
|
|
} |
|
|
|
#else |
|
|
|
static void localfunc (LexState *ls) { |
|
|
|
expdesc b = {.ravi_type = RAVI_TANY, .pc = -1}; |
|
|
|
FuncState *fs = ls->fs; |
|
|
|
/* RAVI change - add type */ |
|
|
|
new_localvar(ls, str_checkname(ls), RAVI_TFUNCTION, NULL); /* new local variable */ |
|
|
|
adjustlocalvars(ls, 1); /* enter its scope */ |
|
|
|
body(ls, &b, 0, ls->linenumber); /* function created in next register */ |
|
|
|
/* debug information will only see the variable after this point! */ |
|
|
|
getlocvar(fs, b.u.info)->startpc = fs->pc; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
/* parse a local variable declaration statement - called from statement() */ |
|
|
|
static void localstat (LexState *ls) { |
|
|
@ -2366,11 +2317,7 @@ static void funcstat (LexState *ls, int line) { |
|
|
|
luaX_next(ls); /* skip FUNCTION */ |
|
|
|
ismethod = funcname(ls, &v); |
|
|
|
DEBUG_VARS(raviY_printf(ls->fs, "funcstat -> declaring function %e\n", &v)); |
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
body(ls, &b, ismethod, line, 0); |
|
|
|
#else |
|
|
|
body(ls, &b, ismethod, line); |
|
|
|
#endif |
|
|
|
luaK_storevar(ls->fs, &v, &b); |
|
|
|
luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ |
|
|
|
} |
|
|
@ -2463,22 +2410,16 @@ static void statement (LexState *ls) { |
|
|
|
case TK_LOCAL: { /* stat -> localstat */ |
|
|
|
luaX_next(ls); /* skip LOCAL */ |
|
|
|
if (testnext(ls, TK_FUNCTION)) /* local function? */ |
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
localfunc(ls, 0); |
|
|
|
#else |
|
|
|
localfunc(ls); |
|
|
|
#endif |
|
|
|
else |
|
|
|
localstat(ls); |
|
|
|
break; |
|
|
|
} |
|
|
|
#ifdef RAVI_DEFER_STATEMENT |
|
|
|
case TK_DEFER: { /* stat -> deferstat */ |
|
|
|
luaX_next(ls); /* skip DEFER */ |
|
|
|
localfunc(ls, 1); |
|
|
|
break; |
|
|
|
} |
|
|
|
#endif |
|
|
|
case TK_DBCOLON: { /* stat -> label */ |
|
|
|
luaX_next(ls); /* skip double colon */ |
|
|
|
labelstat(ls, str_checkname(ls), line); |
|
|
|