| OLD | NEW |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ScannerTask scanner; | 66 ScannerTask scanner; |
| 67 DietParserTask dietParser; | 67 DietParserTask dietParser; |
| 68 ParserTask parser; | 68 ParserTask parser; |
| 69 TreeValidatorTask validator; | 69 TreeValidatorTask validator; |
| 70 ResolverTask resolver; | 70 ResolverTask resolver; |
| 71 TypeCheckerTask checker; | 71 TypeCheckerTask checker; |
| 72 SsaBuilderTask builder; | 72 SsaBuilderTask builder; |
| 73 SsaOptimizerTask optimizer; | 73 SsaOptimizerTask optimizer; |
| 74 SsaCodeGeneratorTask generator; | 74 SsaCodeGeneratorTask generator; |
| 75 CodeEmitterTask emitter; | 75 CodeEmitterTask emitter; |
| 76 CompileTimeConstantHandler compileTimeConstantHandler; | 76 ConstantHandler constantHandler; |
| 77 | 77 |
| 78 static final SourceString MAIN = const SourceString('main'); | 78 static final SourceString MAIN = const SourceString('main'); |
| 79 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 79 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 80 | 80 |
| 81 Compiler() : this.withCurrentDirectory(io.getCurrentDirectory()); | 81 Compiler() : this.withCurrentDirectory(io.getCurrentDirectory()); |
| 82 | 82 |
| 83 Compiler.withCurrentDirectory(String this.currentDirectory) | 83 Compiler.withCurrentDirectory(String this.currentDirectory) |
| 84 : types = new Types(), | 84 : types = new Types(), |
| 85 universe = new Universe(), | 85 universe = new Universe(), |
| 86 worklist = new Queue<WorkItem>() { | 86 worklist = new Queue<WorkItem>() { |
| 87 namer = new Namer(this); | 87 namer = new Namer(this); |
| 88 compileTimeConstantHandler = new CompileTimeConstantHandler(this); | 88 constantHandler = new ConstantHandler(this); |
| 89 scanner = new ScannerTask(this); | 89 scanner = new ScannerTask(this); |
| 90 dietParser = new DietParserTask(this); | 90 dietParser = new DietParserTask(this); |
| 91 parser = new ParserTask(this); | 91 parser = new ParserTask(this); |
| 92 validator = new TreeValidatorTask(this); | 92 validator = new TreeValidatorTask(this); |
| 93 resolver = new ResolverTask(this); | 93 resolver = new ResolverTask(this); |
| 94 checker = new TypeCheckerTask(this); | 94 checker = new TypeCheckerTask(this); |
| 95 builder = new SsaBuilderTask(this); | 95 builder = new SsaBuilderTask(this); |
| 96 optimizer = new SsaOptimizerTask(this); | 96 optimizer = new SsaOptimizerTask(this); |
| 97 generator = new SsaCodeGeneratorTask(this); | 97 generator = new SsaCodeGeneratorTask(this); |
| 98 emitter = new CodeEmitterTask(this); | 98 emitter = new CodeEmitterTask(this); |
| 99 tasks = [scanner, dietParser, parser, resolver, checker, | 99 tasks = [scanner, dietParser, parser, resolver, checker, |
| 100 builder, optimizer, generator, | 100 builder, optimizer, generator, |
| 101 emitter, compileTimeConstantHandler]; | 101 emitter, constantHandler]; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void ensure(bool condition) { | 104 void ensure(bool condition) { |
| 105 if (!condition) cancel('failed assertion in leg'); | 105 if (!condition) cancel('failed assertion in leg'); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void unimplemented(String methodName, | 108 void unimplemented(String methodName, |
| 109 [Node node, Token token, HInstruction instruction, | 109 [Node node, Token token, HInstruction instruction, |
| 110 Element element]) { | 110 Element element]) { |
| 111 cancel("$methodName not implemented", node, token, instruction, element); | 111 cancel("$methodName not implemented", node, token, instruction, element); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 TreeElements analyze(WorkItem work) { | 282 TreeElements analyze(WorkItem work) { |
| 283 work.resolutionTree = analyzeElement(work.element); | 283 work.resolutionTree = analyzeElement(work.element); |
| 284 return work.resolutionTree; | 284 return work.resolutionTree; |
| 285 } | 285 } |
| 286 | 286 |
| 287 String codegen(WorkItem work) { | 287 String codegen(WorkItem work) { |
| 288 String code; | 288 String code; |
| 289 if (work.element.kind == ElementKind.FIELD | 289 if (work.element.kind == ElementKind.FIELD |
| 290 || work.element.kind == ElementKind.PARAMETER) { | 290 || work.element.kind == ElementKind.PARAMETER) { |
| 291 compileTimeConstantHandler.compileWorkItem(work); | 291 constantHandler.compileWorkItem(work); |
| 292 return null; | 292 return null; |
| 293 } else { | 293 } else { |
| 294 HGraph graph = builder.build(work); | 294 HGraph graph = builder.build(work); |
| 295 optimizer.optimize(work, graph); | 295 optimizer.optimize(work, graph); |
| 296 code = generator.generate(work, graph); | 296 code = generator.generate(work, graph); |
| 297 universe.addGeneratedCode(work, code); | 297 universe.addGeneratedCode(work, code); |
| 298 return code; | 298 return code; |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 349 } |
| 350 | 350 |
| 351 FunctionParameters resolveSignature(FunctionElement element) { | 351 FunctionParameters resolveSignature(FunctionElement element) { |
| 352 return withCurrentElement(element, | 352 return withCurrentElement(element, |
| 353 () => resolver.resolveSignature(element)); | 353 () => resolver.resolveSignature(element)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 Object compileVariable(VariableElement element) { | 356 Object compileVariable(VariableElement element) { |
| 357 return withCurrentElement(element, () { | 357 return withCurrentElement(element, () { |
| 358 compile(new WorkItem.toCompile(element)); | 358 compile(new WorkItem.toCompile(element)); |
| 359 return compileTimeConstantHandler.compileVariable(element); | 359 return constantHandler.compileVariable(element); |
| 360 }); | 360 }); |
| 361 } | 361 } |
| 362 | 362 |
| 363 reportWarning(Node node, var message) {} | 363 reportWarning(Node node, var message) {} |
| 364 reportError(Node node, var message) {} | 364 reportError(Node node, var message) {} |
| 365 | 365 |
| 366 Script readScript(Uri uri, [ScriptTag node]) { | 366 Script readScript(Uri uri, [ScriptTag node]) { |
| 367 unimplemented('Compiler.readScript'); | 367 unimplemented('Compiler.readScript'); |
| 368 } | 368 } |
| 369 | 369 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 399 | 399 |
| 400 class CompilerCancelledException implements Exception { | 400 class CompilerCancelledException implements Exception { |
| 401 final String reason; | 401 final String reason; |
| 402 CompilerCancelledException(this.reason); | 402 CompilerCancelledException(this.reason); |
| 403 | 403 |
| 404 String toString() { | 404 String toString() { |
| 405 String banner = 'compiler cancelled'; | 405 String banner = 'compiler cancelled'; |
| 406 return (reason !== null) ? '$banner: $reason' : '$banner'; | 406 return (reason !== null) ? '$banner: $reason' : '$banner'; |
| 407 } | 407 } |
| 408 } | 408 } |
| OLD | NEW |