Expressions #7

Merged
andre merged 21 commits from vm2 into master 2026-05-02 15:07:12 -05:00
4 changed files with 19 additions and 0 deletions
Showing only changes of commit f16f2e0e8e - Show all commits

2
.gitignore vendored
View File

@@ -32,3 +32,5 @@
*.out
*.app
cmake-build-*/
build/

2
.idea/tyche.iml generated Normal file
View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

View File

@@ -36,12 +36,25 @@ int32_t VM::to_integer(int index) const
return i.as_integer();
}
float VM::to_float(int index) const
{
Value i = stack_.at(index);
assert_type(i, Type::Float);
return i.as_float();
}
VM& VM::push_integer(int32_t value)
{
stack_.push(Value::CreateInteger(value));
return *this;
}
VM& VM::push_float(float value)
{
stack_.push(Value::CreateFloat(value));
return *this;
}
void VM::run_until_return()
{
size_t level = stack_.fp_level();

View File

@@ -14,8 +14,10 @@ public:
VM& call(size_t n_params);
[[nodiscard]] int32_t to_integer(int index) const;
[[nodiscard]] float to_float(int index) const;
VM& push_integer(int32_t value);
VM& push_float(float value);
[[nodiscard]] std::string debug_stack() const { return stack_.debug(); }