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

Side by Side Diff: pkg/fletchc/lib/src/fletch_compiler_implementation.dart

Issue 1450393002: Roll sdk dependency to 34357cdad108dcba734949bd13bd28c76ea285e0 (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Address ahe's review Created 5 years 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
« no previous file with comments | « pkg/fletchc/lib/src/fletch_class_builder.dart ('k') | pkg/fletchc/lib/src/fletch_context.dart » ('j') | 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) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.fletch_compiler_implementation; 5 library fletchc.fletch_compiler_implementation;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink; 8 EventSink;
9 9
10 import 'package:sdk_library_metadata/libraries.dart' show 10 import 'package:sdk_library_metadata/libraries.dart' show
11 LibraryInfo; 11 LibraryInfo;
12 12
13 import 'package:compiler/compiler_new.dart' as api; 13 import 'package:compiler/compiler_new.dart' as api;
14 14
15 import 'package:compiler/src/apiimpl.dart' as apiimpl; 15 import 'package:compiler/src/apiimpl.dart' show
16 16 CompilerImpl;
17 import 'package:compiler/src/compiler.dart' show
18 GlobalDependencyRegistry;
19 17
20 import 'package:compiler/src/io/source_file.dart'; 18 import 'package:compiler/src/io/source_file.dart';
21 19
22 import 'package:compiler/src/source_file_provider.dart' show 20 import 'package:compiler/src/source_file_provider.dart' show
23 SourceFileProvider; 21 SourceFileProvider;
24 22
25 import 'package:compiler/src/elements/modelx.dart' show 23 import 'package:compiler/src/elements/modelx.dart' show
26 CompilationUnitElementX, 24 CompilationUnitElementX,
27 LibraryElementX; 25 LibraryElementX;
28 26
29 import 'package:compiler/compiler_new.dart' show 27 import 'package:compiler/compiler_new.dart' show
30 CompilerOutput; 28 CompilerOutput;
31 29
32 import 'package:compiler/src/diagnostics/messages.dart' show 30 import 'package:compiler/src/diagnostics/messages.dart' show
33 Message, 31 Message,
34 MessageKind, 32 MessageKind,
35 MessageTemplate; 33 MessageTemplate;
34
36 import 'package:compiler/src/diagnostics/source_span.dart' show 35 import 'package:compiler/src/diagnostics/source_span.dart' show
37 SourceSpan; 36 SourceSpan;
38 37
39 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show 38 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show
40 DiagnosticMessage, 39 DiagnosticMessage,
41 DiagnosticReporter; 40 DiagnosticReporter;
42 41
43 import 'package:compiler/src/diagnostics/spannable.dart' show 42 import 'package:compiler/src/diagnostics/spannable.dart' show
44 Spannable; 43 Spannable;
45 44
46 import 'fletch_registry.dart' show
47 FletchRegistry;
48
49 import 'please_report_crash.dart' show 45 import 'please_report_crash.dart' show
50 crashReportRequested, 46 crashReportRequested,
51 requestBugReportOnCompilerCrashMessage; 47 requestBugReportOnCompilerCrashMessage;
52 48
53 import 'fletch_function_builder.dart'; 49 import 'fletch_function_builder.dart';
54 import 'debug_info.dart'; 50 import 'debug_info.dart';
55 import 'find_position_visitor.dart'; 51 import 'find_position_visitor.dart';
56 import 'fletch_context.dart'; 52 import 'fletch_context.dart';
57 53
58 import 'fletch_enqueuer.dart' show 54 import 'fletch_enqueuer.dart' show
59 FletchEnqueueTask; 55 FletchEnqueueTask;
60 56
61 import '../fletch_system.dart'; 57 import '../fletch_system.dart';
58
62 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 59 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
63 import 'package:compiler/src/elements/elements.dart'; 60
61 import 'fletch_diagnostic_reporter.dart' show
62 FletchDiagnosticReporter;
64 63
65 const EXTRA_DART2JS_OPTIONS = const <String>[ 64 const EXTRA_DART2JS_OPTIONS = const <String>[
66 // TODO(ahe): This doesn't completely disable type inference. Investigate. 65 // TODO(ahe): This doesn't completely disable type inference. Investigate.
67 '--disable-type-inference', 66 '--disable-type-inference',
68 '--output-type=dart', 67 '--output-type=dart',
69 // We want to continue generating code in the case of errors, to support 68 // We want to continue generating code in the case of errors, to support
70 // incremental fixes of erroneous code. 69 // incremental fixes of erroneous code.
71 '--generate-code-with-compile-time-errors', 70 '--generate-code-with-compile-time-errors',
72 ]; 71 ];
73 72
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 documented: false, 113 documented: false,
115 platforms: FLETCH_PLATFORM), 114 platforms: FLETCH_PLATFORM),
116 115
117 "fletch.os": const LibraryInfo( 116 "fletch.os": const LibraryInfo(
118 "os/os.dart", 117 "os/os.dart",
119 categories: "Client,Server,Embedded", 118 categories: "Client,Server,Embedded",
120 documented: false, 119 documented: false,
121 platforms: FLETCH_PLATFORM), 120 platforms: FLETCH_PLATFORM),
122 }; 121 };
123 122
124 class FletchCompilerImplementation extends apiimpl.CompilerImpl { 123 class FletchCompilerImplementation extends CompilerImpl {
125 final Map<String, LibraryInfo> fletchLibraries = <String, LibraryInfo>{}; 124 final Map<String, LibraryInfo> fletchLibraries = <String, LibraryInfo>{};
126 125
127 final Uri fletchVm; 126 final Uri fletchVm;
128 127
129 /// Location of fletch patch files. 128 /// Location of fletch patch files.
130 final Uri patchRoot; 129 final Uri patchRoot;
131 130
132 final Uri nativesJson; 131 final Uri nativesJson;
133 132
134 Map<Uri, CompilationUnitElementX> compilationUnits; 133 Map<Uri, CompilationUnitElementX> compilationUnits;
135 FletchContext internalContext; 134 FletchContext internalContext;
136 135
137 /// A reference to [../compiler.dart:FletchCompiler] used for testing. 136 /// A reference to [../compiler.dart:FletchCompiler] used for testing.
138 // TODO(ahe): Clean this up and remove this. 137 // TODO(ahe): Clean this up and remove this.
139 var helper; 138 var helper;
140 139
141 @override
142 FletchEnqueueTask get enqueuer => super.enqueuer; 140 FletchEnqueueTask get enqueuer => super.enqueuer;
143 141
144 FletchDiagnosticReporter reporter; 142 FletchDiagnosticReporter reporter;
145 143
146 FletchCompilerImplementation( 144 FletchCompilerImplementation(
147 api.CompilerInput provider, 145 api.CompilerInput provider,
148 api.CompilerOutput outputProvider, 146 api.CompilerOutput outputProvider,
149 api.CompilerDiagnostics handler, 147 api.CompilerDiagnostics handler,
150 Uri libraryRoot, 148 Uri libraryRoot,
151 Uri packageConfig, 149 Uri packageConfig,
(...skipping 13 matching lines...) Expand all
165 163
166 FletchContext get context { 164 FletchContext get context {
167 if (internalContext == null) { 165 if (internalContext == null) {
168 internalContext = new FletchContext(this); 166 internalContext = new FletchContext(this);
169 } 167 }
170 return internalContext; 168 return internalContext;
171 } 169 }
172 170
173 String fletchPatchLibraryFor(String name) => FLETCH_PATCHES[name]; 171 String fletchPatchLibraryFor(String name) => FLETCH_PATCHES[name];
174 172
175 @override
176 Uri lookupLibraryUri(String libraryName) { 173 Uri lookupLibraryUri(String libraryName) {
177 LibraryInfo info = FLETCH_LIBRARIES[libraryName]; 174 LibraryInfo info = FLETCH_LIBRARIES[libraryName];
178 if (info == null) return super.lookupLibraryUri(libraryName); 175 if (info == null) return super.lookupLibraryUri(libraryName);
179 return patchRoot.resolve("lib/${info.path}"); 176 return patchRoot.resolve("lib/${info.path}");
180 } 177 }
181 178
182 Uri resolvePatchUri(String dartLibraryPath) { 179 Uri resolvePatchUri(String dartLibraryPath) {
183 String patchPath = fletchPatchLibraryFor(dartLibraryPath); 180 String patchPath = fletchPatchLibraryFor(dartLibraryPath);
184 if (patchPath == null) return null; 181 if (patchPath == null) return null;
185 return patchRoot.resolve("lib/$patchPath"); 182 return patchRoot.resolve("lib/$patchPath");
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 296 }
300 } 297 }
301 298
302 SourceFile getSourceFile(api.CompilerInput provider, Uri uri) { 299 SourceFile getSourceFile(api.CompilerInput provider, Uri uri) {
303 if (provider is SourceFileProvider) { 300 if (provider is SourceFileProvider) {
304 return provider.sourceFiles[uri]; 301 return provider.sourceFiles[uri];
305 } else { 302 } else {
306 return null; 303 return null;
307 } 304 }
308 } 305 }
309
310 /// A wrapper around a DiagnosticReporter, that customizes some messages to
311 /// Fletch.
312 class FletchDiagnosticReporter extends DiagnosticReporter {
313 DiagnosticReporter _internalReporter;
314
315 FletchDiagnosticReporter(this._internalReporter);
316
317 @override
318 DiagnosticMessage createMessage(Spannable spannable,
319 MessageKind messageKind,
320 [Map arguments = const {}]) {
321 return _internalReporter.createMessage(spannable, messageKind, arguments);
322 }
323
324 @override
325 internalError(Spannable spannable, message) {
326 return _internalReporter.internalError(spannable, message);
327 }
328
329 @override
330 void log(message) {
331 _internalReporter.log(message);
332 }
333
334 @override
335 DiagnosticOptions get options => _internalReporter.options;
336
337 @override
338 void reportError(DiagnosticMessage message,
339 [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
340 if (message.message.kind ==
341 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND) {
342 const String noMirrors =
343 "Fletch doesn't support 'dart:mirrors'. See https://goo.gl/Kwrd0O";
344 message = createMessage(message.spannable,
345 MessageKind.GENERIC,
346 {'text': message});
347 }
348 _internalReporter.reportError(message, infos);
349 }
350
351 @override
352 void reportHint(DiagnosticMessage message,
353 [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
354 _internalReporter.reportHint(message, infos);
355 }
356
357 @override
358 void reportInfo(Spannable node,
359 MessageKind errorCode,
360 [Map arguments = const {}]) {
361 _internalReporter.reportInfo(node, errorCode, arguments);
362 }
363
364 @override
365 void reportWarning(DiagnosticMessage message,
366 [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
367 _internalReporter.reportWarning(message, infos);
368 }
369
370 @override
371 SourceSpan spanFromSpannable(Spannable node) {
372 return _internalReporter.spanFromSpannable(node);
373 }
374
375 @override
376 withCurrentElement(Element element, f()) {
377 return _internalReporter.withCurrentElement(element, f);
378 }
379 }
OLDNEW
« no previous file with comments | « pkg/fletchc/lib/src/fletch_class_builder.dart ('k') | pkg/fletchc/lib/src/fletch_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698