diff --git a/src/cs_gen.cc b/src/cs_gen.cc index 83cb724..c0d35d5 100644 --- a/src/cs_gen.cc +++ b/src/cs_gen.cc @@ -475,7 +475,7 @@ void gen_state::gen_block() { } std::pair gen_state::gen_block( - std::string_view v, std::size_t line, int ret_type, int term + std::string_view v, std::size_t line, int ltype, int term ) { auto csz = code.size(); code.push_back(BC_INST_BLOCK); @@ -495,13 +495,13 @@ std::pair gen_state::gen_block( ret_line = ps.current_line; } if (code.size() > (csz + 2)) { - code.push_back(BC_INST_EXIT | ret_type); + code.push_back(BC_INST_EXIT | ret_code(ltype)); /* encode the block size in BC_INST_BLOCK */ code[csz] |= (std::uint32_t(code.size() - csz - 1) << 8); } else { /* empty code */ code.resize(csz); - code.push_back(BC_INST_EMPTY | ret_type); + code.push_back(BC_INST_EMPTY | ret_code(ltype)); } return std::make_pair(ret_line, v); } diff --git a/src/cs_gen.hh b/src/cs_gen.hh index 0717191..2f695da 100644 --- a/src/cs_gen.hh +++ b/src/cs_gen.hh @@ -99,7 +99,7 @@ struct gen_state { void gen_block(); std::pair gen_block( std::string_view v, std::size_t line, - int ret_type = BC_RET_NULL, int term = '\0' + int ltype = VAL_NULL, int term = '\0' ); private: diff --git a/src/cs_parser.cc b/src/cs_parser.cc index df8bcd5..208f797 100644 --- a/src/cs_parser.cc +++ b/src/cs_parser.cc @@ -396,13 +396,6 @@ std::string_view parser_state::get_word() { return std::string_view{beg, std::size_t(source - beg)}; } -static inline int ret_code(int type, int def = 0) { - if (type >= VAL_ANY) { - return def; - } - return type << BC_INST_RET; -} - static bool compilearg( parser_state &gs, int wordtype, charbuf *word = nullptr ); @@ -710,7 +703,7 @@ static void compileblockmain(parser_state &gs, int wordtype) { case VAL_COND: { auto ret = gs.gs.gen_block(std::string_view{ start, gs.send - }, curline, BC_RET_NULL, ']'); + }, curline, VAL_NULL, ']'); gs.source = ret.second.data(); gs.send = ret.second.data() + ret.second.size(); gs.current_line = ret.first;