| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1139 |
| 1140 void visitLiteralDouble(LiteralDouble node) { | 1140 void visitLiteralDouble(LiteralDouble node) { |
| 1141 push(new HLiteral(node.value, HType.DOUBLE)); | 1141 push(new HLiteral(node.value, HType.DOUBLE)); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 void visitLiteralBool(LiteralBool node) { | 1144 void visitLiteralBool(LiteralBool node) { |
| 1145 push(new HLiteral(node.value, HType.BOOLEAN)); | 1145 push(new HLiteral(node.value, HType.BOOLEAN)); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 void visitLiteralString(LiteralString node) { | 1148 void visitLiteralString(LiteralString node) { |
| 1149 push(new HLiteral(new QuotedString.explicit(node.value), HType.STRING)); | 1149 push(new HLiteral(node.quotedString, HType.STRING)); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 void visitLiteralNull(LiteralNull node) { | 1152 void visitLiteralNull(LiteralNull node) { |
| 1153 push(new HLiteral(null, HType.UNKNOWN)); | 1153 push(new HLiteral(null, HType.UNKNOWN)); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 visitNodeList(NodeList node) { | 1156 visitNodeList(NodeList node) { |
| 1157 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { | 1157 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { |
| 1158 visit(link.head); | 1158 visit(link.head); |
| 1159 } | 1159 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 definitions = joinDefinitions(joinBlock, thenDefinitions, definitions); | 1250 definitions = joinDefinitions(joinBlock, thenDefinitions, definitions); |
| 1251 HPhi phi = new HPhi.manyInputs(null, [thenInstruction, elseInstruction]); | 1251 HPhi phi = new HPhi.manyInputs(null, [thenInstruction, elseInstruction]); |
| 1252 joinBlock.addPhi(phi); | 1252 joinBlock.addPhi(phi); |
| 1253 stack.add(phi); | 1253 stack.add(phi); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 visitStringInterpolation(StringInterpolation node) { | 1256 visitStringInterpolation(StringInterpolation node) { |
| 1257 Operator op = new Operator.synthetic("+"); | 1257 Operator op = new Operator.synthetic("+"); |
| 1258 HInstruction target = new HStatic(interceptors.getOperatorInterceptor(op)); | 1258 HInstruction target = new HStatic(interceptors.getOperatorInterceptor(op)); |
| 1259 add(target); | 1259 add(target); |
| 1260 // Ensure that string literals are marked with the correct quoting | 1260 visit(node.string); |
| 1261 // style and presence of quotes (left quote only on the first one, | 1261 // Handle the parts here, to avoid recreating [target]. |
| 1262 // right quote only on the last one). | |
| 1263 int quoteFlags = QuotedString.flagsFromLeftQuote(node.string.value); | |
| 1264 // The loop is complicated because we have to do something extra for | |
| 1265 // the *last* element. To do that, we handle the [string] of a part | |
| 1266 // in the next iteration, or after the loop for the last element. | |
| 1267 int firstPartFlags = quoteFlags | QuotedString.HAS_LEFT_QUOTE; | |
| 1268 push(new HLiteral(new QuotedString(node.string.value, firstPartFlags), | |
| 1269 HType.STRING)); | |
| 1270 | |
| 1271 SourceString string = null; | |
| 1272 for (StringInterpolationPart part in node.parts) { | 1262 for (StringInterpolationPart part in node.parts) { |
| 1273 HInstruction prefix = pop(); | 1263 HInstruction prefix = pop(); |
| 1274 if (string != null) { | |
| 1275 push(new HLiteral(new QuotedString(string, quoteFlags), | |
| 1276 HType.STRING)); | |
| 1277 push(new HAdd(target, prefix, pop())); | |
| 1278 prefix = pop(); | |
| 1279 } | |
| 1280 visit(part.expression); | 1264 visit(part.expression); |
| 1281 push(new HAdd(target, prefix, pop())); | 1265 push(new HAdd(target, prefix, pop())); |
| 1282 string = part.string.value; | 1266 prefix = pop(); |
| 1267 visit(part.string); |
| 1268 push(new HAdd(target, prefix, pop())); |
| 1283 } | 1269 } |
| 1284 HInstruction prefix = pop(); | |
| 1285 int lastPartFlags = quoteFlags | QuotedString.HAS_RIGHT_QUOTE; | |
| 1286 push(new HLiteral(new QuotedString(string, lastPartFlags), | |
| 1287 HType.STRING)); | |
| 1288 push(new HAdd(target, prefix, pop())); | |
| 1289 } | 1270 } |
| 1290 | 1271 |
| 1291 visitStringInterpolationPart(StringInterpolationPart node) { | 1272 visitStringInterpolationPart(StringInterpolationPart node) { |
| 1292 // The parts are iterated in visitStringInterpolation. | 1273 // The parts are iterated in visitStringInterpolation. |
| 1293 unreachable(); | 1274 unreachable(); |
| 1294 } | 1275 } |
| 1295 | 1276 |
| 1296 visitEmptyStatement(EmptyStatement node) { | 1277 visitEmptyStatement(EmptyStatement node) { |
| 1297 compiler.unimplemented('SsaBuilder.visitEmptyStatement', | 1278 compiler.unimplemented('SsaBuilder.visitEmptyStatement', |
| 1298 node: node); | 1279 node: node); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 } | 1387 } |
| 1407 | 1388 |
| 1408 visitCatchBlock(CatchBlock node) { | 1389 visitCatchBlock(CatchBlock node) { |
| 1409 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); | 1390 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); |
| 1410 } | 1391 } |
| 1411 | 1392 |
| 1412 visitTypedef(Typedef node) { | 1393 visitTypedef(Typedef node) { |
| 1413 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); | 1394 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); |
| 1414 } | 1395 } |
| 1415 } | 1396 } |
| OLD | NEW |