| 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 26 matching lines...) Expand all Loading... |
| 37 if (name === '>>=') return const SourceString('shr'); | 37 if (name === '>>=') return const SourceString('shr'); |
| 38 if (name === '|=') return const SourceString('or'); | 38 if (name === '|=') return const SourceString('or'); |
| 39 if (name === '&=') return const SourceString('and'); | 39 if (name === '&=') return const SourceString('and'); |
| 40 if (name === '^=') return const SourceString('xor'); | 40 if (name === '^=') return const SourceString('xor'); |
| 41 if (name === '++') return const SourceString('add'); | 41 if (name === '++') return const SourceString('add'); |
| 42 if (name === '--') return const SourceString('sub'); | 42 if (name === '--') return const SourceString('sub'); |
| 43 compiler.unimplemented('Unknown operator', node: op); | 43 compiler.unimplemented('Unknown operator', node: op); |
| 44 } | 44 } |
| 45 | 45 |
| 46 Element getStaticInterceptor(SourceString name, int parameters) { | 46 Element getStaticInterceptor(SourceString name, int parameters) { |
| 47 String mangledName = "builtin\$${name}\$${parameters}"; | 47 String mangledName = "builtin\$${name.slowToString()}\$${parameters}"; |
| 48 Element result = compiler.findHelper(new SourceString(mangledName)); | 48 Element result = compiler.findHelper(new SourceString(mangledName)); |
| 49 return result; | 49 return result; |
| 50 } | 50 } |
| 51 | 51 |
| 52 Element getStaticGetInterceptor(SourceString name) { | 52 Element getStaticGetInterceptor(SourceString name) { |
| 53 String mangledName = "builtin\$get\$${name}"; | 53 String mangledName = "builtin\$get\$${name.slowToString()}"; |
| 54 Element result = compiler.findHelper(new SourceString(mangledName)); | 54 Element result = compiler.findHelper(new SourceString(mangledName)); |
| 55 return result; | 55 return result; |
| 56 } | 56 } |
| 57 | 57 |
| 58 Element getStaticSetInterceptor(SourceString name) { | 58 Element getStaticSetInterceptor(SourceString name) { |
| 59 String mangledName = "builtin\$set\$${name}"; | 59 String mangledName = "builtin\$set\$${name.slowToString()}"; |
| 60 Element result = compiler.findHelper(new SourceString(mangledName)); | 60 Element result = compiler.findHelper(new SourceString(mangledName)); |
| 61 return result; | 61 return result; |
| 62 } | 62 } |
| 63 | 63 |
| 64 Element getOperatorInterceptor(Operator op) { | 64 Element getOperatorInterceptor(Operator op) { |
| 65 SourceString name = mapOperatorToMethodName(op); | 65 SourceString name = mapOperatorToMethodName(op); |
| 66 Element result = compiler.findHelper(name); | 66 Element result = compiler.findHelper(name); |
| 67 return result; | 67 return result; |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 // with the set of locals we got after visiting the then | 1189 // with the set of locals we got after visiting the then |
| 1190 // part of the if. | 1190 // part of the if. |
| 1191 open(joinBlock); | 1191 open(joinBlock); |
| 1192 if (joinBlock.predecessors.length == 2) { | 1192 if (joinBlock.predecessors.length == 2) { |
| 1193 localsHandler.mergeWith(thenLocals, joinBlock); | 1193 localsHandler.mergeWith(thenLocals, joinBlock); |
| 1194 } | 1194 } |
| 1195 } | 1195 } |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 SourceString unquote(LiteralString literal, int start) { | 1198 SourceString unquote(LiteralString literal, int start) { |
| 1199 String str = '${literal.value}'; | 1199 String str = '${literal.value.slowToString()}'; |
| 1200 int quotes = 1; | 1200 int quotes = 1; |
| 1201 String quote = str[start]; | 1201 String quote = str[start]; |
| 1202 while (str[quotes + start] === quote) quotes++; | 1202 while (str[quotes + start] === quote) quotes++; |
| 1203 return new SourceString(str.substring(quotes + start, str.length - quotes)); | 1203 return new SourceString(str.substring(quotes + start, str.length - quotes)); |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 void visitLogicalAndOr(Send node, Operator op) { | 1206 void visitLogicalAndOr(Send node, Operator op) { |
| 1207 // x && y is transformed into: | 1207 // x && y is transformed into: |
| 1208 // t0 = boolify(x); | 1208 // t0 = boolify(x); |
| 1209 // if (t0) t1 = boolify(y); | 1209 // if (t0) t1 = boolify(y); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 closureTarget = localsHandler.readLocal(element); | 1655 closureTarget = localsHandler.readLocal(element); |
| 1656 } | 1656 } |
| 1657 var inputs = <HInstruction>[]; | 1657 var inputs = <HInstruction>[]; |
| 1658 inputs.add(closureTarget); | 1658 inputs.add(closureTarget); |
| 1659 addDynamicSendArgumentsToList(node, inputs); | 1659 addDynamicSendArgumentsToList(node, inputs); |
| 1660 push(new HInvokeClosure(selector, inputs)); | 1660 push(new HInvokeClosure(selector, inputs)); |
| 1661 } | 1661 } |
| 1662 | 1662 |
| 1663 visitForeignSend(Send node) { | 1663 visitForeignSend(Send node) { |
| 1664 Identifier selector = node.selector; | 1664 Identifier selector = node.selector; |
| 1665 switch (selector.source.stringValue) { | 1665 switch (selector.source.slowToString()) { |
| 1666 case "JS": | 1666 case "JS": |
| 1667 Link<Node> link = node.arguments; | 1667 Link<Node> link = node.arguments; |
| 1668 // If the invoke is on foreign code, don't visit the first | 1668 // If the invoke is on foreign code, don't visit the first |
| 1669 // argument, which is the type, and the second argument, | 1669 // argument, which is the type, and the second argument, |
| 1670 // which is the foreign code. | 1670 // which is the foreign code. |
| 1671 link = link.tail.tail; | 1671 link = link.tail.tail; |
| 1672 List<HInstruction> inputs = <HInstruction>[]; | 1672 List<HInstruction> inputs = <HInstruction>[]; |
| 1673 addGenericSendArgumentsToList(link, inputs); | 1673 addGenericSendArgumentsToList(link, inputs); |
| 1674 LiteralString type = node.arguments.head; | 1674 LiteralString type = node.arguments.head; |
| 1675 LiteralString literal = node.arguments.tail.head; | 1675 LiteralString literal = node.arguments.tail.head; |
| 1676 compiler.ensure(literal is LiteralString); | 1676 compiler.ensure(literal is LiteralString); |
| 1677 compiler.ensure(type is LiteralString); | 1677 compiler.ensure(type is LiteralString); |
| 1678 compiler.ensure(literal.value.stringValue[0] == '@'); | 1678 compiler.ensure(literal.value.slowToString()[0] == '@'); |
| 1679 push(new HForeign(unquote(literal, 1), unquote(type, 0), inputs)); | 1679 push(new HForeign(unquote(literal, 1), unquote(type, 0), inputs)); |
| 1680 break; | 1680 break; |
| 1681 case "UNINTERCEPTED": | 1681 case "UNINTERCEPTED": |
| 1682 Link<Node> link = node.arguments; | 1682 Link<Node> link = node.arguments; |
| 1683 if (!link.tail.isEmpty()) { | 1683 if (!link.tail.isEmpty()) { |
| 1684 compiler.cancel('More than one expression in UNINTERCEPTED()'); | 1684 compiler.cancel('More than one expression in UNINTERCEPTED()'); |
| 1685 } | 1685 } |
| 1686 Expression expression = link.head; | 1686 Expression expression = link.head; |
| 1687 disableMethodInterception(); | 1687 disableMethodInterception(); |
| 1688 visit(expression); | 1688 visit(expression); |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 } | 2290 } |
| 2291 | 2291 |
| 2292 visitCatchBlock(CatchBlock node) { | 2292 visitCatchBlock(CatchBlock node) { |
| 2293 visit(node.block); | 2293 visit(node.block); |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 visitTypedef(Typedef node) { | 2296 visitTypedef(Typedef node) { |
| 2297 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); | 2297 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); |
| 2298 } | 2298 } |
| 2299 } | 2299 } |
| OLD | NEW |