| 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_STATIC_PROPERTY => |
| 115 NativeBehavior._makeAssignsStaticProperty(); |
| 116 |
| 114 | 117 |
| 115 String toString() { | 118 String toString() { |
| 116 return 'NativeBehavior(' | 119 return 'NativeBehavior(' |
| 117 'returns: ${typesReturned}' | 120 'returns: ${typesReturned}' |
| 118 ', creates: ${typesInstantiated}' | 121 ', creates: ${typesInstantiated}' |
| 119 ', sideEffects: ${sideEffects}' | 122 ', sideEffects: ${sideEffects}' |
| 120 ', throws: ${throwBehavior}' | 123 ', throws: ${throwBehavior}' |
| 121 '${isAllocation ? ", isAllocation" : ""}' | 124 '${isAllocation ? ", isAllocation" : ""}' |
| 122 '${useGvn ? ", useGvn" : ""}' | 125 '${useGvn ? ", useGvn" : ""}' |
| 123 ')'; | 126 ')'; |
| 124 } | 127 } |
| 125 | 128 |
| 126 static NativeBehavior _makePure({bool isAllocation: false}) { | 129 static NativeBehavior _makePure({bool isAllocation: false}) { |
| 127 NativeBehavior behavior = new NativeBehavior(); | 130 NativeBehavior behavior = new NativeBehavior(); |
| 128 behavior.sideEffects.clearAllDependencies(); | 131 behavior.sideEffects.clearAllDependencies(); |
| 129 behavior.sideEffects.clearAllSideEffects(); | 132 behavior.sideEffects.clearAllSideEffects(); |
| 130 behavior.throwBehavior = NativeThrowBehavior.NEVER; | 133 behavior.throwBehavior = NativeThrowBehavior.NEVER; |
| 131 behavior.isAllocation = isAllocation; | 134 behavior.isAllocation = isAllocation; |
| 132 return behavior; | 135 return behavior; |
| 133 } | 136 } |
| 134 | 137 |
| 138 static NativeBehavior _makeAssignsStaticProperty() { |
| 139 NativeBehavior behavior = new NativeBehavior(); |
| 140 behavior.sideEffects.clearAllDependencies(); |
| 141 behavior.sideEffects.clearAllSideEffects(); |
| 142 behavior.sideEffects.setChangesStaticProperty(); |
| 143 behavior.throwBehavior = NativeThrowBehavior.NEVER; |
| 144 behavior.isAllocation = false; |
| 145 return behavior; |
| 146 } |
| 147 |
| 135 /// Processes the type specification string of a call to JS and stores the | 148 /// Processes the type specification string of a call to JS and stores the |
| 136 /// result in the [typesReturned] and [typesInstantiated]. It furthermore | 149 /// result in the [typesReturned] and [typesInstantiated]. It furthermore |
| 137 /// computes the side effects, and, if given, invokes [setSideEffects] with | 150 /// computes the side effects, and, if given, invokes [setSideEffects] with |
| 138 /// the computed effects. If no side effects are encoded in the [specString] | 151 /// the computed effects. If no side effects are encoded in the [specString] |
| 139 /// the [setSideEffects] method is not invoked. | 152 /// the [setSideEffects] method is not invoked. |
| 140 /// | 153 /// |
| 141 /// Two forms of the string is supported: | 154 /// Two forms of the string is supported: |
| 142 /// | 155 /// |
| 143 /// 1) A single type string of the form 'void', '', 'var' or 'T1|...|Tn' which | 156 /// 1) A single type string of the form 'void', '', 'var' or 'T1|...|Tn' which |
| 144 /// defines the types returned, and, for the last form, the types also | 157 /// 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... |
| 875 MessageKind.GENERIC, | 888 MessageKind.GENERIC, |
| 876 {'text': "Type '$typeString' not found."}); | 889 {'text': "Type '$typeString' not found."}); |
| 877 return const DynamicType(); | 890 return const DynamicType(); |
| 878 } | 891 } |
| 879 | 892 |
| 880 static _errorNode(locationNodeOrElement, Parsing parsing) { | 893 static _errorNode(locationNodeOrElement, Parsing parsing) { |
| 881 if (locationNodeOrElement is Node) return locationNodeOrElement; | 894 if (locationNodeOrElement is Node) return locationNodeOrElement; |
| 882 return locationNodeOrElement.parseNode(parsing); | 895 return locationNodeOrElement.parseNode(parsing); |
| 883 } | 896 } |
| 884 } | 897 } |
| OLD | NEW |