| Index: third_party/pkg/angular/lib/core/parser/dynamic_parser.dart
|
| diff --git a/third_party/pkg/angular/lib/core/parser/dynamic_parser.dart b/third_party/pkg/angular/lib/core/parser/dynamic_parser.dart
|
| index ef70c5920337ae68e432cfb38f50a2e2306d0c87..57b88be8324865c401dfac5cf95d3a487d7d8008 100644
|
| --- a/third_party/pkg/angular/lib/core/parser/dynamic_parser.dart
|
| +++ b/third_party/pkg/angular/lib/core/parser/dynamic_parser.dart
|
| @@ -1,23 +1,25 @@
|
| library angular.core.parser.dynamic_parser;
|
|
|
| -import 'package:angular/core/module.dart' show FilterMap, NgInjectableService;
|
| +import 'package:angular/core/annotation_src.dart';
|
| +import 'package:angular/core/module_internal.dart' show FormatterMap;
|
|
|
| import 'package:angular/core/parser/parser.dart';
|
| import 'package:angular/core/parser/lexer.dart';
|
| import 'package:angular/core/parser/dynamic_parser_impl.dart';
|
| -import 'package:angular/core/parser/syntax.dart' show defaultFilterMap;
|
| +import 'package:angular/core/parser/syntax.dart' show defaultFormatterMap;
|
|
|
| import 'package:angular/core/parser/eval.dart';
|
| import 'package:angular/core/parser/utils.dart' show EvalError;
|
| +import 'package:angular/utils.dart';
|
|
|
| -@NgInjectableService()
|
| -class ClosureMap {
|
| - Getter lookupGetter(String name) => null;
|
| - Setter lookupSetter(String name) => null;
|
| - Function lookupFunction(String name, int arity) => null;
|
| +abstract class ClosureMap {
|
| + Getter lookupGetter(String name);
|
| + Setter lookupSetter(String name);
|
| + Symbol lookupSymbol(String name);
|
| + MethodClosure lookupFunction(String name, CallArguments arguments);
|
| }
|
|
|
| -@NgInjectableService()
|
| +@Injectable()
|
| class DynamicParser implements Parser<Expression> {
|
| final Lexer _lexer;
|
| final ParserBackend _backend;
|
| @@ -46,9 +48,9 @@ class DynamicExpression extends Expression {
|
| accept(Visitor visitor) => _expression.accept(visitor);
|
| toString() => _expression.toString();
|
|
|
| - eval(scope, [FilterMap filters = defaultFilterMap]) {
|
| + eval(scope, [FormatterMap formatters = defaultFormatterMap]) {
|
| try {
|
| - return _expression.eval(scope, filters);
|
| + return _expression.eval(scope, formatters);
|
| } on EvalError catch (e, s) {
|
| throw e.unwrap("$this", s);
|
| }
|
| @@ -63,13 +65,12 @@ class DynamicExpression extends Expression {
|
| }
|
| }
|
|
|
| -@NgInjectableService()
|
| +@Injectable()
|
| class DynamicParserBackend extends ParserBackend {
|
| final ClosureMap _closures;
|
| DynamicParserBackend(this._closures);
|
|
|
| - bool isAssignable(Expression expression)
|
| - => expression.isAssignable;
|
| + bool isAssignable(Expression expression) => expression.isAssignable;
|
|
|
| Expression newFilter(expression, name, arguments) {
|
| List allArguments = new List(arguments.length + 1);
|
| @@ -78,83 +79,61 @@ class DynamicParserBackend extends ParserBackend {
|
| return new Filter(expression, name, arguments, allArguments);
|
| }
|
|
|
| - Expression newChain(expressions)
|
| - => new Chain(expressions);
|
| - Expression newAssign(target, value)
|
| - => new Assign(target, value);
|
| - Expression newConditional(condition, yes, no)
|
| - => new Conditional(condition, yes, no);
|
| + Expression newChain(expressions) => new Chain(expressions);
|
| + Expression newAssign(target, value) => new Assign(target, value);
|
| + Expression newConditional(condition, yes, no) =>
|
| + new Conditional(condition, yes, no);
|
|
|
| - Expression newAccessKeyed(object, key)
|
| - => new AccessKeyed(object, key);
|
| - Expression newCallFunction(function, arguments)
|
| - => new CallFunction(function, arguments);
|
| + Expression newAccessKeyed(object, key) => new AccessKeyed(object, key);
|
| + Expression newCallFunction(function, arguments) =>
|
| + new CallFunction(function, _closures, arguments);
|
|
|
| - Expression newPrefixNot(expression)
|
| - => new PrefixNot(expression);
|
| + Expression newPrefixNot(expression) => new PrefixNot(expression);
|
|
|
| - Expression newBinary(operation, left, right)
|
| - => new Binary(operation, left, right);
|
| -
|
| - Expression newLiteralPrimitive(value)
|
| - => new LiteralPrimitive(value);
|
| - Expression newLiteralArray(elements)
|
| - => new LiteralArray(elements);
|
| - Expression newLiteralObject(keys, values)
|
| - => new LiteralObject(keys, values);
|
| - Expression newLiteralString(value)
|
| - => new LiteralString(value);
|
| + Expression newBinary(operation, left, right) =>
|
| + new Binary(operation, left, right);
|
|
|
| + Expression newLiteralPrimitive(value) => new LiteralPrimitive(value);
|
| + Expression newLiteralArray(elements) => new LiteralArray(elements);
|
| + Expression newLiteralObject(keys, values) => new LiteralObject(keys, values);
|
| + Expression newLiteralString(value) => new LiteralString(value);
|
|
|
| Expression newAccessScope(name) {
|
| - Getter getter = _closures.lookupGetter(name);
|
| - Setter setter = _closures.lookupSetter(name);
|
| - if (getter != null && setter != null) {
|
| - return new AccessScopeFast(name, getter, setter);
|
| + Getter getter;
|
| + Setter setter;
|
| + if (name == 'this') {
|
| + getter = (o) => o;
|
| } else {
|
| - return new AccessScope(name);
|
| + _assertNotReserved(name);
|
| + getter = _closures.lookupGetter(name);
|
| + setter = _closures.lookupSetter(name);
|
| }
|
| + return new AccessScopeFast(name, getter, setter);
|
| }
|
|
|
| Expression newAccessMember(object, name) {
|
| + _assertNotReserved(name);
|
| Getter getter = _closures.lookupGetter(name);
|
| Setter setter = _closures.lookupSetter(name);
|
| - if (getter != null && setter != null) {
|
| - return new AccessMemberFast(object, name, getter, setter);
|
| - } else {
|
| - return new AccessMember(object, name);
|
| - }
|
| + return new AccessMemberFast(object, name, getter, setter);
|
| }
|
|
|
| Expression newCallScope(name, arguments) {
|
| - Function constructor = _computeCallConstructor(
|
| - _callScopeConstructors, name, arguments.length);
|
| - return (constructor != null)
|
| - ? constructor(name, arguments, _closures)
|
| - : new CallScope(name, arguments);
|
| + _assertNotReserved(name);
|
| + MethodClosure function = _closures.lookupFunction(name, arguments);
|
| + return new CallScope(name, function, arguments);
|
| }
|
|
|
| Expression newCallMember(object, name, arguments) {
|
| - Function constructor = _computeCallConstructor(
|
| - _callMemberConstructors, name, arguments.length);
|
| - return (constructor != null)
|
| - ? constructor(object, name, arguments, _closures)
|
| - : new CallMember(object, name, arguments);
|
| + _assertNotReserved(name);
|
| + MethodClosure function = _closures.lookupFunction(name, arguments);
|
| + return new CallMember(object, function, name, arguments);
|
| }
|
|
|
| - Function _computeCallConstructor(Map constructors, String name, int arity) {
|
| - Function function = _closures.lookupFunction(name, arity);
|
| - return (function == null) ? null : constructors[arity];
|
| + _assertNotReserved(name) {
|
| + if (isReservedWord(name)) {
|
| + throw "Identifier '$name' is a reserved word.";
|
| + }
|
| }
|
| -
|
| - static final Map<int, Function> _callScopeConstructors = {
|
| - 0: (n, a, c) => new CallScopeFast0(n, a, c.lookupFunction(n, 0)),
|
| - 1: (n, a, c) => new CallScopeFast1(n, a, c.lookupFunction(n, 1)),
|
| - };
|
| -
|
| - static final Map<int, Function> _callMemberConstructors = {
|
| - 0: (o, n, a, c) => new CallMemberFast0(o, n, a, c.lookupFunction(n, 0)),
|
| - 1: (o, n, a, c) => new CallMemberFast1(o, n, a, c.lookupFunction(n, 1)),
|
| - };
|
| }
|
|
|
|
|