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

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

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.test.message_kind_helper; 5 library dart2js.test.message_kind_helper;
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:compiler/src/dart2jslib.dart' show 10 import 'package:compiler/src/dart2jslib.dart' show
11 Compiler, 11 Compiler,
12 MessageKind; 12 MessageKind;
13 import 'package:compiler/src/dart_backend/dart_backend.dart' show 13 import 'package:compiler/src/dart_backend/dart_backend.dart' show
14 DartBackend; 14 DartBackend;
15 import 'package:compiler/src/old_to_new_api.dart' show
16 LegacyCompilerDiagnostics;
15 17
16 import 'memory_compiler.dart'; 18 import 'memory_compiler.dart';
17 19
18 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]'; 20 const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
19 21
20 /// Most examples generate a single diagnostic. 22 /// Most examples generate a single diagnostic.
21 /// Add an exception here if a single diagnostic cannot be produced. 23 /// Add an exception here if a single diagnostic cannot be produced.
22 /// However, consider that a single concise diagnostic is easier to understand, 24 /// However, consider that a single concise diagnostic is easier to understand,
23 /// so try to change error reporting logic before adding an exception. 25 /// so try to change error reporting logic before adding an exception.
24 final Set<MessageKind> kindsWithExtraMessages = new Set<MessageKind>.from([ 26 final Set<MessageKind> kindsWithExtraMessages = new Set<MessageKind>.from([
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 74 }
73 75
74 bool oldBackendIsDart; 76 bool oldBackendIsDart;
75 if (cachedCompiler != null) { 77 if (cachedCompiler != null) {
76 oldBackendIsDart = cachedCompiler.backend is DartBackend; 78 oldBackendIsDart = cachedCompiler.backend is DartBackend;
77 } 79 }
78 bool newBackendIsDart = kind.options.contains('--output-type=dart'); 80 bool newBackendIsDart = kind.options.contains('--output-type=dart');
79 81
80 Compiler compiler = compilerFor( 82 Compiler compiler = compilerFor(
81 example, 83 example,
82 diagnosticHandler: collect, 84 diagnosticHandler: new LegacyCompilerDiagnostics(collect),
83 options: ['--analyze-only', 85 options: ['--analyze-only',
84 '--enable-experimental-mirrors']..addAll(kind.options), 86 '--enable-experimental-mirrors']..addAll(kind.options),
85 cachedCompiler: 87 cachedCompiler:
86 // TODO(johnniwinther): Remove this restriction when constant 88 // TODO(johnniwinther): Remove this restriction when constant
87 // values can be computed directly from the expressions. 89 // values can be computed directly from the expressions.
88 oldBackendIsDart == newBackendIsDart ? cachedCompiler : null); 90 oldBackendIsDart == newBackendIsDart ? cachedCompiler : null);
89 91
90 return compiler.run(Uri.parse('memory:main.dart')).then((_) { 92 return compiler.run(Uri.parse('memory:main.dart')).then((_) {
91 93
92 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""'); 94 Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind)); 139 Expect.isTrue(!pendingStuff || kindsWithPendingClasses.contains(kind));
138 140
139 if (!pendingStuff) { 141 if (!pendingStuff) {
140 // If there is pending stuff, or the compiler was cancelled, we 142 // If there is pending stuff, or the compiler was cancelled, we
141 // shouldn't reuse the compiler. 143 // shouldn't reuse the compiler.
142 cachedCompiler = compiler; 144 cachedCompiler = compiler;
143 } 145 }
144 }); 146 });
145 }).then((_) => cachedCompiler); 147 }).then((_) => cachedCompiler);
146 } 148 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/memory_source_file_helper.dart ('k') | tests/compiler/dart2js/mirror_tree_shaking_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698