Commit graph

363 commits

Author SHA1 Message Date
joeduffy
4ed118e8fa Add basic Mu metadata parsing support
This change adds discovery of Mu metadata in the form of a Mu.json file.
This allows us to eliminate the "TODO" in place of a real package name in
the output ASTs, so our baselines are adjusted accordingly.  This is part
of marapongo/mu#42 -- implementation of real module and package names.
2017-01-10 12:42:42 -08:00
joeduffy
57e8a6aa67 Do a line-by-line comparison for AST checking
This changes the test harness to do a line-by-line comparison, rather than
full text comparison, for AST checking.  This is a bit nicer to diagnose, because
failures will specifically point out the line that deviates, rather than dumping
the (possibly huge) string containing the full expected/actual ASTs.
2017-01-10 12:40:59 -08:00
joeduffy
f2f6826f5b Add a test for exporting a module property 2017-01-10 08:20:01 -08:00
joeduffy
7017828ae5 Add a baseline for the empty test
This adds a baseline for the empty module test, and it passes.
Unfortunately, because module names are absolute file paths, this
baseline file has my machine's specific path embedded in it.  I want
to lock these in so they are passing as I make progress.  Sometime
later this morning I'll fix the module naming to be "relative" and
more Mu-friendly, and this issue will go away.
2017-01-10 08:15:34 -08:00
joeduffy
a2b02381fc Use the module's fileName as its name
For now we will use the module's fileName as its name.  This matches
the ECMAScript semantics, however, we will eventually want to do a pass
to normalize these names into more "Mu-friendly" module names.
2017-01-10 08:14:02 -08:00
joeduffy
641fb5bd21 Fix a few TSLint errors 2017-01-10 08:13:39 -08:00
joeduffy
27eef9903b Use JSON object maps instead of ES6 Maps
This change uses JSON object maps in the AST, rather than ES6 Maps,
so that the resulting data structure is easily serializable.
2017-01-10 07:57:22 -08:00
joeduffy
62e11f37e0 Rename formats doc to languages 2017-01-10 07:32:01 -08:00
joeduffy
2669f5b860 Lower identifiers
This changes the way we represent identifiers slightly, and then lowers
the TypeScript representation to them.  Prior to this change, identifiers
could be naked strings; after this change, identifiers are always first class
AST nodes -- so they can carry location information -- and tokens assume the
role of naked strings.  This means some definition maps must now be keyed by
tokens and also means that some AST node properties that used to carry just
naked strings needed to be updated to carry first class AST nodes.
2017-01-10 07:21:03 -08:00
joeduffy
478d1c3173 Handle unexported top-level variables
This change rearranges some logic to properly handle both exported and
unexported top-level module properties (variables).
2017-01-10 07:07:36 -08:00
joeduffy
972842b687 Implement variable declaration lowering
This is an initial cut at implementing variable declaration lowering.

The lowering is slightly different for module properties and local variables,
since the former requires that code go into the module initializer, while the
latter can mostly happen "inline" as the local variable is bound.

There are some incomplete parts in here -- like lowering type names -- that
are dependent on a few upcoming changes.
2017-01-10 08:33:41 -06:00
joeduffy
1d1e11bb13 Project MuJS modules into MuPack/MuIL metadata
This change translates MuJS modules and their various top-level statements
into the corresponding MuPack/MuIL metadata.  Notably, to ensure static analyzability,
MuIL doesn't permit arbitrary class, function, etc. definitions as statements.  Instead,
they must occur at the top-level, and be recognized as such statically.  That's the bulk
of this change.  The individual nodes aren't necessarily mapped yet, however.
2017-01-09 21:20:19 -06:00
joeduffy
9cb9b4eed8 Export a top-level list of modules
The way ECMAScript and Python work is that each file maps to a module.  There
isn't really an "official" notion of a submodule; instead, directories on the
import path are conventionally used as submodule names.  Aggregate submodules
can be achieved by convention with re-exports in ECMAScript, however this is an
informal notion.  We could keep the current structured submodule notion and require
that all languages map to it, however, it is just as easy to have a flat list of
top-level modules indexed by name.  This change rearranges the AST accordingly.
2017-01-08 16:20:19 -06:00
joeduffy
094d0aa6e0 Add a handy executable wrapper for MuJS 2017-01-08 15:34:10 -06:00
joeduffy
89f2424df1 Add a new harness for test cases
This adds a new test harness that will be used to run baseline-style
tests.  Each subdirectory underneath tests/output will be interpreted as
a test case, each of which can contain an optional `messages.txt` file
which will be compared as the expected output against the compiler's error
and warning messages, and/or an optional `Mu.out.json` file which will be
compared as the expected output against the compiler's output tree.

