| 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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 internalError(node, "no parent"); | 841 internalError(node, "no parent"); |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 } | 844 } |
| 845 | 845 |
| 846 return result; | 846 return result; |
| 847 } | 847 } |
| 848 | 848 |
| 849 @override | 849 @override |
| 850 ir.BoolLiteral visitLiteralBool(LiteralBool node) { | 850 ir.BoolLiteral visitLiteralBool(LiteralBool node) { |
| 851 return new ir.BoolLiteral(node.value); | 851 return associateNode(new ir.BoolLiteral(node.value), node); |
| 852 } | 852 } |
| 853 | 853 |
| 854 @override | 854 @override |
| 855 ir.DoubleLiteral visitLiteralDouble(LiteralDouble node) { | 855 ir.DoubleLiteral visitLiteralDouble(LiteralDouble node) { |
| 856 return new ir.DoubleLiteral(node.value); | 856 return associateNode(new ir.DoubleLiteral(node.value), node); |
| 857 } | 857 } |
| 858 | 858 |
| 859 @override | 859 @override |
| 860 ir.IntLiteral visitLiteralInt(LiteralInt node) { | 860 ir.IntLiteral visitLiteralInt(LiteralInt node) { |
| 861 return new ir.IntLiteral(node.value); | 861 return associateNode(new ir.IntLiteral(node.value), node); |
| 862 } | 862 } |
| 863 | 863 |
| 864 @override | 864 @override |
| 865 ir.ListLiteral visitLiteralList(LiteralList node) { | 865 ir.ListLiteral visitLiteralList(LiteralList node) { |
| 866 // TODO(ahe): Type arguments. | 866 // TODO(ahe): Type arguments. |
| 867 List<ir.Expression> elements = <ir.Expression>[]; | 867 List<ir.Expression> elements = <ir.Expression>[]; |
| 868 for (Expression element in node.elements.nodes) { | 868 for (Expression element in node.elements.nodes) { |
| 869 elements.add(visitForValue(element)); | 869 elements.add(visitForValue(element)); |
| 870 } | 870 } |
| 871 return associateNode( | 871 return associateNode( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 902 } | 902 } |
| 903 | 903 |
| 904 @override | 904 @override |
| 905 ir.NullLiteral visitLiteralNull(LiteralNull node) { | 905 ir.NullLiteral visitLiteralNull(LiteralNull node) { |
| 906 return new ir.NullLiteral(); | 906 return new ir.NullLiteral(); |
| 907 } | 907 } |
| 908 | 908 |
| 909 @override | 909 @override |
| 910 ir.Expression visitLiteralString(LiteralString node) { | 910 ir.Expression visitLiteralString(LiteralString node) { |
| 911 if (node.dartString == null) return new ir.InvalidExpression(); | 911 if (node.dartString == null) return new ir.InvalidExpression(); |
| 912 return new ir.StringLiteral(node.dartString.slowToString()); | 912 return associateNode(new ir.StringLiteral(node.dartString.slowToString()), |
| 913 node); |
| 913 } | 914 } |
| 914 | 915 |
| 915 @override | 916 @override |
| 916 ir.SymbolLiteral visitLiteralSymbol(LiteralSymbol node) { | 917 ir.SymbolLiteral visitLiteralSymbol(LiteralSymbol node) { |
| 917 var result = new ir.SymbolLiteral(node.slowNameString); | 918 var result = new ir.SymbolLiteral(node.slowNameString); |
| 918 return associateNode(result, node); | 919 return associateNode(result, node); |
| 919 } | 920 } |
| 920 | 921 |
| 921 @override | 922 @override |
| 922 visitMetadata(Metadata node) { | 923 visitMetadata(Metadata node) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 ir.SwitchCase irCase = casesIterator.current; | 1033 ir.SwitchCase irCase = casesIterator.current; |
| 1033 List<ir.Statement> statements = <ir.Statement>[]; | 1034 List<ir.Statement> statements = <ir.Statement>[]; |
| 1034 bool hasVariableDeclaration = false; | 1035 bool hasVariableDeclaration = false; |
| 1035 for (Statement statement in caseNode.statements.nodes) { | 1036 for (Statement statement in caseNode.statements.nodes) { |
| 1036 if (buildStatement(statement, statements)) { | 1037 if (buildStatement(statement, statements)) { |
| 1037 hasVariableDeclaration = true; | 1038 hasVariableDeclaration = true; |
| 1038 } | 1039 } |
| 1039 } | 1040 } |
| 1040 if (statements.isEmpty || fallsThrough(statements.last)) { | 1041 if (statements.isEmpty || fallsThrough(statements.last)) { |
| 1041 if (isLastCase) { | 1042 if (isLastCase) { |
| 1042 statements.add(new ir.BreakStatement( | 1043 if (!caseNode.isDefaultCase) { |
| 1043 getBreakTarget(elements.getTargetDefinition(node)))); | 1044 statements.add(new ir.BreakStatement( |
| 1045 getBreakTarget(elements.getTargetDefinition(node)))); |
| 1046 } |
| 1044 } else { | 1047 } else { |
| 1045 statements.add(new ir.ExpressionStatement(new ir.Throw( | 1048 statements.add(new ir.ExpressionStatement(new ir.Throw( |
| 1046 new ir.ConstructorInvocation( | 1049 new ir.ConstructorInvocation( |
| 1047 kernel.getFallThroughErrorConstructor(), | 1050 kernel.getFallThroughErrorConstructor(), |
| 1048 new ir.Arguments.empty())))); | 1051 new ir.Arguments.empty())))); |
| 1049 } | 1052 } |
| 1050 } | 1053 } |
| 1051 ir.Statement body = new ir.Block(statements); | 1054 ir.Statement body = new ir.Block(statements); |
| 1052 irCase.body = body; | 1055 irCase.body = body; |
| 1053 body.parent = irCase; | 1056 body.parent = irCase; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 return buildCompoundAssignment( | 1239 return buildCompoundAssignment( |
| 1237 node, | 1240 node, |
| 1238 buildIndexAccessor(receiver, index), | 1241 buildIndexAccessor(receiver, index), |
| 1239 kernel.irName(operator.selectorName, currentElement), | 1242 kernel.irName(operator.selectorName, currentElement), |
| 1240 visitForValue(rhs)); | 1243 visitForValue(rhs)); |
| 1241 } | 1244 } |
| 1242 | 1245 |
| 1243 @override | 1246 @override |
| 1244 ir.InvocationExpression visitConstConstructorInvoke( | 1247 ir.InvocationExpression visitConstConstructorInvoke( |
| 1245 NewExpression node, ConstructedConstantExpression constant, _) { | 1248 NewExpression node, ConstructedConstantExpression constant, _) { |
| 1246 return buildConstructorInvoke(node, isConst: true); | 1249 return associateNode(buildConstructorInvoke(node, isConst: true), node); |
| 1247 } | 1250 } |
| 1248 | 1251 |
| 1249 @override | 1252 @override |
| 1250 visitConstantGet(Send node, ConstantExpression constant, _) { | 1253 visitConstantGet(Send node, ConstantExpression constant, _) { |
| 1251 // TODO(ahe): This method is never called. Is it a bug in semantic visitor? | 1254 // TODO(ahe): This method is never called. Is it a bug in semantic visitor? |
| 1252 return internalError(node, "ConstantGet"); | 1255 return internalError(node, "ConstantGet"); |
| 1253 } | 1256 } |
| 1254 | 1257 |
| 1255 @override | 1258 @override |
| 1256 visitConstantInvoke(Send node, ConstantExpression constant, | 1259 visitConstantInvoke(Send node, ConstantExpression constant, |
| (...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2856 : this(null, true, node, initializers); | 2859 : this(null, true, node, initializers); |
| 2857 | 2860 |
| 2858 accept(ir.Visitor v) => throw "unsupported"; | 2861 accept(ir.Visitor v) => throw "unsupported"; |
| 2859 | 2862 |
| 2860 visitChildren(ir.Visitor v) => throw "unsupported"; | 2863 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 2861 | 2864 |
| 2862 String toString() { | 2865 String toString() { |
| 2863 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2866 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 2864 } | 2867 } |
| 2865 } | 2868 } |
| OLD | NEW |