* VM creates arrays using the BeginArray and EndArray instructions
* ArrayObj is implemented with a __str__ function (annoying)
* Simple example of array creation is added
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Compile::discover_locals now takes a Vec<SpExpr> instead of a single
SpExpr. It is also called before the compiler starts building the list
of instructions so that all names in the scope are available at
compile-time.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* T and F were builtins that were created as functions. They have been
changed to just be global values instead, so you don't need to suffix
them with ! to get the creamy value inside.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* `if` function stack ordering is changed to use condition, if-false,
if-true (bottom to top). This is so we can pass a value on top of the
stack directly to a new `if` in a condition, so we don't have to store
a new value in a new variable.
* Add __splat__ and __minus__ functions to Int
* Add * and - builtins, which call the __splat__ and __minus__ functions
of the top stack item, respectively.
* Add factorial example because now factorials are possible with this
skeleton implementation, albeit a little hacky with the recursion.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* `if` builtin is the big one here - branching! Yay!
* The `if` builtin requires __bool__ to be implemented for things. This
is added for all builtin objects.
* Vtables have slightly better ergonomics.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This allows us to write out errors that follow the call stack and give
locations to where errors originated.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
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>