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

Side by Side Diff: tests/compiler/dart2js/parser_helper.dart

Issue 10579019: First shot at source maps generation in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix the tests. Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/source_map_builder.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('parser_helper'); 5 #library('parser_helper');
6 6
7 #import("dart:uri"); 7 #import("dart:uri");
8 8
9 #import("../../../lib/compiler/implementation/elements/elements.dart"); 9 #import("../../../lib/compiler/implementation/elements/elements.dart");
10 #import("../../../lib/compiler/implementation/tree/tree.dart"); 10 #import("../../../lib/compiler/implementation/tree/tree.dart");
11 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); 11 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart');
12 #import("../../../lib/compiler/implementation/leg.dart"); 12 #import("../../../lib/compiler/implementation/leg.dart");
13 #import("../../../lib/compiler/implementation/source_file.dart");
13 #import("../../../lib/compiler/implementation/util/util.dart"); 14 #import("../../../lib/compiler/implementation/util/util.dart");
14 15
15 class LoggerCanceler implements DiagnosticListener { 16 class LoggerCanceler implements DiagnosticListener {
16 void cancel([String reason, node, token, instruction, element]) { 17 void cancel([String reason, node, token, instruction, element]) {
17 throw new CompilerCancelledException(reason); 18 throw new CompilerCancelledException(reason);
18 } 19 }
19 20
20 void log(message) { 21 void log(message) {
21 print(message); 22 print(message);
22 } 23 }
(...skipping 20 matching lines...) Expand all
43 Node parseFunction(String text, Compiler compiler) { 44 Node parseFunction(String text, Compiler compiler) {
44 Element element = parseUnit(text, compiler, compiler.mainApp).head; 45 Element element = parseUnit(text, compiler, compiler.mainApp).head;
45 Expect.isNotNull(element); 46 Expect.isNotNull(element);
46 Expect.equals(ElementKind.FUNCTION, element.kind); 47 Expect.equals(ElementKind.FUNCTION, element.kind);
47 return element.parseNode(compiler); 48 return element.parseNode(compiler);
48 } 49 }
49 50
50 Node parseMember(String text) => 51 Node parseMember(String text) =>
51 parseBodyCode(text, (parser, tokens) => parser.parseMember(tokens)); 52 parseBodyCode(text, (parser, tokens) => parser.parseMember(tokens));
52 53
53 class MockFile { 54 class MockFile extends SourceFile {
54 final filename = '<string>'; 55 MockFile(text)
55 final text; 56 : super('<string>', text);
56 MockFile(this.text);
57 } 57 }
58 58
59 Link<Element> parseUnit(String text, Compiler compiler, 59 Link<Element> parseUnit(String text, Compiler compiler,
60 LibraryElement library) { 60 LibraryElement library) {
61 Token tokens = scan(text); 61 Token tokens = scan(text);
62 Uri uri = new Uri(scheme: "source"); 62 Uri uri = new Uri(scheme: "source");
63 var script = new Script(uri, new MockFile(text)); 63 var script = new Script(uri, new MockFile(text));
64 var unit = new CompilationUnitElement(script, library); 64 var unit = new CompilationUnitElement(script, library);
65 int id = 0; 65 int id = 0;
66 ElementListener listener = new ElementListener(compiler, unit, () => id++); 66 ElementListener listener = new ElementListener(compiler, unit, () => id++);
67 PartialParser parser = new PartialParser(listener); 67 PartialParser parser = new PartialParser(listener);
68 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); 68 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens));
69 return unit.topLevelElements; 69 return unit.topLevelElements;
70 } 70 }
71 71
72 // TODO(ahe): We define this method to avoid having to import 72 // TODO(ahe): We define this method to avoid having to import
73 // the scanner in the tests. We should move SourceString to another 73 // the scanner in the tests. We should move SourceString to another
74 // location instead. 74 // location instead.
75 SourceString buildSourceString(String name) { 75 SourceString buildSourceString(String name) {
76 return new SourceString(name); 76 return new SourceString(name);
77 } 77 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/source_map_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698