| 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 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 if (left.isConstantNull() || right.isConstantNull() || | 2553 if (left.isConstantNull() || right.isConstantNull() || |
| 2563 (left.isPrimitive(compiler) && | 2554 (left.isPrimitive(compiler) && |
| 2564 left.instructionType == right.instructionType)) { | 2555 left.instructionType == right.instructionType)) { |
| 2565 return '=='; | 2556 return '=='; |
| 2566 } | 2557 } |
| 2567 return null; | 2558 return null; |
| 2568 } else { | 2559 } else { |
| 2569 return '==='; | 2560 return '==='; |
| 2570 } | 2561 } |
| 2571 } | 2562 } |
| OLD | NEW |