nodes: The Node Identity.

First of the Node refactors.

This is the best slice of isolated changes that I could divine, and I spent a
good half-day of thought on the problem. Basically, nodes have changed their
internal layout, and that means that a lot of node-handling code needs to be
changed to work with them. In particular, since the members of nodes have
changed, their pretty-printing needs to change. But that means that we have to
pull in the newer AST loader and the pretty-printing helper.

I compromised here and gutted ScriptObject. For this commit (and only this
commit!) ScriptObjects do not work.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
nodes: The Node Supremacy.

The short version: We needed to restore ScriptObject. From that, all else
followed.

Patterns now always use ejectors when unifying. This creates a circle between
ejection-as-control and patterns-as-definitions which ends up pulling some
stuff in.

This patch finally kills t.o.__init__, which is pretty cool. It also
introduces ScriptMaps, which are a much-needed structure for optimization.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
nodes: The Node Ultimatum.

At this point, nodes look more or less like they should.

We add transform() methods to all nodes, and then add an optimizer which
rewrites all nodes. The rewrite is top-down in alterations and bottom-up in
recursion, similar to the recursion models provided by SYB/Uniplate/Lens/etc.
Haskell generic term/type rewriting systems.

Of course, since we're not using Haskell, we must reinvent all of our own
wheels.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
Load and use the prelude.

Included are tools for making module importing and evaluation easier.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects/iteration: Iterative JIT primitive loops.

These are necessary for JIT'ing loops.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
Create simple predicate guards.

These guards are essentially type-checkers.

Rather than testing individual guards, the tests cover the guard generation
machinery instead.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
simple: A bunch of stuff. Also other cleanups.

This used to be the big squash, but we've actually rebased it all away! Yay!

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects/data: Add StrObject.getString().

There used to be more stuff here, but it got rebased away.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
Switch to atoms.

This one's really big. This could be thought of as sort of a 2.0 moment. I
will *not* squash this commit.

Instead of passing around verbs and implying arity from length of argument
lists, consolidate them into atoms, which wrap verbs and arity and are easily
promotable by the JIT.

Additionally, improve several JIT annotations, including atom promotion, node
promotion, and immutability of certain lists. We're looking at traces that are
half the length of what they used to be.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
nodes: Reveal nodes in JIT traces.

Wow. I can see exactly what is and is not optimized away. This is awesome!

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects/data: Check for OOB in StrObject get/1, and test.

Post-atom.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects/data: Add IntObject max/1 and min/1, and test.

Post-atom.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects/collections: Add indexOf/1.

Post-atom.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects/data: Add toString/0 for ints.

Post-atom.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
Create import() and factor main slightly.

Post-atom but could be moved.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
objects: Implement M.toString() and general toObject() plumbing.

This is incredibly hacky, but it reflects the general desire for repr() to be
very close to toString() or toQuote() in output.

_printOn() is not yet supported, but it might be rolled into this patch later.

Also use a UnicodeBuilder for string joins.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>
Add unit testing to the universal scope.

Because tests are important. This greatly lowers the burden of unit testing.

Signed-off-by: Corbin Simpson <cds@corbinsimpson.com> <simpsoco@google.com>