Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: pkg/compiler/lib/src/kernel/kernel_visitor.dart

Issue 2518023002: Update third_party/pkg/kernel version (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 ir.DartType guard = computeType(node.type); 703 ir.DartType guard = computeType(node.type);
704 return new ir.Catch(exception, buildStatementInBlock(node.block), 704 return new ir.Catch(exception, buildStatementInBlock(node.block),
705 guard: guard, stackTrace: trace); 705 guard: guard, stackTrace: trace);
706 } 706 }
707 707
708 @override 708 @override
709 ir.ConditionalExpression visitConditional(Conditional node) { 709 ir.ConditionalExpression visitConditional(Conditional node) {
710 return new ir.ConditionalExpression( 710 return new ir.ConditionalExpression(
711 visitForValue(node.condition), 711 visitForValue(node.condition),
712 visitWithCurrentContext(node.thenExpression), 712 visitWithCurrentContext(node.thenExpression),
713 visitWithCurrentContext(node.elseExpression)); 713 visitWithCurrentContext(node.elseExpression),
714 null);
714 } 715 }
715 716
716 @override 717 @override
717 ir.Statement visitContinueStatement(ContinueStatement node) { 718 ir.Statement visitContinueStatement(ContinueStatement node) {
718 JumpTarget target = elements.getTargetOf(node); 719 JumpTarget target = elements.getTargetOf(node);
719 if (target == null || !target.statement.isValidContinueTarget()) { 720 if (target == null || !target.statement.isValidContinueTarget()) {
720 // This is a continue in an invalid position. 721 // This is a continue in an invalid position.
721 return new ir.InvalidStatement(); 722 return new ir.InvalidStatement();
722 } 723 }
723 ir.SwitchCase switchCase = getContinueSwitchTarget(target); 724 ir.SwitchCase switchCase = getContinueSwitchTarget(target);
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 visitForValue(receiver), nameToIrName(name), value); 1306 visitForValue(receiver), nameToIrName(name), value);
1306 } 1307 }
1307 1308
1308 @override 1309 @override
1309 ir.Expression handleDynamicSetIfNulls( 1310 ir.Expression handleDynamicSetIfNulls(
1310 Send node, Node receiver, Name name, Node rhs, _) { 1311 Send node, Node receiver, Name name, Node rhs, _) {
1311 ir.Name irName = nameToIrName(name); 1312 ir.Name irName = nameToIrName(name);
1312 Accessor accessor = (receiver == null) 1313 Accessor accessor = (receiver == null)
1313 ? new ThisPropertyAccessor(irName, null, null) 1314 ? new ThisPropertyAccessor(irName, null, null)
1314 : PropertyAccessor.make(visitForValue(receiver), irName, null, null); 1315 : PropertyAccessor.make(visitForValue(receiver), irName, null, null);
1315 return accessor.buildNullAwareAssignment(visitForValue(rhs), 1316 return accessor.buildNullAwareAssignment(visitForValue(rhs), null,
1316 voidContext: isVoidContext); 1317 voidContext: isVoidContext);
1317 } 1318 }
1318 1319
1319 @override 1320 @override
1320 ir.TypeLiteral visitDynamicTypeLiteralGet( 1321 ir.TypeLiteral visitDynamicTypeLiteralGet(
1321 Send node, ConstantExpression constant, _) { 1322 Send node, ConstantExpression constant, _) {
1322 return buildTypeLiteral(constant); 1323 return buildTypeLiteral(constant);
1323 } 1324 }
1324 1325
1325 @override 1326 @override
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 ConstructorElement constructor, 1498 ConstructorElement constructor,
1498 InterfaceType type, 1499 InterfaceType type,
1499 NodeList arguments, 1500 NodeList arguments,
1500 CallStructure callStructure, 1501 CallStructure callStructure,
1501 _) { 1502 _) {
1502 return buildConstructorInvoke(node, isConst: false); 1503 return buildConstructorInvoke(node, isConst: false);
1503 } 1504 }
1504 1505
1505 Accessor buildNullAwarePropertyAccessor(Node receiver, Name name) { 1506 Accessor buildNullAwarePropertyAccessor(Node receiver, Name name) {
1506 return new NullAwarePropertyAccessor( 1507 return new NullAwarePropertyAccessor(
1507 visitForValue(receiver), nameToIrName(name), null, null); 1508 visitForValue(receiver), nameToIrName(name), null, null, null);
1508 } 1509 }
1509 1510
1510 @override 1511 @override
1511 ir.Expression visitIfNotNullDynamicPropertyGet( 1512 ir.Expression visitIfNotNullDynamicPropertyGet(
1512 Send node, Node receiver, Name name, _) { 1513 Send node, Node receiver, Name name, _) {
1513 return buildNullAwarePropertyAccessor(receiver, name).buildSimpleRead(); 1514 return buildNullAwarePropertyAccessor(receiver, name).buildSimpleRead();
1514 } 1515 }
1515 1516
1516 @override 1517 @override
1517 ir.Let visitIfNotNullDynamicPropertyInvoke( 1518 ir.Let visitIfNotNullDynamicPropertyInvoke(
1518 Send node, Node receiverNode, NodeList arguments, Selector selector, _) { 1519 Send node, Node receiverNode, NodeList arguments, Selector selector, _) {
1519 ir.VariableDeclaration receiver = 1520 ir.VariableDeclaration receiver =
1520 makeOrReuseVariable(visitForValue(receiverNode)); 1521 makeOrReuseVariable(visitForValue(receiverNode));
1521 return makeLet( 1522 return makeLet(
1522 receiver, 1523 receiver,
1523 new ir.ConditionalExpression( 1524 new ir.ConditionalExpression(
1524 buildIsNull(new ir.VariableGet(receiver)), 1525 buildIsNull(new ir.VariableGet(receiver)),
1525 new ir.NullLiteral(), 1526 new ir.NullLiteral(),
1526 buildInvokeSelector(new ir.VariableGet(receiver), selector, 1527 buildInvokeSelector(new ir.VariableGet(receiver), selector,
1527 buildArguments(arguments)))); 1528 buildArguments(arguments)),
1529 null));
1528 } 1530 }
1529 1531
1530 @override 1532 @override
1531 ir.Expression visitIfNotNullDynamicPropertySet( 1533 ir.Expression visitIfNotNullDynamicPropertySet(
1532 SendSet node, Node receiver, Name name, Node rhs, _) { 1534 SendSet node, Node receiver, Name name, Node rhs, _) {
1533 return buildNullAwarePropertyAccessor(receiver, name) 1535 return buildNullAwarePropertyAccessor(receiver, name)
1534 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 1536 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
1535 } 1537 }
1536 1538
1537 @override 1539 @override
1538 ir.Expression visitIfNotNullDynamicPropertySetIfNull( 1540 ir.Expression visitIfNotNullDynamicPropertySetIfNull(
1539 Send node, Node receiver, Name name, Node rhs, _) { 1541 Send node, Node receiver, Name name, Node rhs, _) {
1540 return buildNullAwarePropertyAccessor(receiver, name) 1542 return buildNullAwarePropertyAccessor(receiver, name)
1541 .buildNullAwareAssignment(visitForValue(rhs), 1543 .buildNullAwareAssignment(visitForValue(rhs), null,
1542 voidContext: isVoidContext); 1544 voidContext: isVoidContext);
1543 } 1545 }
1544 1546
1545 ir.LogicalExpression buildLogicalExpression( 1547 ir.LogicalExpression buildLogicalExpression(
1546 Node left, Operator operator, Node right) { 1548 Node left, Operator operator, Node right) {
1547 return new ir.LogicalExpression( 1549 return new ir.LogicalExpression(
1548 visitForValue(left), operator.source, visitForValue(right)); 1550 visitForValue(left), operator.source, visitForValue(right));
1549 } 1551 }
1550 1552
1551 @override 1553 @override
1552 ir.LogicalExpression visitIfNull(Send node, Node left, Node right, _) { 1554 ir.Expression visitIfNull(Send node, Node left, Node right, _) {
1553 return buildLogicalExpression(left, node.selector, right); 1555 var leftValue = new ir.VariableDeclaration.forValue(visitForValue(left));
1556 return new ir.Let(
1557 leftValue,
1558 new ir.ConditionalExpression(buildIsNull(new ir.VariableGet(leftValue)),
1559 visitForValue(right), new ir.VariableGet(leftValue), null));
1554 } 1560 }
1555 1561
1556 @override 1562 @override
1557 ir.Initializer visitImplicitSuperConstructorInvoke(FunctionExpression node, 1563 ir.Initializer visitImplicitSuperConstructorInvoke(FunctionExpression node,
1558 ConstructorElement superConstructor, InterfaceType type, _) { 1564 ConstructorElement superConstructor, InterfaceType type, _) {
1559 if (superConstructor == null) { 1565 if (superConstructor == null) {
1560 // TODO(ahe): Semantic visitor shouldn't call this. 1566 // TODO(ahe): Semantic visitor shouldn't call this.
1561 return new ir.InvalidInitializer(); 1567 return new ir.InvalidInitializer();
1562 } 1568 }
1563 return new ir.SuperInitializer( 1569 return new ir.SuperInitializer(
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 NodeList arguments, CallStructure callStructure, _) { 1836 NodeList arguments, CallStructure callStructure, _) {
1831 return associateNode( 1837 return associateNode(
1832 buildCall(buildLocalGet(element), callStructure, arguments), node); 1838 buildCall(buildLocalGet(element), callStructure, arguments), node);
1833 } 1839 }
1834 1840
1835 @override 1841 @override
1836 ir.Expression handleLocalSetIfNulls( 1842 ir.Expression handleLocalSetIfNulls(
1837 SendSet node, LocalElement local, Node rhs, _, 1843 SendSet node, LocalElement local, Node rhs, _,
1838 {bool isSetterValid}) { 1844 {bool isSetterValid}) {
1839 return new VariableAccessor(getLocal(local)).buildNullAwareAssignment( 1845 return new VariableAccessor(getLocal(local)).buildNullAwareAssignment(
1840 visitForValue(rhs), 1846 visitForValue(rhs), null,
1841 voidContext: isVoidContext); 1847 voidContext: isVoidContext);
1842 } 1848 }
1843 1849
1844 @override 1850 @override
1845 IrFunction visitRedirectingFactoryConstructorDeclaration( 1851 IrFunction visitRedirectingFactoryConstructorDeclaration(
1846 FunctionExpression node, 1852 FunctionExpression node,
1847 ConstructorElement constructor, 1853 ConstructorElement constructor,
1848 NodeList parameters, 1854 NodeList parameters,
1849 DartType redirectionType, // TODO(ahe): Should be InterfaceType. 1855 DartType redirectionType, // TODO(ahe): Should be InterfaceType.
1850 ConstructorElement redirectionTarget, 1856 ConstructorElement redirectionTarget,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 Element getter, 1953 Element getter,
1948 CompoundGetter getterKind, 1954 CompoundGetter getterKind,
1949 Element setter, 1955 Element setter,
1950 CompoundSetter setterKind, 1956 CompoundSetter setterKind,
1951 Node rhs, 1957 Node rhs,
1952 _) { 1958 _) {
1953 if (setterKind == CompoundSetter.INVALID) { 1959 if (setterKind == CompoundSetter.INVALID) {
1954 setter = null; 1960 setter = null;
1955 } 1961 }
1956 return buildStaticAccessor(getter, setter).buildNullAwareAssignment( 1962 return buildStaticAccessor(getter, setter).buildNullAwareAssignment(
1957 visitForValue(rhs), 1963 visitForValue(rhs), null,
1958 voidContext: isVoidContext); 1964 voidContext: isVoidContext);
1959 } 1965 }
1960 1966
1961 ir.VariableDeclaration getLocal(LocalElement local) { 1967 ir.VariableDeclaration getLocal(LocalElement local) {
1962 return locals.putIfAbsent(local, () { 1968 return locals.putIfAbsent(local, () {
1963 // Currently, initializing formals are not final. 1969 // Currently, initializing formals are not final.
1964 bool isFinal = local.isFinal && !local.isInitializingFormal; 1970 bool isFinal = local.isFinal && !local.isInitializingFormal;
1965 return associateElement( 1971 return associateElement(
1966 new ir.VariableDeclaration(local.name, 1972 new ir.VariableDeclaration(local.name,
1967 initializer: null, 1973 initializer: null,
(...skipping 16 matching lines...) Expand all
1984 FunctionSignature signature = function.functionSignature; 1990 FunctionSignature signature = function.functionSignature;
1985 requiredParameterCount = signature.requiredParameterCount; 1991 requiredParameterCount = signature.requiredParameterCount;
1986 signature.forEachParameter((ParameterElement parameter) { 1992 signature.forEachParameter((ParameterElement parameter) {
1987 ir.VariableDeclaration variable = getLocal(parameter); 1993 ir.VariableDeclaration variable = getLocal(parameter);
1988 if (parameter.isNamed) { 1994 if (parameter.isNamed) {
1989 namedParameters.add(variable); 1995 namedParameters.add(variable);
1990 } else { 1996 } else {
1991 positionalParameters.add(variable); 1997 positionalParameters.add(variable);
1992 } 1998 }
1993 }); 1999 });
2000 namedParameters.sort();
1994 signature.forEachParameter((ParameterElement parameter) { 2001 signature.forEachParameter((ParameterElement parameter) {
1995 if (!parameter.isOptional) return; 2002 if (!parameter.isOptional) return;
1996 ir.Expression initializer = visitForValue(parameter.initializer); 2003 ir.Expression initializer = visitForValue(parameter.initializer);
1997 ir.VariableDeclaration variable = getLocal(parameter); 2004 ir.VariableDeclaration variable = getLocal(parameter);
1998 if (initializer != null) { 2005 if (initializer != null) {
1999 variable.initializer = initializer; 2006 variable.initializer = initializer;
2000 initializer.parent = variable; 2007 initializer.parent = variable;
2001 } 2008 }
2002 }); 2009 });
2003 if (function.isGenerativeConstructor) { 2010 if (function.isGenerativeConstructor) {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 Element getter, 2394 Element getter,
2388 CompoundGetter getterKind, 2395 CompoundGetter getterKind,
2389 Element setter, 2396 Element setter,
2390 CompoundSetter setterKind, 2397 CompoundSetter setterKind,
2391 Node rhs, 2398 Node rhs,
2392 _) { 2399 _) {
2393 if (setterKind == CompoundSetter.INVALID) { 2400 if (setterKind == CompoundSetter.INVALID) {
2394 setter = null; 2401 setter = null;
2395 } 2402 }
2396 return buildSuperPropertyAccessor(getter, setter).buildNullAwareAssignment( 2403 return buildSuperPropertyAccessor(getter, setter).buildNullAwareAssignment(
2397 visitForValue(rhs), 2404 visitForValue(rhs), null,
2398 voidContext: isVoidContext); 2405 voidContext: isVoidContext);
2399 } 2406 }
2400 2407
2401 @override 2408 @override
2402 ir.SuperMethodInvocation visitSuperIndex( 2409 ir.SuperMethodInvocation visitSuperIndex(
2403 Send node, FunctionElement function, Node index, _) { 2410 Send node, FunctionElement function, Node index, _) {
2404 return buildSuperIndexAccessor(index, function).buildSimpleRead(); 2411 return buildSuperIndexAccessor(index, function).buildSimpleRead();
2405 } 2412 }
2406 2413
2407 @override 2414 @override
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 ir.Expression visitTypeVariableTypeLiteralSet( 2623 ir.Expression visitTypeVariableTypeLiteralSet(
2617 SendSet node, TypeVariableElement element, Node rhs, _) { 2624 SendSet node, TypeVariableElement element, Node rhs, _) {
2618 return new ReadOnlyAccessor(buildTypeVariable(element)) 2625 return new ReadOnlyAccessor(buildTypeVariable(element))
2619 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 2626 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
2620 } 2627 }
2621 2628
2622 @override 2629 @override
2623 ir.Expression visitTypeVariableTypeLiteralSetIfNull( 2630 ir.Expression visitTypeVariableTypeLiteralSetIfNull(
2624 Send node, TypeVariableElement element, Node rhs, _) { 2631 Send node, TypeVariableElement element, Node rhs, _) {
2625 return new ReadOnlyAccessor(buildTypeVariable(element)) 2632 return new ReadOnlyAccessor(buildTypeVariable(element))
2626 .buildNullAwareAssignment(visitForValue(rhs), 2633 .buildNullAwareAssignment(visitForValue(rhs), null,
2627 voidContext: isVoidContext); 2634 voidContext: isVoidContext);
2628 } 2635 }
2629 2636
2630 @override 2637 @override
2631 ir.TypeLiteral visitTypedefTypeLiteralGet( 2638 ir.TypeLiteral visitTypedefTypeLiteralGet(
2632 Send node, ConstantExpression constant, _) { 2639 Send node, ConstantExpression constant, _) {
2633 return buildTypeLiteral(constant); 2640 return buildTypeLiteral(constant);
2634 } 2641 }
2635 2642
2636 @override 2643 @override
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 @override 2689 @override
2683 visitForIn(ForIn node) { 2690 visitForIn(ForIn node) {
2684 // Shouldn't be called, handled by [visitAsyncForIn] or [visitSyncForIn]. 2691 // Shouldn't be called, handled by [visitAsyncForIn] or [visitSyncForIn].
2685 return internalError(node, "ForIn"); 2692 return internalError(node, "ForIn");
2686 } 2693 }
2687 2694
2688 @override 2695 @override
2689 ir.Expression visitIndexSetIfNull( 2696 ir.Expression visitIndexSetIfNull(
2690 SendSet node, Node receiver, Node index, Node rhs, _) { 2697 SendSet node, Node receiver, Node index, Node rhs, _) {
2691 return buildIndexAccessor(receiver, index).buildNullAwareAssignment( 2698 return buildIndexAccessor(receiver, index).buildNullAwareAssignment(
2692 visitForValue(rhs), 2699 visitForValue(rhs), null,
2693 voidContext: isVoidContext); 2700 voidContext: isVoidContext);
2694 } 2701 }
2695 2702
2696 @override 2703 @override
2697 ir.Expression visitSuperIndexSetIfNull(SendSet node, MethodElement getter, 2704 ir.Expression visitSuperIndexSetIfNull(SendSet node, MethodElement getter,
2698 MethodElement setter, Node index, Node rhs, _) { 2705 MethodElement setter, Node index, Node rhs, _) {
2699 return buildSuperIndexAccessor(index, getter, setter) 2706 return buildSuperIndexAccessor(index, getter, setter)
2700 .buildNullAwareAssignment(visitForValue(rhs), 2707 .buildNullAwareAssignment(visitForValue(rhs), null,
2701 voidContext: isVoidContext); 2708 voidContext: isVoidContext);
2702 } 2709 }
2703 2710
2704 @override 2711 @override
2705 ir.Node visitVariableDefinitions(VariableDefinitions definitions) { 2712 ir.Node visitVariableDefinitions(VariableDefinitions definitions) {
2706 // TODO(ahe): This method is copied from [SemanticDeclarationResolvedMixin] 2713 // TODO(ahe): This method is copied from [SemanticDeclarationResolvedMixin]
2707 // and modified. Perhaps we can find a way to avoid code duplication. 2714 // and modified. Perhaps we can find a way to avoid code duplication.
2708 List<ir.VariableDeclaration> variables = <ir.VariableDeclaration>[]; 2715 List<ir.VariableDeclaration> variables = <ir.VariableDeclaration>[];
2709 computeVariableStructures(definitions, 2716 computeVariableStructures(definitions,
2710 (Node node, VariableStructure structure) { 2717 (Node node, VariableStructure structure) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 : this(null, true, node, initializers); 2797 : this(null, true, node, initializers);
2791 2798
2792 accept(ir.Visitor v) => throw "unsupported"; 2799 accept(ir.Visitor v) => throw "unsupported";
2793 2800
2794 visitChildren(ir.Visitor v) => throw "unsupported"; 2801 visitChildren(ir.Visitor v) => throw "unsupported";
2795 2802
2796 String toString() { 2803 String toString() {
2797 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 2804 return "IrFunction($kind, $isConstructor, $node, $initializers)";
2798 } 2805 }
2799 } 2806 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698