| 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Note: copied from package:kernel at revision 7346348. | 5 // Note: copied from package:kernel at revision 7346348. |
| 6 | 6 |
| 7 /// A library to help transform compounds and null-aware accessors into | 7 /// A library to help transform compounds and null-aware accessors into |
| 8 /// let expressions. | 8 /// let expressions. |
| 9 library kernel.frontend.accessors; | 9 library kernel.frontend.accessors; |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 _finish(Expression body) => makeLet( | 219 _finish(Expression body) => makeLet( |
| 220 receiver, | 220 receiver, |
| 221 new ConditionalExpression( | 221 new ConditionalExpression( |
| 222 buildIsNull(receiverAccess()), new NullLiteral(), body, type)); | 222 buildIsNull(receiverAccess()), new NullLiteral(), body, type)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 class SuperPropertyAccessor extends Accessor { | 225 class SuperPropertyAccessor extends Accessor { |
| 226 Name name; | 226 Name name; |
| 227 Member getter, setter; | 227 Member getter, setter; |
| 228 final int charOffset; |
| 228 | 229 |
| 229 SuperPropertyAccessor(this.name, this.getter, this.setter); | 230 SuperPropertyAccessor(this.name, this.getter, this.setter, this.charOffset); |
| 230 | 231 |
| 231 _makeRead() { | 232 _makeRead() { |
| 232 if (getter == null) return makeInvalidRead(); | 233 if (getter == null) return makeInvalidRead(); |
| 233 // TODO(ahe): Use [DirectPropertyGet] when possible. | 234 // TODO(ahe): Use [DirectPropertyGet] when possible. |
| 234 Expression result = new DirectPropertyGet(new ThisExpression(), getter); | 235 Expression result = new DirectPropertyGet(new ThisExpression(), getter) |
| 235 result = new SuperPropertyGet(name, getter); | 236 ..fileOffset = charOffset; |
| 237 result = new SuperPropertyGet(name, getter)..fileOffset = charOffset; |
| 236 return result; | 238 return result; |
| 237 } | 239 } |
| 238 | 240 |
| 239 _makeWrite(Expression value, bool voidContext) { | 241 _makeWrite(Expression value, bool voidContext) { |
| 240 if (setter == null) return makeInvalidWrite(value); | 242 if (setter == null) return makeInvalidWrite(value); |
| 241 // TODO(ahe): Use [DirectPropertySet] when possible. | 243 // TODO(ahe): Use [DirectPropertySet] when possible. |
| 242 Expression result = | 244 Expression result = new DirectPropertySet( |
| 243 new DirectPropertySet(new ThisExpression(), setter, value); | 245 new ThisExpression(), setter, value)..fileOffset = charOffset; |
| 244 result = new SuperPropertySet(name, value, setter); | 246 result = new SuperPropertySet(name, value, setter)..fileOffset = charOffset; |
| 245 return result; | 247 return result; |
| 246 } | 248 } |
| 247 } | 249 } |
| 248 | 250 |
| 249 final Name _indexGet = new Name('[]'); | 251 final Name _indexGet = new Name('[]'); |
| 250 final Name _indexSet = new Name('[]='); | 252 final Name _indexSet = new Name('[]='); |
| 251 | 253 |
| 252 class IndexAccessor extends Accessor { | 254 class IndexAccessor extends Accessor { |
| 253 Expression receiver; | 255 Expression receiver; |
| 254 Expression index; | 256 Expression index; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 485 |
| 484 VariableDeclaration makeOrReuseVariable(Expression value) { | 486 VariableDeclaration makeOrReuseVariable(Expression value) { |
| 485 // TODO: Devise a way to remember if a variable declaration was reused | 487 // TODO: Devise a way to remember if a variable declaration was reused |
| 486 // or is fresh (hence needs a let binding). | 488 // or is fresh (hence needs a let binding). |
| 487 return new VariableDeclaration.forValue(value); | 489 return new VariableDeclaration.forValue(value); |
| 488 } | 490 } |
| 489 | 491 |
| 490 Expression wrapInvalid(Expression e) { | 492 Expression wrapInvalid(Expression e) { |
| 491 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); | 493 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); |
| 492 } | 494 } |
| OLD | NEW |