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

Side by Side Diff: pkg/compiler/lib/src/compiler.dart

Issue 2644843006: Use packages dart_parser, dart_scanner, and compiler_util. (Closed)
Patch Set: Created 3 years, 11 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
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 dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show EventSink, Future; 7 import 'dart:async' show EventSink, Future;
8 8
9 import '../compiler_new.dart' as api; 9 import '../compiler_new.dart' as api;
10 import 'cache_strategy.dart' show CacheStrategy; 10 import 'cache_strategy.dart' show CacheStrategy;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 import 'options.dart' show CompilerOptions, DiagnosticOptions; 58 import 'options.dart' show CompilerOptions, DiagnosticOptions;
59 import 'parser/diet_parser_task.dart' show DietParserTask; 59 import 'parser/diet_parser_task.dart' show DietParserTask;
60 import 'parser/parser_task.dart' show ParserTask; 60 import 'parser/parser_task.dart' show ParserTask;
61 import 'patch_parser.dart' show PatchParserTask; 61 import 'patch_parser.dart' show PatchParserTask;
62 import 'resolution/resolution.dart' show ResolverTask; 62 import 'resolution/resolution.dart' show ResolverTask;
63 import 'resolved_uri_translator.dart'; 63 import 'resolved_uri_translator.dart';
64 import 'scanner/scanner_task.dart' show ScannerTask; 64 import 'scanner/scanner_task.dart' show ScannerTask;
65 import 'script.dart' show Script; 65 import 'script.dart' show Script;
66 import 'serialization/task.dart' show SerializationTask; 66 import 'serialization/task.dart' show SerializationTask;
67 import 'ssa/nodes.dart' show HInstruction; 67 import 'ssa/nodes.dart' show HInstruction;
68 import 'tokens/token.dart' show StringToken, Token, TokenPair; 68 import 'package:dart_scanner/dart_scanner.dart' show StringToken, Token;
69 import 'tokens/token_map.dart' show TokenMap; 69 import 'tokens/token_map.dart' show TokenMap;
70 import 'tracer.dart' show Tracer; 70 import 'tracer.dart' show Tracer;
71 import 'tree/tree.dart' show Node, TypeAnnotation; 71 import 'tree/tree.dart' show Node, TypeAnnotation;
72 import 'typechecker.dart' show TypeCheckerTask; 72 import 'typechecker.dart' show TypeCheckerTask;
73 import 'types/types.dart' show GlobalTypeInferenceTask; 73 import 'types/types.dart' show GlobalTypeInferenceTask;
74 import 'universe/selector.dart' show Selector; 74 import 'universe/selector.dart' show Selector;
75 import 'universe/world_builder.dart' 75 import 'universe/world_builder.dart'
76 show ResolutionWorldBuilder, CodegenWorldBuilder; 76 show ResolutionWorldBuilder, CodegenWorldBuilder;
77 import 'universe/use.dart' show StaticUse, TypeUse; 77 import 'universe/use.dart' show StaticUse, TypeUse;
78 import 'universe/world_impact.dart' 78 import 'universe/world_impact.dart'
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // objects needed by other tasks. 263 // objects needed by other tasks.
264 enqueuer, 264 enqueuer,
265 dumpInfoTask = new DumpInfoTask(this), 265 dumpInfoTask = new DumpInfoTask(this),
266 selfTask = new GenericTask('self', measurer), 266 selfTask = new GenericTask('self', measurer),
267 ]; 267 ];
268 if (options.resolveOnly) { 268 if (options.resolveOnly) {
269 serialization.supportSerialization = true; 269 serialization.supportSerialization = true;
270 } 270 }
271 271
272 _parsingContext = 272 _parsingContext =
273 new ParsingContext(reporter, parser, patchParser, backend); 273 new ParsingContext(reporter, parser, scanner, patchParser, backend);
274 274
275 tasks.addAll(backend.tasks); 275 tasks.addAll(backend.tasks);
276 } 276 }
277 277
278 /// Creates the backend. 278 /// Creates the backend.
279 /// 279 ///
280 /// Override this to mock the backend for testing. 280 /// Override this to mock the backend for testing.
281 Backend createBackend() { 281 Backend createBackend() {
282 return new js_backend.JavaScriptBackend(this, 282 return new js_backend.JavaScriptBackend(this,
283 generateSourceMap: options.generateSourceMap, 283 generateSourceMap: options.generateSourceMap,
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1636
1637 void reportAssertionFailure(SpannableAssertionFailure ex) { 1637 void reportAssertionFailure(SpannableAssertionFailure ex) {
1638 String message = 1638 String message =
1639 (ex.message != null) ? tryToString(ex.message) : tryToString(ex); 1639 (ex.message != null) ? tryToString(ex.message) : tryToString(ex);
1640 reportDiagnosticInternal( 1640 reportDiagnosticInternal(
1641 createMessage(ex.node, MessageKind.GENERIC, {'text': message}), 1641 createMessage(ex.node, MessageKind.GENERIC, {'text': message}),
1642 const <DiagnosticMessage>[], 1642 const <DiagnosticMessage>[],
1643 api.Diagnostic.CRASH); 1643 api.Diagnostic.CRASH);
1644 } 1644 }
1645 1645
1646 @override
1647 SourceSpan spanFromToken(Token token) => spanFromTokens(token, token);
1648
1646 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { 1649 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) {
1647 if (begin == null || end == null) { 1650 if (begin == null || end == null) {
1648 // TODO(ahe): We can almost always do better. Often it is only 1651 // TODO(ahe): We can almost always do better. Often it is only
1649 // end that is null. Otherwise, we probably know the current 1652 // end that is null. Otherwise, we probably know the current
1650 // URI. 1653 // URI.
1651 throw 'Cannot find tokens to produce error message.'; 1654 throw 'Cannot find tokens to produce error message.';
1652 } 1655 }
1653 if (uri == null && currentElement != null) { 1656 if (uri == null && currentElement != null) {
1654 uri = currentElement.compilationUnit.script.resourceUri; 1657 uri = currentElement.compilationUnit.script.resourceUri;
1655 assert(invariant(currentElement, () { 1658 assert(invariant(currentElement, () {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 if (node == CURRENT_ELEMENT_SPANNABLE) { 1787 if (node == CURRENT_ELEMENT_SPANNABLE) {
1785 node = currentElement; 1788 node = currentElement;
1786 } else if (node == NO_LOCATION_SPANNABLE) { 1789 } else if (node == NO_LOCATION_SPANNABLE) {
1787 if (currentElement == null) return null; 1790 if (currentElement == null) return null;
1788 node = currentElement; 1791 node = currentElement;
1789 } 1792 }
1790 if (node is SourceSpan) { 1793 if (node is SourceSpan) {
1791 return node; 1794 return node;
1792 } else if (node is Node) { 1795 } else if (node is Node) {
1793 return spanFromNode(node); 1796 return spanFromNode(node);
1794 } else if (node is TokenPair) {
1795 return spanFromTokens(node.begin, node.end);
1796 } else if (node is Token) {
1797 return spanFromTokens(node, node);
1798 } else if (node is HInstruction) { 1797 } else if (node is HInstruction) {
1799 return spanFromHInstruction(node); 1798 return spanFromHInstruction(node);
1800 } else if (node is Element) { 1799 } else if (node is Element) {
1801 return spanFromElement(node); 1800 return spanFromElement(node);
1802 } else if (node is MetadataAnnotation) { 1801 } else if (node is MetadataAnnotation) {
1803 return node.sourcePosition; 1802 return node.sourcePosition;
1804 } else if (node is Local) { 1803 } else if (node is Local) {
1805 Local local = node; 1804 Local local = node;
1806 return spanFromElement(local.executableContext); 1805 return spanFromElement(local.executableContext);
1807 } else { 1806 } else {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 _ElementScanner(this.scanner); 2231 _ElementScanner(this.scanner);
2233 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); 2232 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library);
2234 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); 2233 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit);
2235 } 2234 }
2236 2235
2237 class _EmptyEnvironment implements Environment { 2236 class _EmptyEnvironment implements Environment {
2238 const _EmptyEnvironment(); 2237 const _EmptyEnvironment();
2239 2238
2240 String valueOf(String key) => null; 2239 String valueOf(String key) => null;
2241 } 2240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698