| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 return element.getCompilationUnit().script.file; | 59 return element.getCompilationUnit().script.file; |
| 60 } | 60 } |
| 61 | 61 |
| 62 js.Fun buildJavaScriptFunction(FunctionElement element, | 62 js.Fun buildJavaScriptFunction(FunctionElement element, |
| 63 List<js.Parameter> parameters, | 63 List<js.Parameter> parameters, |
| 64 js.Block body) { | 64 js.Block body) { |
| 65 return attachPosition(new js.Fun(parameters, body), element); | 65 return attachPosition(new js.Fun(parameters, body), element); |
| 66 } | 66 } |
| 67 | 67 |
| 68 CodeBuffer prettyPrint(js.Node node) { | |
| 69 var code = js.prettyPrint(node, compiler, allowVariableMinification: true); | |
| 70 return code; | |
| 71 } | |
| 72 | |
| 73 js.Expression generateCode(CodegenWorkItem work, HGraph graph) { | 68 js.Expression generateCode(CodegenWorkItem work, HGraph graph) { |
| 74 if (work.element.isField()) { | 69 if (work.element.isField()) { |
| 75 return generateLazyInitializer(work, graph); | 70 return generateLazyInitializer(work, graph); |
| 76 } else { | 71 } else { |
| 77 return generateMethod(work, graph); | 72 return generateMethod(work, graph); |
| 78 } | 73 } |
| 79 } | 74 } |
| 80 | 75 |
| 81 js.Expression generateLazyInitializer(work, graph) { | 76 js.Expression generateLazyInitializer(work, graph) { |
| 82 return measure(() { | 77 return measure(() { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return TYPE_STATEMENT; | 396 return TYPE_STATEMENT; |
| 402 } | 397 } |
| 403 } while (limits.contains(basicBlock)); | 398 } while (limits.contains(basicBlock)); |
| 404 return result; | 399 return result; |
| 405 } | 400 } |
| 406 | 401 |
| 407 bool isJSExpression(HExpressionInformation info) { | 402 bool isJSExpression(HExpressionInformation info) { |
| 408 return !identical(expressionType(info), TYPE_STATEMENT); | 403 return !identical(expressionType(info), TYPE_STATEMENT); |
| 409 } | 404 } |
| 410 | 405 |
| 411 bool isJSDeclaration(HExpressionInformation info) { | |
| 412 return identical(expressionType(info), TYPE_DECLARATION); | |
| 413 } | |
| 414 | |
| 415 bool isJSCondition(HExpressionInformation info) { | 406 bool isJSCondition(HExpressionInformation info) { |
| 416 HSubExpressionBlockInformation graph = info; | 407 HSubExpressionBlockInformation graph = info; |
| 417 SubExpression limits = graph.subExpression; | 408 SubExpression limits = graph.subExpression; |
| 418 return !identical(expressionType(info), TYPE_STATEMENT) && | 409 return !identical(expressionType(info), TYPE_STATEMENT) && |
| 419 (limits.end.last is HConditionalBranch); | 410 (limits.end.last is HConditionalBranch); |
| 420 } | 411 } |
| 421 | 412 |
| 422 /** | 413 /** |
| 423 * Generate statements from block information. | 414 * Generate statements from block information. |
| 424 * If the block information contains expressions, generate only | 415 * If the block information contains expressions, generate only |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 cases.add(new js.Default(currentContainer)); | 679 cases.add(new js.Default(currentContainer)); |
| 689 generateStatements(info.statements.last); | 680 generateStatements(info.statements.last); |
| 690 | 681 |
| 691 currentContainer = oldContainer; | 682 currentContainer = oldContainer; |
| 692 | 683 |
| 693 js.Statement result = new js.Switch(key, cases); | 684 js.Statement result = new js.Switch(key, cases); |
| 694 pushStatement(wrapIntoLabels(result, info.labels)); | 685 pushStatement(wrapIntoLabels(result, info.labels)); |
| 695 return true; | 686 return true; |
| 696 } | 687 } |
| 697 | 688 |
| 698 bool visitSequenceInfo(HStatementSequenceInformation info) { | |
| 699 return false; | |
| 700 } | |
| 701 | |
| 702 bool visitSubGraphInfo(HSubGraphBlockInformation info) { | 689 bool visitSubGraphInfo(HSubGraphBlockInformation info) { |
| 703 visitSubGraph(info.subGraph); | 690 visitSubGraph(info.subGraph); |
| 704 return true; | 691 return true; |
| 705 } | 692 } |
| 706 | 693 |
| 707 bool visitSubExpressionInfo(HSubExpressionBlockInformation info) { | 694 bool visitSubExpressionInfo(HSubExpressionBlockInformation info) { |
| 708 return false; | 695 return false; |
| 709 } | 696 } |
| 710 | 697 |
| 711 bool visitAndOrInfo(HAndOrBlockInformation info) { | |
| 712 return false; | |
| 713 } | |
| 714 | |
| 715 bool visitTryInfo(HTryBlockInformation info) { | 698 bool visitTryInfo(HTryBlockInformation info) { |
| 716 js.Block body = generateStatementsInNewBlock(info.body); | 699 js.Block body = generateStatementsInNewBlock(info.body); |
| 717 js.Catch catchPart = null; | 700 js.Catch catchPart = null; |
| 718 js.Block finallyPart = null; | 701 js.Block finallyPart = null; |
| 719 if (info.catchBlock != null) { | 702 if (info.catchBlock != null) { |
| 720 void register(ClassElement classElement) { | 703 void register(ClassElement classElement) { |
| 721 if (classElement != null) { | 704 if (classElement != null) { |
| 722 world.registerInstantiatedClass(classElement, work.resolutionTree); | 705 world.registerInstantiatedClass(classElement, work.resolutionTree); |
| 723 } | 706 } |
| 724 } | 707 } |
| (...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 if (left.isConstantNull() || right.isConstantNull() || | 2545 if (left.isConstantNull() || right.isConstantNull() || |
| 2563 (left.isPrimitive(compiler) && | 2546 (left.isPrimitive(compiler) && |
| 2564 left.instructionType == right.instructionType)) { | 2547 left.instructionType == right.instructionType)) { |
| 2565 return '=='; | 2548 return '=='; |
| 2566 } | 2549 } |
| 2567 return null; | 2550 return null; |
| 2568 } else { | 2551 } else { |
| 2569 return '==='; | 2552 return '==='; |
| 2570 } | 2553 } |
| 2571 } | 2554 } |
| OLD | NEW |