This commit is contained in:
Stephan Hadinger 2021-08-16 12:22:02 +02:00
parent 660698dc10
commit b870ca1aa3
3 changed files with 18 additions and 9 deletions

View File

@ -408,7 +408,7 @@ static int var2reg(bfuncinfo *finfo, bexpdesc *e, int dst)
codeABx(finfo, OP_GETGBL, dst, e->v.idx);
break;
case ETNGLOBAL:
codeABC(finfo, OP_GETNGBL, dst, e->v.ss.obj, e->v.ss.idx);
codeABC(finfo, OP_GETNGBL, dst, e->v.ss.idx, 0);
break;
case ETUPVAL:
codeABx(finfo, OP_GETUPV, dst, e->v.idx);
@ -601,7 +601,7 @@ static void setbgblvar(bfuncinfo *finfo, bopcode op, bexpdesc *e1, int src)
code_move(finfo, finfo->freereg, src);
src = finfo->freereg;
}
codeABC(finfo, op, src, 0, e1->v.idx);
codeABC(finfo, op, src, e1->v.idx, 0);
}
static void setsupvar(bfuncinfo *finfo, bopcode op, bexpdesc *e1, int src)

View File

@ -467,6 +467,7 @@ static int singlevaraux(bvm *vm, bfuncinfo *finfo, bstring *s, bexpdesc *var)
static void singlevar(bparser *parser, bexpdesc *var)
{
bexpdesc key;
bstring *varname = next_token(parser).u.s;
int type = singlevaraux(parser->vm, parser->finfo, varname, var);
switch (type) {
@ -479,13 +480,10 @@ static void singlevar(bparser *parser, bexpdesc *var)
var->v.idx = be_global_find(parser->vm, varname);
break;
case ETNGLOBAL:
{
bexpdesc key;
init_exp(&key, ETSTRING, 0);
key.v.s = varname;
init_exp(var, ETNGLOBAL, 0);
var->v.idx = be_code_nglobal(parser->finfo, &key);
}
init_exp(&key, ETSTRING, 0);
key.v.s = varname;
init_exp(var, ETNGLOBAL, 0);
var->v.idx = be_code_nglobal(parser->finfo, &key);
break;
default:
break;

View File

@ -352,6 +352,17 @@ typedef struct bntvmodule {
PROTO_VAR_INFO_BLOCK \
}
#define be_define_local_closure(_name) \
const bclosure _name##_closure = { \
NULL, /* bgcobject *next */ \
BE_CLOSURE, /* type BE_CLOSURE */ \
GC_CONST, /* marked GC_CONST */ \
0, /* nupvals */ \
NULL, /* bgcobject *gray */ \
(bproto*) &_name##_proto, /* proto */ \
{ NULL } /* upvals */ \
}
/* new version for more compact literals */
#define be_local_closure(_name, _proto) \
static const bclosure _name##_closure = { \