Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: third_party/pkg/angular/lib/core/parser/dynamic_parser.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 57b88be8324865c401dfac5cf95d3a487d7d8008..ef70c5920337ae68e432cfb38f50a2e2306d0c87 100644
--- a/third_party/pkg/angular/lib/core/parser/dynamic_parser.dart
+++ b/third_party/pkg/angular/lib/core/parser/dynamic_parser.dart
@@ -1,25 +1,23 @@
library angular.core.parser.dynamic_parser;
-import 'package:angular/core/annotation_src.dart';
-import 'package:angular/core/module_internal.dart' show FormatterMap;
+import 'package:angular/core/module.dart' show FilterMap, NgInjectableService;
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 defaultFormatterMap;
+import 'package:angular/core/parser/syntax.dart' show defaultFilterMap;
import 'package:angular/core/parser/eval.dart';
import 'package:angular/core/parser/utils.dart' show EvalError;
-import 'package:angular/utils.dart';
-abstract class ClosureMap {
- Getter lookupGetter(String name);
- Setter lookupSetter(String name);
- Symbol lookupSymbol(String name);
- MethodClosure lookupFunction(String name, CallArguments arguments);
+@NgInjectableService()
+class ClosureMap {
+ Getter lookupGetter(String name) => null;
+ Setter lookupSetter(String name) => null;
+ Function lookupFunction(String name, int arity) => null;
}
-@Injectable()
+@NgInjectableService()
class DynamicParser implements Parser<Expression> {
final Lexer _lexer;
final ParserBackend _backend;
@@ -48,9 +46,9 @@ class DynamicExpression extends Expression {
accept(Visitor visitor) => _expression.accept(visitor);
toString() => _expression.toString();
- eval(scope, [FormatterMap formatters = defaultFormatterMap]) {
+ eval(scope, [FilterMap filters = defaultFilterMap]) {
try {
- return _expression.eval(scope, formatters);
+ return _expression.eval(scope, filters);
} on EvalError catch (e, s) {
throw e.unwrap("$this", s);
}
@@ -65,12 +63,13 @@ class DynamicExpression extends Expression {
}
}
-@Injectable()
+@NgInjectableService()
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);
@@ -79,61 +78,83 @@ 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, _closures, arguments);
+ Expression newAccessKeyed(object, key)
+ => new AccessKeyed(object, key);
+ Expression newCallFunction(function, arguments)
+ => new CallFunction(function, arguments);
- Expression newPrefixNot(expression) => new PrefixNot(expression);
+ Expression newPrefixNot(expression)
+ => new PrefixNot(expression);
- Expression newBinary(operation, left, right) =>
- new Binary(operation, left, right);
+ 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 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;
- Setter setter;
- if (name == 'this') {
- getter = (o) => o;
+ Getter getter = _closures.lookupGetter(name);
+ Setter setter = _closures.lookupSetter(name);
+ if (getter != null && setter != null) {
+ return new AccessScopeFast(name, getter, setter);
} else {
- _assertNotReserved(name);
- getter = _closures.lookupGetter(name);
- setter = _closures.lookupSetter(name);
+ return new AccessScope(name);
}
- return new AccessScopeFast(name, getter, setter);
}
Expression newAccessMember(object, name) {
- _assertNotReserved(name);
Getter getter = _closures.lookupGetter(name);
Setter setter = _closures.lookupSetter(name);
- return new AccessMemberFast(object, name, getter, setter);
+ if (getter != null && setter != null) {
+ return new AccessMemberFast(object, name, getter, setter);
+ } else {
+ return new AccessMember(object, name);
+ }
}
Expression newCallScope(name, arguments) {
- _assertNotReserved(name);
- MethodClosure function = _closures.lookupFunction(name, arguments);
- return new CallScope(name, function, arguments);
+ Function constructor = _computeCallConstructor(
+ _callScopeConstructors, name, arguments.length);
+ return (constructor != null)
+ ? constructor(name, arguments, _closures)
+ : new CallScope(name, arguments);
}
Expression newCallMember(object, name, arguments) {
- _assertNotReserved(name);
- MethodClosure function = _closures.lookupFunction(name, arguments);
- return new CallMember(object, function, name, arguments);
+ Function constructor = _computeCallConstructor(
+ _callMemberConstructors, name, arguments.length);
+ return (constructor != null)
+ ? constructor(object, name, arguments, _closures)
+ : new CallMember(object, name, arguments);
}
- _assertNotReserved(name) {
- if (isReservedWord(name)) {
- throw "Identifier '$name' is a reserved word.";
- }
+ Function _computeCallConstructor(Map constructors, String name, int arity) {
+ Function function = _closures.lookupFunction(name, arity);
+ return (function == null) ? null : constructors[arity];
}
+
+ 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)),
+ };
}

Powered by Google App Engine
This is Rietveld 408576698