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

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

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/cps_ir/scalar_replacement.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) 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.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../common/names.dart' show 9 import '../common/names.dart' show
10 Names, 10 Names,
11 Selectors; 11 Selectors;
12 import '../common/tasks.dart' show 12 import '../common/tasks.dart' show
13 CompilerTask; 13 CompilerTask;
14 import '../compiler.dart' show 14 import '../compiler.dart' show
15 Compiler; 15 Compiler;
16 import '../constants/expressions.dart'; 16 import '../constants/expressions.dart';
17 import '../dart_types.dart'; 17 import '../dart_types.dart';
18 import '../diagnostics/diagnostic_listener.dart' show
19 DiagnosticReporter;
18 import '../diagnostics/invariant.dart' show 20 import '../diagnostics/invariant.dart' show
19 invariant; 21 invariant;
20 import '../elements/elements.dart'; 22 import '../elements/elements.dart';
21 import '../elements/modelx.dart' show 23 import '../elements/modelx.dart' show
22 SynthesizedConstructorElementX, 24 SynthesizedConstructorElementX,
23 ConstructorBodyElementX, 25 ConstructorBodyElementX,
24 FunctionSignatureX; 26 FunctionSignatureX;
25 import '../io/source_information.dart'; 27 import '../io/source_information.dart';
26 import '../js_backend/js_backend.dart' show 28 import '../js_backend/js_backend.dart' show
27 JavaScriptBackend, 29 JavaScriptBackend,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 : super(compiler); 78 : super(compiler);
77 79
78 String get name => 'CPS builder'; 80 String get name => 'CPS builder';
79 81
80 ir.FunctionDefinition buildNode(AstElement element) { 82 ir.FunctionDefinition buildNode(AstElement element) {
81 return measure(() { 83 return measure(() {
82 bailoutMessage = null; 84 bailoutMessage = null;
83 85
84 TreeElements elementsMapping = element.resolvedAst.elements; 86 TreeElements elementsMapping = element.resolvedAst.elements;
85 element = element.implementation; 87 element = element.implementation;
86 return compiler.withCurrentElement(element, () { 88 return reporter.withCurrentElement(element, () {
87 SourceInformationBuilder sourceInformationBuilder = 89 SourceInformationBuilder sourceInformationBuilder =
88 sourceInformationStrategy.createBuilderForContext(element); 90 sourceInformationStrategy.createBuilderForContext(element);
89 91
90 IrBuilderVisitor builder = 92 IrBuilderVisitor builder =
91 new JsIrBuilderVisitor( 93 new JsIrBuilderVisitor(
92 elementsMapping, compiler, sourceInformationBuilder); 94 elementsMapping, compiler, sourceInformationBuilder);
93 ir.FunctionDefinition irNode = builder.buildExecutable(element); 95 ir.FunctionDefinition irNode = builder.buildExecutable(element);
94 if (irNode == null) { 96 if (irNode == null) {
95 bailoutMessage = builder.bailoutMessage; 97 bailoutMessage = builder.bailoutMessage;
96 } else if (builderCallback != null) { 98 } else if (builderCallback != null) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // assigned in the delimited subexpression to their reaching definition --- 155 // assigned in the delimited subexpression to their reaching definition ---
154 // that is, the definition in effect at the hole in 'current'. These are 156 // that is, the definition in effect at the hole in 'current'. These are
155 // used to determine if a join-point continuation needs to be passed 157 // used to determine if a join-point continuation needs to be passed
156 // arguments, and what the arguments are. 158 // arguments, and what the arguments are.
157 159
158 /// Construct a top-level visitor. 160 /// Construct a top-level visitor.
159 IrBuilderVisitor(this.elements, 161 IrBuilderVisitor(this.elements,
160 this.compiler, 162 this.compiler,
161 this.sourceInformationBuilder); 163 this.sourceInformationBuilder);
162 164
165 DiagnosticReporter get reporter => compiler.reporter;
166
163 String bailoutMessage = null; 167 String bailoutMessage = null;
164 168
165 @override 169 @override
166 ir.Primitive apply(ast.Node node, _) => node.accept(this); 170 ir.Primitive apply(ast.Node node, _) => node.accept(this);
167 171
168 @override 172 @override
169 SemanticSendVisitor get sendVisitor => this; 173 SemanticSendVisitor get sendVisitor => this;
170 174
171 /** 175 /**
172 * Builds the [ir.FunctionDefinition] for an executable element. In case the 176 * Builds the [ir.FunctionDefinition] for an executable element. In case the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 232
229 ir.Primitive visit(ast.Node node) => node.accept(this); 233 ir.Primitive visit(ast.Node node) => node.accept(this);
230 234
231 // ## Statements ## 235 // ## Statements ##
232 visitBlock(ast.Block node) { 236 visitBlock(ast.Block node) {
233 irBuilder.buildBlock(node.statements.nodes, build); 237 irBuilder.buildBlock(node.statements.nodes, build);
234 } 238 }
235 239
236 ir.Primitive visitBreakStatement(ast.BreakStatement node) { 240 ir.Primitive visitBreakStatement(ast.BreakStatement node) {
237 if (!irBuilder.buildBreak(elements.getTargetOf(node))) { 241 if (!irBuilder.buildBreak(elements.getTargetOf(node))) {
238 compiler.internalError(node, "'break' target not found"); 242 reporter.internalError(node, "'break' target not found");
239 } 243 }
240 return null; 244 return null;
241 } 245 }
242 246
243 ir.Primitive visitContinueStatement(ast.ContinueStatement node) { 247 ir.Primitive visitContinueStatement(ast.ContinueStatement node) {
244 if (!irBuilder.buildContinue(elements.getTargetOf(node))) { 248 if (!irBuilder.buildContinue(elements.getTargetOf(node))) {
245 compiler.internalError(node, "'continue' target not found"); 249 reporter.internalError(node, "'continue' target not found");
246 } 250 }
247 return null; 251 return null;
248 } 252 }
249 253
250 // Build(EmptyStatement, C) = C 254 // Build(EmptyStatement, C) = C
251 ir.Primitive visitEmptyStatement(ast.EmptyStatement node) { 255 ir.Primitive visitEmptyStatement(ast.EmptyStatement node) {
252 assert(irBuilder.isOpen); 256 assert(irBuilder.isOpen);
253 return null; 257 return null;
254 } 258 }
255 259
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 return action(); 2255 return action();
2252 } catch(e) { 2256 } catch(e) {
2253 if (e == ABORT_IRNODE_BUILDER) { 2257 if (e == ABORT_IRNODE_BUILDER) {
2254 return null; 2258 return null;
2255 } 2259 }
2256 rethrow; 2260 rethrow;
2257 } 2261 }
2258 } 2262 }
2259 2263
2260 internalError(ast.Node node, String message) { 2264 internalError(ast.Node node, String message) {
2261 compiler.internalError(node, message); 2265 reporter.internalError(node, message);
2262 } 2266 }
2263 2267
2264 @override 2268 @override
2265 visitNode(ast.Node node) { 2269 visitNode(ast.Node node) {
2266 giveup(node, "Unhandled node"); 2270 giveup(node, "Unhandled node");
2267 } 2271 }
2268 2272
2269 dynamic giveup(ast.Node node, [String reason]) { 2273 dynamic giveup(ast.Node node, [String reason]) {
2270 bailoutMessage = '($node): $reason'; 2274 bailoutMessage = '($node): $reason';
2271 throw ABORT_IRNODE_BUILDER; 2275 throw ABORT_IRNODE_BUILDER;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 root = buildStaticFieldInitializer(element); 2643 root = buildStaticFieldInitializer(element);
2640 } else { 2644 } else {
2641 // Instance field initializers are inlined in the constructor, 2645 // Instance field initializers are inlined in the constructor,
2642 // so we shouldn't need to build anything here. 2646 // so we shouldn't need to build anything here.
2643 // TODO(asgerf): But what should we return? 2647 // TODO(asgerf): But what should we return?
2644 return null; 2648 return null;
2645 } 2649 }
2646 break; 2650 break;
2647 2651
2648 default: 2652 default:
2649 compiler.internalError(element, "Unexpected element type $element"); 2653 reporter.internalError(element, "Unexpected element type $element");
2650 } 2654 }
2651 return root; 2655 return root;
2652 }); 2656 });
2653 } 2657 }
2654 2658
2655 ir.FunctionDefinition buildStaticFieldInitializer(FieldElement element) { 2659 ir.FunctionDefinition buildStaticFieldInitializer(FieldElement element) {
2656 if (!backend.constants.lazyStatics.contains(element)) { 2660 if (!backend.constants.lazyStatics.contains(element)) {
2657 return null; // Nothing to do. 2661 return null; // Nothing to do.
2658 } 2662 }
2659 closureClassMap = 2663 closureClassMap =
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 Selector selector = elements.getSelector(initializer); 2902 Selector selector = elements.getSelector(initializer);
2899 List<ir.Primitive> arguments = initializer.arguments.mapToList(visit); 2903 List<ir.Primitive> arguments = initializer.arguments.mapToList(visit);
2900 evaluateConstructorCallFromInitializer( 2904 evaluateConstructorCallFromInitializer(
2901 target, 2905 target,
2902 selector.callStructure, 2906 selector.callStructure,
2903 arguments, 2907 arguments,
2904 supers, 2908 supers,
2905 fieldValues); 2909 fieldValues);
2906 hasConstructorCall = true; 2910 hasConstructorCall = true;
2907 } else { 2911 } else {
2908 compiler.internalError(initializer, 2912 reporter.internalError(initializer,
2909 "Unexpected initializer type $initializer"); 2913 "Unexpected initializer type $initializer");
2910 } 2914 }
2911 } 2915 }
2912 } 2916 }
2913 // If no super() or this() was found, also call default superconstructor. 2917 // If no super() or this() was found, also call default superconstructor.
2914 if (!hasConstructorCall && !enclosingClass.isObject) { 2918 if (!hasConstructorCall && !enclosingClass.isObject) {
2915 ClassElement superClass = enclosingClass.superclass; 2919 ClassElement superClass = enclosingClass.superclass;
2916 FunctionElement target = superClass.lookupDefaultConstructor(); 2920 FunctionElement target = superClass.lookupDefaultConstructor();
2917 if (target == null) { 2921 if (target == null) {
2918 compiler.internalError(superClass, "No default constructor available."); 2922 reporter.internalError(superClass, "No default constructor available.");
2919 } 2923 }
2920 target = target.implementation; 2924 target = target.implementation;
2921 evaluateConstructorCallFromInitializer( 2925 evaluateConstructorCallFromInitializer(
2922 target, 2926 target,
2923 CallStructure.NO_ARGS, 2927 CallStructure.NO_ARGS,
2924 const [], 2928 const [],
2925 supers, 2929 supers,
2926 fieldValues); 2930 fieldValues);
2927 } 2931 }
2928 // Add this constructor after the superconstructors. 2932 // Add this constructor after the superconstructors.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 internalError(node, 'Expected at least $minimum arguments.'); 3368 internalError(node, 'Expected at least $minimum arguments.');
3365 } 3369 }
3366 } 3370 }
3367 3371
3368 /// Call a helper method from the isolate library. The isolate library uses 3372 /// Call a helper method from the isolate library. The isolate library uses
3369 /// its own isolate structure, that encapsulates dart2js's isolate. 3373 /// its own isolate structure, that encapsulates dart2js's isolate.
3370 ir.Primitive buildIsolateHelperInvocation(String helperName, 3374 ir.Primitive buildIsolateHelperInvocation(String helperName,
3371 CallStructure callStructure) { 3375 CallStructure callStructure) {
3372 Element element = backend.isolateHelperLibrary.find(helperName); 3376 Element element = backend.isolateHelperLibrary.find(helperName);
3373 if (element == null) { 3377 if (element == null) {
3374 compiler.internalError(node, 3378 reporter.internalError(node,
3375 'Isolate library and compiler mismatch.'); 3379 'Isolate library and compiler mismatch.');
3376 } 3380 }
3377 List<ir.Primitive> arguments = translateStaticArguments(argumentList, 3381 List<ir.Primitive> arguments = translateStaticArguments(argumentList,
3378 element, callStructure); 3382 element, callStructure);
3379 return irBuilder.buildStaticFunctionInvocation(element, 3383 return irBuilder.buildStaticFunctionInvocation(element,
3380 callStructure, arguments, 3384 callStructure, arguments,
3381 sourceInformation: 3385 sourceInformation:
3382 sourceInformationBuilder.buildCall(node, node.selector)); 3386 sourceInformationBuilder.buildCall(node, node.selector));
3383 } 3387 }
3384 3388
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 if (compiler.backend.isForeign(function)) { 3579 if (compiler.backend.isForeign(function)) {
3576 return handleForeignCode(node, function, argumentList, callStructure); 3580 return handleForeignCode(node, function, argumentList, callStructure);
3577 } else { 3581 } else {
3578 return irBuilder.buildStaticFunctionInvocation(function, callStructure, 3582 return irBuilder.buildStaticFunctionInvocation(function, callStructure,
3579 translateStaticArguments(argumentList, function, callStructure), 3583 translateStaticArguments(argumentList, function, callStructure),
3580 sourceInformation: 3584 sourceInformation:
3581 sourceInformationBuilder.buildCall(node, node.selector)); 3585 sourceInformationBuilder.buildCall(node, node.selector));
3582 } 3586 }
3583 } 3587 }
3584 } 3588 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/cps_ir/scalar_replacement.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698