Add branching and more coherent method of function calls

We're turing-complete, babey!

* Call stack for functions now differentiates between native and quote
  calls
* Better API for builtin functions allowing for more control
* Example showing off branches

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-01-12 21:49:41 -08:00
parent c31be8142c
commit 90f27a4108
5 changed files with 274 additions and 66 deletions

View File

@@ -2,6 +2,7 @@ use crate::object::{QuoteTable, Value};
use crate::scope::*;
use crate::syn::ast::*;
use crate::vm::inst::*;
use std::rc::Rc;
pub struct Compile<'s> {
scope_stack: &'s mut ScopeStack,
@@ -35,7 +36,7 @@ impl<'s> Compile<'s> {
// this gets compiled whenever it gets evaluated
Expr::Quote(exprs) => {
self.scope_stack.push_scope();
let compiled = self.compile(exprs);
let compiled = Rc::new(self.compile(exprs));
let locals = self.scope_stack.pop_scope().unwrap();
let quote = self
.quote_table