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 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 | 1589 |
1590 bool get hasValue => true; | 1590 bool get hasValue => true; |
1591 bool get isSafeForElimination => true; | 1591 bool get isSafeForElimination => true; |
1592 bool get isSafeForReordering => true; | 1592 bool get isSafeForReordering => true; |
1593 | 1593 |
1594 void setParentPointers() { | 1594 void setParentPointers() { |
1595 _setParentsOnList(values, this); | 1595 _setParentsOnList(values, this); |
1596 } | 1596 } |
1597 } | 1597 } |
1598 | 1598 |
1599 class LiteralMapEntry { | |
1600 final Reference<Primitive> key; | |
1601 final Reference<Primitive> value; | |
1602 | |
1603 LiteralMapEntry(Primitive key, Primitive value) | |
1604 : this.key = new Reference<Primitive>(key), | |
1605 this.value = new Reference<Primitive>(value); | |
1606 } | |
1607 | |
1608 class LiteralMap extends Primitive { | |
1609 final InterfaceType dartType; | |
1610 final List<LiteralMapEntry> entries; | |
1611 | |
1612 LiteralMap(this.dartType, this.entries); | |
1613 | |
1614 accept(Visitor visitor) => visitor.visitLiteralMap(this); | |
1615 | |
1616 bool get hasValue => true; | |
1617 bool get isSafeForElimination => true; | |
1618 bool get isSafeForReordering => true; | |
1619 | |
1620 void setParentPointers() { | |
1621 for (LiteralMapEntry entry in entries) { | |
1622 entry.key.parent = this; | |
1623 entry.value.parent = this; | |
1624 } | |
1625 } | |
1626 } | |
1627 | |
1628 class Parameter extends Primitive { | 1599 class Parameter extends Primitive { |
1629 Parameter(Entity hint) { | 1600 Parameter(Entity hint) { |
1630 super.hint = hint; | 1601 super.hint = hint; |
1631 } | 1602 } |
1632 | 1603 |
1633 accept(Visitor visitor) => visitor.visitParameter(this); | 1604 accept(Visitor visitor) => visitor.visitParameter(this); |
1634 | 1605 |
1635 String toString() => 'Parameter(${hint == null ? null : hint.name})'; | 1606 String toString() => 'Parameter(${hint == null ? null : hint.name})'; |
1636 | 1607 |
1637 bool get hasValue => true; | 1608 bool get hasValue => true; |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 T visitInvokeMethodDirectly(InvokeMethodDirectly node); | 1929 T visitInvokeMethodDirectly(InvokeMethodDirectly node); |
1959 T visitInvokeConstructor(InvokeConstructor node); | 1930 T visitInvokeConstructor(InvokeConstructor node); |
1960 T visitTypeCast(TypeCast node); | 1931 T visitTypeCast(TypeCast node); |
1961 T visitSetMutable(SetMutable node); | 1932 T visitSetMutable(SetMutable node); |
1962 T visitSetStatic(SetStatic node); | 1933 T visitSetStatic(SetStatic node); |
1963 T visitSetField(SetField node); | 1934 T visitSetField(SetField node); |
1964 T visitGetLazyStatic(GetLazyStatic node); | 1935 T visitGetLazyStatic(GetLazyStatic node); |
1965 T visitAwait(Await node); | 1936 T visitAwait(Await node); |
1966 T visitYield(Yield node); | 1937 T visitYield(Yield node); |
1967 T visitLiteralList(LiteralList node); | 1938 T visitLiteralList(LiteralList node); |
1968 T visitLiteralMap(LiteralMap node); | |
1969 T visitConstant(Constant node); | 1939 T visitConstant(Constant node); |
1970 T visitGetMutable(GetMutable node); | 1940 T visitGetMutable(GetMutable node); |
1971 T visitParameter(Parameter node); | 1941 T visitParameter(Parameter node); |
1972 T visitMutableVariable(MutableVariable node); | 1942 T visitMutableVariable(MutableVariable node); |
1973 T visitGetStatic(GetStatic node); | 1943 T visitGetStatic(GetStatic node); |
1974 T visitInterceptor(Interceptor node); | 1944 T visitInterceptor(Interceptor node); |
1975 T visitCreateInstance(CreateInstance node); | 1945 T visitCreateInstance(CreateInstance node); |
1976 T visitGetField(GetField node); | 1946 T visitGetField(GetField node); |
1977 T visitCreateBox(CreateBox node); | 1947 T visitCreateBox(CreateBox node); |
1978 T visitReifyRuntimeType(ReifyRuntimeType node); | 1948 T visitReifyRuntimeType(ReifyRuntimeType node); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 visitGetLazyStatic(GetLazyStatic node) { | 2109 visitGetLazyStatic(GetLazyStatic node) { |
2140 processGetLazyStatic(node); | 2110 processGetLazyStatic(node); |
2141 } | 2111 } |
2142 | 2112 |
2143 processLiteralList(LiteralList node) {} | 2113 processLiteralList(LiteralList node) {} |
2144 visitLiteralList(LiteralList node) { | 2114 visitLiteralList(LiteralList node) { |
2145 processLiteralList(node); | 2115 processLiteralList(node); |
2146 node.values.forEach(processReference); | 2116 node.values.forEach(processReference); |
2147 } | 2117 } |
2148 | 2118 |
2149 processLiteralMap(LiteralMap node) {} | |
2150 visitLiteralMap(LiteralMap node) { | |
2151 processLiteralMap(node); | |
2152 for (LiteralMapEntry entry in node.entries) { | |
2153 processReference(entry.key); | |
2154 processReference(entry.value); | |
2155 } | |
2156 } | |
2157 | |
2158 processConstant(Constant node) {} | 2119 processConstant(Constant node) {} |
2159 visitConstant(Constant node) { | 2120 visitConstant(Constant node) { |
2160 processConstant(node); | 2121 processConstant(node); |
2161 } | 2122 } |
2162 | 2123 |
2163 processMutableVariable(node) {} | 2124 processMutableVariable(node) {} |
2164 visitMutableVariable(MutableVariable node) { | 2125 visitMutableVariable(MutableVariable node) { |
2165 processMutableVariable(node); | 2126 processMutableVariable(node); |
2166 } | 2127 } |
2167 | 2128 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 | 2526 |
2566 Definition visitYield(Yield node) { | 2527 Definition visitYield(Yield node) { |
2567 return new Yield(getCopy(node.input), node.hasStar); | 2528 return new Yield(getCopy(node.input), node.hasStar); |
2568 } | 2529 } |
2569 | 2530 |
2570 Definition visitLiteralList(LiteralList node) { | 2531 Definition visitLiteralList(LiteralList node) { |
2571 return new LiteralList(node.dartType, getList(node.values)) | 2532 return new LiteralList(node.dartType, getList(node.values)) |
2572 ..allocationSiteType = node.allocationSiteType; | 2533 ..allocationSiteType = node.allocationSiteType; |
2573 } | 2534 } |
2574 | 2535 |
2575 Definition visitLiteralMap(LiteralMap node) { | |
2576 List<LiteralMapEntry> entries = node.entries.map((LiteralMapEntry entry) { | |
2577 return new LiteralMapEntry(getCopy(entry.key), getCopy(entry.value)); | |
2578 }).toList(); | |
2579 return new LiteralMap(node.dartType, entries); | |
2580 } | |
2581 | |
2582 Definition visitConstant(Constant node) { | 2536 Definition visitConstant(Constant node) { |
2583 return new Constant(node.value, sourceInformation: node.sourceInformation); | 2537 return new Constant(node.value, sourceInformation: node.sourceInformation); |
2584 } | 2538 } |
2585 | 2539 |
2586 Definition visitGetMutable(GetMutable node) { | 2540 Definition visitGetMutable(GetMutable node) { |
2587 return new GetMutable(getCopy(node.variable)); | 2541 return new GetMutable(getCopy(node.variable)); |
2588 } | 2542 } |
2589 | 2543 |
2590 Definition visitParameter(Parameter node) { | 2544 Definition visitParameter(Parameter node) { |
2591 return new Parameter(node.hint); | 2545 return new Parameter(node.hint); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2830 plug(new Branch.loose(_definitions.getCopy(node.condition), | 2784 plug(new Branch.loose(_definitions.getCopy(node.condition), |
2831 _copies[node.trueContinuation.definition], | 2785 _copies[node.trueContinuation.definition], |
2832 _copies[node.falseContinuation.definition]) | 2786 _copies[node.falseContinuation.definition]) |
2833 ..isStrictCheck = node.isStrictCheck); | 2787 ..isStrictCheck = node.isStrictCheck); |
2834 } | 2788 } |
2835 | 2789 |
2836 visitUnreachable(Unreachable node) { | 2790 visitUnreachable(Unreachable node) { |
2837 plug(new Unreachable()); | 2791 plug(new Unreachable()); |
2838 } | 2792 } |
2839 } | 2793 } |
OLD | NEW |