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>
This commit is contained in:
2020-10-07 17:21:01 -07:00
parent 76d0e6723f
commit 16063d50f8
6 changed files with 81 additions and 5 deletions

View File

@@ -166,7 +166,7 @@ fn flatten<T>(head: Result<Vec<T>>, tail: Result<T>) -> Result<Vec<T>> {
fn parse_string(input: &str) -> String {
let mut s = String::new();
let input = &input[1..input.bytes().len() - 1];
let input = &input[..input.bytes().len() - 1];
let mut chars = input.chars();
while let Some(c) = chars.next() {
if c == '\\' {