VM basics (#5)
Co-authored-by: Andre Wagner <WagnerAndre@JohnDeere.com> Reviewed-on: https://192.168.5.48/andre/tyche/pulls/5
This commit was merged in pull request #5.
This commit is contained in:
18
src/vm/expr.cc
Normal file
18
src/vm/expr.cc
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "expr.hh"
|
||||
|
||||
#include "vm_exceptions.hh"
|
||||
|
||||
namespace tyche::vm {
|
||||
|
||||
Value binary_operation(Value const& a, Value const& b, BinaryOperationType op)
|
||||
{
|
||||
// TODO - this is temporary code
|
||||
|
||||
if (a.type() == Type::Integer && b.type() == Type::Integer && op == BinaryOperationType::Sum) {
|
||||
return Value::CreateInteger(a.as_integer() + b.as_integer());
|
||||
} else {
|
||||
throw VMInvalidOperation(op, a.type(), b.type());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user