Commit Graph

146 Commits

Author SHA1 Message Date
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
John Messerly 772f6f6d1b fixes #185, track const ctor dependencies, plus a static field fix
R=vsm@google.com

Review URL: https://codereview.chromium.org/1141663003
2015-05-20 09:19:08 -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
John Messerly 08fb2161f7 fixes #184, type literals now use emitTypeName
this fixes `dart.dynamic` as well as other cases covered by emitTypeName

R=vsm@google.com

Review URL: https://codereview.chromium.org/1142713004
2015-05-18 13:41:25 -07:00
Vijay Menon 3377d2b7c5 Angular workarounds
- Workaround for symbolized methods (e.g., core.$map)
- dload/dput workarounds
- NSM workaround
- generic method type check workarounds

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1131143002
2015-05-14 12:47:32 -07:00
John Messerly ef1739d8eb Make typedefs lazy again
reverts part of https://github.com/dart-lang/dev_compiler/commit/3dcea8bf156b3947c4dbf4b36da55a64cd9dc492
On its own, it's probably okay, but trips on other issues we have w.r.t. JsName types and NoInterfaceObject apis

R=vsm@google.com

Review URL: https://codereview.chromium.org/1135883004
2015-05-14 09:45:41 -07:00
John Messerly aba85e3d9f fixes #131, use before define from variables to classes
Factored the load order logic into its own file, as it was easier to work with that way. We could definitely tweak the structure.

Also tried hoisting constants out to top level, but it's not quite ready yet, so splitting that work out into a separate CL.

(also fixes #152 about cleaning up lazyClass, and fixes #181 about static fields)

R=vsm@google.com

Review URL: https://codereview.chromium.org/1133593004
2015-05-12 11:47:36 -07:00
John Messerly 32f3c78b82 fix temps that have the same name to have different Elements
this was happening because we picked up an == operator from analyzer's Element

also adds an assert, because I took way too much time figuring out what the heck was happening there :)

R=vsm@google.com

Review URL: https://codereview.chromium.org/1139673005
2015-05-11 16:40:16 -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 da208152ea fixes #157, renaming local library identifiers if needed.
readability regression, but fairly simple fix. looks okay in libraries with few imports, bad if they have a lot. ultimately I think this gets cleaned up as part of emitting modules + handling module lowering in JS codegen, see issue #34.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1122133003
2015-05-06 13:47:38 -07:00
Vijay Menon 1a0efac4e5 Do not suppress implicit constructors that need a super call.
This fixes a bug creating an _AsyncCompleter (_Completer.future was not being initialized).

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1122883002
2015-05-04 14:50:34 -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
John Messerly 56c75ff912 fix #159, static renames for caller/arguments
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1111803005
2015-04-29 16:07:37 -07:00
John Messerly dc4b3d5be9 fix static members in _emitMemberName
static/top-levels don't need extension method, operator renames, or different slots* for private members

