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

Unified Diff: third_party/pkg/angular/lib/tools/parser_generator/generator.dart

Issue 1058283006: Update pubspecs and dependencies to get pkgbuild tests working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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/tools/parser_generator/generator.dart
diff --git a/third_party/pkg/angular/lib/tools/parser_generator/generator.dart b/third_party/pkg/angular/lib/tools/parser_generator/generator.dart
deleted file mode 100644
index 27877cdf8dc8ae8270a6e7712ed3b095a2766601..0000000000000000000000000000000000000000
--- a/third_party/pkg/angular/lib/tools/parser_generator/generator.dart
+++ /dev/null
@@ -1,86 +0,0 @@
-library generator;
-
-import 'package:angular/core/module.dart';
-import 'package:angular/core/parser/parser.dart';
-import 'package:angular/tools/parser_generator/dart_code_gen.dart';
-
-class NullFilterMap implements FilterMap {
- call(name) => null;
- Type operator[](annotation) => null;
- forEach(fn) { }
- annotationsFor(type) => null;
-}
-
-class SourcePrinter {
- printSrc(src) {
- print(src);
- }
-}
-
-class ParserGenerator {
- final Parser _parser;
- final DartCodeGen _codegen;
- final SourcePrinter _printer;
- ParserGenerator(this._parser, this._codegen, this._printer);
-
- void print(object) {
- _printer.printSrc('$object');
- }
-
- generateParser(Iterable<String> expressions) {
- print("StaticParserFunctions functions()");
- print(" => new StaticParserFunctions(");
- print(" buildEval(), buildAssign());");
- print("");
-
- // Compute the function maps.
- Map eval = {};
- Map assign = {};
- expressions.forEach((exp) {
- generateCode(exp, eval, assign);
- });
-
- // Generate the code.
- generateBuildFunction('buildEval', eval);
- generateBuildFunction('buildAssign', assign);
- _codegen.getters.helpers.values.forEach(print);
- _codegen.holders.helpers.values.forEach(print);
- _codegen.setters.helpers.values.forEach(print);
- }
-
- void generateBuildFunction(String name, Map map) {
- String mapLiteral = map.keys.map((e) => ' "$e": ${map[e]}').join(',\n');
- print("Map<String, Function> $name() {");
- print(" return {\n$mapLiteral\n };");
- print("}");
- print("");
- }
-
- void generateCode(String exp, Map eval, Map assign) {
- String escaped = escape(exp);
- try {
- Expression e = _parser(exp);
- if (e.isAssignable) assign[escaped] = getCode(e, true);
- eval[escaped] = getCode(e, false);
- } catch (e) {
- if ("$e".contains('Parser Error') ||
- "$e".contains('Lexer Error') ||
- "$e".contains('Unexpected end of expression')) {
- eval[escaped] = '"${escape(e.toString())}"';
- } else {
- rethrow;
- }
- }
- }
-
- String getCode(Expression e, bool assign) {
- String args = assign ? "scope, value" : "scope, filters";
- String code = _codegen.generate(e, assign);
- if (e.isChain) {
- code = code.replaceAll('\n', '\n ');
- return "($args) {\n $code\n }";
- } else {
- return "($args) => $code";
- }
- }
-}

Powered by Google App Engine
This is Rietveld 408576698