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

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

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/eval_access.dart
diff --git a/third_party/pkg/angular/lib/core/parser/eval_access.dart b/third_party/pkg/angular/lib/core/parser/eval_access.dart
index 54c7cf64c38545c6ada3cc965126e760dc164682..d8f47fea71f4799061f732478915bc35ca010ceb 100644
--- a/third_party/pkg/angular/lib/core/parser/eval_access.dart
+++ b/third_party/pkg/angular/lib/core/parser/eval_access.dart
@@ -4,11 +4,12 @@ import 'dart:mirrors';
import 'package:angular/core/parser/parser.dart';
import 'package:angular/core/parser/syntax.dart' as syntax;
import 'package:angular/core/parser/utils.dart';
+import 'package:angular/core/module.dart';
class AccessScope extends syntax.AccessScope with AccessReflective {
final Symbol symbol;
- AccessScope(String name) : super(name), symbol = new Symbol(name);
- eval(scope) => _eval(scope);
+ AccessScope(String name) : super(name), symbol = newSymbol(name);
+ eval(scope, [FilterMap filters]) => _eval(scope);
assign(scope, value) => _assign(scope, scope, value);
}
@@ -16,14 +17,15 @@ class AccessScopeFast extends syntax.AccessScope with AccessFast {
final Getter getter;
final Setter setter;
AccessScopeFast(String name, this.getter, this.setter) : super(name);
- eval(scope) => _eval(scope);
+ eval(scope, [FilterMap filters]) => _eval(scope);
assign(scope, value) => _assign(scope, scope, value);
}
class AccessMember extends syntax.AccessMember with AccessReflective {
final Symbol symbol;
- AccessMember(object, String name) : super(object, name), symbol = new Symbol(name);
- eval(scope) => _eval(object.eval(scope));
+ AccessMember(object, String name)
+ : super(object, name), symbol = newSymbol(name);
+ eval(scope, [FilterMap filters]) => _eval(object.eval(scope, filters));
assign(scope, value) => _assign(scope, object.eval(scope), value);
_assignToNonExisting(scope, value) => object.assign(scope, { name: value });
}
@@ -33,14 +35,15 @@ class AccessMemberFast extends syntax.AccessMember with AccessFast {
final Setter setter;
AccessMemberFast(object, String name, this.getter, this.setter)
: super(object, name);
- eval(scope) => _eval(object.eval(scope));
+ eval(scope, [FilterMap filters]) => _eval(object.eval(scope, filters));
assign(scope, value) => _assign(scope, object.eval(scope), value);
_assignToNonExisting(scope, value) => object.assign(scope, { name: value });
}
class AccessKeyed extends syntax.AccessKeyed {
AccessKeyed(object, key) : super(object, key);
- eval(scope) => getKeyed(object.eval(scope), key.eval(scope));
+ eval(scope, [FilterMap filters]) =>
+ getKeyed(object.eval(scope, filters), key.eval(scope, filters));
assign(scope, value) => setKeyed(object.eval(scope), key.eval(scope), value);
}
@@ -67,7 +70,7 @@ abstract class AccessReflective {
int cachedKind = _cachedKind;
if (cachedKind == CACHED_MAP) return holder[name];
var value = _cachedValue;
- return (cachedKind == CACHED_FIELD)
+ return (cachedKind == CACHED_FIELD && value != null)
? value.getField(symbol).reflectee
: value;
}
@@ -81,6 +84,9 @@ abstract class AccessReflective {
_cachedKind = CACHED_MAP;
_cachedValue = null;
return holder[name];
+ } else if (symbol == null) {
+ _cachedHolder = UNINITIALIZED;
+ return null;
}
InstanceMirror mirror = reflect(holder);
try {
@@ -89,10 +95,14 @@ abstract class AccessReflective {
_cachedValue = mirror;
return result;
} on NoSuchMethodError catch (e) {
- var result = createInvokeClosure(mirror, symbol);
- if (result == null) rethrow;
- _cachedKind = CACHED_VALUE;
- return _cachedValue = result;
+ if (isNoSuchMethodDueToGetField(e)) {
+ var result = createInvokeClosure(mirror, symbol);
+ if (result == null) rethrow;
+ _cachedKind = CACHED_VALUE;
+ return _cachedValue = result;
+ } else {
+ rethrow;
+ }
} on UnsupportedError catch (e) {
var result = createInvokeClosure(mirror, symbol);
if (result == null) rethrow;
@@ -101,12 +111,18 @@ abstract class AccessReflective {
}
}
+ bool isNoSuchMethodDueToGetField(NoSuchMethodError e) {
+ var msg = e.toString();
+ return msg.indexOf("has no instance getter '$name'.") != -1 || // Dart VM
+ msg.indexOf('Cannot call "$name\$') != -1; // Dart2JS
+ }
+
_assign(scope, holder, value) {
if (holder is Map) {
holder[name] = value;
} else if (holder == null) {
_assignToNonExisting(scope, value);
- } else {
+ } else if (symbol != null) {
reflect(holder).setField(symbol, value);
}
return value;

Powered by Google App Engine
This is Rietveld 408576698