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

Side by Side Diff: frog/leg/compiler.dart

Issue 9592009: Reapply "Refactor constant part." (r4958) with fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update tests and fix code after renaming. Created 8 years, 9 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 | Annotate | Revision Log
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 class WorkItem { 5 class WorkItem {
6 final Element element; 6 final Element element;
7 TreeElements resolutionTree; 7 TreeElements resolutionTree;
8 Function run; 8 Function run;
9 Map<int, BailoutInfo> bailouts = null; 9 Map<int, BailoutInfo> bailouts = null;
10 bool allowSpeculativeOptimization = true; 10 bool allowSpeculativeOptimization = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ScannerTask scanner; 69 ScannerTask scanner;
70 DietParserTask dietParser; 70 DietParserTask dietParser;
71 ParserTask parser; 71 ParserTask parser;
72 TreeValidatorTask validator; 72 TreeValidatorTask validator;
73 ResolverTask resolver; 73 ResolverTask resolver;
74 TypeCheckerTask checker; 74 TypeCheckerTask checker;
75 SsaBuilderTask builder; 75 SsaBuilderTask builder;
76 SsaOptimizerTask optimizer; 76 SsaOptimizerTask optimizer;
77 SsaCodeGeneratorTask generator; 77 SsaCodeGeneratorTask generator;
78 CodeEmitterTask emitter; 78 CodeEmitterTask emitter;
79 CompileTimeConstantHandler compileTimeConstantHandler; 79 ConstantHandler constantHandler;
80 80
81 static final SourceString MAIN = const SourceString('main'); 81 static final SourceString MAIN = const SourceString('main');
82 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); 82 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod');
83 static final SourceString NO_SUCH_METHOD_EXCEPTION = 83 static final SourceString NO_SUCH_METHOD_EXCEPTION =
84 const SourceString('NoSuchMethodException'); 84 const SourceString('NoSuchMethodException');
85 static final SourceString OBJECT = const SourceString('Object'); 85 static final SourceString OBJECT = const SourceString('Object');
86 bool enabledNoSuchMethod = false; 86 bool enabledNoSuchMethod = false;
87 87
88 Compiler.withCurrentDirectory(String this.currentDirectory, 88 Compiler.withCurrentDirectory(String this.currentDirectory,
89 [this.tracer = const Tracer()]) 89 [this.tracer = const Tracer()])
90 : types = new Types(), 90 : types = new Types(),
91 universe = new Universe(), 91 universe = new Universe(),
92 worklist = new Queue<WorkItem>() { 92 worklist = new Queue<WorkItem>() {
93 namer = new Namer(this); 93 namer = new Namer(this);
94 compileTimeConstantHandler = new CompileTimeConstantHandler(this); 94 constantHandler = new ConstantHandler(this);
95 scanner = new ScannerTask(this); 95 scanner = new ScannerTask(this);
96 dietParser = new DietParserTask(this); 96 dietParser = new DietParserTask(this);
97 parser = new ParserTask(this); 97 parser = new ParserTask(this);
98 validator = new TreeValidatorTask(this); 98 validator = new TreeValidatorTask(this);
99 resolver = new ResolverTask(this); 99 resolver = new ResolverTask(this);
100 checker = new TypeCheckerTask(this); 100 checker = new TypeCheckerTask(this);
101 builder = new SsaBuilderTask(this); 101 builder = new SsaBuilderTask(this);
102 optimizer = new SsaOptimizerTask(this); 102 optimizer = new SsaOptimizerTask(this);
103 generator = new SsaCodeGeneratorTask(this); 103 generator = new SsaCodeGeneratorTask(this);
104 emitter = new CodeEmitterTask(this); 104 emitter = new CodeEmitterTask(this);
105 tasks = [scanner, dietParser, parser, resolver, checker, 105 tasks = [scanner, dietParser, parser, resolver, checker,
106 builder, optimizer, generator, 106 builder, optimizer, generator,
107 emitter, compileTimeConstantHandler]; 107 emitter, constantHandler];
108 } 108 }
109 109
110 void ensure(bool condition) { 110 void ensure(bool condition) {
111 if (!condition) cancel('failed assertion in leg'); 111 if (!condition) cancel('failed assertion in leg');
112 } 112 }
113 113
114 void unimplemented(String methodName, 114 void unimplemented(String methodName,
115 [Node node, Token token, HInstruction instruction, 115 [Node node, Token token, HInstruction instruction,
116 Element element]) { 116 Element element]) {
117 cancel("$methodName not implemented", node, token, instruction, element); 117 cancel("$methodName not implemented", node, token, instruction, element);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 TreeElements analyze(WorkItem work) { 290 TreeElements analyze(WorkItem work) {
291 work.resolutionTree = analyzeElement(work.element); 291 work.resolutionTree = analyzeElement(work.element);
292 return work.resolutionTree; 292 return work.resolutionTree;
293 } 293 }
294 294
295 String codegen(WorkItem work) { 295 String codegen(WorkItem work) {
296 String code; 296 String code;
297 if (work.element.kind == ElementKind.FIELD 297 if (work.element.kind == ElementKind.FIELD
298 || work.element.kind == ElementKind.PARAMETER) { 298 || work.element.kind == ElementKind.PARAMETER) {
299 compileTimeConstantHandler.compileWorkItem(work); 299 constantHandler.compileWorkItem(work);
300 return null; 300 return null;
301 } else { 301 } else {
302 HGraph graph = builder.build(work); 302 HGraph graph = builder.build(work);
303 optimizer.optimize(work, graph); 303 optimizer.optimize(work, graph);
304 code = generator.generate(work, graph); 304 code = generator.generate(work, graph);
305 universe.addGeneratedCode(work, code); 305 universe.addGeneratedCode(work, code);
306 return code; 306 return code;
307 } 307 }
308 } 308 }
309 309
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 357 }
358 358
359 FunctionParameters resolveSignature(FunctionElement element) { 359 FunctionParameters resolveSignature(FunctionElement element) {
360 return withCurrentElement(element, 360 return withCurrentElement(element,
361 () => resolver.resolveSignature(element)); 361 () => resolver.resolveSignature(element));
362 } 362 }
363 363
364 Object compileVariable(VariableElement element) { 364 Object compileVariable(VariableElement element) {
365 return withCurrentElement(element, () { 365 return withCurrentElement(element, () {
366 compile(new WorkItem.toCompile(element)); 366 compile(new WorkItem.toCompile(element));
367 return compileTimeConstantHandler.compileVariable(element); 367 return constantHandler.compileVariable(element);
368 }); 368 });
369 } 369 }
370 370
371 reportWarning(Node node, var message) {} 371 reportWarning(Node node, var message) {}
372 reportError(Node node, var message) {} 372 reportError(Node node, var message) {}
373 373
374 Script readScript(Uri uri, [ScriptTag node]) { 374 Script readScript(Uri uri, [ScriptTag node]) {
375 unimplemented('Compiler.readScript'); 375 unimplemented('Compiler.readScript');
376 } 376 }
377 377
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 // TODO(ahe): Remove when the VM supports implicit interfaces. 425 // TODO(ahe): Remove when the VM supports implicit interfaces.
426 class LTracer implements Tracer { 426 class LTracer implements Tracer {
427 const LTracer(); 427 const LTracer();
428 final bool enabled = false; 428 final bool enabled = false;
429 void traceGraph(String name, var graph) { 429 void traceGraph(String name, var graph) {
430 } 430 }
431 void close() { 431 void close() {
432 } 432 }
433 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698