Commit graph

594 commits

Author SHA1 Message Date
joeduffy
6c26693fea Move default to a property on package, not a bit on module
The old method of specifying a default module for a package was using
a bit on the module definition itself.  The new method is to specify the
module name as part of the package definition itself.

The new approach makes more sense for a couple reasons.  1) it doesn't
make sense to have more than one "default" for a given package, and yet
the old model didn't prevent this; the new one prevents it by construction.
2) The defaultness of a module is really an aspect of the package, not the
module, who is generally unaware of the package containing it.

The other reason is that I'm auditing the code for nondeterministic map
enumerations, and this came up, which simply pushed me over the edge.
2017-02-06 18:33:31 -07:00
joeduffy
4cf8654bf1 Fix a few lint issues 2017-02-06 18:08:22 -07:00
joeduffy
ca313f10d5 Emit proper TypeToken AST nodes 2017-02-03 21:03:34 -08:00
joeduffy
4cb66fc520 Implement extends/implements heritage clauses 2017-02-03 20:57:35 -08:00
joeduffy
8254a7977c Fix a lint error that crept in: missing semicolon 2017-02-03 20:20:43 -08:00
joeduffy
c3f4f0ad0d Propagate source location for this and super 2017-02-03 20:20:22 -08:00
joeduffy
deb015a15d Implement multi-pass module binding
The prior module binding logic was naive.  It turns out that, because of inter-module
references within the same package, the order of binding certain modules and its members
within a package matters.  This leads to a more Java/C#/JavaScript/etc. multi-pass model,
versus a classical single-pass C/C++ model (which requires forward declarations).

To do this, we bind things in this order within a package:

* First, we add an entry for each module.  It is largely empty, but at least names resolve.

* Second, we bind all imports.  Since all modules are known, all inter-module tokens resolve.

* Next, we can bind class symbols.  Note that we must do this prior to module properties,
  methods, and exports, since they might be referenced and need to exist first.  As before,
  we do not yet bind function bodies, since those can reference anything.

* Now we bind all module "members", meaning any module scoped properties and methods.  Again,
  we do not bind function bodies just yet.  This is just a symbolic binding step.

* Next, we can finally bind exports.  Because exports may reference any members, all of the
  above must have been done first.  But all possibly exported symbols are now resolved.

* Finally, we can bind function bodies.
2017-02-03 19:57:53 -08:00
joeduffy
15ba2949dc Add a mu verify command
This adds a `mu verify` command that simply runs the verification
pass against a MuPackage and its MuIL.  This is handy for compiler
authors to verify that the right stuff is getting emitted.
2017-02-03 19:27:37 -08:00
joeduffy
a1c94275e0 Restructure format/output selection a bit
This change restructures how MuJS selects the format and output a
bit, so that simply running `mujs -f yaml` will output a default
`Mupack.yaml` in the current directory.
2017-02-03 14:56:36 -08:00
joeduffy
21aa240eca Save MuJS output to Mupack.json by default
This change stops printing the AST to output after compilation.  It's
a little confusing and, especially as Mu test programs are getting larger,
staring at 1,000s of lines of JSON whiz by is losing it's fun.

By default, the compiler saves output into Mupack.json.  This can be
overridden with the --out switch (-o for short).  Both JSON and YAML files
are supported (as are unrecognized extensions, which get JSON by default).
Another switch --format (-f for short) is supported to explicitly specify
the output format.  A special -out of "-" means "print to stdoutput", so
for instance, running `mujs -o=- -f=yaml` will print YAML to the console.
2017-02-03 12:41:10 -08:00
joeduffy
a0de263930 Add a tsconfig to the Thumbnailer example 2017-02-03 12:14:40 -08:00
joeduffy
7854e0d393 Merge branch 'master' of github.com:marapongo/mu 2017-02-03 12:09:56 -08:00
joeduffy
03b065015f Add a missing } 2017-02-03 12:09:48 -08:00
joeduffy
6e0d17c47c Don't attempt to transform if there were errors
This change doesn't attempt to transform the resulting AST if there
were any compiler errors.  The old code erroneously proceeded in cases
where errors occurred but an AST was actually produced, leading to
possible assertions and other unexpected conditions.
2017-02-03 12:08:41 -08:00
Joe Duffy
382de02bc6 Minor comment update 2017-02-03 05:40:22 -08:00
Joe Duffy
dbf86736e1 Move ec2instance example underneath aws/
I just introduced the examples/aws/ directory yesterday to hold some
of our basic AWS examples, as I expect us to start accumulating more
of them.  So this just moves ec2instance underneath that directory.
We should probably think about further reorganizing these (e.g., into
demos/, scenarios/, etc.), ass we accumulate more examples.
2017-02-03 05:38:06 -08:00
Joe Duffy
929aa0e0a7 Merge pull request #75 from lukehoban/ec2instance
Simple EC2 instance example
2017-02-03 05:34:29 -08:00
Luke Hoban
464bd4fe28 Simple EC2 instance example 2017-02-02 22:03:12 -08:00
joeduffy
f6c96c2c86 Bind and validate function calls 2017-02-02 17:11:58 -08:00
joeduffy
a5b7a35629 Fix up some error messages 2017-02-02 16:58:53 -08:00
joeduffy
cf6bbd460d Colorize MuJS errors/warnings
I've had a few times where I missed errors/warnings whizzing by alongside
other spew.  Although this was probably technically a "waste" of 10 minutes,
it actually would have saved me at least 10 in the past.  So, there you go.
2017-02-02 16:47:45 -08:00
joeduffy
9adcc8cff9 Print the export token during describe 2017-02-02 15:03:51 -08:00
joeduffy
5492ccba7c Add map tests
This adds map tests for ES6-style maps encoded in MuPack/MuIL.

