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

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

Issue 257423008: 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/parser_static.dart
diff --git a/third_party/pkg/angular/lib/core/parser/parser_static.dart b/third_party/pkg/angular/lib/core/parser/parser_static.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cf1c53255516667a814b4fe543efcc7ee02cf062
--- /dev/null
+++ b/third_party/pkg/angular/lib/core/parser/parser_static.dart
@@ -0,0 +1,78 @@
+library angular.core.parser_static;
+
+import 'package:angular/core/parser/parser.dart';
+
+
+class StaticClosureMap extends ClosureMap {
+ final Map<String, Getter> getters;
+ final Map<String, Setter> setters;
+ final Map<String, Symbol> symbols;
+
+ StaticClosureMap(this.getters, this.setters, this.symbols);
+
+ Getter lookupGetter(String name) {
+ Getter getter = getters[name];
+ if (getter == null) throw "No getter for '$name'.";
+ return getter;
+ }
+
+ Setter lookupSetter(String name) {
+ Setter setter = setters[name];
+ if (setter == null) throw "No setter for '$name'.";
+ return setter;
+ }
+
+ MethodClosure lookupFunction(String name, CallArguments arguments) {
+ var fn = lookupGetter(name);
+ return (o, posArgs, namedArgs) {
+ var sNamedArgs = {};
+ namedArgs.forEach((name, value) => sNamedArgs[symbols[name]] = value);
+ if (o is Map) {
+ var fn = o[name];
+ if (fn is Function) {
+ return Function.apply(fn, posArgs, sNamedArgs);
+ } else {
+ throw "Property '$name' is not of type function.";
+ }
+ } else {
+ return Function.apply(fn(o), posArgs, sNamedArgs);
+ }
+ };
+ }
+
+ Symbol lookupSymbol(String name) {
+ Symbol symbol = symbols[name];
+ if (symbol == null) throw "No symbol for '$name'.";
+ return symbol;
+ }
+}
+
+
+/**
+ * The [AccessFast] mixin is used to share code between access expressions
+ * where we have a pair of pre-compiled getter and setter functions that we
+ * use to do the access the field.
+ */
+abstract class AccessFast {
+ String get name;
+ Getter get getter;
+ Setter get setter;
+
+ _eval(holder) {
+ if (holder == null) return null;
+ return (holder is Map) ? holder[name] : getter(holder);
+ }
+
+ _assign(scope, holder, value) {
+ if (holder == null) {
+ _assignToNonExisting(scope, value);
+ return value;
+ } else {
+ return (holder is Map) ? (holder[name] = value) : setter(holder, value);
+ }
+ }
+
+ // By default we don't do any assignments to non-existing holders. This
+ // is overwritten for access to members.
+ _assignToNonExisting(scope, value) => null;
+}

Powered by Google App Engine
This is Rietveld 408576698