diff --git a/src/cs_bcode.hh b/src/cs_bcode.hh index cfd1a53..a234df4 100644 --- a/src/cs_bcode.hh +++ b/src/cs_bcode.hh @@ -142,14 +142,8 @@ enum { BC_INST_CONC, /* like above but without delimiter */ BC_INST_CONC_W, - /* push the value of svar with index D on the stack according to M */ - BC_INST_SVAR, - /* push the value of ivar with index D on the stack according to M */ - BC_INST_IVAR, - /* push the value of fvar with index D on the stack according to M */ - BC_INST_FVAR, - /* pop a value off the stack and set vvar with index D to it */ - BC_INST_FVAR1, + /* push the value of var with index D on the stack according to M */ + BC_INST_VAR, /* pop a value off the stack and set alias with index D to it */ BC_INST_ALIAS, /* pop 2 values off the stack; top is value to set, below is alias name */ diff --git a/src/cs_gen.cc b/src/cs_gen.cc index bc68165..cbf4e0d 100644 --- a/src/cs_gen.cc +++ b/src/cs_gen.cc @@ -328,21 +328,9 @@ void gen_state::gen_val( } } -void gen_state::gen_lookup_ivar(ident &id, int ltype) { +void gen_state::gen_lookup_var(ident &id, int ltype) { code.push_back( - BC_INST_IVAR | ret_code(ltype, BC_RET_INT) | (id.index() << 8) - ); -} - -void gen_state::gen_lookup_fvar(ident &id, int ltype) { - code.push_back( - BC_INST_FVAR | ret_code(ltype, BC_RET_FLOAT) | (id.index() << 8) - ); -} - -void gen_state::gen_lookup_svar(ident &id, int ltype) { - code.push_back( - BC_INST_SVAR | ret_code(ltype, BC_RET_STRING) | (id.index() << 8) + BC_INST_VAR | ret_code(ltype) | (id.index() << 8) ); } diff --git a/src/cs_gen.hh b/src/cs_gen.hh index 2f695da..05a90be 100644 --- a/src/cs_gen.hh +++ b/src/cs_gen.hh @@ -60,9 +60,7 @@ struct gen_state { std::size_t line = 0 ); - void gen_lookup_ivar(ident &id, int ltype = 0); - void gen_lookup_fvar(ident &id, int ltype = 0); - void gen_lookup_svar(ident &id, int ltype = 0); + void gen_lookup_var(ident &id, int ltype = 0); void gen_lookup_alias(ident &id, int ltype = 0, int dtype = 0); void gen_lookup_ident(int ltype = 0); diff --git a/src/cs_parser.cc b/src/cs_parser.cc index 5c4deee..1fe104e 100644 --- a/src/cs_parser.cc +++ b/src/cs_parser.cc @@ -481,24 +481,11 @@ lookup_id: ); switch (id.type()) { case ident_type::IVAR: - if (ltype == VAL_POP) { - return; - } - gs.gen_lookup_ivar(id, ltype); - switch (ltype) { - case VAL_CODE: - case VAL_IDENT: - lookup_done(gs, ltype); - break; - default: - break; - } - return; case ident_type::FVAR: if (ltype == VAL_POP) { return; } - gs.gen_lookup_fvar(id, ltype); + gs.gen_lookup_var(id, ltype); switch (ltype) { case VAL_CODE: case VAL_IDENT: @@ -513,7 +500,7 @@ lookup_id: case VAL_POP: return; default: - gs.gen_lookup_svar(id, ltype); + gs.gen_lookup_var(id, ltype); break; } lookup_done(gs, ltype); @@ -605,13 +592,9 @@ lookup_id: ); switch (id.type()) { case ident_type::IVAR: - gs.gen_lookup_ivar(id); - return true; case ident_type::FVAR: - gs.gen_lookup_fvar(id); - return true; case ident_type::SVAR: - gs.gen_lookup_svar(id); + gs.gen_lookup_var(id); return true; case ident_type::ALIAS: gs.gen_lookup_alias(id); diff --git a/src/cs_vm.cc b/src/cs_vm.cc index 362710f..9b466ab 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -716,31 +716,11 @@ std::uint32_t *vm_exec( continue; } - case BC_INST_SVAR | BC_RET_STRING: - case BC_INST_SVAR | BC_RET_NULL: - case BC_INST_SVAR | BC_RET_INT: - case BC_INST_SVAR | BC_RET_FLOAT: - args.emplace_back() = static_cast( - ts.istate->identmap[op >> 8] - )->value(); - force_arg(cs, args.back(), op & BC_INST_RET_MASK); - continue; - - case BC_INST_IVAR | BC_RET_INT: - case BC_INST_IVAR | BC_RET_NULL: - case BC_INST_IVAR | BC_RET_STRING: - case BC_INST_IVAR | BC_RET_FLOAT: - args.emplace_back() = static_cast( - ts.istate->identmap[op >> 8] - )->value(); - force_arg(cs, args.back(), op & BC_INST_RET_MASK); - continue; - - case BC_INST_FVAR | BC_RET_FLOAT: - case BC_INST_FVAR | BC_RET_NULL: - case BC_INST_FVAR | BC_RET_STRING: - case BC_INST_FVAR | BC_RET_INT: - args.emplace_back() = static_cast( + case BC_INST_VAR | BC_RET_NULL: + case BC_INST_VAR | BC_RET_INT: + case BC_INST_VAR | BC_RET_FLOAT: + case BC_INST_VAR | BC_RET_STRING: + args.emplace_back() = static_cast( ts.istate->identmap[op >> 8] )->value(); force_arg(cs, args.back(), op & BC_INST_RET_MASK);