OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 |
| 5 import 'package:kernel/ast.dart' as ir; |
| 6 |
| 7 import "../dart_types.dart" show DartType, InterfaceType; |
| 8 import "../elements/elements.dart" |
| 9 show |
| 10 AstElement, |
| 11 ConstructorElement, |
| 12 Element, |
| 13 ErroneousElement, |
| 14 FunctionElement, |
| 15 MethodElement; |
| 16 import "../resolution/operators.dart" |
| 17 show AssignmentOperator, BinaryOperator, IncDecOperator, UnaryOperator; |
| 18 import "../tree/tree.dart" show Expression, NewExpression, Node, NodeList, Send; |
| 19 import "../universe/call_structure.dart" show CallStructure; |
| 20 import "../universe/selector.dart" show Selector; |
| 21 import 'accessors.dart'; |
| 22 import "kernel.dart" show Kernel; |
| 23 |
| 24 abstract class UnresolvedVisitor { |
| 25 Kernel get kernel; |
| 26 |
| 27 // Implemented in KernelVisitor |
| 28 AstElement get currentElement; |
| 29 bool get isVoidContext; |
| 30 ir.Arguments buildArguments(NodeList arguments); |
| 31 ir.TreeNode visitForValue(Expression node); |
| 32 |
| 33 // TODO(ahe): Delete this method. |
| 34 ir.InvalidExpression handleUnresolved(Node node); |
| 35 |
| 36 /// Similar to [Kernel.functionToIr] but returns null if [function] is a |
| 37 /// synthetic function created for error recovery. |
| 38 ir.Member possiblyErroneousFunctionToIr(FunctionElement function) { |
| 39 return kernel.isSyntheticError(function) |
| 40 ? null |
| 41 : kernel.functionToIr(function); |
| 42 } |
| 43 |
| 44 /// Throws a [NoSuchMethodError] corresponding to a call to |
| 45 /// [receiver].[memberName] with the arguments [callArguments]. |
| 46 /// |
| 47 /// The exception object is built by calling [exceptionBuilder]. This should |
| 48 /// take the same arguments as the default constructor to [NoSuchMethodError], |
| 49 /// but the method itself may encode additional details about the call than |
| 50 /// is possible through the public interface of NoSuchMethodError. |
| 51 /// |
| 52 /// Note that [callArguments] are the arguments as they occur in the attempted |
| 53 /// call in user code -- they are not the arguments to [exceptionBuilder]. |
| 54 /// |
| 55 /// If [candidateTarget] is given, it will provide the expected parameter |
| 56 /// names. |
| 57 ir.Expression buildThrowNoSuchMethodError(ir.Procedure exceptionBuilder, |
| 58 ir.Expression receiver, String memberName, ir.Arguments callArguments, |
| 59 [Element candidateTarget]) { |
| 60 ir.Expression memberNameArg = new ir.SymbolLiteral(memberName); |
| 61 ir.Expression positional = new ir.ListLiteral(callArguments.positional); |
| 62 ir.Expression named = new ir.MapLiteral(callArguments.named.map((e) { |
| 63 return new ir.MapEntry(new ir.SymbolLiteral(e.name), e.value); |
| 64 }).toList()); |
| 65 if (candidateTarget is FunctionElement) { |
| 66 // Ensure [candidateTarget] has been resolved. |
| 67 possiblyErroneousFunctionToIr(candidateTarget); |
| 68 } |
| 69 ir.Expression existingArguments; |
| 70 if (candidateTarget is FunctionElement && |
| 71 !kernel.isSyntheticError(candidateTarget) && |
| 72 candidateTarget.hasFunctionSignature) { |
| 73 List<ir.Expression> existingArgumentsList = <ir.Expression>[]; |
| 74 candidateTarget.functionSignature.forEachParameter((param) { |
| 75 existingArgumentsList.add(new ir.StringLiteral(param.name)); |
| 76 }); |
| 77 existingArguments = new ir.ListLiteral(existingArgumentsList); |
| 78 } else { |
| 79 existingArguments = new ir.NullLiteral(); |
| 80 } |
| 81 return new ir.Throw(new ir.StaticInvocation( |
| 82 exceptionBuilder, |
| 83 new ir.Arguments(<ir.Expression>[ |
| 84 receiver, |
| 85 memberNameArg, |
| 86 positional, |
| 87 named, |
| 88 existingArguments |
| 89 ]))); |
| 90 } |
| 91 |
| 92 /// Throws a NoSuchMethodError for an unresolved getter named [name]. |
| 93 ir.Expression buildThrowUnresolvedGetter(String name, |
| 94 [ir.Procedure exceptionBuilder]) { |
| 95 // TODO(asgerf): We should remove this fallback, but in some cases we do |
| 96 // not get sufficient information to determine exactly what kind of |
| 97 // getter it is. |
| 98 exceptionBuilder ??= kernel.getGenericNoSuchMethodBuilder(); |
| 99 return buildThrowNoSuchMethodError( |
| 100 exceptionBuilder, new ir.NullLiteral(), name, new ir.Arguments.empty()); |
| 101 } |
| 102 |
| 103 ir.Expression buildThrowUnresolvedSetter(String name, ir.Expression argument, |
| 104 [ir.Procedure exceptionBuilder]) { |
| 105 // TODO(asgerf): We should remove this fallback, but in some cases we do |
| 106 // not get sufficient information to determine exactly what kind of |
| 107 // setter it is. |
| 108 exceptionBuilder ??= kernel.getGenericNoSuchMethodBuilder(); |
| 109 return buildThrowNoSuchMethodError(exceptionBuilder, new ir.NullLiteral(), |
| 110 name, new ir.Arguments(<ir.Expression>[argument])); |
| 111 } |
| 112 |
| 113 ir.Expression buildThrowUnresolvedSuperGetter(String name) { |
| 114 return buildThrowNoSuchMethodError(kernel.getUnresolvedSuperGetterBuilder(), |
| 115 new ir.ThisExpression(), name, new ir.Arguments.empty()); |
| 116 } |
| 117 |
| 118 ir.Expression buildThrowUnresolvedSuperSetter( |
| 119 String name, ir.Expression argument) { |
| 120 return buildThrowNoSuchMethodError( |
| 121 kernel.getUnresolvedSuperSetterBuilder(), |
| 122 new ir.ThisExpression(), |
| 123 name, |
| 124 new ir.Arguments(<ir.Expression>[argument])); |
| 125 } |
| 126 |
| 127 ir.Expression buildThrowSingleArgumentError( |
| 128 ir.Procedure exceptionBuilder, String errorMessage) { |
| 129 return new ir.Throw(new ir.StaticInvocation(exceptionBuilder, |
| 130 new ir.Arguments(<ir.Expression>[new ir.StringLiteral(errorMessage)]))); |
| 131 } |
| 132 |
| 133 ir.Expression visitUnresolvedClassConstructorInvoke( |
| 134 NewExpression node, |
| 135 ErroneousElement element, |
| 136 DartType type, |
| 137 NodeList arguments, |
| 138 Selector selector, |
| 139 _) { |
| 140 // TODO(asgerf): The VM includes source information as part of the error |
| 141 // message. We could do the same when we add source maps. |
| 142 return buildThrowSingleArgumentError( |
| 143 kernel.getMalformedTypeErrorBuilder(), element.message); |
| 144 } |
| 145 |
| 146 ir.Expression visitUnresolvedConstructorInvoke( |
| 147 NewExpression node, |
| 148 Element constructor, |
| 149 DartType type, |
| 150 NodeList arguments, |
| 151 Selector selector, |
| 152 _) { |
| 153 ir.Expression receiver = new ir.TypeLiteral(kernel.interfaceTypeToIr(type)); |
| 154 String methodName = |
| 155 node.send.selector != null ? '${node.send.selector}' : type.name; |
| 156 return buildThrowNoSuchMethodError(kernel.getUnresolvedConstructorBuilder(), |
| 157 receiver, methodName, buildArguments(arguments), constructor); |
| 158 } |
| 159 |
| 160 ir.Expression visitUnresolvedCompound( |
| 161 Send node, Element element, AssignmentOperator operator, Node rhs, _) { |
| 162 return buildThrowUnresolvedGetter('${node.selector}'); |
| 163 } |
| 164 |
| 165 ir.Expression visitUnresolvedGet(Send node, Element element, _) { |
| 166 return buildThrowUnresolvedGetter('${node.selector}'); |
| 167 } |
| 168 |
| 169 ir.Expression visitUnresolvedInvoke( |
| 170 Send node, Element element, NodeList arguments, Selector selector, _) { |
| 171 // TODO(asgerf): Should we use a type literal as receiver for unresolved |
| 172 // static invocations? |
| 173 return buildThrowNoSuchMethodError(kernel.getGenericNoSuchMethodBuilder(), |
| 174 new ir.NullLiteral(), element.name, buildArguments(arguments), element); |
| 175 } |
| 176 |
| 177 ir.Expression visitUnresolvedPostfix( |
| 178 Send node, Element element, IncDecOperator operator, _) { |
| 179 return buildThrowUnresolvedGetter('${node.selector}'); |
| 180 } |
| 181 |
| 182 ir.Expression visitUnresolvedPrefix( |
| 183 Send node, Element element, IncDecOperator operator, _) { |
| 184 return buildThrowUnresolvedGetter('${node.selector}'); |
| 185 } |
| 186 |
| 187 ir.Expression visitUnresolvedRedirectingFactoryConstructorInvoke( |
| 188 NewExpression node, |
| 189 ConstructorElement constructor, |
| 190 InterfaceType type, |
| 191 NodeList arguments, |
| 192 CallStructure callStructure, |
| 193 _) { |
| 194 // The body of the factory will throw an error. |
| 195 return new ir.StaticInvocation( |
| 196 possiblyErroneousFunctionToIr(constructor), buildArguments(arguments)); |
| 197 } |
| 198 |
| 199 ir.Expression visitUnresolvedSet(Send node, Element element, Node rhs, _) { |
| 200 return buildThrowUnresolvedSetter('${node.selector}', visitForValue(rhs)); |
| 201 } |
| 202 |
| 203 ir.Expression visitUnresolvedSetIfNull( |
| 204 Send node, Element element, Node rhs, _) { |
| 205 return buildThrowUnresolvedGetter('${node.selector}'); |
| 206 } |
| 207 |
| 208 ir.Expression visitUnresolvedStaticGetterCompound(Send node, Element element, |
| 209 MethodElement setter, AssignmentOperator operator, Node rhs, _) { |
| 210 return buildThrowUnresolvedGetter( |
| 211 '${node.selector}', kernel.getUnresolvedStaticGetterBuilder()); |
| 212 } |
| 213 |
| 214 ir.Expression visitUnresolvedStaticGetterPostfix(Send node, Element element, |
| 215 MethodElement setter, IncDecOperator operator, _) { |
| 216 return buildThrowUnresolvedGetter( |
| 217 '${node.selector}', kernel.getUnresolvedStaticGetterBuilder()); |
| 218 } |
| 219 |
| 220 ir.Expression visitUnresolvedStaticGetterPrefix(Send node, Element element, |
| 221 MethodElement setter, IncDecOperator operator, _) { |
| 222 return buildThrowUnresolvedGetter( |
| 223 '${node.selector}', kernel.getUnresolvedStaticGetterBuilder()); |
| 224 } |
| 225 |
| 226 ir.Expression visitUnresolvedStaticGetterSetIfNull( |
| 227 Send node, Element element, MethodElement setter, Node rhs, _) { |
| 228 return buildThrowUnresolvedGetter( |
| 229 '${node.selector}', kernel.getUnresolvedStaticGetterBuilder()); |
| 230 } |
| 231 |
| 232 ir.Expression visitUnresolvedStaticSetterCompound( |
| 233 Send node, |
| 234 MethodElement getter, |
| 235 Element element, |
| 236 AssignmentOperator operator, |
| 237 Node rhs, |
| 238 _) { |
| 239 return buildThrowUnresolvedSetter('${node.selector}', visitForValue(rhs), |
| 240 kernel.getUnresolvedStaticSetterBuilder()); |
| 241 } |
| 242 |
| 243 ir.Expression visitUnresolvedStaticSetterPostfix(Send node, |
| 244 MethodElement getter, Element element, IncDecOperator operator, _) { |
| 245 var accessor = new ClassStaticAccessor( |
| 246 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 247 return accessor.buildPostfixIncrement(new ir.Name(operator.selectorName), |
| 248 voidContext: isVoidContext); |
| 249 } |
| 250 |
| 251 ir.Expression visitUnresolvedStaticSetterPrefix(Send node, |
| 252 MethodElement getter, Element element, IncDecOperator operator, _) { |
| 253 var accessor = new ClassStaticAccessor( |
| 254 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 255 return accessor.buildPrefixIncrement(new ir.Name(operator.selectorName), |
| 256 voidContext: isVoidContext); |
| 257 } |
| 258 |
| 259 ir.Expression visitUnresolvedStaticSetterSetIfNull( |
| 260 Send node, MethodElement getter, Element element, Node rhs, _) { |
| 261 var accessor = new ClassStaticAccessor( |
| 262 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 263 return accessor.buildNullAwareAssignment(visitForValue(rhs), |
| 264 voidContext: isVoidContext); |
| 265 } |
| 266 |
| 267 ir.Expression visitUnresolvedSuperBinary( |
| 268 Send node, Element element, BinaryOperator operator, Node argument, _) { |
| 269 return buildThrowNoSuchMethodError( |
| 270 kernel.getUnresolvedSuperMethodBuilder(), |
| 271 new ir.ThisExpression(), |
| 272 operator.selectorName, |
| 273 new ir.Arguments(<ir.Expression>[visitForValue(argument)])); |
| 274 } |
| 275 |
| 276 ir.Expression visitUnresolvedSuperCompound( |
| 277 Send node, Element element, AssignmentOperator operator, Node rhs, _) { |
| 278 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 279 } |
| 280 |
| 281 ir.Expression visitUnresolvedSuperCompoundIndexSet(Send node, Element element, |
| 282 Node index, AssignmentOperator operator, Node rhs, _) { |
| 283 var accessor = new SuperIndexAccessor(this, visitForValue(index), |
| 284 possiblyErroneousFunctionToIr(element), null); |
| 285 return accessor.buildCompoundAssignment( |
| 286 new ir.Name(operator.selectorName), visitForValue(rhs)); |
| 287 } |
| 288 |
| 289 ir.Expression visitUnresolvedSuperGet(Send node, Element element, _) { |
| 290 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 291 } |
| 292 |
| 293 ir.Expression visitUnresolvedSuperGetterCompound(Send node, Element element, |
| 294 MethodElement setter, AssignmentOperator operator, Node rhs, _) { |
| 295 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 296 } |
| 297 |
| 298 ir.Expression visitUnresolvedSuperGetterCompoundIndexSet( |
| 299 Send node, |
| 300 Element element, |
| 301 MethodElement setter, |
| 302 Node index, |
| 303 AssignmentOperator operator, |
| 304 Node rhs, |
| 305 _) { |
| 306 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 307 } |
| 308 |
| 309 ir.Expression visitUnresolvedSuperGetterIndexPostfix( |
| 310 Send node, |
| 311 Element element, |
| 312 MethodElement setter, |
| 313 Node index, |
| 314 IncDecOperator operator, |
| 315 _) { |
| 316 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 317 } |
| 318 |
| 319 ir.Expression visitUnresolvedSuperGetterIndexPrefix( |
| 320 Send node, |
| 321 Element element, |
| 322 MethodElement setter, |
| 323 Node index, |
| 324 IncDecOperator operator, |
| 325 _) { |
| 326 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 327 } |
| 328 |
| 329 ir.Expression visitUnresolvedSuperGetterPostfix(Send node, Element element, |
| 330 MethodElement setter, IncDecOperator operator, _) { |
| 331 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 332 } |
| 333 |
| 334 ir.Expression visitUnresolvedSuperGetterPrefix(Send node, Element element, |
| 335 MethodElement setter, IncDecOperator operator, _) { |
| 336 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 337 } |
| 338 |
| 339 ir.Expression visitUnresolvedSuperGetterSetIfNull( |
| 340 Send node, Element element, MethodElement setter, Node rhs, _) { |
| 341 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 342 } |
| 343 |
| 344 ir.Expression visitUnresolvedSuperIndex( |
| 345 Send node, Element element, Node index, _) { |
| 346 return new SuperIndexAccessor(this, visitForValue(index), null, null) |
| 347 .buildSimpleRead(); |
| 348 } |
| 349 |
| 350 ir.Expression visitUnresolvedSuperIndexPostfix( |
| 351 Send node, Element element, Node index, IncDecOperator operator, _) { |
| 352 return new SuperIndexAccessor(this, visitForValue(index), null, null) |
| 353 .buildSimpleRead(); |
| 354 } |
| 355 |
| 356 ir.Expression visitUnresolvedSuperIndexPrefix( |
| 357 Send node, Element element, Node index, IncDecOperator operator, _) { |
| 358 return new SuperIndexAccessor(this, visitForValue(index), null, null) |
| 359 .buildSimpleRead(); |
| 360 } |
| 361 |
| 362 ir.Expression visitUnresolvedSuperIndexSet( |
| 363 Send node, Element element, Node index, Node rhs, _) { |
| 364 return new SuperIndexAccessor(this, visitForValue(index), null, null) |
| 365 .buildAssignment(visitForValue(rhs)); |
| 366 } |
| 367 |
| 368 ir.Expression visitUnresolvedSuperInvoke( |
| 369 Send node, Element element, NodeList arguments, Selector selector, _) { |
| 370 // TODO(asgerf): Should really invoke 'super.noSuchMethod'. |
| 371 return buildThrowNoSuchMethodError(kernel.getUnresolvedSuperMethodBuilder(), |
| 372 new ir.ThisExpression(), '${node.selector}', buildArguments(arguments)); |
| 373 } |
| 374 |
| 375 ir.Expression visitUnresolvedSuperPostfix( |
| 376 Send node, Element element, IncDecOperator operator, _) { |
| 377 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 378 } |
| 379 |
| 380 ir.Expression visitUnresolvedSuperPrefix( |
| 381 Send node, Element element, IncDecOperator operator, _) { |
| 382 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 383 } |
| 384 |
| 385 ir.Expression visitUnresolvedSuperSetIfNull( |
| 386 Send node, Element element, Node rhs, _) { |
| 387 return buildThrowUnresolvedSuperGetter('${node.selector}'); |
| 388 } |
| 389 |
| 390 ir.Expression visitUnresolvedSuperSetterCompound( |
| 391 Send node, |
| 392 MethodElement getter, |
| 393 Element element, |
| 394 AssignmentOperator operator, |
| 395 Node rhs, |
| 396 _) { |
| 397 var accessor = new SuperPropertyAccessor( |
| 398 this, '${node.selector}', possiblyErroneousFunctionToIr(getter), null); |
| 399 return accessor.buildCompoundAssignment( |
| 400 new ir.Name(operator.selectorName), visitForValue(rhs)); |
| 401 } |
| 402 |
| 403 ir.Expression visitUnresolvedSuperSetterCompoundIndexSet( |
| 404 Send node, |
| 405 MethodElement getter, |
| 406 Element element, |
| 407 Node index, |
| 408 AssignmentOperator operator, |
| 409 Node rhs, |
| 410 _) { |
| 411 var accessor = new SuperIndexAccessor(this, visitForValue(index), |
| 412 possiblyErroneousFunctionToIr(getter), null); |
| 413 return accessor.buildCompoundAssignment( |
| 414 new ir.Name(operator.selectorName), visitForValue(rhs)); |
| 415 } |
| 416 |
| 417 ir.Expression visitUnresolvedSuperSetterIndexPostfix( |
| 418 Send node, |
| 419 MethodElement indexFunction, |
| 420 Element element, |
| 421 Node index, |
| 422 IncDecOperator operator, |
| 423 _) { |
| 424 var accessor = new SuperIndexAccessor(this, visitForValue(index), |
| 425 possiblyErroneousFunctionToIr(indexFunction), null); |
| 426 return accessor.buildPostfixIncrement(new ir.Name(operator.selectorName)); |
| 427 } |
| 428 |
| 429 ir.Expression visitUnresolvedSuperSetterIndexPrefix( |
| 430 Send node, |
| 431 MethodElement indexFunction, |
| 432 Element element, |
| 433 Node index, |
| 434 IncDecOperator operator, |
| 435 _) { |
| 436 var accessor = new SuperIndexAccessor(this, visitForValue(index), |
| 437 possiblyErroneousFunctionToIr(indexFunction), null); |
| 438 return accessor.buildPrefixIncrement(new ir.Name(operator.selectorName)); |
| 439 } |
| 440 |
| 441 ir.Expression visitUnresolvedSuperSetterPostfix(Send node, |
| 442 MethodElement getter, Element element, IncDecOperator operator, _) { |
| 443 var accessor = new SuperPropertyAccessor( |
| 444 this, '${node.selector}', possiblyErroneousFunctionToIr(getter), null); |
| 445 return accessor.buildPostfixIncrement(new ir.Name(operator.selectorName)); |
| 446 } |
| 447 |
| 448 ir.Expression visitUnresolvedSuperSetterPrefix(Send node, |
| 449 MethodElement getter, Element element, IncDecOperator operator, _) { |
| 450 var accessor = new SuperPropertyAccessor( |
| 451 this, '${node.selector}', possiblyErroneousFunctionToIr(getter), null); |
| 452 return accessor.buildPrefixIncrement(new ir.Name(operator.selectorName)); |
| 453 } |
| 454 |
| 455 ir.Expression visitUnresolvedSuperSetterSetIfNull( |
| 456 Send node, MethodElement getter, Element element, Node rhs, _) { |
| 457 var accessor = new SuperPropertyAccessor( |
| 458 this, '${node.selector}', possiblyErroneousFunctionToIr(getter), null); |
| 459 return accessor.buildNullAwareAssignment(visitForValue(rhs)); |
| 460 } |
| 461 |
| 462 ir.Expression visitUnresolvedSuperUnary( |
| 463 Send node, UnaryOperator operator, Element element, _) { |
| 464 // TODO(asgerf): Should really call 'super.noSuchMethod'. |
| 465 return buildThrowNoSuchMethodError( |
| 466 kernel.getUnresolvedSuperMethodBuilder(), |
| 467 new ir.ThisExpression(), |
| 468 operator.selectorName, |
| 469 new ir.Arguments.empty()); |
| 470 } |
| 471 |
| 472 ir.Expression visitUnresolvedTopLevelGetterCompound( |
| 473 Send node, |
| 474 Element element, |
| 475 MethodElement setter, |
| 476 AssignmentOperator operator, |
| 477 Node rhs, |
| 478 _) { |
| 479 return buildThrowUnresolvedGetter( |
| 480 '${node.selector}', kernel.getUnresolvedTopLevelGetterBuilder()); |
| 481 } |
| 482 |
| 483 ir.Expression visitUnresolvedTopLevelGetterPostfix(Send node, Element element, |
| 484 MethodElement setter, IncDecOperator operator, _) { |
| 485 return buildThrowUnresolvedGetter( |
| 486 '${node.selector}', kernel.getUnresolvedTopLevelGetterBuilder()); |
| 487 } |
| 488 |
| 489 ir.Expression visitUnresolvedTopLevelGetterPrefix(Send node, Element element, |
| 490 MethodElement setter, IncDecOperator operator, _) { |
| 491 return buildThrowUnresolvedGetter( |
| 492 '${node.selector}', kernel.getUnresolvedTopLevelGetterBuilder()); |
| 493 } |
| 494 |
| 495 ir.Expression visitUnresolvedTopLevelGetterSetIfNull( |
| 496 Send node, Element element, MethodElement setter, Node rhs, _) { |
| 497 return buildThrowUnresolvedGetter( |
| 498 '${node.selector}', kernel.getUnresolvedTopLevelGetterBuilder()); |
| 499 } |
| 500 |
| 501 ir.Expression visitUnresolvedTopLevelSetterCompound( |
| 502 Send node, |
| 503 MethodElement getter, |
| 504 Element element, |
| 505 AssignmentOperator operator, |
| 506 Node rhs, |
| 507 _) { |
| 508 var accessor = new TopLevelStaticAccessor( |
| 509 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 510 return accessor.buildCompoundAssignment( |
| 511 new ir.Name(operator.selectorName), visitForValue(rhs), |
| 512 voidContext: isVoidContext); |
| 513 } |
| 514 |
| 515 ir.Expression visitUnresolvedTopLevelSetterPostfix(Send node, |
| 516 MethodElement getter, Element element, IncDecOperator operator, _) { |
| 517 var accessor = new TopLevelStaticAccessor( |
| 518 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 519 return accessor.buildPostfixIncrement(new ir.Name(operator.selectorName), |
| 520 voidContext: isVoidContext); |
| 521 } |
| 522 |
| 523 ir.Expression visitUnresolvedTopLevelSetterPrefix(Send node, |
| 524 MethodElement getter, Element element, IncDecOperator operator, _) { |
| 525 var accessor = new TopLevelStaticAccessor( |
| 526 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 527 return accessor.buildPrefixIncrement(new ir.Name(operator.selectorName), |
| 528 voidContext: isVoidContext); |
| 529 } |
| 530 |
| 531 ir.Expression visitUnresolvedTopLevelSetterSetIfNull( |
| 532 Send node, MethodElement getter, Element element, Node rhs, _) { |
| 533 var accessor = new TopLevelStaticAccessor( |
| 534 this, getter.name, possiblyErroneousFunctionToIr(getter), null); |
| 535 return accessor.buildNullAwareAssignment(visitForValue(rhs), |
| 536 voidContext: isVoidContext); |
| 537 } |
| 538 |
| 539 ir.Expression visitUnresolvedSuperGetterIndexSetIfNull(Send node, |
| 540 Element element, MethodElement setter, Node index, Node rhs, _) { |
| 541 var accessor = new SuperIndexAccessor(this, visitForValue(index), null, |
| 542 possiblyErroneousFunctionToIr(setter)); |
| 543 return accessor.buildNullAwareAssignment(visitForValue(rhs)); |
| 544 } |
| 545 |
| 546 ir.Expression visitUnresolvedSuperSetterIndexSetIfNull(Send node, |
| 547 MethodElement getter, Element element, Node index, Node rhs, _) { |
| 548 var accessor = new SuperIndexAccessor(this, visitForValue(index), |
| 549 possiblyErroneousFunctionToIr(getter), null); |
| 550 return accessor.buildNullAwareAssignment(visitForValue(rhs)); |
| 551 } |
| 552 |
| 553 ir.Expression visitUnresolvedSuperIndexSetIfNull( |
| 554 Send node, Element element, Node index, Node rhs, _) { |
| 555 var accessor = |
| 556 new SuperIndexAccessor(this, visitForValue(index), null, null); |
| 557 return accessor.buildNullAwareAssignment(visitForValue(rhs)); |
| 558 } |
| 559 |
| 560 ir.Expression visitUnresolvedSuperSet( |
| 561 Send node, Element element, Node rhs, _) { |
| 562 return buildThrowUnresolvedSuperSetter( |
| 563 '${node.selector}', visitForValue(rhs)); |
| 564 } |
| 565 } |
OLD | NEW |