Chromium Code Reviews| 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 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1223 ir.FunctionExpression function = | 1223 ir.FunctionExpression function = |
| 1224 new ir.FunctionExpression(buildFunctionNode(closure, body)); | 1224 new ir.FunctionExpression(buildFunctionNode(closure, body)); |
| 1225 kernel.localFunctions[closure] = function; | 1225 kernel.localFunctions[closure] = function; |
| 1226 return function; | 1226 return function; |
| 1227 }); | 1227 }); |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 @override | 1230 @override |
| 1231 ir.Expression visitCompoundIndexSet(SendSet node, Node receiver, Node index, | 1231 ir.Expression visitCompoundIndexSet(SendSet node, Node receiver, Node index, |
| 1232 AssignmentOperator operator, Node rhs, _) { | 1232 AssignmentOperator operator, Node rhs, _) { |
| 1233 // TODO(sra): Find binary operator. | |
| 1233 return buildIndexAccessor(receiver, index).buildCompoundAssignment( | 1234 return buildIndexAccessor(receiver, index).buildCompoundAssignment( |
| 1234 kernel.irName(operator.selectorName, currentElement), | 1235 kernel.irName(operator.selectorName, currentElement), |
| 1235 visitForValue(rhs), | 1236 visitForValue(rhs), |
| 1236 voidContext: isVoidContext); | 1237 voidContext: isVoidContext); |
| 1237 } | 1238 } |
| 1238 | 1239 |
| 1239 @override | 1240 @override |
| 1240 ir.InvocationExpression visitConstConstructorInvoke( | 1241 ir.InvocationExpression visitConstConstructorInvoke( |
| 1241 NewExpression node, ConstructedConstantExpression constant, _) { | 1242 NewExpression node, ConstructedConstantExpression constant, _) { |
| 1242 return buildConstructorInvoke(node, isConst: true); | 1243 return buildConstructorInvoke(node, isConst: true); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1282 node); | 1283 node); |
| 1283 } | 1284 } |
| 1284 | 1285 |
| 1285 @override | 1286 @override |
| 1286 ir.Expression handleDynamicCompounds( | 1287 ir.Expression handleDynamicCompounds( |
| 1287 Send node, Node receiver, Name name, CompoundRhs rhs, _) { | 1288 Send node, Node receiver, Name name, CompoundRhs rhs, _) { |
| 1288 ir.Expression receiverNode = | 1289 ir.Expression receiverNode = |
| 1289 receiver == null ? new ir.ThisExpression() : visitForValue(receiver); | 1290 receiver == null ? new ir.ThisExpression() : visitForValue(receiver); |
| 1290 ir.Expression compound = buildCompound( | 1291 ir.Expression compound = buildCompound( |
| 1291 PropertyAccessor.make(receiverNode, nameToIrName(name), null, null), | 1292 PropertyAccessor.make(receiverNode, nameToIrName(name), null, null), |
| 1292 rhs); | 1293 rhs, |
| 1294 node); | |
| 1293 if (compound is ir.VariableSet) { | 1295 if (compound is ir.VariableSet) { |
| 1294 associateNode(compound.value, node); | 1296 associateNode(compound.value, node); |
| 1295 } else { | 1297 } else { |
| 1296 associateNode(compound, node); | 1298 associateNode(compound, node); |
| 1297 } | 1299 } |
| 1298 return compound; | 1300 return compound; |
| 1299 } | 1301 } |
| 1300 | 1302 |
| 1301 @override | 1303 @override |
| 1302 ir.PropertySet visitDynamicPropertySet( | 1304 ir.PropertySet visitDynamicPropertySet( |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1713 | 1715 |
| 1714 ir.VariableGet buildLocalGet(LocalElement local) { | 1716 ir.VariableGet buildLocalGet(LocalElement local) { |
| 1715 return new ir.VariableGet(getLocal(local)); | 1717 return new ir.VariableGet(getLocal(local)); |
| 1716 } | 1718 } |
| 1717 | 1719 |
| 1718 @override | 1720 @override |
| 1719 ir.VariableGet handleLocalGet(Send node, LocalElement element, _) { | 1721 ir.VariableGet handleLocalGet(Send node, LocalElement element, _) { |
| 1720 return buildLocalGet(element); | 1722 return buildLocalGet(element); |
| 1721 } | 1723 } |
| 1722 | 1724 |
| 1723 ir.Expression buildCompound(Accessor accessor, CompoundRhs rhs) { | 1725 ir.Expression buildCompound(Accessor accessor, CompoundRhs rhs, |
| 1726 SendSet node) { | |
| 1724 ir.Name name = kernel.irName(rhs.operator.selectorName, currentElement); | 1727 ir.Name name = kernel.irName(rhs.operator.selectorName, currentElement); |
| 1728 ir.Expression result; | |
| 1725 switch (rhs.kind) { | 1729 switch (rhs.kind) { |
| 1726 case CompoundKind.POSTFIX: | 1730 case CompoundKind.POSTFIX: |
| 1727 return accessor.buildPostfixIncrement(name, voidContext: isVoidContext); | 1731 result = accessor.buildPostfixIncrement(name, voidContext: isVoidContext ); |
| 1732 break; | |
| 1728 | 1733 |
| 1729 case CompoundKind.PREFIX: | 1734 case CompoundKind.PREFIX: |
| 1730 return accessor.buildPrefixIncrement(name, voidContext: isVoidContext); | 1735 result = accessor.buildPrefixIncrement(name, voidContext: isVoidContext) ; |
| 1736 break; | |
| 1731 | 1737 |
| 1732 case CompoundKind.ASSIGNMENT: | 1738 case CompoundKind.ASSIGNMENT: |
| 1733 return accessor.buildCompoundAssignment(name, visitForValue(rhs.rhs), | 1739 result = accessor.buildCompoundAssignment(name, visitForValue(rhs.rhs), |
| 1734 voidContext: isVoidContext); | 1740 voidContext: isVoidContext); |
| 1741 break; | |
| 1735 } | 1742 } |
| 1743 assert(accessor.builtBinary != null); | |
| 1744 kernel.nodeToAstOperator[accessor.builtBinary] = node; | |
| 1745 if (accessor.builtGetter != null) { | |
| 1746 kernel.nodeToAst[accessor.builtGetter] = node; | |
| 1747 } | |
| 1748 return result; | |
| 1736 } | 1749 } |
| 1737 | 1750 |
| 1738 @override | 1751 @override |
| 1739 ir.Expression handleLocalCompounds( | 1752 ir.Expression handleLocalCompounds( |
| 1740 SendSet node, LocalElement local, CompoundRhs rhs, _, | 1753 SendSet node, LocalElement local, CompoundRhs rhs, _, |
| 1741 {bool isSetterValid}) { | 1754 {bool isSetterValid}) { |
| 1742 ir.Expression compound = | 1755 ir.Expression compound = |
| 1743 buildCompound(new VariableAccessor(getLocal(local)), rhs); | 1756 buildCompound(new VariableAccessor(getLocal(local)), rhs, node); |
| 1744 if (compound is ir.VariableSet) { | 1757 if (compound is ir.VariableSet) { |
| 1745 associateNode(compound.value, node); | 1758 associateNode(compound.value, node); |
| 1746 } else { | 1759 } else { |
| 1747 associateNode(compound, node); | 1760 associateNode(compound, node); |
| 1748 } | 1761 } |
| 1749 return compound; | 1762 return compound; |
| 1750 } | 1763 } |
| 1751 | 1764 |
| 1752 @override | 1765 @override |
| 1753 ir.VariableSet handleLocalSet( | 1766 ir.VariableSet handleLocalSet( |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2229 | 2242 |
| 2230 @override | 2243 @override |
| 2231 ir.Expression visitSuperCompoundIndexSet( | 2244 ir.Expression visitSuperCompoundIndexSet( |
| 2232 SendSet node, | 2245 SendSet node, |
| 2233 MethodElement getter, | 2246 MethodElement getter, |
| 2234 MethodElement setter, | 2247 MethodElement setter, |
| 2235 Node index, | 2248 Node index, |
| 2236 AssignmentOperator operator, | 2249 AssignmentOperator operator, |
| 2237 Node rhs, | 2250 Node rhs, |
| 2238 _) { | 2251 _) { |
| 2252 // TODO(sra): Find binary operator. | |
| 2239 return buildSuperIndexAccessor(index, getter, setter) | 2253 return buildSuperIndexAccessor(index, getter, setter) |
| 2240 .buildCompoundAssignment( | 2254 .buildCompoundAssignment( |
| 2241 kernel.irName(operator.selectorName, currentElement), | 2255 kernel.irName(operator.selectorName, currentElement), |
| 2242 visitForValue(rhs), | 2256 visitForValue(rhs), |
| 2243 voidContext: isVoidContext); | 2257 voidContext: isVoidContext); |
| 2244 } | 2258 } |
| 2245 | 2259 |
| 2246 @override | 2260 @override |
| 2247 ir.Initializer visitSuperConstructorInvoke( | 2261 ir.Initializer visitSuperConstructorInvoke( |
| 2248 Send node, | 2262 Send node, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2280 SendSet node, | 2294 SendSet node, |
| 2281 Element getter, | 2295 Element getter, |
| 2282 CompoundGetter getterKind, | 2296 CompoundGetter getterKind, |
| 2283 Element setter, | 2297 Element setter, |
| 2284 CompoundSetter setterKind, | 2298 CompoundSetter setterKind, |
| 2285 CompoundRhs rhs, | 2299 CompoundRhs rhs, |
| 2286 _) { | 2300 _) { |
| 2287 if (setterKind == CompoundSetter.INVALID) { | 2301 if (setterKind == CompoundSetter.INVALID) { |
| 2288 setter = null; | 2302 setter = null; |
| 2289 } | 2303 } |
| 2290 return buildCompound(buildSuperPropertyAccessor(getter, setter), rhs); | 2304 return buildCompound(buildSuperPropertyAccessor(getter, setter), rhs, node); |
| 2291 } | 2305 } |
| 2292 | 2306 |
| 2293 @override | 2307 @override |
| 2294 ir.Expression handleStaticCompounds( | 2308 ir.Expression handleStaticCompounds( |
| 2295 SendSet node, | 2309 SendSet node, |
| 2296 Element getter, | 2310 Element getter, |
| 2297 CompoundGetter getterKind, | 2311 CompoundGetter getterKind, |
| 2298 Element setter, | 2312 Element setter, |
| 2299 CompoundSetter setterKind, | 2313 CompoundSetter setterKind, |
| 2300 CompoundRhs rhs, | 2314 CompoundRhs rhs, |
| 2301 _) { | 2315 _) { |
| 2302 if (setterKind == CompoundSetter.INVALID) { | 2316 if (setterKind == CompoundSetter.INVALID) { |
| 2303 setter = null; | 2317 setter = null; |
| 2304 } | 2318 } |
| 2305 return buildCompound(buildStaticAccessor(getter, setter), rhs); | 2319 return buildCompound(buildStaticAccessor(getter, setter), rhs, node); |
| 2306 } | 2320 } |
| 2307 | 2321 |
| 2308 @override | 2322 @override |
| 2309 ir.Expression handleTypeLiteralConstantCompounds( | 2323 ir.Expression handleTypeLiteralConstantCompounds( |
| 2310 SendSet node, ConstantExpression constant, CompoundRhs rhs, _) { | 2324 SendSet node, ConstantExpression constant, CompoundRhs rhs, _) { |
| 2311 return buildCompound(new ReadOnlyAccessor(buildTypeLiteral(constant)), rhs); | 2325 return buildCompound(new ReadOnlyAccessor(buildTypeLiteral(constant)), rhs, node); |
|
asgerf
2016/11/24 09:44:32
long line
sra1
2016/11/24 23:53:52
Done.
| |
| 2312 } | 2326 } |
| 2313 | 2327 |
| 2314 ir.TypeLiteral buildTypeVariable(TypeVariableElement element) { | 2328 ir.TypeLiteral buildTypeVariable(TypeVariableElement element) { |
| 2315 return new ir.TypeLiteral(kernel.typeToIr(element.type)); | 2329 return new ir.TypeLiteral(kernel.typeToIr(element.type)); |
| 2316 } | 2330 } |
| 2317 | 2331 |
| 2318 @override | 2332 @override |
| 2319 ir.Expression handleTypeVariableTypeLiteralCompounds( | 2333 ir.Expression handleTypeVariableTypeLiteralCompounds( |
| 2320 SendSet node, TypeVariableElement element, CompoundRhs rhs, _) { | 2334 SendSet node, TypeVariableElement element, CompoundRhs rhs, _) { |
| 2321 return buildCompound(new ReadOnlyAccessor(buildTypeVariable(element)), rhs); | 2335 return buildCompound(new ReadOnlyAccessor(buildTypeVariable(element)), rhs, node); |
|
asgerf
2016/11/24 09:44:32
long line
sra1
2016/11/24 23:53:52
Done.
| |
| 2322 } | 2336 } |
| 2323 | 2337 |
| 2324 @override | 2338 @override |
| 2325 ir.SuperPropertyGet visitSuperFieldGet(Send node, FieldElement field, _) { | 2339 ir.SuperPropertyGet visitSuperFieldGet(Send node, FieldElement field, _) { |
| 2326 return buildSuperPropertyAccessor(field).buildSimpleRead(); | 2340 return buildSuperPropertyAccessor(field).buildSimpleRead(); |
| 2327 } | 2341 } |
| 2328 | 2342 |
| 2329 @override | 2343 @override |
| 2330 ir.MethodInvocation visitSuperFieldInvoke(Send node, FieldElement field, | 2344 ir.MethodInvocation visitSuperFieldInvoke(Send node, FieldElement field, |
| 2331 NodeList arguments, CallStructure callStructure, _) { | 2345 NodeList arguments, CallStructure callStructure, _) { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2798 : this(null, true, node, initializers); | 2812 : this(null, true, node, initializers); |
| 2799 | 2813 |
| 2800 accept(ir.Visitor v) => throw "unsupported"; | 2814 accept(ir.Visitor v) => throw "unsupported"; |
| 2801 | 2815 |
| 2802 visitChildren(ir.Visitor v) => throw "unsupported"; | 2816 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 2803 | 2817 |
| 2804 String toString() { | 2818 String toString() { |
| 2805 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2819 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 2806 } | 2820 } |
| 2807 } | 2821 } |
| OLD | NEW |