| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library rasta.error; | 5 library rasta.error; |
| 6 | 6 |
| 7 import "package:compiler/src/resolution/operators.dart" show | 7 import "package:compiler/src/resolution/operators.dart" show |
| 8 AssignmentOperator, | 8 AssignmentOperator, |
| 9 BinaryOperator, | 9 BinaryOperator, |
| 10 IncDecOperator, | 10 IncDecOperator, |
| 11 UnaryOperator; | 11 UnaryOperator; |
| 12 | 12 |
| 13 import "package:compiler/src/universe/call_structure.dart" show | 13 import "package:compiler/src/universe/call_structure.dart" show |
| 14 CallStructure; | 14 CallStructure; |
| 15 | 15 |
| 16 import "package:compiler/src/elements/elements.dart" show | 16 import "package:compiler/src/elements/elements.dart" show |
| 17 Element, | 17 Element, |
| 18 ErroneousElement; | 18 ErroneousElement; |
| 19 | 19 |
| 20 import "package:compiler/src/dart_types.dart" show | 20 import "package:compiler/src/dart_types.dart" show |
| 21 DartType; | 21 DartType; |
| 22 | 22 |
| 23 import "package:compiler/src/tree/tree.dart" show | 23 import "package:compiler/src/tree/tree.dart" show |
| 24 Expression, |
| 24 NewExpression, | 25 NewExpression, |
| 25 Node, | 26 Node, |
| 26 NodeList, | 27 NodeList, |
| 27 Operator, | 28 Operator, |
| 28 Send, | 29 Send, |
| 29 SendSet; | 30 SendSet; |
| 30 | 31 |
| 31 import "package:compiler/src/universe/selector.dart" show | 32 import "package:compiler/src/universe/selector.dart" show |
| 32 Selector; | 33 Selector; |
| 33 | 34 |
| 34 import 'package:kernel/ast.dart' as ir; | 35 import 'package:kernel/ast.dart' as ir; |
| 35 | 36 |
| 36 abstract class RastaError { | 37 abstract class RastaError { |
| 37 ir.Throw handleError(Node node); | 38 // TODO(ahe): Get rid of this method, each error should be handled according |
| 39 // to the semantics required by the Dart Language Specification. |
| 40 ir.Expression handleError(Expression node); |
| 38 | 41 |
| 39 ir.Throw errorInvalidBinary( | 42 ir.Expression errorInvalidBinary( |
| 40 Send node, | 43 Send node, |
| 41 ErroneousElement error, | 44 ErroneousElement error, |
| 42 BinaryOperator operator, | 45 BinaryOperator operator, |
| 43 Node right, | 46 Node right, |
| 44 _) { | 47 _) { |
| 45 return handleError(node); | 48 return handleError(node); |
| 46 } | 49 } |
| 47 | 50 |
| 48 ir.Throw errorInvalidCompound( | 51 ir.Expression errorInvalidCompound( |
| 49 Send node, | 52 Send node, |
| 50 ErroneousElement error, | 53 ErroneousElement error, |
| 51 AssignmentOperator operator, | 54 AssignmentOperator operator, |
| 52 Node rhs, | 55 Node rhs, |
| 53 _) { | 56 _) { |
| 54 return handleError(node); | 57 return handleError(node); |
| 55 } | 58 } |
| 56 | 59 |
| 57 ir.Throw errorInvalidCompoundIndexSet( | 60 ir.Expression errorInvalidCompoundIndexSet( |
| 58 Send node, | 61 Send node, |
| 59 ErroneousElement error, | 62 ErroneousElement error, |
| 60 Node index, | 63 Node index, |
| 61 AssignmentOperator operator, | 64 AssignmentOperator operator, |
| 62 Node rhs, | 65 Node rhs, |
| 63 _) { | 66 _) { |
| 64 return handleError(node); | 67 return handleError(node); |
| 65 } | 68 } |
| 66 | 69 |
| 67 ir.Throw errorInvalidEquals( | 70 ir.Expression errorInvalidEquals( |
| 68 Send node, | 71 Send node, |
| 69 ErroneousElement error, | 72 ErroneousElement error, |
| 70 Node right, | 73 Node right, |
| 71 _) { | 74 _) { |
| 72 return handleError(node); | 75 return handleError(node); |
| 73 } | 76 } |
| 74 | 77 |
| 75 ir.Throw errorInvalidGet( | 78 ir.Expression errorInvalidGet( |
| 76 Send node, | 79 Send node, |
| 77 ErroneousElement error, | 80 ErroneousElement error, |
| 78 _) { | 81 _) { |
| 79 return handleError(node); | 82 return handleError(node); |
| 80 } | 83 } |
| 81 | 84 |
| 82 ir.Throw errorInvalidIndex( | 85 ir.Expression errorInvalidIndex( |
| 83 Send node, | 86 Send node, |
| 84 ErroneousElement error, | 87 ErroneousElement error, |
| 85 Node index, | 88 Node index, |
| 86 _) { | 89 _) { |
| 87 return handleError(node); | 90 return handleError(node); |
| 88 } | 91 } |
| 89 | 92 |
| 90 ir.Throw errorInvalidIndexPostfix( | 93 ir.Expression errorInvalidIndexPostfix( |
| 91 Send node, | 94 Send node, |
| 92 ErroneousElement error, | 95 ErroneousElement error, |
| 93 Node index, | 96 Node index, |
| 94 IncDecOperator operator, | 97 IncDecOperator operator, |
| 95 _) { | 98 _) { |
| 96 return handleError(node); | 99 return handleError(node); |
| 97 } | 100 } |
| 98 | 101 |
| 99 ir.Throw errorInvalidIndexPrefix( | 102 ir.Expression errorInvalidIndexPrefix( |
| 100 Send node, | 103 Send node, |
| 101 ErroneousElement error, | 104 ErroneousElement error, |
| 102 Node index, | 105 Node index, |
| 103 IncDecOperator operator, | 106 IncDecOperator operator, |
| 104 _) { | 107 _) { |
| 105 return handleError(node); | 108 return handleError(node); |
| 106 } | 109 } |
| 107 | 110 |
| 108 ir.Throw errorInvalidIndexSet( | 111 ir.Expression errorInvalidIndexSet( |
| 109 Send node, | 112 Send node, |
| 110 ErroneousElement error, | 113 ErroneousElement error, |
| 111 Node index, | 114 Node index, |
| 112 Node rhs, | 115 Node rhs, |
| 113 _) { | 116 _) { |
| 114 return handleError(node); | 117 return handleError(node); |
| 115 } | 118 } |
| 116 | 119 |
| 117 ir.Throw errorInvalidInvoke( | 120 ir.Expression errorInvalidInvoke( |
| 118 Send node, | 121 Send node, |
| 119 ErroneousElement error, | 122 ErroneousElement error, |
| 120 NodeList arguments, | 123 NodeList arguments, |
| 121 Selector selector, | 124 Selector selector, |
| 122 _) { | 125 _) { |
| 123 return handleError(node); | 126 return handleError(node); |
| 124 } | 127 } |
| 125 | 128 |
| 126 ir.Throw errorInvalidNotEquals( | 129 ir.Expression errorInvalidNotEquals( |
| 127 Send node, | 130 Send node, |
| 128 ErroneousElement error, | 131 ErroneousElement error, |
| 129 Node right, | 132 Node right, |
| 130 _) { | 133 _) { |
| 131 return handleError(node); | 134 return handleError(node); |
| 132 } | 135 } |
| 133 | 136 |
| 134 ir.Throw errorInvalidPostfix( | 137 ir.Expression errorInvalidPostfix( |
| 135 Send node, | 138 Send node, |
| 136 ErroneousElement error, | 139 ErroneousElement error, |
| 137 IncDecOperator operator, | 140 IncDecOperator operator, |
| 138 _) { | 141 _) { |
| 139 return handleError(node); | 142 return handleError(node); |
| 140 } | 143 } |
| 141 | 144 |
| 142 ir.Throw errorInvalidPrefix( | 145 ir.Expression errorInvalidPrefix( |
| 143 Send node, | 146 Send node, |
| 144 ErroneousElement error, | 147 ErroneousElement error, |
| 145 IncDecOperator operator, | 148 IncDecOperator operator, |
| 146 _) { | 149 _) { |
| 147 return handleError(node); | 150 return handleError(node); |
| 148 } | 151 } |
| 149 | 152 |
| 150 ir.Throw errorInvalidSet( | 153 ir.Expression errorInvalidSet( |
| 151 Send node, | 154 Send node, |
| 152 ErroneousElement error, | 155 ErroneousElement error, |
| 153 Node rhs, | 156 Node rhs, |
| 154 _) { | 157 _) { |
| 155 return handleError(node); | 158 return handleError(node); |
| 156 } | 159 } |
| 157 | 160 |
| 158 ir.Throw errorInvalidSetIfNull( | 161 ir.Expression errorInvalidSetIfNull( |
| 159 Send node, | 162 Send node, |
| 160 ErroneousElement error, | 163 ErroneousElement error, |
| 161 Node rhs, | 164 Node rhs, |
| 162 _) { | 165 _) { |
| 163 return handleError(node); | 166 return handleError(node); |
| 164 } | 167 } |
| 165 | 168 |
| 166 ir.Throw errorInvalidUnary( | 169 ir.Expression errorInvalidUnary( |
| 167 Send node, | 170 Send node, |
| 168 UnaryOperator operator, | 171 UnaryOperator operator, |
| 169 ErroneousElement error, | 172 ErroneousElement error, |
| 170 _) { | 173 _) { |
| 171 return handleError(node); | 174 return handleError(node); |
| 172 } | 175 } |
| 173 | 176 |
| 174 ir.Throw errorNonConstantConstructorInvoke( | 177 ir.Expression errorNonConstantConstructorInvoke( |
| 175 NewExpression node, | 178 NewExpression node, |
| 176 Element element, | 179 Element element, |
| 177 DartType type, | 180 DartType type, |
| 178 NodeList arguments, | 181 NodeList arguments, |
| 179 CallStructure callStructure, | 182 CallStructure callStructure, |
| 180 _) { | 183 _) { |
| 181 return handleError(node); | 184 return handleError(node); |
| 182 } | 185 } |
| 183 | 186 |
| 184 ir.Throw errorUndefinedBinaryExpression( | 187 ir.Expression errorUndefinedBinaryExpression( |
| 185 Send node, | 188 Send node, |
| 186 Node left, | 189 Node left, |
| 187 Operator operator, | 190 Operator operator, |
| 188 Node right, | 191 Node right, |
| 189 _) { | 192 _) { |
| 190 return handleError(node); | 193 return handleError(node); |
| 191 } | 194 } |
| 192 | 195 |
| 193 ir.Throw errorUndefinedUnaryExpression( | 196 ir.Expression errorUndefinedUnaryExpression( |
| 194 Send node, | 197 Send node, |
| 195 Operator operator, | 198 Operator operator, |
| 196 Node expression, | 199 Node expression, |
| 197 _) { | 200 _) { |
| 198 return handleError(node); | 201 return handleError(node); |
| 199 } | 202 } |
| 200 | 203 |
| 201 ir.Throw errorUnresolvedFieldInitializer( | 204 ir.Expression errorUnresolvedFieldInitializer( |
| 202 SendSet node, | 205 SendSet node, |
| 203 Element element, | 206 Element element, |
| 204 Node initializer, | 207 Node initializer, |
| 205 _) { | 208 _) { |
| 206 return handleError(node); | 209 return handleError(node); |
| 207 } | 210 } |
| 208 | 211 |
| 209 ir.Throw errorUnresolvedSuperConstructorInvoke( | 212 ir.Expression errorUnresolvedSuperConstructorInvoke( |
| 210 Send node, | 213 Send node, |
| 211 Element element, | 214 Element element, |
| 212 NodeList arguments, | 215 NodeList arguments, |
| 213 Selector selector, | 216 Selector selector, |
| 214 _) { | 217 _) { |
| 215 return handleError(node); | 218 return handleError(node); |
| 216 } | 219 } |
| 217 | 220 |
| 218 ir.Throw errorUnresolvedThisConstructorInvoke( | 221 ir.Expression errorUnresolvedThisConstructorInvoke( |
| 219 Send node, | 222 Send node, |
| 220 Element element, | 223 Element element, |
| 221 NodeList arguments, | 224 NodeList arguments, |
| 222 Selector selector, | 225 Selector selector, |
| 223 _) { | 226 _) { |
| 224 return handleError(node); | 227 return handleError(node); |
| 225 } | 228 } |
| 226 | 229 |
| 227 ir.Throw errorInvalidIndexSetIfNull( | 230 ir.Expression errorInvalidIndexSetIfNull( |
| 228 SendSet node, ErroneousElement error, Node index, Node rhs, _) { | 231 SendSet node, ErroneousElement error, Node index, Node rhs, _) { |
| 229 return handleError(node); | 232 return handleError(node); |
| 230 } | 233 } |
| 231 } | 234 } |
| OLD | NEW |