Commit Graph

392 Commits

Author SHA1 Message Date
Vijay Menon b0abb3b302 Some preliminary support for quasi-generics
This just expands John's earlier hack on min/max.  No downward
inference, etc, but it captures some simple cases.  Worthwhile?

Testing whether this makes much of a difference on our larger code bases.

R=jmesserly@google.com, leafp@google.com

Review URL: https://codereview.chromium.org/1317933005 .
2015-08-31 09:56:41 -07:00
John Messerly 9c832d6a6b makes tests faster, see #304
this doesn't completely address the issue, but it knocks off some of the time.
also attempt to stabilize error message order.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1321103002 .
2015-08-28 10:14:16 -07:00
John Messerly c4b754b041 use the real matchers for running language tests
R=vsm@google.com

Review URL: https://codereview.chromium.org/1321683004 .
2015-08-28 09:27:36 -07:00
Olivier Chafik 59cf5dd893 Output some basic type annotations for the Closure Compiler when --closure is set. 2015-08-27 16:30:20 +01:00
Vijay Menon 604b199ed3 Make implicit casts hints
This appears to cut out about 1/3 of the strong mode errors reported
in angular2.  The actual cases removed that I looked at seem fine - e.g., we may inject an implicit cast, but it'll work fine at runtime.

Fixes #302

R=leafp@google.com

Review URL: https://codereview.chromium.org/1310053005 .
2015-08-26 15:01:59 -07:00
John Messerly 74c760066b implement null aware ops, fixes #249
this also implements multitest support, which fixes #280

Fixes some other preexisting bugs:
* MetaLets did not simplify themselves correctly in some nested cases
* Library prefixed identifiers did not work as lvalues in opassign
* dsetindex/dput/[]= methods did not return a value
* checker did not correctly handle invalid constructor field initializers
* cascades did not correctly work with method invocations(?)
* postfix ++/-- did not correctly generate lvalues in some cases

The good news: because this reuses on our existing lvalue/metalet helpers, it managed to flush out a lot of bugs in other features that use them.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1316723003 .
2015-08-25 15:13:18 -07:00
John Messerly e420033f7c sort errors so they appear in stable order
should be the same order analyzer_cli uses

R=vsm@google.com

Review URL: https://codereview.chromium.org/1299993004 .
2015-08-20 08:59:48 -07:00
Vijay Menon 136396c107 Regen js_test.txt
I'm seeing this diff locally on presubmit.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1300203002 .
2015-08-19 13:09:37 -07:00
Leaf Petersen 8d36859187 Attach type info to extension method and object method tear-offs
Fixes #189.

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1293293002 .
2015-08-19 10:01:12 -07:00
John Messerly 38065257a2 fixes #292, report async_helper test failures
R=vsm@google.com

Review URL: https://codereview.chromium.org/1289673007 .
2015-08-19 08:35:41 -07:00
Vijay Menon c0100939c2 Implement more of dart:mirrors
This unblocks angular.

See #199

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1252953003 .
2015-08-07 12:40:34 -07:00
John Messerly cbe23ee268 implement exports, fixes #141
R=vsm@google.com

Review URL: https://codereview.chromium.org/1263583005 .
2015-08-04 17:23:13 -07:00
John Messerly b393e12c6b fixes #197, don't generate casts that always pass
R=vsm@google.com

Review URL: https://codereview.chromium.org/1261783005 .
2015-08-04 15:42:13 -07:00
John Messerly 8422d7ab48 fix language_tests.js to use strict mode
we weren't running a bunch of tests on the bots :|
amazingly, none were broken yet
this also fixes karma.conf log level, and disables some spammy prints from one of the tests

R=vsm@google.com

Review URL: https://codereview.chromium.org/1257233008 .
2015-08-03 14:08:28 -07:00
Olivier Chafik 8426fa9e17 Added bin/devrun.dart, which runs DDC's output with iojs or d8 (issue #225) 2015-07-29 14:17:56 +01:00
John Messerly 9137a4538c fixes #221, initial sync*, async, async* implementation
also fixes #270

R=vsm@google.com

Review URL: https://codereview.chromium.org/1243503007 .
2015-07-28 16:52:23 -07:00
John Messerly 7252228557 fix truncate call to use extension method
R=vsm@google.com

Review URL: https://codereview.chromium.org/1249043006 .
2015-07-22 14:52:40 -07:00
John Messerly 394836eaa2 fixes #259, clone ast before mutation
R=vsm@google.com

Review URL: https://codereview.chromium.org/1245013005 .
2015-07-21 15:36:55 -07:00
John Messerly 60aba749ca fixes #219, able to compile multiple entry points
also speeds up codegen_test by reusing the analysis context
BatchCompiler is pretty close to how analyzer_cli works now (other than missing features)

R=vsm@google.com

