bc: make bc_program_pushVar "z-function"
function old new delta bc_program_pushVar 200 198 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
2930123279
commit
b402ff844c
@ -186,7 +186,7 @@
|
|||||||
typedef enum BcStatus {
|
typedef enum BcStatus {
|
||||||
BC_STATUS_SUCCESS = 0,
|
BC_STATUS_SUCCESS = 0,
|
||||||
BC_STATUS_FAILURE = 1,
|
BC_STATUS_FAILURE = 1,
|
||||||
BC_STATUS_PARSE_EMPTY_EXP = 2, // bc_parse_expr() uses this
|
BC_STATUS_PARSE_EMPTY_EXP = 2, // bc_parse_expr_empty_ok() uses this
|
||||||
BC_STATUS_EOF = 3, // bc_vm_stdin() uses this
|
BC_STATUS_EOF = 3, // bc_vm_stdin() uses this
|
||||||
} BcStatus;
|
} BcStatus;
|
||||||
|
|
||||||
@ -1299,6 +1299,7 @@ static int push_input_byte(BcVec *vec, char c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is not a "z" function: can also return BC_STATUS_EOF
|
||||||
static BcStatus bc_read_line(BcVec *vec)
|
static BcStatus bc_read_line(BcVec *vec)
|
||||||
{
|
{
|
||||||
BcStatus s;
|
BcStatus s;
|
||||||
@ -4906,6 +4907,7 @@ static FAST_FUNC BcStatus bc_parse_parse(BcParse *p)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is not a "z" function: can also return BC_STATUS_PARSE_EMPTY_EXP
|
||||||
static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext next)
|
static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext next)
|
||||||
{
|
{
|
||||||
BcStatus s = BC_STATUS_SUCCESS;
|
BcStatus s = BC_STATUS_SUCCESS;
|
||||||
@ -6109,10 +6111,9 @@ static BcStatus bc_program_assign(char inst)
|
|||||||
bc_program_pushVar(code, bgn)
|
bc_program_pushVar(code, bgn)
|
||||||
// for bc, 'pop' and 'copy' are always false
|
// for bc, 'pop' and 'copy' are always false
|
||||||
#endif
|
#endif
|
||||||
static BcStatus bc_program_pushVar(char *code, size_t *bgn,
|
static BC_STATUS bc_program_pushVar(char *code, size_t *bgn,
|
||||||
bool pop, bool copy)
|
bool pop, bool copy)
|
||||||
{
|
{
|
||||||
BcStatus s = BC_STATUS_SUCCESS;
|
|
||||||
BcResult r;
|
BcResult r;
|
||||||
char *name = bc_program_name(code, bgn);
|
char *name = bc_program_name(code, bgn);
|
||||||
|
|
||||||
@ -6128,7 +6129,7 @@ static BcStatus bc_program_pushVar(char *code, size_t *bgn,
|
|||||||
|
|
||||||
if (!BC_PROG_STACK(v, 2 - copy)) {
|
if (!BC_PROG_STACK(v, 2 - copy)) {
|
||||||
free(name);
|
free(name);
|
||||||
return bc_error_stack_has_too_few_elements();
|
RETURN_STATUS(bc_error_stack_has_too_few_elements());
|
||||||
}
|
}
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
@ -6153,8 +6154,13 @@ static BcStatus bc_program_pushVar(char *code, size_t *bgn,
|
|||||||
|
|
||||||
bc_vec_push(&G.prog.results, &r);
|
bc_vec_push(&G.prog.results, &r);
|
||||||
|
|
||||||
return s;
|
RETURN_STATUS(BC_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
#if ERRORS_ARE_FATAL
|
||||||
|
# define zbc_program_pushVar(...) (bc_program_pushVar(__VA_ARGS__), BC_STATUS_SUCCESS)
|
||||||
|
#else
|
||||||
|
# define zbc_program_pushVar(...) bc_program_pushVar(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
static BC_STATUS zbc_program_pushArray(char *code, size_t *bgn,
|
static BC_STATUS zbc_program_pushArray(char *code, size_t *bgn,
|
||||||
char inst)
|
char inst)
|
||||||
@ -6826,7 +6832,7 @@ static BcStatus bc_program_exec(void)
|
|||||||
s = bc_program_read();
|
s = bc_program_read();
|
||||||
break;
|
break;
|
||||||
case BC_INST_VAR:
|
case BC_INST_VAR:
|
||||||
s = bc_program_pushVar(code, &ip->idx, false, false);
|
s = zbc_program_pushVar(code, &ip->idx, false, false);
|
||||||
break;
|
break;
|
||||||
case BC_INST_ARRAY_ELEM:
|
case BC_INST_ARRAY_ELEM:
|
||||||
case BC_INST_ARRAY:
|
case BC_INST_ARRAY:
|
||||||
@ -6954,7 +6960,7 @@ static BcStatus bc_program_exec(void)
|
|||||||
case BC_INST_LOAD:
|
case BC_INST_LOAD:
|
||||||
case BC_INST_PUSH_VAR: {
|
case BC_INST_PUSH_VAR: {
|
||||||
bool copy = inst == BC_INST_LOAD;
|
bool copy = inst == BC_INST_LOAD;
|
||||||
s = bc_program_pushVar(code, &ip->idx, true, copy);
|
s = zbc_program_pushVar(code, &ip->idx, true, copy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BC_INST_PUSH_TO_VAR: {
|
case BC_INST_PUSH_TO_VAR: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user