Expressions #7

Merged
andre merged 21 commits from vm2 into master 2026-05-02 15:07:12 -05:00
2 changed files with 14 additions and 17 deletions
Showing only changes of commit eed9196cd1 - Show all commits

View File

@@ -32,6 +32,9 @@ After some additional development:
- [x] Assembler - [x] Assembler
- [ ] VM execution - [ ] VM execution
- [ ] Stack operations (nil, integer, float, string, function) - [ ] Stack operations (nil, integer, float, string, function)
- [ ] Integer
- [ ] Float
- [ ] String
- [ ] Expressions - [ ] Expressions
- [ ] Local/global variables - [ ] Local/global variables
- [ ] Functions - [ ] Functions

View File

@@ -95,24 +95,18 @@ TEST(VM, BasicCode)
TEST(VM, SumIntegers) TEST(VM, SumIntegers)
{ {
ASSERT_EQ(VM().load_bytecode(as::Assembler(R"( auto test_op = [](int32_t op1, int32_t op2, std::string oper) {
return VM().load_bytecode(as::Assembler(std::format(R"(
.func 0 .func 0
pushi 2 pushi {}
pushi 3 pushi {}
sum {}
ret ret
)").assemble()).call(0).to_integer(-1), 5); )", op1, op2, oper)).assemble()).call(0).to_integer(-1);
} };
TEST(VM, SubtractIntegers) ASSERT_EQ(test_op(2, 3, "sum"), 5);
{ ASSERT_EQ(test_op(2, 3, "sub"), -1);
ASSERT_EQ(VM().load_bytecode(as::Assembler(R"(
.func 0
pushi 2
pushi 3
sub
ret
)").assemble()).call(0).to_integer(-1), -1);
} }
int main(int argc, char** argv) int main(int argc, char** argv)