It also fixes one simple bug, where we should not populate the
compiler options with TypeScript defaults *unless* they are (a)
missing from the arguments and (b) not discovered from a tsconfig
file.  Otherwise, we will rewrite overrides with the defaults.
2017-02-02 14:57:37 -08:00
joeduffy
f84d9341dd Add a clean target
This change just adds a clean target to the MuJS compiler's package
file.  If you rename tests, the old files stick around inside of bin/,
possibly causing superfluous test failures.  A clean does the trick.
2017-02-02 14:30:28 -08:00
joeduffy
69465b55a9 Generate correct array type tokens
This change adds support for generating array type tokens from MuJS.
Previously, we'd try to load up the Array type's associate MuPackage,
which is TypeScript's standard library; and then we'd error out
because, of course, it doesn't have one.  Now we recognize references
to it (and ES6-style Map<K, V>) to generate the correct tokens.

This includes a bunch of new array tests.
2017-02-02 14:28:05 -08:00
joeduffy
b9dea700f1 Eliminate some cruft
This nixes the old *.mu files from the AWS MuPackage (when Mull was a thing),
and the nasty YAML files (when Go templates in YAML was a thing...(?!)).  The
TypeScript variants remain, however, which is what we'll use going forward.
2017-02-02 12:48:55 -08:00
joeduffy
50f5ef7fb4 Print import tokens, not their AST nodes 2017-02-02 12:34:47 -08:00
joeduffy
e1f3c5ce0e Rebaseline some tests after fixing tslint errors 2017-02-02 12:29:36 -08:00
joeduffy
6a4e7fe37b Emit proper type tokens for object and array literals 2017-02-02 12:27:59 -08:00
joeduffy
6fe7d77bd7 Fix test globbing
To prevent shell expansion of the glob "**", we must quote the path.
This fixes a bug that @lukehoban ran into last night on Windows, where
globbing wasn't be expanded the same way; ironically, it seems to have
been expanded the way we actually wanted it to...but obviously we want
globbing to work well on *NIX filesystems even moreso than Windows.

This also fies a couple missed lint errors in our tests that are
revealed as a result.
2017-02-02 11:33:30 -08:00
joeduffy
468a69363f Add a couple TODOs to the resources design doc
This stuff is still evolving -- and I've put it on pause to make progress
on graph generation -- but I had these edits in my enlistment and didn't
want to lose them.
2017-02-02 11:20:08 -08:00
joeduffy
f6c5e9d30a Add a couple log statements to graph generation 2017-02-02 11:18:39 -08:00
joeduffy
6ecfe0e0c8 Remove an errant * 2017-02-02 11:14:10 -08:00
joeduffy
b1d371a10e Fix a minor typo with library scope name 2017-02-02 11:13:40 -08:00
joeduffy
208c71978e Add one more clarifying note to the README 2017-02-02 11:12:09 -08:00
joeduffy
6065d2dc26 Update some READMEs from last night
This change updates the READMEs based on some difficulties we had
getting Kurt and Luke's enlistments up and running last night.
2017-02-02 11:09:33 -08:00
joeduffy
448d9d2f28 Merge branch 'master' of github.com:marapongo/mu 2017-02-02 10:53:51 -08:00
joeduffy
e953c68074 Add a minimal AWS VPC blueprint to the examples 2017-02-02 10:53:35 -08:00
Joe Duffy
01b08caef9 Merge pull request #71 from kurtb/patch-1
Update README with some missing dependencies
2017-02-01 23:30:18 -08:00
joeduffy
87506c37c2 Bind constructor types correctly
This change stops digging into the "new" expression and instead uses
the TypeScript-assigned type (based on its bound signature).  The result
is that expressions of the form

    import * as aws from "aws";
    let vm = new aws.ec2.VM(...);

now typecheck and emit fully resolved type tokens for the constructed types.
2017-02-01 23:20:53 -08:00
joeduffy
1481b993fa Only print the MuJS AST if no errors occurred 2017-02-01 22:37:29 -08:00
joeduffy
c8d6444fb6 Use os.EOL in place of "\n"s 2017-02-01 22:13:55 -08:00
joeduffy
8c9c481048 Check in the Mu standard library 2017-02-01 21:06:34 -08:00
joeduffy
b5a18d45ea Update nodets dependency to use published NPM module 2017-02-01 20:29:36 -08:00
joeduffy
1c6126c807 Eliminate Typings from postinstall script 2017-02-01 20:19:46 -08:00
joeduffy
39ffd1c923 Update the glide file 2017-02-01 20:06:31 -08:00
joeduffy
f5faf058c0 Check in a missing test file
...and also fix up .gitignore to only ignore /mu/ -- the binary created
when you `go build` -- and not the Mu project file (needed for this test).
2017-02-01 19:41:13 -08:00
kurtb
e1d56138ec Update README with some missing dependencies 2017-02-01 19:33:45 -08:00
joeduffy
054d928170 Add a very basic graph pretty printer
This is pretty worthless, but will help me debug some issues locally.
Eventually we want MuGL to be fully serializable, including the option
to emit DOT files.
2017-02-01 09:07:30 -08:00
joeduffy
2a2dfdc5c0 Tolerate nil this for variable assignments 2017-02-01 08:59:59 -08:00