Commit Graph

4 Commits

Author SHA1 Message Date
f35d44cf65 Add add, sub, mul, and div functions to integers
Arithmetic among integers is supportd. Yey!

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-19 16:41:57 -07:00
902da3f2f3 Add internal error handling to VM, plus function arity
* VM is able to handle basic runtime errors although there is no way to
  catch this in executing code currently
* If a function is called with the wrong number of arguments (arity) it
  will invoke a runtime error.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-13 14:07:22 -07:00
c738c52455 Add Method type for objects
* Methods are wrappers created with an owner and a function, which
  passes the owner as the first argument when the function is called.
* Fix a small bug in the VM where the pc was being set at the wrong
  time

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-08 16:10:10 -07:00
16063d50f8 Add a couple of builtin functions, and the Vm::call() method
* Builtin functions print and println have been added
* If a global lookup fails, the VM will attempt to look up a builtin
* Vm::call(fun, args) allows interrupting the current execution state
  and starting a new function instead. It will return the value left on
  top of the stack.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-07 17:21:01 -07:00