There's just a single "empty" test case for now.  I will start getting in
the habit of checking in a companion test for each AST kind we lower.
2017-01-08 15:20:46 -06:00
joeduffy
2eaff6a316 Implement unary operator lowering 2017-01-08 10:13:15 -06:00
joeduffy
7873ce0874 Add a note about exceptions vs fail-fast 2017-01-08 07:47:12 -06:00
joeduffy
d36a522c33 Mention we want to lock down SSH by default
Also, add a link to marapongo/mu#33.
2017-01-08 07:31:59 -06:00
joeduffy
a4f68abafb Add more details on pinned versions 2017-01-08 07:27:12 -06:00
joeduffy
92dd19d98a Add new AST node types to MuPack doc 2017-01-03 04:14:56 -08:00
joeduffy
f2e70c6222 Map binary operators during lowering 2017-01-03 04:14:37 -08:00
joeduffy
2d5a81e350 Add a note about the need to figure out string functions 2017-01-03 03:56:15 -08:00
joeduffy
0979c0c165 Add IsInst and TypeOf expressions
This adds two expressions we will need to support many type test patterns.

IsInst simply checks an expression for castability to a target type; it evaluates
to a boolean.

TypeOf fetches the runtime type of a given expression and evaluates to its name.
Right now, this is just a string token, rather than some richer RTTI object.
2017-01-03 03:48:28 -08:00
joeduffy
bebc952998 Add a note on dependency pinning 2017-01-03 03:41:41 -08:00
joeduffy
ca124ea3a6 Add more AST lowerings for trivial kinds
This includes AST lowering for DebuggerStatements and ConditionalExpressions,
both of which are straightforward boilerplate mappings.
2017-01-02 16:44:51 -08:00
joeduffy
e8e031f97c Map a few more trivial AST kinds
This is mostly boilerplate, mapping the following AST kinds: IfStatement,
ReturnStatement, ThrowStatement, Block, EmptyStatement, ExpressionStatement,
and LabeledStatement.
2017-01-02 16:33:31 -08:00
joeduffy
25c321e5f6 Fix a few random typos I noticed 2017-01-02 16:26:19 -08:00
joeduffy
41323c1dc7 Reorder some things 2017-01-01 18:34:31 -08:00
joeduffy
c403f9b444 Nit, shorten the ridiculously lengthy title 2017-01-01 18:33:28 -08:00
joeduffy
17a0f62f8d Add a few tidbits, include an AST shape snapshot in MuIL section 2017-01-01 18:29:07 -08:00
joeduffy
78b2adc9fe Overhaul the stacks.md design document
The stacks.md document used to describe the metadata format.  Now that we've
moved away from the old model of YAML + Go templates, and created the MuPack/MuIL
format, this document needed to be overhauled.

It's pretty bare bones now, however it will eventually evolve into a document
describing how the Mu abstractions map down onto MuPack/MuIL concepts.  For example,
it describes how subclassing mu.Stack creates a "stack", even though at the MuPack/MuIL
level it's just any old subclass.
2017-01-01 18:06:03 -08:00
joeduffy
36ab7a8710 Add some out of date markers 2017-01-01 17:11:28 -08:00
joeduffy
0c2940ba0b Goodbye Mull2
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction ice
Is also great
And would suffice.
2017-01-01 17:05:48 -08:00
joeduffy
e451d64a71 Tidy up a few things, especially references to "resources" 2017-01-01 16:57:12 -08:00
joeduffy
a2ca2c84af Flesh out the cross-cloud doc 2017-01-01 16:35:23 -08:00
joeduffy
7a502cb83a Flesh out a bunch of things 2017-01-01 16:17:30 -08:00
joeduffy
7d249894ee Freshen up the description of dependency management 2017-01-01 16:02:18 -08:00
joeduffy
1895753f53 Goodbye Mull
A Death blow is a Life blow to Some
Who till they died, did not alive become--
Who had they lived, had died but when
They died, Vitality begun.
2017-01-01 15:24:25 -08:00
joeduffy
67ca1a6cc4 Add a README pointer to the overview doc 2017-01-01 15:19:22 -08:00
joeduffy
1bd1aaf968 Reorganize documents a bit and add an index 2017-01-01 15:18:36 -08:00
joeduffy
8f820ce11f Rename languages.md to formats.md
And also wordsmith a bunch of the front matter.
2017-01-01 15:12:51 -08:00
joeduffy
f42e2579f4 Bring the concepts section up to date 2017-01-01 14:39:26 -08:00
joeduffy
d4d6f3e018 Update the targets table 2017-01-01 14:24:08 -08:00
joeduffy
a1d21b0d73 Move most docs into a design subdirectory 2017-01-01 14:18:00 -08:00
joeduffy
1ffb120bb3 Add a placeholder for competetive landscape in overview doc 2017-01-01 14:17:36 -08:00
joeduffy
82135ab219 Add a paragraph about interpretation 2017-01-01 14:17:08 -08:00
joeduffy
36534145a5 Rename architecture.md to overview.md
...and also add some front matter about the Mu problem and solution statements.
2017-01-01 14:13:25 -08:00
joeduffy
ca7023602a Make a few nit/todo/wordsmithing edits 2017-01-01 12:58:40 -08:00
joeduffy
9089718fcf Add some simple control flow transformations
This includes break, continue, and while, which are trivial.  It also
includes do/while, which requires a simple rewrite during the lowering,
since MuIL only supports the one simple kind of loop.
2016-12-31 14:53:37 -08:00
joeduffy
2c7bbde93f Add an Identifier node kind 2016-12-31 14:18:55 -08:00