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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1536 use(node.receiver); | 1536 use(node.receiver); |
1537 List<js.Expression> arguments = <js.Expression>[pop()]; | 1537 List<js.Expression> arguments = <js.Expression>[pop()]; |
1538 push(new js.Call(interceptor, arguments), node); | 1538 push(new js.Call(interceptor, arguments), node); |
1539 } | 1539 } |
1540 | 1540 |
1541 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { | 1541 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { |
1542 use(node.receiver); | 1542 use(node.receiver); |
1543 js.Expression object = pop(); | 1543 js.Expression object = pop(); |
1544 SourceString name = node.selector.name; | 1544 SourceString name = node.selector.name; |
1545 String methodName; | 1545 String methodName; |
1546 List<js.Expression> arguments; | 1546 List<js.Expression> arguments = visitArguments(node.inputs); |
1547 Element target = node.element; | 1547 Element target = node.element; |
1548 | 1548 |
1549 // Avoid adding the generative constructor name to the list of | 1549 // Avoid adding the generative constructor name to the list of |
1550 // seen selectors. | 1550 // seen selectors. |
1551 if (target != null && target.isGenerativeConstructorBody()) { | 1551 if (target != null && target.isGenerativeConstructorBody()) { |
1552 methodName = name.slowToString(); | 1552 methodName = name.slowToString(); |
1553 arguments = visitArguments(node.inputs); | 1553 } else if (target == backend.jsArrayAdd) { |
1554 methodName = 'push'; | |
1555 } else if (target == backend.jsArrayRemoveLast) { | |
1556 methodName = 'pop'; | |
1557 } else if (target == backend.jsStringSplit) { | |
1558 methodName = 'split'; | |
1559 world.registerInstantiatedClass(compiler.listClass); | |
kasperl
2012/11/29 08:10:48
Add a comment that explains why you need to instan
ngeoffray
2012/11/29 08:46:51
Done.
| |
1560 } else if (target == backend.jsStringConcat) { | |
1561 push(new js.Binary('+', object, arguments[0]), node); | |
1562 return; | |
1554 } else { | 1563 } else { |
1555 methodName = backend.namer.instanceMethodInvocationName( | 1564 methodName = backend.namer.instanceMethodInvocationName( |
1556 node.selector.library, name, node.selector); | 1565 node.selector.library, name, node.selector); |
1557 arguments = visitArguments(node.inputs); | |
1558 bool inLoop = node.block.enclosingLoopHeader != null; | 1566 bool inLoop = node.block.enclosingLoopHeader != null; |
1559 | 1567 |
1560 Selector selector = getOptimizedSelectorFor(node, node.selector); | 1568 Selector selector = getOptimizedSelectorFor(node, node.selector); |
1561 if (node.isInterceptorCall) { | 1569 if (node.isInterceptorCall) { |
1562 backend.addInterceptedSelector(selector); | 1570 backend.addInterceptedSelector(selector); |
1563 } | 1571 } |
1564 // Register this invocation to collect the types used at all call sites. | 1572 // Register this invocation to collect the types used at all call sites. |
1565 backend.registerDynamicInvocation(node, selector, types); | 1573 backend.registerDynamicInvocation(node, selector, types); |
1566 | 1574 |
1567 // If we don't know what we're calling or if we are calling a getter, | 1575 // If we don't know what we're calling or if we are calling a getter, |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3020 if (leftType.canBeNull() && rightType.canBeNull()) { | 3028 if (leftType.canBeNull() && rightType.canBeNull()) { |
3021 if (left.isConstantNull() || right.isConstantNull() || | 3029 if (left.isConstantNull() || right.isConstantNull() || |
3022 (leftType.isPrimitive() && leftType == rightType)) { | 3030 (leftType.isPrimitive() && leftType == rightType)) { |
3023 return '=='; | 3031 return '=='; |
3024 } | 3032 } |
3025 return null; | 3033 return null; |
3026 } else { | 3034 } else { |
3027 return '==='; | 3035 return '==='; |
3028 } | 3036 } |
3029 } | 3037 } |
OLD | NEW |