| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 4 |
| 5 part of native; | 5 part of native; |
| 6 | 6 |
| 7 /// This class is a temporary work-around until we get a more powerful DartType. | 7 /// This class is a temporary work-around until we get a more powerful DartType. |
| 8 class SpecialType { | 8 class SpecialType { |
| 9 final String name; | 9 final String name; |
| 10 const SpecialType._(this.name); | 10 const SpecialType._(this.name); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 NativeThrowBehavior throwBehavior = NativeThrowBehavior.MAY; | 104 NativeThrowBehavior throwBehavior = NativeThrowBehavior.MAY; |
| 105 | 105 |
| 106 bool isAllocation = false; | 106 bool isAllocation = false; |
| 107 bool useGvn = false; | 107 bool useGvn = false; |
| 108 | 108 |
| 109 // TODO(sra): Make NativeBehavior immutable so PURE and PURE_ALLOCATION can be | 109 // TODO(sra): Make NativeBehavior immutable so PURE and PURE_ALLOCATION can be |
| 110 // final constant-like objects. | 110 // final constant-like objects. |
| 111 static NativeBehavior get PURE => NativeBehavior._makePure(); | 111 static NativeBehavior get PURE => NativeBehavior._makePure(); |
| 112 static NativeBehavior get PURE_ALLOCATION => | 112 static NativeBehavior get PURE_ALLOCATION => |
| 113 NativeBehavior._makePure(isAllocation: true); | 113 NativeBehavior._makePure(isAllocation: true); |
| 114 static NativeBehavior get CHANGES_OTHER => NativeBehavior._makeChangesOther(); | |
| 115 static NativeBehavior get DEPENDS_OTHER => NativeBehavior._makeDependsOther(); | |
| 116 | |
| 117 | 114 |
| 118 String toString() { | 115 String toString() { |
| 119 return 'NativeBehavior(' | 116 return 'NativeBehavior(' |
| 120 'returns: ${typesReturned}' | 117 'returns: ${typesReturned}' |
| 121 ', creates: ${typesInstantiated}' | 118 ', creates: ${typesInstantiated}' |
| 122 ', sideEffects: ${sideEffects}' | 119 ', sideEffects: ${sideEffects}' |
| 123 ', throws: ${throwBehavior}' | 120 ', throws: ${throwBehavior}' |
| 124 '${isAllocation ? ", isAllocation" : ""}' | 121 '${isAllocation ? ", isAllocation" : ""}' |
| 125 '${useGvn ? ", useGvn" : ""}' | 122 '${useGvn ? ", useGvn" : ""}' |
| 126 ')'; | 123 ')'; |
| 127 } | 124 } |
| 128 | 125 |
| 129 static NativeBehavior _makePure({bool isAllocation: false}) { | 126 static NativeBehavior _makePure({bool isAllocation: false}) { |
| 130 NativeBehavior behavior = new NativeBehavior(); | 127 NativeBehavior behavior = new NativeBehavior(); |
| 131 behavior.sideEffects.clearAllDependencies(); | 128 behavior.sideEffects.clearAllDependencies(); |
| 132 behavior.sideEffects.clearAllSideEffects(); | 129 behavior.sideEffects.clearAllSideEffects(); |
| 133 behavior.throwBehavior = NativeThrowBehavior.NEVER; | 130 behavior.throwBehavior = NativeThrowBehavior.NEVER; |
| 134 behavior.isAllocation = isAllocation; | 131 behavior.isAllocation = isAllocation; |
| 135 return behavior; | 132 return behavior; |
| 136 } | 133 } |
| 137 | 134 |
| 138 static NativeBehavior _makeChangesOther() { | |
| 139 // TODO(25544): Have a distinct effect instead of using static properties to | |
| 140 // model 'other' effects. | |
| 141 return _makePure()..behavior.sideEffects.setChangesStaticProperty(); | |
| 142 } | |
| 143 | |
| 144 static NativeBehavior _makeDependsOther() { | |
| 145 // TODO(25544): Have a distinct effect instead of using static properties to | |
| 146 // model 'other' effects. | |
| 147 return _makePure()..behavior.sideEffects.setDependsStaticProperty(); | |
| 148 } | |
| 149 | |
| 150 /// Processes the type specification string of a call to JS and stores the | 135 /// Processes the type specification string of a call to JS and stores the |
| 151 /// result in the [typesReturned] and [typesInstantiated]. It furthermore | 136 /// result in the [typesReturned] and [typesInstantiated]. It furthermore |
| 152 /// computes the side effects, and, if given, invokes [setSideEffects] with | 137 /// computes the side effects, and, if given, invokes [setSideEffects] with |
| 153 /// the computed effects. If no side effects are encoded in the [specString] | 138 /// the computed effects. If no side effects are encoded in the [specString] |
| 154 /// the [setSideEffects] method is not invoked. | 139 /// the [setSideEffects] method is not invoked. |
| 155 /// | 140 /// |
| 156 /// Two forms of the string is supported: | 141 /// Two forms of the string is supported: |
| 157 /// | 142 /// |
| 158 /// 1) A single type string of the form 'void', '', 'var' or 'T1|...|Tn' which | 143 /// 1) A single type string of the form 'void', '', 'var' or 'T1|...|Tn' which |
| 159 /// defines the types returned, and, for the last form, the types also | 144 /// defines the types returned, and, for the last form, the types also |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 MessageKind.GENERIC, | 875 MessageKind.GENERIC, |
| 891 {'text': "Type '$typeString' not found."}); | 876 {'text': "Type '$typeString' not found."}); |
| 892 return const DynamicType(); | 877 return const DynamicType(); |
| 893 } | 878 } |
| 894 | 879 |
| 895 static _errorNode(locationNodeOrElement, Parsing parsing) { | 880 static _errorNode(locationNodeOrElement, Parsing parsing) { |
| 896 if (locationNodeOrElement is Node) return locationNodeOrElement; | 881 if (locationNodeOrElement is Node) return locationNodeOrElement; |
| 897 return locationNodeOrElement.parseNode(parsing); | 882 return locationNodeOrElement.parseNode(parsing); |
| 898 } | 883 } |
| 899 } | 884 } |
| OLD | NEW |