| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 builtin_operator; | 4 library builtin_operator; |
| 5 // This is shared by the CPS and Tree IRs. | 5 // This is shared by the CPS and Tree IRs. |
| 6 // Both cps_ir_nodes and tree_ir_nodes import and re-export this file. | 6 // Both cps_ir_nodes and tree_ir_nodes import and re-export this file. |
| 7 | 7 |
| 8 /// An operator supported natively in the CPS and Tree IRs using the | 8 /// An operator supported natively in the CPS and Tree IRs using the |
| 9 /// `ApplyBuiltinOperator` instructions. | 9 /// `ApplyBuiltinOperator` instructions. |
| 10 /// | 10 /// |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 /// | 151 /// |
| 152 /// Precondition: Argument is a JavaScript Array. | 152 /// Precondition: Argument is a JavaScript Array. |
| 153 IsUnmodifiableJSArray, | 153 IsUnmodifiableJSArray, |
| 154 | 154 |
| 155 // TODO(sra): Remove this and replace with IsFalsy(IsUnmodifiableArray(x)). | 155 // TODO(sra): Remove this and replace with IsFalsy(IsUnmodifiableArray(x)). |
| 156 IsModifiableJSArray, | 156 IsModifiableJSArray, |
| 157 } | 157 } |
| 158 | 158 |
| 159 /// A method supported natively in the CPS and Tree IRs using the | 159 /// A method supported natively in the CPS and Tree IRs using the |
| 160 /// `ApplyBuiltinMethod` instructions. | 160 /// `ApplyBuiltinMethod` instructions. |
| 161 /// | 161 /// |
| 162 /// These methods all operate on a distinguished 'object' argument, and | 162 /// These methods all operate on a distinguished 'object' argument, and |
| 163 /// take zero or more additional arguments. | 163 /// take zero or more additional arguments. |
| 164 /// | 164 /// |
| 165 /// These methods may mutate and depend on the state of the object argument, | 165 /// These methods may mutate and depend on the state of the object argument, |
| 166 /// but may not depend on or mutate any other state. An exception is thrown | 166 /// but may not depend on or mutate any other state. An exception is thrown |
| 167 /// if the object is null, but otherwise they cannot throw or diverge. | 167 /// if the object is null, but otherwise they cannot throw or diverge. |
| 168 enum BuiltinMethod { | 168 enum BuiltinMethod { |
| 169 /// Add an item to a native list. | 169 /// Add an item to a native list. |
| 170 /// | 170 /// |
| 171 /// Takes any number of arguments, each argument will be added to the | 171 /// Takes any number of arguments, each argument will be added to the |
| 172 /// list on the order given (as per the JS `push` method). | 172 /// list on the order given (as per the JS `push` method). |
| 173 /// | 173 /// |
| 174 /// Compiles to `object.push(x1, ..., xN)`. | 174 /// Compiles to `object.push(x1, ..., xN)`. |
| 175 Push, | 175 Push, |
| 176 | 176 |
| 177 /// Remove and return the last item from a native list. | 177 /// Remove and return the last item from a native list. |
| 178 /// | 178 /// |
| 179 /// Takes no arguments. | 179 /// Takes no arguments. |
| 180 /// | 180 /// |
| 181 /// Compiles to `object.pop()`. | 181 /// Compiles to `object.pop()`. |
| 182 Pop, | 182 Pop, |
| 183 } | 183 } |
| 184 |
| 185 /// True for the built-in operators that may be used in a compound assignment. |
| 186 bool isCompoundableOperator(BuiltinOperator operator) { |
| 187 switch(operator) { |
| 188 case BuiltinOperator.NumAdd: |
| 189 case BuiltinOperator.NumSubtract: |
| 190 case BuiltinOperator.NumMultiply: |
| 191 case BuiltinOperator.NumDivide: |
| 192 case BuiltinOperator.NumRemainder: |
| 193 case BuiltinOperator.StringConcatenate: |
| 194 return true; |
| 195 default: |
| 196 return false; |
| 197 } |
| 198 } |
| OLD | NEW |