Merge pull request #12984 from s-hadinger/berry_fix_cond

Berry fix bug in conditional
This commit is contained in:
s-hadinger 2021-08-26 19:06:15 +02:00 committed by GitHub
commit 36c89dc6f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -111,7 +111,7 @@ void be_print_inst(binstruction ins, int pc)
logbuf("%s\tK%d", opc2str(op), IGET_Bx(ins)); logbuf("%s\tK%d", opc2str(op), IGET_Bx(ins));
break; break;
case OP_CLOSE: case OP_LDNIL: case OP_CLOSE: case OP_LDNIL:
logbuf("%s\t%d", opc2str(op), IGET_RA(ins)); logbuf("%s\tR%d", opc2str(op), IGET_RA(ins));
break; break;
case OP_RAISE: case OP_RAISE:
logbuf("%s\t%d\t%c%d\t%c%d", opc2str(op), IGET_RA(ins), logbuf("%s\t%d\t%c%d\t%c%d", opc2str(op), IGET_RA(ins),

View File

@ -97,7 +97,7 @@ static void match_notoken(bparser *parser, btokentype type)
} }
} }
/* check that if the expdesc is a symbol, it is avalid one or raise an exception */ /* check that if the expdesc is a symbol, it is a valid one or raise an exception */
static void check_symbol(bparser *parser, bexpdesc *e) static void check_symbol(bparser *parser, bexpdesc *e)
{ {
if (e->type == ETVOID && e->v.s == NULL) { /* error when token is not a symbol */ if (e->type == ETVOID && e->v.s == NULL) { /* error when token is not a symbol */
@ -106,7 +106,7 @@ static void check_symbol(bparser *parser, bexpdesc *e)
} }
} }
/* check that the value in `e` is valid for a variable, i.e. conatins a value or a valid symbol */ /* check that the value in `e` is valid for a variable, i.e. contains a value or a valid symbol */
static void check_var(bparser *parser, bexpdesc *e) static void check_var(bparser *parser, bexpdesc *e)
{ {
check_symbol(parser, e); /* check the token is a symbol */ check_symbol(parser, e); /* check the token is a symbol */
@ -989,6 +989,7 @@ static void cond_expr(bparser *parser, bexpdesc *e)
if (next_type(parser) == OptQuestion) { if (next_type(parser) == OptQuestion) {
int jf, jl = NO_JUMP; /* jump list */ int jf, jl = NO_JUMP; /* jump list */
bfuncinfo *finfo = parser->finfo; bfuncinfo *finfo = parser->finfo;
check_var(parser, e); /* check if valid */
scan_next_token(parser); /* skip '?' */ scan_next_token(parser); /* skip '?' */
be_code_jumpbool(finfo, e, bfalse); /* go if true */ be_code_jumpbool(finfo, e, bfalse); /* go if true */
jf = e->f; jf = e->f;