Review URL: https://codereview.chromium.org/1235503010.
2015-07-16 17:41:33 -07:00
Vijay Menon f50661aac4 Add support for Enums
Fixes #248

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1224083017.
2015-07-14 17:48:38 -07:00
Vijay Menon 8ccef442a3 Fixes #254 - Better stacktrace support
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1233553005
2015-07-14 13:33:01 -07:00
John Messerly bc4e0f2a38 fixes #6, refactor to use AnalysisError/Listener throughout dev_compiler
Main goal here was to get rid of the enter/exit compilation unit tracking, to allow further Compiler/Server refactoring. We can get the Uri/LineInfo/contents off Source, which AnalysisError already has
SummaryReporter is now fairly generic.

TODOs for the future:
* figure out what to do about ErrorCodes, in particular dev_compiler prefix feels off.
* skip the intermediate StaticInfo types? They're really just builders now for AnalysisError.
* don't classify all existing messages as "AnalyzerError" ... just print them ...
* skip logger. For our command line program, stdout is part of its "API", IMO it shouldn't use logging for those messages. Consider Pub, which uses stdout/err for its messages, and uses logging for more detailed troubleshooting.

R=pquitslund@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1230903002.
2015-07-10 10:15:08 -07:00
John Messerly 98d14b14da initial sync*, part of #221
Right now it maps straight to ES6 generators. This should handle some basic cases, but there's more work to get all of the corners working. For example: it doesn't implement Iterable yet.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1207313002.
2015-06-26 16:02:30 -07:00
John Messerly c2e65df22c fixes #168, dart:js implementation with a test
R=vsm@google.com

Review URL: https://codereview.chromium.org/1200233004.
2015-06-25 13:18:52 -07:00
Leaf Petersen 4e7920c487 Handle dynamic as bottom inside of function type reps.
This changes the way we handle dynamic at runtime to be more correct and cleaner.  We now simply emit dynamic as dynamic instead of as core.Object.  There are now two ways to construct a function type: one can construct a fuzzy function type (the default), or a definite function type.  The constructor for a fuzzy function type replaces all uses of dynamic with bottom.  This function type is used for all type annotations.  Definite function types do not replace dynamic with bottom.  These only occur as the runtime type of actual functions, for which we really know the type. Because we now eagerly sort this out when we create the function type, the subtyping code doesn't need to deal with this.

This allows some additional subtyping: closures which actually are typed to take dynamic would previously not have been allowed to be cast to something with a concrete argument type.  Now this is allowed (see the change in runtime_tests.js for an example of this).

This fixes #107.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1195523002
2015-06-17 16:46:38 -07:00
John Messerly de6df99db0 fixes #226 super == and fixes #227 escape \r \f
R=vsm@google.com

Review URL: https://codereview.chromium.org/1183453005.
2015-06-16 16:52:32 -07:00
Vijay Menon d48b153193 dart:mirrors
This is a very bare bones version - just enough to get angular running.

See #199

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1186683005.
2015-06-15 16:22:54 -07:00
John Messerly b769aa5fbc fixes #25, most analyzer errors were not computed
It helps to call computeErrors ;)

R=vsm@google.com

Review URL: https://codereview.chromium.org/1183733004.
2015-06-15 08:55:59 -07:00
Leaf Petersen b9c83e0013 Most of this CL just re-organizes the runtime code into multiple sub-libraries. js_utils and loader remain as top level symbols (the former so that it has no dependencies, the latter since it defines the module system that the rest use).
The dart runtime files are roughly split around functional boundaries.  Comments at the top of each file describe the function of the library.  I'm not sure that these are 100% right yet, but they're closer.  We may want to iterate on the organization.

The main dart runtime file just re-exports various symbols from the sub-libraries.  It has hard dependencies on the other runtime files, some of which have soft (lazy) dependencies on SDK files.  The generated code now depends on dart and dartx as a imported libraries, rather than as top level symbols.

This CL also includes some new code to make type representations a bit better.  This is mostly in the new types.js file, which makes all of the non-instance types (dynamic, bottom, void, function types) subtypes of a common representation type.  Among other things, they now have the correct runtime type (core.Type).  Some of the type code has been rationalized around this a bit, but there is more left to do here.  The setSignature code in classes.js now also places the correct runtime type on nominal (instance) types.  There are new tests in the runtime_tests.js file to test for this.

The static object method code that implements the Object methods has not yet been updated to dispatch on type representations.  I will do that in a separate CL.

BUG=
R=jmesserly@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1182653002
2015-06-12 13:34:39 -07:00
John Messerly b62fdb577d fixes #217, Object members on extension types
R=vsm@google.com

Review URL: https://codereview.chromium.org/1173023004.
2015-06-10 13:52:18 -07:00
John Messerly d52346c201 fixes #215, removes special case for length
R=vsm@google.com

Review URL: https://codereview.chromium.org/1178523004.
2015-06-10 12:21:49 -07:00
Vijay Menon c139653fcb Check for duplicate library names
This bites us on Angular - dart:collection and angular's collection
(facade) lib smash on top of each other, silently causing issues.

