| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_nodes; | 4 library dart2js.ir_nodes; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'cps_fragment.dart' show CpsFragment; | 7 import 'cps_fragment.dart' show CpsFragment; |
| 8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
| 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 bool get hasValue => true; | 1428 bool get hasValue => true; |
| 1429 bool get isSafeForElimination => true; | 1429 bool get isSafeForElimination => true; |
| 1430 bool get isSafeForReordering => true; | 1430 bool get isSafeForReordering => true; |
| 1431 | 1431 |
| 1432 void setParentPointers() {} | 1432 void setParentPointers() {} |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 /// Creates an instance of a class and initializes its fields and runtime type | 1435 /// Creates an instance of a class and initializes its fields and runtime type |
| 1436 /// information. | 1436 /// information. |
| 1437 class CreateInstance extends Primitive { | 1437 class CreateInstance extends Primitive { |
| 1438 final ClassElement classElement; | 1438 final InterfaceType dartType; |
| 1439 | 1439 |
| 1440 /// Initial values for the fields on the class. | 1440 /// Initial values for the fields on the class. |
| 1441 /// The order corresponds to the order of fields on the class. | 1441 /// The order corresponds to the order of fields on the class. |
| 1442 final List<Reference<Primitive>> arguments; | 1442 final List<Reference<Primitive>> arguments; |
| 1443 | 1443 |
| 1444 /// The runtime type information structure which contains the type arguments. | 1444 /// The runtime type information structure which contains the type arguments. |
| 1445 /// | 1445 /// |
| 1446 /// May be `null` to indicate that no type information is needed because the | 1446 /// May be `null` to indicate that no type information is needed because the |
| 1447 /// compiler determined that the type information for instances of this class | 1447 /// compiler determined that the type information for instances of this class |
| 1448 /// is not needed at runtime. | 1448 /// is not needed at runtime. |
| 1449 final List<Reference<Primitive>> typeInformation; | 1449 final List<Reference<Primitive>> typeInformation; |
| 1450 | 1450 |
| 1451 final SourceInformation sourceInformation; | 1451 final SourceInformation sourceInformation; |
| 1452 | 1452 |
| 1453 CreateInstance(this.classElement, List<Primitive> arguments, | 1453 ClassElement get classElement => dartType.element; |
| 1454 |
| 1455 CreateInstance(this.dartType, List<Primitive> arguments, |
| 1454 List<Primitive> typeInformation, | 1456 List<Primitive> typeInformation, |
| 1455 this.sourceInformation) | 1457 this.sourceInformation) |
| 1456 : this.arguments = _referenceList(arguments), | 1458 : this.arguments = _referenceList(arguments), |
| 1457 this.typeInformation = _referenceList(typeInformation); | 1459 this.typeInformation = _referenceList(typeInformation); |
| 1458 | 1460 |
| 1459 accept(Visitor visitor) => visitor.visitCreateInstance(this); | 1461 accept(Visitor visitor) => visitor.visitCreateInstance(this); |
| 1460 | 1462 |
| 1461 bool get hasValue => true; | 1463 bool get hasValue => true; |
| 1462 bool get isSafeForElimination => true; | 1464 bool get isSafeForElimination => true; |
| 1463 bool get isSafeForReordering => true; | 1465 bool get isSafeForReordering => true; |
| 1464 | 1466 |
| 1465 toString() => 'CreateInstance($classElement)'; | 1467 toString() => 'CreateInstance($dartType)'; |
| 1466 | 1468 |
| 1467 void setParentPointers() { | 1469 void setParentPointers() { |
| 1468 _setParentsOnList(arguments, this); | 1470 _setParentsOnList(arguments, this); |
| 1469 if (typeInformation != null) _setParentsOnList(typeInformation, this); | 1471 if (typeInformation != null) _setParentsOnList(typeInformation, this); |
| 1470 } | 1472 } |
| 1471 } | 1473 } |
| 1472 | 1474 |
| 1473 /// Obtains the interceptor for the given value. This is a method table | 1475 /// Obtains the interceptor for the given value. This is a method table |
| 1474 /// corresponding to the Dart class of the value. | 1476 /// corresponding to the Dart class of the value. |
| 1475 /// | 1477 /// |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 | 1570 |
| 1569 bool get hasValue => true; | 1571 bool get hasValue => true; |
| 1570 bool get isSafeForElimination => true; | 1572 bool get isSafeForElimination => true; |
| 1571 bool get isSafeForReordering => true; | 1573 bool get isSafeForReordering => true; |
| 1572 | 1574 |
| 1573 void setParentPointers() {} | 1575 void setParentPointers() {} |
| 1574 } | 1576 } |
| 1575 | 1577 |
| 1576 class LiteralList extends Primitive { | 1578 class LiteralList extends Primitive { |
| 1577 /// The List type being created; this is not the type argument. | 1579 /// The List type being created; this is not the type argument. |
| 1578 final InterfaceType dartType; | 1580 InterfaceType dartType; |
| 1579 final List<Reference<Primitive>> values; | 1581 final List<Reference<Primitive>> values; |
| 1580 | 1582 |
| 1581 /// If non-null, this is an allocation site-specific type for the list | 1583 /// If non-null, this is an allocation site-specific type for the list |
| 1582 /// created here. | 1584 /// created here. |
| 1583 TypeMask allocationSiteType; | 1585 TypeMask allocationSiteType; |
| 1584 | 1586 |
| 1585 LiteralList(this.dartType, List<Primitive> values, {this.allocationSiteType}) | 1587 LiteralList(this.dartType, List<Primitive> values, {this.allocationSiteType}) |
| 1586 : this.values = _referenceList(values); | 1588 : this.values = _referenceList(values); |
| 1587 | 1589 |
| 1588 accept(Visitor visitor) => visitor.visitLiteralList(this); | 1590 accept(Visitor visitor) => visitor.visitLiteralList(this); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1599 class LiteralMapEntry { | 1601 class LiteralMapEntry { |
| 1600 final Reference<Primitive> key; | 1602 final Reference<Primitive> key; |
| 1601 final Reference<Primitive> value; | 1603 final Reference<Primitive> value; |
| 1602 | 1604 |
| 1603 LiteralMapEntry(Primitive key, Primitive value) | 1605 LiteralMapEntry(Primitive key, Primitive value) |
| 1604 : this.key = new Reference<Primitive>(key), | 1606 : this.key = new Reference<Primitive>(key), |
| 1605 this.value = new Reference<Primitive>(value); | 1607 this.value = new Reference<Primitive>(value); |
| 1606 } | 1608 } |
| 1607 | 1609 |
| 1608 class LiteralMap extends Primitive { | 1610 class LiteralMap extends Primitive { |
| 1609 final InterfaceType dartType; | 1611 InterfaceType dartType; |
| 1610 final List<LiteralMapEntry> entries; | 1612 final List<LiteralMapEntry> entries; |
| 1611 | 1613 |
| 1612 LiteralMap(this.dartType, this.entries); | 1614 LiteralMap(this.dartType, this.entries); |
| 1613 | 1615 |
| 1614 accept(Visitor visitor) => visitor.visitLiteralMap(this); | 1616 accept(Visitor visitor) => visitor.visitLiteralMap(this); |
| 1615 | 1617 |
| 1616 bool get hasValue => true; | 1618 bool get hasValue => true; |
| 1617 bool get isSafeForElimination => true; | 1619 bool get isSafeForElimination => true; |
| 1618 bool get isSafeForReordering => true; | 1620 bool get isSafeForReordering => true; |
| 1619 | 1621 |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 | 2467 |
| 2466 /// A visitor to copy instances of [Definition] or its subclasses, except for | 2468 /// A visitor to copy instances of [Definition] or its subclasses, except for |
| 2467 /// instances of [Continuation]. | 2469 /// instances of [Continuation]. |
| 2468 /// | 2470 /// |
| 2469 /// The visitor maintains a map from original definitions to their copies. | 2471 /// The visitor maintains a map from original definitions to their copies. |
| 2470 /// When the [copy] method is called for a non-Continuation definition, | 2472 /// When the [copy] method is called for a non-Continuation definition, |
| 2471 /// a copy is created, added to the map and returned as the result. Copying a | 2473 /// a copy is created, added to the map and returned as the result. Copying a |
| 2472 /// definition assumes that the definitions of all references have already | 2474 /// definition assumes that the definitions of all references have already |
| 2473 /// been copied by the same visitor. | 2475 /// been copied by the same visitor. |
| 2474 class DefinitionCopyingVisitor extends Visitor<Definition> { | 2476 class DefinitionCopyingVisitor extends Visitor<Definition> { |
| 2475 Map<Definition, Definition> _copies = <Definition, Definition>{}; | 2477 final Map<Definition, Definition> _copies = <Definition, Definition>{}; |
| 2478 DartType concreteType; |
| 2476 | 2479 |
| 2477 /// Put a copy into the map. | 2480 /// Put a copy into the map. |
| 2478 /// | 2481 /// |
| 2479 /// This method should be used instead of directly adding copies to the map. | 2482 /// This method should be used instead of directly adding copies to the map. |
| 2480 Definition putCopy(Definition original, Definition copy) { | 2483 Definition putCopy(Definition original, Definition copy) { |
| 2481 if (copy is Variable) { | 2484 if (copy is Variable) { |
| 2482 Variable originalVariable = original; | 2485 Variable originalVariable = original; |
| 2483 copy.type = originalVariable.type; | 2486 copy.type = originalVariable.type; |
| 2484 copy.hint = originalVariable.hint; | 2487 copy.hint = originalVariable.hint; |
| 2485 } | 2488 } |
| 2486 return _copies[original] = copy; | 2489 return _copies[original] = copy; |
| 2487 } | 2490 } |
| 2488 | 2491 |
| 2489 /// Get the copy of a [Reference]'s definition from the map. | 2492 /// Get the copy of a [Reference]'s definition from the map. |
| 2490 Definition getCopy(Reference reference) => _copies[reference.definition]; | 2493 Definition getCopy(Reference reference) => _copies[reference.definition]; |
| 2491 | 2494 |
| 2492 /// Map a list of [Reference]s to the list of their definition's copies. | 2495 /// Map a list of [Reference]s to the list of their definition's copies. |
| 2493 List<Definition> getList(List<Reference> list) => list.map(getCopy).toList(); | 2496 List<Definition> getList(List<Reference> list) => list.map(getCopy).toList(); |
| 2494 | 2497 |
| 2498 DartType substType(DartType dartType) { |
| 2499 return concreteType != null |
| 2500 ? dartType.substByContext(concreteType) |
| 2501 : dartType; |
| 2502 } |
| 2503 |
| 2495 /// Copy a non-[Continuation] [Definition]. | 2504 /// Copy a non-[Continuation] [Definition]. |
| 2496 Definition copy(Definition node) { | 2505 Definition copy(Definition node) { |
| 2497 assert (node is! Continuation); | 2506 assert (node is! Continuation); |
| 2498 return putCopy(node, visit(node)); | 2507 return putCopy(node, visit(node)); |
| 2499 } | 2508 } |
| 2500 | 2509 |
| 2501 Definition visit(Node node) => node.accept(this); | 2510 Definition visit(Node node) => node.accept(this); |
| 2502 | 2511 |
| 2503 visitFunctionDefinition(FunctionDefinition node) {} | 2512 visitFunctionDefinition(FunctionDefinition node) {} |
| 2504 visitLetPrim(LetPrim node) {} | 2513 visitLetPrim(LetPrim node) {} |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2526 | 2535 |
| 2527 Definition visitInvokeMethodDirectly(InvokeMethodDirectly node) { | 2536 Definition visitInvokeMethodDirectly(InvokeMethodDirectly node) { |
| 2528 return new InvokeMethodDirectly(getCopy(node.receiver), node.target, | 2537 return new InvokeMethodDirectly(getCopy(node.receiver), node.target, |
| 2529 node.selector, | 2538 node.selector, |
| 2530 getList(node.arguments), | 2539 getList(node.arguments), |
| 2531 node.sourceInformation, | 2540 node.sourceInformation, |
| 2532 callingConvention: node.callingConvention); | 2541 callingConvention: node.callingConvention); |
| 2533 } | 2542 } |
| 2534 | 2543 |
| 2535 Definition visitInvokeConstructor(InvokeConstructor node) { | 2544 Definition visitInvokeConstructor(InvokeConstructor node) { |
| 2536 return new InvokeConstructor(node.dartType, node.target, node.selector, | 2545 return new InvokeConstructor(substType(node.dartType), node.target, |
| 2546 node.selector, |
| 2537 getList(node.arguments), | 2547 getList(node.arguments), |
| 2538 node.sourceInformation); | 2548 node.sourceInformation); |
| 2539 } | 2549 } |
| 2540 | 2550 |
| 2541 Definition visitTypeCast(TypeCast node) { | 2551 Definition visitTypeCast(TypeCast node) { |
| 2542 return new TypeCast(getCopy(node.value), node.dartType, | 2552 return new TypeCast(getCopy(node.value), substType(node.dartType), |
| 2543 getList(node.typeArguments)); | 2553 getList(node.typeArguments)); |
| 2544 } | 2554 } |
| 2545 | 2555 |
| 2546 Definition visitSetMutable(SetMutable node) { | 2556 Definition visitSetMutable(SetMutable node) { |
| 2547 return new SetMutable(getCopy(node.variable), getCopy(node.value)); | 2557 return new SetMutable(getCopy(node.variable), getCopy(node.value)); |
| 2548 } | 2558 } |
| 2549 | 2559 |
| 2550 Definition visitSetStatic(SetStatic node) { | 2560 Definition visitSetStatic(SetStatic node) { |
| 2551 return new SetStatic(node.element, getCopy(node.value), | 2561 return new SetStatic(node.element, getCopy(node.value), |
| 2552 node.sourceInformation); | 2562 node.sourceInformation); |
| 2553 } | 2563 } |
| 2554 | 2564 |
| 2555 Definition visitSetField(SetField node) { | 2565 Definition visitSetField(SetField node) { |
| 2556 return new SetField(getCopy(node.object), node.field, getCopy(node.value)); | 2566 return new SetField(getCopy(node.object), node.field, getCopy(node.value)); |
| 2557 } | 2567 } |
| 2558 | 2568 |
| 2559 Definition visitGetLazyStatic(GetLazyStatic node) { | 2569 Definition visitGetLazyStatic(GetLazyStatic node) { |
| 2560 return new GetLazyStatic(node.element, node.sourceInformation); | 2570 return new GetLazyStatic(node.element, node.sourceInformation); |
| 2561 } | 2571 } |
| 2562 | 2572 |
| 2563 Definition visitAwait(Await node) { | 2573 Definition visitAwait(Await node) { |
| 2564 return new Await(getCopy(node.input)); | 2574 return new Await(getCopy(node.input)); |
| 2565 } | 2575 } |
| 2566 | 2576 |
| 2567 Definition visitYield(Yield node) { | 2577 Definition visitYield(Yield node) { |
| 2568 return new Yield(getCopy(node.input), node.hasStar); | 2578 return new Yield(getCopy(node.input), node.hasStar); |
| 2569 } | 2579 } |
| 2570 | 2580 |
| 2571 Definition visitLiteralList(LiteralList node) { | 2581 Definition visitLiteralList(LiteralList node) { |
| 2572 return new LiteralList(node.dartType, getList(node.values)); | 2582 return new LiteralList(substType(node.dartType), getList(node.values)); |
| 2573 } | 2583 } |
| 2574 | 2584 |
| 2575 Definition visitLiteralMap(LiteralMap node) { | 2585 Definition visitLiteralMap(LiteralMap node) { |
| 2576 List<LiteralMapEntry> entries = node.entries.map((LiteralMapEntry entry) { | 2586 List<LiteralMapEntry> entries = node.entries.map((LiteralMapEntry entry) { |
| 2577 return new LiteralMapEntry(getCopy(entry.key), getCopy(entry.value)); | 2587 return new LiteralMapEntry(getCopy(entry.key), getCopy(entry.value)); |
| 2578 }).toList(); | 2588 }).toList(); |
| 2579 return new LiteralMap(node.dartType, entries); | 2589 return new LiteralMap(substType(node.dartType), entries); |
| 2580 } | 2590 } |
| 2581 | 2591 |
| 2582 Definition visitConstant(Constant node) { | 2592 Definition visitConstant(Constant node) { |
| 2583 return new Constant(node.value, sourceInformation: node.sourceInformation); | 2593 return new Constant(node.value, sourceInformation: node.sourceInformation); |
| 2584 } | 2594 } |
| 2585 | 2595 |
| 2586 Definition visitGetMutable(GetMutable node) { | 2596 Definition visitGetMutable(GetMutable node) { |
| 2587 return new GetMutable(getCopy(node.variable)); | 2597 return new GetMutable(getCopy(node.variable)); |
| 2588 } | 2598 } |
| 2589 | 2599 |
| 2590 Definition visitParameter(Parameter node) { | 2600 Definition visitParameter(Parameter node) { |
| 2591 return new Parameter(node.hint); | 2601 return new Parameter(node.hint); |
| 2592 } | 2602 } |
| 2593 | 2603 |
| 2594 Definition visitMutableVariable(MutableVariable node) { | 2604 Definition visitMutableVariable(MutableVariable node) { |
| 2595 return new MutableVariable(node.hint); | 2605 return new MutableVariable(node.hint); |
| 2596 } | 2606 } |
| 2597 | 2607 |
| 2598 Definition visitGetStatic(GetStatic node) { | 2608 Definition visitGetStatic(GetStatic node) { |
| 2599 return new GetStatic(node.element, node.sourceInformation); | 2609 return new GetStatic(node.element, node.sourceInformation); |
| 2600 } | 2610 } |
| 2601 | 2611 |
| 2602 Definition visitInterceptor(Interceptor node) { | 2612 Definition visitInterceptor(Interceptor node) { |
| 2603 return new Interceptor(getCopy(node.input), node.sourceInformation) | 2613 return new Interceptor(getCopy(node.input), node.sourceInformation) |
| 2604 ..interceptedClasses.addAll(node.interceptedClasses); | 2614 ..interceptedClasses.addAll(node.interceptedClasses); |
| 2605 } | 2615 } |
| 2606 | 2616 |
| 2607 Definition visitCreateInstance(CreateInstance node) { | 2617 Definition visitCreateInstance(CreateInstance node) { |
| 2608 return new CreateInstance(node.classElement, getList(node.arguments), | 2618 return new CreateInstance(substType(node.dartType), |
| 2619 getList(node.arguments), |
| 2609 getList(node.typeInformation), | 2620 getList(node.typeInformation), |
| 2610 node.sourceInformation); | 2621 node.sourceInformation); |
| 2611 } | 2622 } |
| 2612 | 2623 |
| 2613 Definition visitGetField(GetField node) { | 2624 Definition visitGetField(GetField node) { |
| 2614 return new GetField(getCopy(node.object), node.field); | 2625 return new GetField(getCopy(node.object), node.field); |
| 2615 } | 2626 } |
| 2616 | 2627 |
| 2617 Definition visitCreateBox(CreateBox node) { | 2628 Definition visitCreateBox(CreateBox node) { |
| 2618 return new CreateBox(); | 2629 return new CreateBox(); |
| 2619 } | 2630 } |
| 2620 | 2631 |
| 2621 Definition visitReifyRuntimeType(ReifyRuntimeType node) { | 2632 Definition visitReifyRuntimeType(ReifyRuntimeType node) { |
| 2622 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation); | 2633 return new ReifyRuntimeType(getCopy(node.value), node.sourceInformation); |
| 2623 } | 2634 } |
| 2624 | 2635 |
| 2625 Definition visitReadTypeVariable(ReadTypeVariable node) { | 2636 Definition visitReadTypeVariable(ReadTypeVariable node) { |
| 2626 return new ReadTypeVariable(node.variable, getCopy(node.target), | 2637 return new ReadTypeVariable(node.variable, getCopy(node.target), |
| 2627 node.sourceInformation); | 2638 node.sourceInformation); |
| 2628 } | 2639 } |
| 2629 | 2640 |
| 2630 Definition visitTypeExpression(TypeExpression node) { | 2641 Definition visitTypeExpression(TypeExpression node) { |
| 2642 // Note: Do not use substType for the TypeExpression's DartType. The type |
| 2643 // variables in TypeExpression are not "free", they are bound by the |
| 2644 // TypeExpression itself. |
| 2631 return new TypeExpression(node.dartType, getList(node.arguments)); | 2645 return new TypeExpression(node.dartType, getList(node.arguments)); |
| 2632 } | 2646 } |
| 2633 | 2647 |
| 2634 Definition visitCreateInvocationMirror(CreateInvocationMirror node) { | 2648 Definition visitCreateInvocationMirror(CreateInvocationMirror node) { |
| 2635 return new CreateInvocationMirror(node.selector, getList(node.arguments)); | 2649 return new CreateInvocationMirror(node.selector, getList(node.arguments)); |
| 2636 } | 2650 } |
| 2637 | 2651 |
| 2638 Definition visitTypeTest(TypeTest node) { | 2652 Definition visitTypeTest(TypeTest node) { |
| 2639 return new TypeTest(getCopy(node.value), node.dartType, | 2653 return new TypeTest(getCopy(node.value), substType(node.dartType), |
| 2640 getList(node.typeArguments)); | 2654 getList(node.typeArguments)); |
| 2641 } | 2655 } |
| 2642 | 2656 |
| 2643 Definition visitTypeTestViaFlag(TypeTestViaFlag node) { | 2657 Definition visitTypeTestViaFlag(TypeTestViaFlag node) { |
| 2644 return new TypeTestViaFlag(getCopy(node.interceptor), node.dartType); | 2658 return new TypeTestViaFlag(getCopy(node.interceptor), |
| 2659 substType(node.dartType)); |
| 2645 } | 2660 } |
| 2646 | 2661 |
| 2647 Definition visitApplyBuiltinOperator(ApplyBuiltinOperator node) { | 2662 Definition visitApplyBuiltinOperator(ApplyBuiltinOperator node) { |
| 2648 return new ApplyBuiltinOperator(node.operator, getList(node.arguments), | 2663 return new ApplyBuiltinOperator(node.operator, getList(node.arguments), |
| 2649 node.sourceInformation); | 2664 node.sourceInformation); |
| 2650 } | 2665 } |
| 2651 | 2666 |
| 2652 Definition visitApplyBuiltinMethod(ApplyBuiltinMethod node) { | 2667 Definition visitApplyBuiltinMethod(ApplyBuiltinMethod node) { |
| 2653 return new ApplyBuiltinMethod(node.method, getCopy(node.receiver), | 2668 return new ApplyBuiltinMethod(node.method, getCopy(node.receiver), |
| 2654 getList(node.arguments), | 2669 getList(node.arguments), |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2737 _stack.add(() { | 2752 _stack.add(() { |
| 2738 Expression savedFirst = _first; | 2753 Expression savedFirst = _first; |
| 2739 _first = _current = null; | 2754 _first = _current = null; |
| 2740 _processBlock(cont.body); | 2755 _processBlock(cont.body); |
| 2741 _copies[cont].body = _first; | 2756 _copies[cont].body = _first; |
| 2742 _first = savedFirst; | 2757 _first = savedFirst; |
| 2743 _current = null; | 2758 _current = null; |
| 2744 }); | 2759 }); |
| 2745 } | 2760 } |
| 2746 | 2761 |
| 2747 FunctionDefinition copy(FunctionDefinition node) { | 2762 /// Creates a copy of [node]. |
| 2763 /// |
| 2764 /// If [concreteType] is given, type variables declared in [concreteType]'s |
| 2765 /// class are subsituted with the type arguments used in [concreteType]. |
| 2766 /// For example, if `List<String>` is given, the type variable of `List` |
| 2767 /// is replaced with `String`. It is for performance reasons that type |
| 2768 /// substitution is integrated into the copying operation. |
| 2769 FunctionDefinition copy(FunctionDefinition node, {DartType concreteType}) { |
| 2748 assert(_first == null && _current == null); | 2770 assert(_first == null && _current == null); |
| 2749 _first = _current = null; | 2771 _first = _current = null; |
| 2772 _definitions.concreteType = concreteType; |
| 2750 // Definitions are copied where they are bound, before processing | 2773 // Definitions are copied where they are bound, before processing |
| 2751 // expressions in the scope of their binding. | 2774 // expressions in the scope of their binding. |
| 2752 Parameter thisParameter = node.thisParameter == null | 2775 Parameter thisParameter = node.thisParameter == null |
| 2753 ? null | 2776 ? null |
| 2754 : _definitions.copy(node.thisParameter); | 2777 : _definitions.copy(node.thisParameter); |
| 2755 List<Parameter> parameters = | 2778 List<Parameter> parameters = |
| 2756 node.parameters.map(_definitions.copy).toList(); | 2779 node.parameters.map(_definitions.copy).toList(); |
| 2757 // Though the return continuation's parameter does not have any uses, | 2780 // Though the return continuation's parameter does not have any uses, |
| 2758 // we still make a proper copy to ensure that hints, type, etc. are | 2781 // we still make a proper copy to ensure that hints, type, etc. are |
| 2759 // copied. | 2782 // copied. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2830 plug(new Branch.loose(_definitions.getCopy(node.condition), | 2853 plug(new Branch.loose(_definitions.getCopy(node.condition), |
| 2831 _copies[node.trueContinuation.definition], | 2854 _copies[node.trueContinuation.definition], |
| 2832 _copies[node.falseContinuation.definition]) | 2855 _copies[node.falseContinuation.definition]) |
| 2833 ..isStrictCheck = node.isStrictCheck); | 2856 ..isStrictCheck = node.isStrictCheck); |
| 2834 } | 2857 } |
| 2835 | 2858 |
| 2836 visitUnreachable(Unreachable node) { | 2859 visitUnreachable(Unreachable node) { |
| 2837 plug(new Unreachable()); | 2860 plug(new Unreachable()); |
| 2838 } | 2861 } |
| 2839 } | 2862 } |
| OLD | NEW |