Commit Graph

230 Commits

Author SHA1 Message Date
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 8f9c38b128 Enable is and as checks on non-ground types
Failures generate a StrongModeError.  Fixes #236.  Partially addresses #238.

Some issues to do:
- We're too eager to throw a StrongModeError.  E.g., <int>[] is List<String> will throw.
- We don't differentiate between implicit and explicit casts.

R=leafp@google.com

Review URL: https://codereview.chromium.org/1298893003 .
2015-08-19 06:15:04 -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 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
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 c56eec5708 fixes dart.throw to work for non-objects
language tests use this, for example

R=vsm@google.com

Review URL: https://codereview.chromium.org/1245023004 .
2015-07-23 09:34:41 -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
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
Vijay Menon 5ff3864a18 Load on demand
This fixes ordering issues.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1171843002
2015-06-09 08:05:26 -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 a7adab29fa fixes browser/runtime_test, and a few of extension member fixes
* fixes generic List. Because generic arrays have the proto of JSArray, which itself extends Array, we need to make sure we don't override members from Array.

* fixes tear offs, they were not preserving type signatures in some cases. This doesn't change how we store signatures, but perhaps something we could consider, to make this bug less likely.

* the defineExtensionMembers call was not getting emitted unless the type implemented at least one interface.

R=leafp@google.com

Review URL: https://codereview.chromium.org/1156273010
2015-06-05 16:22:37 -07:00
Leaf Petersen aac783cfcf Allow null args to dynamic invocations
Fixes #194.

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1149243002
2015-05-26 11:28:59 -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 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 8040611a79 This CL implements tagging of functions and methods with function types.
For every class, we now generate a setSignature call which attaches properties to the constructor recording the method signatures, the static function signatures, and the names of all of the static methods. This call also attaches a getter to every static method which returns the type of the function.  Methods are only decorated with runtime types when torn off.  At a tear-off, the type is looked up in the constructor, and then attached to the bound function.

Top level functions and statement level functions get annotated with their type immediately after their declaration.  We could consider moving all of the top level function annotations to the end of the file, but for now I've left it inline.

Closures (function expressions) get wrapped in calls to a dart.fn helper, with type information attached in one of various forms.  This is currently the least attractive part of this CL.  We may want to iterate on the syntax for this.

I've added some support for NSM checking to the dsend/dcall case as well.

We may wish to iterate on the syntax, and on the runtime representation of types, but this should move us forward from a functionality standpoint.

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

Review URL: https://codereview.chromium.org/1138793002
2015-05-19 16:24:35 -07:00
Vijay Menon 7ca96fd202 Revert "Update runtime tests"
TBR=jmesserly@google.com

Review URL: https://codereview.chromium.org/1141873003
2015-05-14 09:57:57 -07:00
Vijay Menon c569af4ba8 Update runtime tests
TBR=jmesserly@google.com

Review URL: https://codereview.chromium.org/1143433002
2015-05-13 08:54:30 -07:00
Vijay Menon 286a2f36c5 Fixes #178
Expand out constructor call if needed.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1135543003
2015-05-11 10:56:11 -07:00
John Messerly ef8edb1273 fixes #175, fixed arrays
R=vsm@google.com

Review URL: https://codereview.chromium.org/1138533003
2015-05-08 14:33:37 -07:00
John Messerly 36373f06f2 add checks needed for covariant generics, and fixes #154, List<E> now has the right runtime type.
R=leafp@google.com

Review URL: https://codereview.chromium.org/1117793002
2015-05-01 14:11:52 -07:00
Vijay Menon 0d49f0175a Generate static calls for Object fields and methods
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1100633006
2015-04-23 14:23:39 -07:00
John Messerly af584262c5 fix list initializers
also removes the int.parse hack, adds a special case to dindex instead.

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

Review URL: https://codereview.chromium.org/1093353004
2015-04-21 11:25:03 -07:00
Vijay Menon cb7143a32f Initial support for runtime function types and type checking
Notes:
- We probably should have a general type object class for all types.  Just handling function types for now.
- Not yet encoding the type on functions during codegen ... falling back on arity effectively.
- typedefs are lazy to avoid ordering issues.  Could perhaps reuse existing logic instead.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1076883003
2015-04-09 18:39:59 -07:00
John Messerly a4cbcc0c07 implement mixins in subtype checks, more codegen fixes
or: how creating a SplayTreeSet<String> leads to fixing a bunch of stuff

R=vsm@google.com

Review URL: https://codereview.chromium.org/1058653002
2015-04-02 12:16:24 -07:00
John Messerly 864299081e partially implement instance of checks and some codegen fixes
R=vsm@google.com

Review URL: https://codereview.chromium.org/1050723002
2015-04-01 09:44:37 -07:00
John Messerly bf9a2b9015 add test tools, implement generic type constructor
test tools are from https://github.com/webcomponents/webcomponentsjs/tree/master/tests/tools

R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/151127013
2015-02-11 16:53:05 -08:00