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 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2391 inputs.add(closureTarget); | 2391 inputs.add(closureTarget); |
2392 addDynamicSendArgumentsToList(node, inputs); | 2392 addDynamicSendArgumentsToList(node, inputs); |
2393 pushWithPosition(new HInvokeClosure(selector, inputs), node); | 2393 pushWithPosition(new HInvokeClosure(selector, inputs), node); |
2394 } | 2394 } |
2395 | 2395 |
2396 void handleForeignJs(Send node) { | 2396 void handleForeignJs(Send node) { |
2397 Link<Node> link = node.arguments; | 2397 Link<Node> link = node.arguments; |
2398 // If the invoke is on foreign code, don't visit the first | 2398 // If the invoke is on foreign code, don't visit the first |
2399 // argument, which is the type, and the second argument, | 2399 // argument, which is the type, and the second argument, |
2400 // which is the foreign code. | 2400 // which is the foreign code. |
2401 if (link.isEmpty() || link.tail.isEmpty()) { | 2401 if (link.isEmpty() || link.isEmpty()) { |
2402 compiler.cancel('At least two arguments expected', | 2402 compiler.cancel('At least two arguments expected', |
2403 node: node.argumentsNode); | 2403 node: node.argumentsNode); |
2404 } | 2404 } |
| 2405 link = link.tail.tail; |
2405 List<HInstruction> inputs = <HInstruction>[]; | 2406 List<HInstruction> inputs = <HInstruction>[]; |
2406 Node type = link.head; | 2407 addGenericSendArgumentsToList(link, inputs); |
2407 Node code = link.tail.head; | 2408 Node type = node.arguments.head; |
2408 addGenericSendArgumentsToList(link.tail.tail, inputs); | 2409 Node literal = node.arguments.tail.head; |
2409 | 2410 if (literal is !StringNode || literal.dynamic.isInterpolation) { |
| 2411 compiler.cancel('JS code must be a string literal', node: literal); |
| 2412 } |
2410 if (type is !LiteralString) { | 2413 if (type is !LiteralString) { |
2411 // The type must not be a juxtaposition or interpolation. | 2414 compiler.cancel( |
2412 compiler.cancel('The type of a JS expression must be a string literal', | 2415 'The type of a JS expression must be a string literal', node: type); |
2413 node: type); | |
2414 } | 2416 } |
2415 LiteralString typeString = type; | 2417 push(new HForeign( |
2416 | 2418 literal.dynamic.dartString, type.dynamic.dartString, inputs)); |
2417 if (code is StringNode) { | |
2418 StringNode codeString = code; | |
2419 if (!codeString.isInterpolation) { | |
2420 // codeString may not be an interpolation, but may be a juxtaposition. | |
2421 push(new HForeign(codeString.dartString, | |
2422 typeString.dartString, | |
2423 inputs)); | |
2424 return; | |
2425 } | |
2426 } | |
2427 compiler.cancel('JS code must be a string literal', node: literal); | |
2428 } | 2419 } |
2429 | 2420 |
2430 void handleForeignUnintercepted(Send node) { | 2421 void handleForeignUnintercepted(Send node) { |
2431 Link<Node> link = node.arguments; | 2422 Link<Node> link = node.arguments; |
2432 if (!link.tail.isEmpty()) { | 2423 if (!link.tail.isEmpty()) { |
2433 compiler.cancel( | 2424 compiler.cancel( |
2434 'More than one expression in UNINTERCEPTED()', node: node); | 2425 'More than one expression in UNINTERCEPTED()', node: node); |
2435 } | 2426 } |
2436 Expression expression = link.head; | 2427 Expression expression = link.head; |
2437 disableMethodInterception(); | 2428 disableMethodInterception(); |
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4199 new HSubGraphBlockInformation(elseBranch.graph)); | 4190 new HSubGraphBlockInformation(elseBranch.graph)); |
4200 | 4191 |
4201 HBasicBlock conditionStartBlock = conditionBranch.block; | 4192 HBasicBlock conditionStartBlock = conditionBranch.block; |
4202 conditionStartBlock.setBlockFlow(info, joinBlock); | 4193 conditionStartBlock.setBlockFlow(info, joinBlock); |
4203 SubGraph conditionGraph = conditionBranch.graph; | 4194 SubGraph conditionGraph = conditionBranch.graph; |
4204 HIf branch = conditionGraph.end.last; | 4195 HIf branch = conditionGraph.end.last; |
4205 assert(branch is HIf); | 4196 assert(branch is HIf); |
4206 branch.blockInformation = conditionStartBlock.blockFlow; | 4197 branch.blockInformation = conditionStartBlock.blockFlow; |
4207 } | 4198 } |
4208 } | 4199 } |
OLD | NEW |