| 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 Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2555 void visitLiteralString(LiteralString node) { | 2555 void visitLiteralString(LiteralString node) { |
| 2556 stack.add(graph.addConstantString(node.dartString, node)); | 2556 stack.add(graph.addConstantString(node.dartString, node)); |
| 2557 } | 2557 } |
| 2558 | 2558 |
| 2559 void visitStringJuxtaposition(StringJuxtaposition node) { | 2559 void visitStringJuxtaposition(StringJuxtaposition node) { |
| 2560 if (!node.isInterpolation) { | 2560 if (!node.isInterpolation) { |
| 2561 // This is a simple string with no interpolations. | 2561 // This is a simple string with no interpolations. |
| 2562 stack.add(graph.addConstantString(node.dartString, node)); | 2562 stack.add(graph.addConstantString(node.dartString, node)); |
| 2563 return; | 2563 return; |
| 2564 } | 2564 } |
| 2565 StringBuilderVisitor stringBuilder = new StringBuilderVisitor(this); | 2565 StringBuilderVisitor stringBuilder = new StringBuilderVisitor(this, node); |
| 2566 stringBuilder.visit(node); | 2566 stringBuilder.visit(node); |
| 2567 stack.add(stringBuilder.result); | 2567 stack.add(stringBuilder.result); |
| 2568 } | 2568 } |
| 2569 | 2569 |
| 2570 void visitLiteralNull(LiteralNull node) { | 2570 void visitLiteralNull(LiteralNull node) { |
| 2571 stack.add(graph.addConstantNull()); | 2571 stack.add(graph.addConstantNull()); |
| 2572 } | 2572 } |
| 2573 | 2573 |
| 2574 visitNodeList(NodeList node) { | 2574 visitNodeList(NodeList node) { |
| 2575 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { | 2575 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2707 open(joinBlock); | 2707 open(joinBlock); |
| 2708 | 2708 |
| 2709 localsHandler.mergeWith(thenLocals, joinBlock); | 2709 localsHandler.mergeWith(thenLocals, joinBlock); |
| 2710 HPhi phi = new HPhi.manyInputs(null, | 2710 HPhi phi = new HPhi.manyInputs(null, |
| 2711 <HInstruction>[thenInstruction, elseInstruction]); | 2711 <HInstruction>[thenInstruction, elseInstruction]); |
| 2712 joinBlock.addPhi(phi); | 2712 joinBlock.addPhi(phi); |
| 2713 stack.add(phi); | 2713 stack.add(phi); |
| 2714 } | 2714 } |
| 2715 | 2715 |
| 2716 visitStringInterpolation(StringInterpolation node) { | 2716 visitStringInterpolation(StringInterpolation node) { |
| 2717 StringBuilderVisitor stringBuilder = new StringBuilderVisitor(this); | 2717 StringBuilderVisitor stringBuilder = new StringBuilderVisitor(this, node); |
| 2718 stringBuilder.visit(node); | 2718 stringBuilder.visit(node); |
| 2719 stack.add(stringBuilder.result); | 2719 stack.add(stringBuilder.result); |
| 2720 } | 2720 } |
| 2721 | 2721 |
| 2722 visitStringInterpolationPart(StringInterpolationPart node) { | 2722 visitStringInterpolationPart(StringInterpolationPart node) { |
| 2723 // The parts are iterated in visitStringInterpolation. | 2723 // The parts are iterated in visitStringInterpolation. |
| 2724 compiler.internalError('visitStringInterpolation should not be called', | 2724 compiler.internalError('visitStringInterpolation should not be called', |
| 2725 node: node); | 2725 node: node); |
| 2726 } | 2726 } |
| 2727 | 2727 |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3384 | 3384 |
| 3385 /** | 3385 /** |
| 3386 * Visitor that handles generation of string literals (LiteralString, | 3386 * Visitor that handles generation of string literals (LiteralString, |
| 3387 * StringInterpolation), and otherwise delegates to the given visitor for | 3387 * StringInterpolation), and otherwise delegates to the given visitor for |
| 3388 * non-literal subexpressions. | 3388 * non-literal subexpressions. |
| 3389 * TODO(lrn): Consider whether to handle compile time constant int/boolean | 3389 * TODO(lrn): Consider whether to handle compile time constant int/boolean |
| 3390 * expressions as well. | 3390 * expressions as well. |
| 3391 */ | 3391 */ |
| 3392 class StringBuilderVisitor extends AbstractVisitor { | 3392 class StringBuilderVisitor extends AbstractVisitor { |
| 3393 final SsaBuilder builder; | 3393 final SsaBuilder builder; |
| 3394 final Node node; |
| 3394 | 3395 |
| 3395 /** | 3396 /** |
| 3396 * The string value generated so far. | 3397 * The string value generated so far. |
| 3397 */ | 3398 */ |
| 3398 HInstruction result = null; | 3399 HInstruction result = null; |
| 3399 | 3400 |
| 3400 StringBuilderVisitor(this.builder); | 3401 StringBuilderVisitor(this.builder, this.node); |
| 3401 | 3402 |
| 3402 void visit(Node node) { | 3403 void visit(Node node) { |
| 3403 node.accept(this); | 3404 node.accept(this); |
| 3404 } | 3405 } |
| 3405 | 3406 |
| 3406 visitNode(Node node) { | 3407 visitNode(Node node) { |
| 3407 builder.compiler.internalError('unexpected node', node: node); | 3408 builder.compiler.internalError('unexpected node', node: node); |
| 3408 } | 3409 } |
| 3409 | 3410 |
| 3410 void visitExpression(Node node) { | 3411 void visitExpression(Node node) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3424 | 3425 |
| 3425 void visitStringJuxtaposition(StringJuxtaposition node) { | 3426 void visitStringJuxtaposition(StringJuxtaposition node) { |
| 3426 node.visitChildren(this); | 3427 node.visitChildren(this); |
| 3427 } | 3428 } |
| 3428 | 3429 |
| 3429 void visitNodeList(NodeList node) { | 3430 void visitNodeList(NodeList node) { |
| 3430 node.visitChildren(this); | 3431 node.visitChildren(this); |
| 3431 } | 3432 } |
| 3432 | 3433 |
| 3433 HInstruction concat(HInstruction left, HInstruction right) { | 3434 HInstruction concat(HInstruction left, HInstruction right) { |
| 3434 HInstruction instruction = new HStringConcat(left, right); | 3435 HInstruction instruction = new HStringConcat(left, right, node); |
| 3435 builder.add(instruction); | 3436 builder.add(instruction); |
| 3436 return instruction; | 3437 return instruction; |
| 3437 } | 3438 } |
| 3438 } | 3439 } |
| OLD | NEW |