fix neg constant

This commit is contained in:
blueloveTH 2023-02-13 18:06:52 +08:00
parent 6067436e46
commit ce0ba313d1
2 changed files with 7 additions and 6 deletions

View File

@ -65,6 +65,8 @@ struct CodeObject {
std::vector<CodeBlock> blocks = { CodeBlock{NO_BLOCK, -1} };
emhash8::HashMap<Str, int> labels;
void optimize(VM* vm);
bool add_label(const Str& label){
if(labels.contains(label)) return false;
labels[label] = codes.size();
@ -86,8 +88,6 @@ struct CodeObject {
return consts.size() - 1;
}
void optimize(VM* vm);
/************************************************/
int _curr_block_i = 0;
bool _rvalue = false;

View File

@ -1135,3 +1135,4 @@ void CodeObject::optimize(VM* vm){
consts[pos] = vm->num_negated(consts[pos]);
}
}
}