| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 import 'package:kernel/frontend/accessors.dart' | 6 import 'package:kernel/frontend/accessors.dart' |
| 7 show | 7 show |
| 8 Accessor, | 8 Accessor, |
| 9 IndexAccessor, | 9 IndexAccessor, |
| 10 NullAwarePropertyAccessor, | 10 NullAwarePropertyAccessor, |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 internalError(node, "no parent"); | 843 internalError(node, "no parent"); |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 } | 846 } |
| 847 | 847 |
| 848 return result; | 848 return result; |
| 849 } | 849 } |
| 850 | 850 |
| 851 @override | 851 @override |
| 852 ir.BoolLiteral visitLiteralBool(LiteralBool node) { | 852 ir.BoolLiteral visitLiteralBool(LiteralBool node) { |
| 853 return new ir.BoolLiteral(node.value); | 853 return associateNode(new ir.BoolLiteral(node.value), node); |
| 854 } | 854 } |
| 855 | 855 |
| 856 @override | 856 @override |
| 857 ir.DoubleLiteral visitLiteralDouble(LiteralDouble node) { | 857 ir.DoubleLiteral visitLiteralDouble(LiteralDouble node) { |
| 858 return new ir.DoubleLiteral(node.value); | 858 return associateNode(new ir.DoubleLiteral(node.value), node); |
| 859 } | 859 } |
| 860 | 860 |
| 861 @override | 861 @override |
| 862 ir.IntLiteral visitLiteralInt(LiteralInt node) { | 862 ir.IntLiteral visitLiteralInt(LiteralInt node) { |
| 863 return new ir.IntLiteral(node.value); | 863 return associateNode(new ir.IntLiteral(node.value), node); |
| 864 } | 864 } |
| 865 | 865 |
| 866 @override | 866 @override |
| 867 ir.ListLiteral visitLiteralList(LiteralList node) { | 867 ir.ListLiteral visitLiteralList(LiteralList node) { |
| 868 // TODO(ahe): Type arguments. | 868 // TODO(ahe): Type arguments. |
| 869 List<ir.Expression> elements = <ir.Expression>[]; | 869 List<ir.Expression> elements = <ir.Expression>[]; |
| 870 for (Expression element in node.elements.nodes) { | 870 for (Expression element in node.elements.nodes) { |
| 871 elements.add(visitForValue(element)); | 871 elements.add(visitForValue(element)); |
| 872 } | 872 } |
| 873 return associateNode( | 873 return associateNode( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 904 } | 904 } |
| 905 | 905 |
| 906 @override | 906 @override |
| 907 ir.NullLiteral visitLiteralNull(LiteralNull node) { | 907 ir.NullLiteral visitLiteralNull(LiteralNull node) { |
| 908 return new ir.NullLiteral(); | 908 return new ir.NullLiteral(); |
| 909 } | 909 } |
| 910 | 910 |
| 911 @override | 911 @override |
| 912 ir.Expression visitLiteralString(LiteralString node) { | 912 ir.Expression visitLiteralString(LiteralString node) { |
| 913 if (node.dartString == null) return new ir.InvalidExpression(); | 913 if (node.dartString == null) return new ir.InvalidExpression(); |
| 914 return new ir.StringLiteral(node.dartString.slowToString()); | 914 return associateNode(new ir.StringLiteral(node.dartString.slowToString()), |
| 915 node); |
| 915 } | 916 } |
| 916 | 917 |
| 917 @override | 918 @override |
| 918 ir.SymbolLiteral visitLiteralSymbol(LiteralSymbol node) { | 919 ir.SymbolLiteral visitLiteralSymbol(LiteralSymbol node) { |
| 919 var result = new ir.SymbolLiteral(node.slowNameString); | 920 var result = new ir.SymbolLiteral(node.slowNameString); |
| 920 return associateNode(result, node); | 921 return associateNode(result, node); |
| 921 } | 922 } |
| 922 | 923 |
| 923 @override | 924 @override |
| 924 visitMetadata(Metadata node) { | 925 visitMetadata(Metadata node) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 ir.SwitchCase irCase = casesIterator.current; | 1035 ir.SwitchCase irCase = casesIterator.current; |
| 1035 List<ir.Statement> statements = <ir.Statement>[]; | 1036 List<ir.Statement> statements = <ir.Statement>[]; |
| 1036 bool hasVariableDeclaration = false; | 1037 bool hasVariableDeclaration = false; |
| 1037 for (Statement statement in caseNode.statements.nodes) { | 1038 for (Statement statement in caseNode.statements.nodes) { |
| 1038 if (buildStatement(statement, statements)) { | 1039 if (buildStatement(statement, statements)) { |
| 1039 hasVariableDeclaration = true; | 1040 hasVariableDeclaration = true; |
| 1040 } | 1041 } |
| 1041 } | 1042 } |
| 1042 if (statements.isEmpty || fallsThrough(statements.last)) { | 1043 if (statements.isEmpty || fallsThrough(statements.last)) { |
| 1043 if (isLastCase) { | 1044 if (isLastCase) { |
| 1044 statements.add(new ir.BreakStatement( | 1045 if (!caseNode.isDefaultCase) { |
| 1045 getBreakTarget(elements.getTargetDefinition(node)))); | 1046 statements.add(new ir.BreakStatement( |
| 1047 getBreakTarget(elements.getTargetDefinition(node)))); |
| 1048 } |
| 1046 } else { | 1049 } else { |
| 1047 statements.add(new ir.ExpressionStatement(new ir.Throw( | 1050 statements.add(new ir.ExpressionStatement(new ir.Throw( |
| 1048 new ir.ConstructorInvocation( | 1051 new ir.ConstructorInvocation( |
| 1049 kernel.getFallThroughErrorConstructor(), | 1052 kernel.getFallThroughErrorConstructor(), |
| 1050 new ir.Arguments.empty())))); | 1053 new ir.Arguments.empty())))); |
| 1051 } | 1054 } |
| 1052 } | 1055 } |
| 1053 ir.Statement body = new ir.Block(statements); | 1056 ir.Statement body = new ir.Block(statements); |
| 1054 irCase.body = body; | 1057 irCase.body = body; |
| 1055 body.parent = irCase; | 1058 body.parent = irCase; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 return buildCompoundAssignment( | 1255 return buildCompoundAssignment( |
| 1253 node, | 1256 node, |
| 1254 buildIndexAccessor(receiver, index), | 1257 buildIndexAccessor(receiver, index), |
| 1255 kernel.irName(operator.selectorName, currentElement), | 1258 kernel.irName(operator.selectorName, currentElement), |
| 1256 visitForValue(rhs)); | 1259 visitForValue(rhs)); |
| 1257 } | 1260 } |
| 1258 | 1261 |
| 1259 @override | 1262 @override |
| 1260 ir.InvocationExpression visitConstConstructorInvoke( | 1263 ir.InvocationExpression visitConstConstructorInvoke( |
| 1261 NewExpression node, ConstructedConstantExpression constant, _) { | 1264 NewExpression node, ConstructedConstantExpression constant, _) { |
| 1262 return buildConstructorInvoke(node, isConst: true); | 1265 return associateNode(buildConstructorInvoke(node, isConst: true), node); |
| 1263 } | 1266 } |
| 1264 | 1267 |
| 1265 @override | 1268 @override |
| 1266 visitConstantGet(Send node, ConstantExpression constant, _) { | 1269 visitConstantGet(Send node, ConstantExpression constant, _) { |
| 1267 // TODO(ahe): This method is never called. Is it a bug in semantic visitor? | 1270 // TODO(ahe): This method is never called. Is it a bug in semantic visitor? |
| 1268 return internalError(node, "ConstantGet"); | 1271 return internalError(node, "ConstantGet"); |
| 1269 } | 1272 } |
| 1270 | 1273 |
| 1271 @override | 1274 @override |
| 1272 visitConstantInvoke(Send node, ConstantExpression constant, | 1275 visitConstantInvoke(Send node, ConstantExpression constant, |
| (...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2872 : this(null, true, node, initializers); | 2875 : this(null, true, node, initializers); |
| 2873 | 2876 |
| 2874 accept(ir.Visitor v) => throw "unsupported"; | 2877 accept(ir.Visitor v) => throw "unsupported"; |
| 2875 | 2878 |
| 2876 visitChildren(ir.Visitor v) => throw "unsupported"; | 2879 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 2877 | 2880 |
| 2878 String toString() { | 2881 String toString() { |
| 2879 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2882 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 2880 } | 2883 } |
| 2881 } | 2884 } |
| OLD | NEW |