| OLD | NEW |
| 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 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart"); | 5 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart"); |
| 6 #import("../../../lib/compiler/implementation/elements/elements.dart"); // only
need CompilationUnitElement | 6 #import("../../../lib/compiler/implementation/elements/elements.dart"); // only
need CompilationUnitElement |
| 7 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 7 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
| 8 #import("../../../lib/compiler/implementation/leg.dart"); // only need Diagnosti
cListener & Script | 8 #import("../../../lib/compiler/implementation/leg.dart"); // only need Diagnosti
cListener & Script |
| 9 | 9 |
| 10 // This is the number of spaces to trim from the test code. | 10 // This is the number of spaces to trim from the test code. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 Script script = new Script(null, null); | 103 Script script = new Script(null, null); |
| 104 LibraryElement lib = new LibraryElement(script); | 104 LibraryElement lib = new LibraryElement(script); |
| 105 CompilationUnitElement element = new CompilationUnitElement(script, lib); | 105 CompilationUnitElement element = new CompilationUnitElement(script, lib); |
| 106 StringScanner scanner = new StringScanner(source); | 106 StringScanner scanner = new StringScanner(source); |
| 107 Token beginToken = scanner.tokenize(); | 107 Token beginToken = scanner.tokenize(); |
| 108 NodeListener listener = new NodeListener(diagnosticListener, element); | 108 NodeListener listener = new NodeListener(diagnosticListener, element); |
| 109 Parser parser = new Parser(listener); | 109 Parser parser = new Parser(listener); |
| 110 parser.parseUnit(beginToken); | 110 parser.parseUnit(beginToken); |
| 111 Node node = listener.popNode(); | 111 Node node = listener.popNode(); |
| 112 Expect.isTrue(listener.nodes.isEmpty()); | 112 Expect.isTrue(listener.nodes.isEmpty()); |
| 113 return new Unparser().unparse(node); | 113 return unparse(node); |
| 114 } | 114 } |
| 115 | 115 |
| 116 class MessageCollector implements DiagnosticListener { | 116 class MessageCollector implements DiagnosticListener { |
| 117 List<String> messages; | 117 List<String> messages; |
| 118 MessageCollector() { | 118 MessageCollector() { |
| 119 messages = []; | 119 messages = []; |
| 120 } | 120 } |
| 121 void cancel([String reason, node, token, instruction, element]) { | 121 void cancel([String reason, node, token, instruction, element]) { |
| 122 messages.add(reason); | 122 messages.add(reason); |
| 123 throw reason; | 123 throw reason; |
| 124 } | 124 } |
| 125 void log(message) { | 125 void log(message) { |
| 126 messages.add(message); | 126 messages.add(message); |
| 127 } | 127 } |
| 128 void internalErrorOnElement(Element element, String message) { | 128 void internalErrorOnElement(Element element, String message) { |
| 129 throw message; | 129 throw message; |
| 130 } | 130 } |
| 131 void internalError(String message, | 131 void internalError(String message, |
| 132 [Node node, Token token, Dynamic instruction, | 132 [Node node, Token token, Dynamic instruction, |
| 133 Element element]) { | 133 Element element]) { |
| 134 throw message; | 134 throw message; |
| 135 } | 135 } |
| 136 } | 136 } |
| OLD | NEW |