We'll need a better naming convention - perhaps we should use the lib
name and require uniqueness.

Fixes #208

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1145243013
2015-06-05 16:34:10 -07:00
John Messerly cac786f671 fixes #173, ability to use native JS indexers
dom_experimental could opt-in to use this

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1145833004
2015-06-05 12:14:09 -07:00
John Messerly 89b3d920d6 fixes #206, add checking for unary ops
fixes #207, checking for boolean conversions

R=leafp@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1147143007
2015-06-05 12:12:27 -07:00
Leaf Petersen 695ae10131 Delete dart2js specific private library code.
This trims out a large chunk of the more obviously dart2js specific stuff from js_helper.dart and its dependencies.

BUG=
R=jmesserly@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1152333009
2015-06-05 09:52:18 -07:00
John Messerly 6c3cdd707d fixes #40, extension methods for primitive types
fixes #138, extension methods for Iterable/List injected as needed, regardless of how the methods started

fixes #142, extension methods and dynamic dispatch

small change that fixes #139, recognize that '.length' doesn't need an extension method

Also restores JSArray, moved the methods out of List, which is back to just being an interface.

NOTE: this removes the capability of types that mix native JS members and some Dart extension members, instead it now *hides* all JS members for these native types. We'll want to bring that feature back to support dart:html, so it's just a simplification for now. Should be easy to add that capability when we pull in dart:html for reals.

R=leafp@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1153003003
2015-06-04 14:58:18 -07:00
John Messerly 33eee25590 fixes #43, remove => workaround
R=leafp@google.com

Review URL: https://codereview.chromium.org/1169473003
2015-06-02 16:30:23 -07:00
John Messerly 9a95d18c13 fixes #182, avoid injecting a duplicate link rel=stylesheet
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1145893008
2015-06-01 16:54:01 -07:00
John Messerly 92773980ab Revert "fixes #173, ability to use native JS indexers"
This reverts commit 8dc1eeeb4dcc4d186f59513abd18f98e67c36339.

Review URL: https://codereview.chromium.org/1160343003
2015-06-01 09:31:01 -07:00
John Messerly 59852b526b fixes #173, ability to use native JS indexers
dom_experimental could opt-in to use this

Review URL: https://codereview.chromium.org/1145833004
2015-06-01 08:46:26 -07:00
John Messerly 81fc365b95 fixes #193, factory constructors as static methods
R=vsm@google.com

Review URL: https://codereview.chromium.org/1156993015
2015-05-29 14:52:10 -07:00
Vijay Menon 526ac2e153 Modified sunflower
Need to rebase over this pending CL before it's ready for review / landing:

https://codereview.chromium.org/1143953004/

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1147053003
2015-05-29 06:24:48 -07:00
Leaf Petersen e270186901 Fix names in named parameter lists
This fixes #195.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1150623004
2015-05-21 15:04:22 -07:00
Leaf Petersen 694240c2ea Add constructors to signatures.
This adds the types of constructors onto class signatures and makes them available via an exported function in the dart runtime.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1152583002
2015-05-21 14:49:11 -07:00
Leaf Petersen 99433b7121 No dynamic at runtime.
Reify dynamic as bottom or Object as appropriate in the generated code.

For general function types, dynamic parameters become bottom, and all other uses of dynamic become Object.

For concrete function types (the rtti attached to function objects) dynamic parameters also become Object.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1148333003
2015-05-20 16:36:25 -07:00
Leaf Petersen 50e50530ab Use short array syntax in method signatures.
This follows up on a suggestion from jmesserly to use a shorter syntax in methods signatures.  Replaces:

dart.functionType(t, [t0,..., tn], extras)

with

[t, [t0, ..., tn], extras]

BUG=
R=jmesserly@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1145283002
2015-05-20 16:11:42 -07:00
Leaf Petersen fcb7dfad95 Use signature inheritance when method types are unchanged
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1144303003
2015-05-20 13:41:48 -07:00
Leaf Petersen 8322940ecd Use dart.tearoff helper at tearoff sites.
When we tear off a method, replace the obj.foo.bind(obj) pattern with dart.tearoff(obj, 'foo'), and the dart.bind(exp, 'foo') pattern with dart.tearoff(exp, 'foo').  This helper does both the bind and attaches rtti.

This CL also stops binding of static methods when they are town off, since I think this is unnecessary.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1142293002
2015-05-20 11:13:36 -07:00
Leaf Petersen 406e68ccec Check whether type parameters are loaded before emitting.
This fixes #190.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1143253003
2015-05-20 09:47:39 -07:00
Vijay Menon 0ce490561c Type check binary expressions
Fixes #188

R=leafp@google.com

Review URL: https://codereview.chromium.org/1137543005
2015-05-20 09:24:16 -07:00