Skip to content

Commit

Permalink
perf: use MultiplyRR instruction to multiply two variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mrunix00 committed Apr 24, 2024
1 parent 3d48d2c commit 0b0bc06
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/bytecode/builtin_functions/MultiplyFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ namespace Bytecode::BuiltinFunctions {
}}});
return;
}
if (((TokenNode *) args[0])->token.type == Token::Symbol &&
((TokenNode *) args[1])->token.type == Token::Symbol &&
segment->find_variable(((TokenNode *) args[1])->getName()) != -1) {
instructions.push_back(new (Instruction){
Instruction::MultiplyRR,
{.rr_params = {
segment->find_variable(((TokenNode *) args[0])->getName()),
segment->find_variable(((TokenNode *) args[1])->getName()),
}}});
return;
}
}

args[0]->compile(segment, program, instructions);
Expand Down

0 comments on commit 0b0bc06

Please sign in to comment.