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
This is some first steps towards hooking the reifier into the js backend. I've made the reifier operate on whole libraries instead of per compilation unit so that it can be hoisted out as a separate pass. I changed the API of the reifier to return a map from new type identifiers to information about their library of origin, so that the code generators can deal with these appropriately. Take a look, see what you think - suggestions as to how to structure this to interact well with the JS backend welcome.
BUG=
R=jmesserly@google.com, vsm@google.com
Review URL: https://codereview.chromium.org/1070453002
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
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
There is the separate, but related question of how to invoke Object
methods when the receiver is Object or a JS primitive. That should be
handled in the JS backend. I can tackle that next if no one else is.
See #98.
R=jmesserly@google.com
Review URL: https://codereview.chromium.org/1055923002
This changes the RestrictedTypeRules to eliminate a direct dependency on CheckerReporter. Instead of logging a missing type error with the reporter directly, it now calls an optional callback. The Checker registers an appropriate callback for its errors. Currently the code generators don't log these errors. This eliminates the dependency of the code generators on the checker reporter.
BUG=
R=jmesserly@google.com
Review URL: https://codereview.chromium.org/1067553004
During inference, allow sub-expressions of type dynamic to be cast to the inferred type.
This CL also adds special case support for the case where we are trying to infer a type for a closure literal with a fuzzy type - often these closures are already well-typed (or easily inferable) if we eliminate the fuzziness.
This gets rid of two of the static errors on angular hello world, along with most of the InferableClosure warnings (turning them into InferredTypeClosure infos).
Most of the remaining InferableClosure cases are function literals with block function bodies, which I don't handle in general yet.
BUG=
R=vsm@google.com
Review URL: https://codereview.chromium.org/1059763003
This records the actual point at which type inference fails and uses that to give a better error message. So where before we would say:
severe: line 76, column 38 of package:angular2/src/forms/directives.dart: [StaticTypeError] Type check failed: [c.validator, this.validator] (List<dynamic>) is not of type List<Function>
c.validator = validators.compose([c.validator, this.validator]);
we will now in addition say:
because c.validator cannot be typed as Function
BUG=
R=vsm@google.com
Review URL: https://codereview.chromium.org/1056183002
cleaner since we only worry about it in one place, and the "this" check is easier and more precise now.
incidentally, I saw a CL go by on the V8 bug, looks like it's close to being fixed
R=jacobr@google.com
Review URL: https://codereview.chromium.org/1052693004
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
* static methods qualified properly
* static method privacy is now enforced
* avoid static method names banned in strict mode
* avoid variable names banned in strict mode
We might want to relax privacy (for both instance and static), but for now it's nice and consistent with instance methods using ES6 Symbol
R=jacobr@google.com
Review URL: https://codereview.chromium.org/1034273003
Also changes Printer to not walk the tree an extra time unless we are minifiying.
The tree structure appears to be helping VarCollector, by encoding some information into the static AST structure. (although some aspects were unused, such as function names). It's easy enough to encode this behavior in VarCollector itself. Having a unified Identifier benefits our tree transform, since we don't need to worry about generating three different types of things under largely identical circumstances.
I'm planning to build on this later, but this version is purely a refactor.
R=vsm@google.com
Review URL: https://codereview.chromium.org/1029583011
This breaks out casts / coercions into:
Standard (on by default)
- DynamicCasts: dynamic -> T
- AssignmentCasts: T x = expr; // T must be a ground type
Inference (this will go away)
- InferableLiteral
- InferableClosure
- InferableAllocation
Implicit (no flag yet, but i'll add to disable by default)
- DownCastComposite: Any cast to a non-ground type
- DownCastImplicit: Any other implicit downcast not covered above
A flag is also added to enable/disable all wrapping. This is not off by default yet, but that is the intent.
R=leafp@google.com
Review URL: https://codereview.chromium.org/1038583004
This was added to our version, while still figuring out js_ast. As it is now, Printer handles property names quite well on its own, so the extra AST node doesn't add anything.
R=vsm@google.com
Review URL: https://codereview.chromium.org/1030243002