.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -32,3 +32,5 @@
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
|
cmake-build-*/
|
||||||
|
build/
|
||||||
|
|||||||
2
.idea/tyche.iml
generated
Normal file
2
.idea/tyche.iml
generated
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||||
13
src/vm/vm.cc
13
src/vm/vm.cc
@@ -36,12 +36,25 @@ int32_t VM::to_integer(int index) const
|
|||||||
return i.as_integer();
|
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)
|
VM& VM::push_integer(int32_t value)
|
||||||
{
|
{
|
||||||
stack_.push(Value::CreateInteger(value));
|
stack_.push(Value::CreateInteger(value));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VM& VM::push_float(float value)
|
||||||
|
{
|
||||||
|
stack_.push(Value::CreateFloat(value));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void VM::run_until_return()
|
void VM::run_until_return()
|
||||||
{
|
{
|
||||||
size_t level = stack_.fp_level();
|
size_t level = stack_.fp_level();
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ public:
|
|||||||
VM& call(size_t n_params);
|
VM& call(size_t n_params);
|
||||||
|
|
||||||
[[nodiscard]] int32_t to_integer(int index) const;
|
[[nodiscard]] int32_t to_integer(int index) const;
|
||||||
|
[[nodiscard]] float to_float(int index) const;
|
||||||
|
|
||||||
VM& push_integer(int32_t value);
|
VM& push_integer(int32_t value);
|
||||||
|
VM& push_float(float value);
|
||||||
|
|
||||||
[[nodiscard]] std::string debug_stack() const { return stack_.debug(); }
|
[[nodiscard]] std::string debug_stack() const { return stack_.debug(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user