| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 /// A method supported natively in the CPS and Tree IRs using the | 180 /// A method supported natively in the CPS and Tree IRs using the |
| 181 /// `ApplyBuiltinMethod` instructions. | 181 /// `ApplyBuiltinMethod` instructions. |
| 182 /// | 182 /// |
| 183 /// These methods all operate on a distinguished 'object' argument, and | 183 /// These methods all operate on a distinguished 'object' argument, and |
| 184 /// take zero or more additional arguments. | 184 /// take zero or more additional arguments. |
| 185 /// | 185 /// |
| 186 /// These methods may mutate and depend on the state of the object argument, | 186 /// These methods may mutate and depend on the state of the object argument, |
| 187 /// but may not depend on or mutate any other state. An exception is thrown | 187 /// but may not depend on or mutate any other state. An exception is thrown |
| 188 /// if the object is null, but otherwise they cannot throw or diverge. | 188 /// if the object is null, but otherwise they cannot throw or diverge. |
| 189 enum BuiltinMethod { | 189 enum BuiltinMethod { |
| 190 /// Add an item to a native list. | 190 /// Add an item to an array. |
| 191 /// | 191 /// |
| 192 /// Takes any number of arguments, each argument will be added to the | 192 /// Takes any number of arguments, each argument will be added to the |
| 193 /// list on the order given (as per the JS `push` method). | 193 /// list on the order given (as per the JS `push` method). |
| 194 /// | 194 /// |
| 195 /// Compiles to `object.push(x1, ..., xN)`. | 195 /// Compiles to `object.push(x1, ..., xN)`. |
| 196 Push, | 196 Push, |
| 197 | 197 |
| 198 /// Remove and return the last item from a native list. | 198 /// Remove and return the last item from an array. |
| 199 /// | 199 /// |
| 200 /// Takes no arguments. | 200 /// Takes no arguments. |
| 201 /// | 201 /// |
| 202 /// Compiles to `object.pop()`. | 202 /// Compiles to `object.pop()`. |
| 203 Pop, | 203 Pop, |
| 204 |
| 205 /// Sets the length of the array. |
| 206 /// |
| 207 /// Compiles to `object.length = x1`. |
| 208 SetLength, |
| 204 } | 209 } |
| 205 | 210 |
| 206 /// True for the built-in operators that may be used in a compound assignment. | 211 /// True for the built-in operators that may be used in a compound assignment. |
| 207 bool isCompoundableOperator(BuiltinOperator operator) { | 212 bool isCompoundableOperator(BuiltinOperator operator) { |
| 208 switch(operator) { | 213 switch(operator) { |
| 209 case BuiltinOperator.NumAdd: | 214 case BuiltinOperator.NumAdd: |
| 210 case BuiltinOperator.NumSubtract: | 215 case BuiltinOperator.NumSubtract: |
| 211 case BuiltinOperator.NumMultiply: | 216 case BuiltinOperator.NumMultiply: |
| 212 case BuiltinOperator.NumDivide: | 217 case BuiltinOperator.NumDivide: |
| 213 case BuiltinOperator.NumRemainder: | 218 case BuiltinOperator.NumRemainder: |
| 214 case BuiltinOperator.StringConcatenate: | 219 case BuiltinOperator.StringConcatenate: |
| 215 return true; | 220 return true; |
| 216 default: | 221 default: |
| 217 return false; | 222 return false; |
| 218 } | 223 } |
| 219 } | 224 } |
| OLD | NEW |