Chromium Code Reviews| 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 /// |
| 11 /// These operators are pure in the sense that they cannot throw, diverge, | 11 /// These operators are pure in the sense that they cannot throw, diverge, |
| 12 /// have observable side-effects, return new objects, nor depend on any | 12 /// have observable side-effects, return new objects, nor depend on any |
| 13 /// mutable state. | 13 /// mutable state. |
| 14 /// | 14 /// |
| 15 /// Most operators place restrictions on the values that may be given as | 15 /// Most operators place restrictions on the values that may be given as |
| 16 /// argument; their behaviour is unspecified if those requirements are violated. | 16 /// argument; their behaviour is unspecified if those requirements are violated. |
| 17 /// | 17 /// |
| 18 /// In all cases, the word "null" refers to the Dart null object, corresponding | 18 /// In all cases, the word "null" refers to the Dart null object, corresponding |
| 19 /// to both JS null and JS undefined. | 19 /// to both JS null and JS undefined. |
| 20 /// | |
| 21 /// Some operators, notably [IsFloor] and [IsNumberAndFloor], take "repeated" | |
|
karlklose
2015/06/18 07:36:56
We could avoid this problem by adding 'typeof' and
asgerf
2015/06/18 09:08:49
(Summary from offline discussion with Karl)
I agr
| |
| 22 /// arguments to reflect the number of times the given value is referenced | |
| 23 /// by the generated code. The tree IR needs to know the number of references | |
| 24 /// to safely propagate assignments. | |
| 20 enum BuiltinOperator { | 25 enum BuiltinOperator { |
| 21 /// The numeric binary operators must take two numbers as argument. | 26 /// The numeric binary operators must take two numbers as argument. |
| 22 /// The bitwise operators coerce the result to an unsigned integer, but | 27 /// The bitwise operators coerce the result to an unsigned integer, but |
| 23 /// otherwise these all behave like the corresponding JS operator. | 28 /// otherwise these all behave like the corresponding JS operator. |
| 24 NumAdd, | 29 NumAdd, |
| 25 NumSubtract, | 30 NumSubtract, |
| 26 NumMultiply, | 31 NumMultiply, |
| 27 NumAnd, | 32 NumAnd, |
| 28 NumOr, | 33 NumOr, |
| 29 NumXor, | 34 NumXor, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 48 /// One of the following must hold: | 53 /// One of the following must hold: |
| 49 /// - At least one argument is null. | 54 /// - At least one argument is null. |
| 50 /// - Arguments are both strings, or both booleans, or both numbers. | 55 /// - Arguments are both strings, or both booleans, or both numbers. |
| 51 LooseEq, | 56 LooseEq, |
| 52 | 57 |
| 53 /// Negated version of [LooseEq]. Introduced by [LogicalRewriter] in Tree IR. | 58 /// Negated version of [LooseEq]. Introduced by [LogicalRewriter] in Tree IR. |
| 54 LooseNeq, | 59 LooseNeq, |
| 55 | 60 |
| 56 /// Returns true if the argument is false, +0. -0, NaN, the empty string, | 61 /// Returns true if the argument is false, +0. -0, NaN, the empty string, |
| 57 /// or null. | 62 /// or null. |
| 58 IsFalsy | 63 IsFalsy, |
| 64 | |
| 65 /// Returns true if the argument is a number. | |
| 66 /// | |
| 67 /// Compiles to `typeof x === 'number'` | |
| 68 IsNumber, | |
| 69 | |
| 70 /// Returns true if the argument is not a number. | |
| 71 /// | |
| 72 /// Compiles to `typeof x !== 'number'`. | |
| 73 IsNotNumber, | |
| 74 | |
| 75 /// Returns true if the argument is an integer, false if it is a double or | |
| 76 /// null, and unspecified if it is anything else. | |
| 77 /// | |
| 78 /// The argument must be repeated 2 times. | |
| 79 /// | |
| 80 /// Compiles to `Math.floor(x) === x` | |
| 81 IsFloor, | |
| 82 | |
| 83 /// Returns true if the argument is an integer. | |
| 84 /// | |
| 85 /// The argument must be repeated 3 times. | |
| 86 /// | |
| 87 /// Compiles to `typeof x === 'number' && Math.floor(x) === x` | |
| 88 IsNumberAndFloor, | |
| 59 } | 89 } |
| OLD | NEW |