I'm trying to remember why this was added in the first place - I think
to simplifly cloning? It's not important now though.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Obj is now a trait instead of a struct
* Value enum is gone, replaced with individual structs that implement
Obj
* All instances where a Value was used, a Gc<(dyn Obj + 'static)> takes
its place. ObjPtr is shorthand for this.
* A __str__ method for objects is implemented for a couple builtin types
as a proof-of-concept
* println and print builtin functions are implemented using this
interface
There's still a lot to do, mostly with interned values. For example,
whenever a new string object is created, a new __str__ function object
is created each time, rather than reusing the first one that was
created. Stuff like that.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
I just learned about thread local storage, so we really don't
lazy_static for anything anymore - it was only being used for the lexer
regex.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
I'm not writing my own GC, it's a huge pain in Rust. I'm using the gc
library instead.
Base object stuff implementation is here too. Hopefully going to start
using ObjPtr instead of Value next.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Span was using the auto-implemented PartialCmp during testing, which was
interfering with the new "source" member, causing test failures.
PartialCmp of a Span during testing is now always true.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Positions were being calculated by looking at the *first* character,
which would cause the same character to be visited twice. Now, if the
character is a null byte (\0), it won't advance the position at all.
The null byte should be a safe sentinel value to use because it
(hypothetically) shouldn't be showing up in a source file. This will
probably cause a hang if a file that starts with null bytes, but that's
a problem for future me.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* RuntimeSpanError was an extraneous solution to adding spans to the
errors; so instead this behavior has been delegated to the
RuntimeError itself.
* Usage of Inst has mostly been replaced with SpInst so if an error is
encountered, we can spit out where it happened in the source code
(hopefully with a stack trace).
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>
This is the path to the location that this span is pointing to. This is
usually going to be a file path, but it can really be anything you want.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This helps split up expressions, meta calls (like includes) that can be
expanded into more expressions.
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>
* crate::scope instead of crate::syn::word, which makes more sense
because scopes are not really used in syntax at all
* Reference-counted BuiltinFn values are available for creation now
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Nothing fancy yet. This commit adds a bunch of stuff (oops):
* compiling code
* VM with instructions
* remove eval.rs and just eval in the Machine struct itself
* squash most warnings now that we're using stuff here
And probably more. But that's all for now folks
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
We're not compiling yet and mostly want to get the name stuff figured
out. Also may switch to using anyhow error handling.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>