Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // TODO(sigmund): rename universe => world | |
| 2 /// Describes individual features that may be seen in a program. Most features | |
| 3 /// can be described only by name using the [Feature] enum, some features are | |
| 4 /// expressed including details on how they are used. For example, whether a | |
| 5 /// list literal was constant or empty. | |
| 6 /// | |
| 7 /// The use of these features is typically discovered in an early phase of the | |
| 8 /// compilation pipeline, for example during resolution. | |
| 9 library compiler.universe.feature; | |
| 10 | |
| 11 import '../dart_types.dart' show InterfaceType; | |
| 12 | |
| 13 /// A language feature that may be seen in the program. | |
|
Siggi Cherem (dart-lang)
2016/08/16 18:21:51
FYI - I updated the library and class docs (see or
| |
| 14 // TODO(johnniwinther): Should mirror usage be part of this? | |
| 15 enum Feature { | |
| 16 /// Invocation of a generative construction on an abstract class. | |
| 17 ABSTRACT_CLASS_INSTANTIATION, | |
| 18 | |
| 19 /// An assert statement with no message. | |
| 20 ASSERT, | |
| 21 | |
| 22 /// An assert statement with a message. | |
| 23 ASSERT_WITH_MESSAGE, | |
| 24 | |
| 25 /// A method with an `async` body modifier. | |
| 26 ASYNC, | |
| 27 | |
| 28 /// An asynchronous for in statement like `await for (var e in i) {}`. | |
| 29 ASYNC_FOR_IN, | |
| 30 | |
| 31 /// A method with an `async*` body modifier. | |
| 32 ASYNC_STAR, | |
| 33 | |
| 34 /// A catch statement. | |
| 35 CATCH_STATEMENT, | |
| 36 | |
| 37 /// A compile time error. | |
| 38 COMPILE_TIME_ERROR, | |
| 39 | |
| 40 /// A fall through in a switch case. | |
| 41 FALL_THROUGH_ERROR, | |
| 42 | |
| 43 /// A ++/-- operation. | |
| 44 INC_DEC_OPERATION, | |
| 45 | |
| 46 /// A field whose initialization is not a constant. | |
| 47 LAZY_FIELD, | |
| 48 | |
| 49 /// A catch clause with a variable for the stack trace. | |
| 50 STACK_TRACE_IN_CATCH, | |
| 51 | |
| 52 /// String interpolation. | |
| 53 STRING_INTERPOLATION, | |
| 54 | |
| 55 /// String juxtaposition. | |
| 56 STRING_JUXTAPOSITION, | |
| 57 | |
| 58 /// An implicit call to `super.noSuchMethod`, like calling an unresolved | |
| 59 /// super method. | |
| 60 SUPER_NO_SUCH_METHOD, | |
| 61 | |
| 62 /// A redirection to the `Symbol` constructor. | |
| 63 SYMBOL_CONSTRUCTOR, | |
| 64 | |
| 65 /// An synchronous for in statement, like `for (var e in i) {}`. | |
| 66 SYNC_FOR_IN, | |
| 67 | |
| 68 /// A method with a `sync*` body modifier. | |
| 69 SYNC_STAR, | |
| 70 | |
| 71 /// A throw expression. | |
| 72 THROW_EXPRESSION, | |
| 73 | |
| 74 /// An implicit throw of a `NoSuchMethodError`, like calling an unresolved | |
| 75 /// static method. | |
| 76 THROW_NO_SUCH_METHOD, | |
| 77 | |
| 78 /// An implicit throw of a runtime error, like | |
| 79 THROW_RUNTIME_ERROR, | |
| 80 | |
| 81 /// The need for a type variable bound check, like instantiation of a generic | |
| 82 /// type whose type variable have non-trivial bounds. | |
| 83 TYPE_VARIABLE_BOUNDS_CHECK, | |
| 84 } | |
| 85 | |
| 86 /// Describes a use of a map literal in the program. | |
| 87 class MapLiteralUse { | |
| 88 final InterfaceType type; | |
| 89 final bool isConstant; | |
| 90 final bool isEmpty; | |
| 91 | |
| 92 MapLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false}); | |
| 93 | |
| 94 int get hashCode { | |
| 95 return type.hashCode * 13 + | |
| 96 isConstant.hashCode * 17 + | |
| 97 isEmpty.hashCode * 19; | |
| 98 } | |
| 99 | |
| 100 bool operator ==(other) { | |
| 101 if (identical(this, other)) return true; | |
| 102 if (other is! MapLiteralUse) return false; | |
| 103 return type == other.type && | |
| 104 isConstant == other.isConstant && | |
| 105 isEmpty == other.isEmpty; | |
| 106 } | |
| 107 | |
| 108 String toString() { | |
| 109 return 'MapLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)'; | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 /// Describes the use of a list literal in the program. | |
| 114 class ListLiteralUse { | |
| 115 final InterfaceType type; | |
| 116 final bool isConstant; | |
| 117 final bool isEmpty; | |
| 118 | |
| 119 ListLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false}); | |
| 120 | |
| 121 int get hashCode { | |
| 122 return type.hashCode * 13 + | |
| 123 isConstant.hashCode * 17 + | |
| 124 isEmpty.hashCode * 19; | |
| 125 } | |
| 126 | |
| 127 bool operator ==(other) { | |
| 128 if (identical(this, other)) return true; | |
| 129 if (other is! ListLiteralUse) return false; | |
| 130 return type == other.type && | |
| 131 isConstant == other.isConstant && | |
| 132 isEmpty == other.isEmpty; | |
| 133 } | |
| 134 | |
| 135 String toString() { | |
| 136 return 'ListLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)'; | |
| 137 } | |
| 138 } | |
| OLD | NEW |