(static members are qualified by the static type, so they aren't ambiguous, e.g. Foo._foo and Bar._foo where Foo and Bar are in same/different libraries)

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1111863002
2015-04-29 14:45:14 -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 5af860f9ac fix #155, numeric integer literals
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1090613006
2015-04-23 13:43:53 -07:00
John Messerly a127bab753 canonicalize const
R=vsm@google.com

Review URL: https://codereview.chromium.org/1099333002
2015-04-23 09:12:26 -07:00
John Messerly 0efa91a94e implement tear offs
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1088943006
2015-04-21 15:30:18 -07:00
John Messerly bbe6801eff fixes #145, optional params+initializing formals+private fields
R=vsm@google.com

Review URL: https://codereview.chromium.org/1082333004
2015-04-21 15:28:46 -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 9efc804f94 Remove workaround
Upstream bug is fixed now.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1096353002
2015-04-21 10:09:45 -07:00
John Messerly b01750fb6e fix super ctor logic
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1095683005
2015-04-21 09:33:41 -07:00
John Messerly 3eca59c586 fix fields that override getters/setters
R=leafp@google.com

Review URL: https://codereview.chromium.org/1099743002
2015-04-21 09:07:22 -07:00
Leaf Petersen a880c6fcb9 Reifier hookup
Hook the coercion reifier into the JS backend.

The principle observed changes in the output are from the downward type inference eliminating casts.

The coercion reifier changes in this CL in two ways.

The first is a relatively minor change to factor out the instrumented runtime calls.  The reifier is now parameterized by a runtime object.  If present, casts, wraps, and type object creation are delegated to the runtime.  Otherwise the reifier just produces cast objects directly.  The JS codegen always does the latter.

The larger change is an attempt to make the new AST nodes be resolved.  This is principally done for the typedefs produced for casts - we're not using wrapping right now so I've left that for future if we want it.  This is a bit painful - if we continue down this path I think I'll want to factor this out into a ResolvedAstBuilder or somesuch, but for now this seems to be working.

The rest of the changes are just plumbing in the coercion reifier and its dependencies into the js backend.

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1096583002
2015-04-17 13:56:04 -07:00
John Messerly 33322cb95b Smarter js temp naming, fixes #136
JSTemporary is now identified by instance, not its String name. This provides enough information to do renaming correctly and avoid the bug in #136.

The namer now considers all scopes where the temporary is visible, and chooses a name that doesn't conflict with other identifiers. Because it only considers scopes where the temp appears, it does less renaming that the previous version.
2015-04-15 14:47:29 -07:00
John Messerly da91435c66 fixes for angular hello: String + and disable broken arg parsing
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1085723002
2015-04-14 18:04:14 -07:00
John Messerly 267050cdac refactor emitMemberName to be used more consistently
other changes:
* adds _emitSend for more consistent emitting of method calls. can't be used everywhere yet, but it unifies some things
* more consistent use of the core.String.* static pattern
* fix dynamic invoke to private members
* fix implicit-this to use emitMemberName, which makes them work with extension methods
* build the global extension method table up-front and optimize lookups (method name first, then subtype test if needed)
* teach the compiler that IsExpression never returns null

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1083763003
2015-04-14 16:07:28 -07:00
John Messerly ca2fff3c05 rename dart_runtime.js helpers
this should make the diff simpler in the other CL

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1074923003
2015-04-14 13:48:31 -07:00
John Messerly 880a99c1bd fix sunflower -- dom types were not resolving
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1088663002
2015-04-13 13:22:23 -07:00
Vijay Menon bbbee7c524 Fix a couple codegen crashers
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1062823004
2015-04-10 13:41:43 -07:00
John Messerly 13cf3805b8 implement opassign, fix bugs in pre/postfix, introduce a let* helper
Simplifies js_codegen to remove the special cases for things like cascades and statement parent, instead these "fall out" of JSMetaLet node and the various to* methods in js_ast. As a result of handling things more uniformly, code gets cleaner in a lot of cases. One slight "regression" is a cascade at the end of a variable init list with multiple variables. But multiple variables aren't very common so doesn't seem worth optimizing readability there.

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

Review URL: https://codereview.chromium.org/1069493002
2015-04-10 09:53:35 -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 db9e46344b update baseline
forgot to do this after a merge

Review URL: https://codereview.chromium.org/1067553002
2015-04-06 09:20:40 -07:00
John Messerly 941dda3403 use VariableElement instead of VariableElementImpl in _isStateless
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1056183003
2015-04-06 09:13:04 -07:00
Vijay Menon cad0430c0d Tweaks to warning level and reporting
R=leafp@google.com

Review URL: https://codereview.chromium.org/1059873002
2015-04-03 15:46:58 -07:00
Jacob Richman 5a5ddca7bc Extension method support to move us closer to a valid List implementation.
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1059583002
2015-04-03 14:52:04 -07:00
Leaf Petersen 0399992b81 Downwards closure inference. This implements a basic form of downwards closure inference. It only handles expression functions (=> e), and it does not try to narrow the type of parameters.
BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1050703002
2015-04-03 09:17:30 -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 db1d4fac75 reduce diff churn due to server_mode test
essentially verify the expected HTML in the test
this tripped on an interesting issue, we have two ways of computing MD5 hashes that produce different answers. I left that as a TODO.

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1056613002
2015-04-01 13:49:11 -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
Leaf Petersen da58b9d8aa Downward inference
This is a first cut at downwards inference. The interaction with InferableLiteral etc isn't well sorted out yet, so while downwards inference on nested expressions works, there will currently be spurious warnings.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1038213003
2015-03-31 13:24:25 -07:00
Sigmund Cherem c48018ee62 Update widget with latext fix from source_span
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1047083002
2015-03-31 13:11:14 -07:00
John Messerly 3ce5a11d77 compute interfaces lazily
otherwise we'd have to make a lot more classes lazy

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1047203002
2015-03-31 09:14:37 -07:00
Vijay Menon 75ee9c6cc5 Handle for-in loops
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1048863003
2015-03-30 17:22:46 -07:00
John Messerly 5472d0cfcd keep mixin and interface implementation info at runtime
R=jacobr@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1043003002
2015-03-30 16:09:48 -07:00
John Messerly fc02cba0f4 use == and != to enable handling null/undefined
R=jacobr@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1047023002
2015-03-30 16:01:22 -07:00
John Messerly 1515ceaa8e fixes private named constructors
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1042943003
2015-03-30 14:30:01 -07:00