| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library backend_ast_nodes; | 5 library backend_ast_nodes; |
| 6 | 6 |
| 7 import '../constants/values.dart' as values; | 7 import '../constants/values.dart' as values; |
| 8 import '../dart_types.dart' as types; | 8 import '../dart_types.dart' as types; |
| 9 import '../elements/elements.dart' as elements; | 9 import '../elements/elements.dart' as elements; |
| 10 import '../tree/tree.dart' as tree; | 10 import '../tree/tree.dart' as tree; |
| 11 import '../util/characters.dart' as characters; | 11 import '../util/characters.dart' as characters; |
| 12 | 12 |
| 13 /// The following nodes correspond to [tree.Send] expressions: | 13 /// The following nodes correspond to [tree.Send] expressions: |
| 14 /// [FieldExpression], [IndexExpression], [Assignment], [Increment], | 14 /// [FieldExpression], [IndexExpression], [Assignment], [Increment], |
| 15 /// [CallFunction], [CallMethod], [CallNew], [CallStatic], [UnaryOperator], | 15 /// [CallFunction], [CallMethod], [CallNew], [CallStatic], [UnaryOperator], |
| 16 /// [BinaryOperator], and [TypeOperator]. | 16 /// [BinaryOperator], and [TypeOperator]. |
| 17 abstract class Node {} | 17 abstract class Node {} |
| 18 | 18 |
| 19 /// Receiver is an [Expression] or the [SuperReceiver]. | 19 /// Receiver is an [Expression] or the [SuperReceiver]. |
| 20 abstract class Receiver extends Node {} | 20 abstract class Receiver extends Node {} |
| 21 | 21 |
| 22 /// Argument is an [Expression] or a [NamedArgument]. | 22 /// Argument is an [Expression] or a [NamedArgument]. |
| 23 abstract class Argument extends Node {} | 23 abstract class Argument extends Node {} |
| 24 | 24 |
| 25 abstract class Expression extends Node implements Receiver, Argument { | 25 abstract class Expression extends Node implements Receiver, Argument { |
| 26 bool get assignable => false; | 26 bool get assignable => false; |
| 27 } | 27 } |
| 28 | 28 |
| 29 abstract class ExecutableDefinition extends Node { |
| 30 elements.Element get element; |
| 31 } |
| 32 |
| 33 class FieldDefinition extends ExecutableDefinition { |
| 34 final elements.Element element; |
| 35 final Expression initializer; |
| 36 FieldDefinition(this.element, this.initializer); |
| 37 } |
| 38 |
| 29 abstract class Statement extends Node {} | 39 abstract class Statement extends Node {} |
| 30 | 40 |
| 31 /// Used as receiver in expressions that dispatch to the super class. | 41 /// Used as receiver in expressions that dispatch to the super class. |
| 32 /// For instance, an expression such as `super.f()` is represented | 42 /// For instance, an expression such as `super.f()` is represented |
| 33 /// by a [CallMethod] node with [SuperReceiver] as its receiver. | 43 /// by a [CallMethod] node with [SuperReceiver] as its receiver. |
| 34 class SuperReceiver extends Receiver { | 44 class SuperReceiver extends Receiver { |
| 35 static final SuperReceiver _instance = new SuperReceiver._create(); | 45 static final SuperReceiver _instance = new SuperReceiver._create(); |
| 36 | 46 |
| 37 factory SuperReceiver() => _instance; | 47 factory SuperReceiver() => _instance; |
| 38 SuperReceiver._create(); | 48 SuperReceiver._create(); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 [ this.defaultValue ]) : type = returnType { | 299 [ this.defaultValue ]) : type = returnType { |
| 290 assert(parameters != null); | 300 assert(parameters != null); |
| 291 } | 301 } |
| 292 | 302 |
| 293 /// True if this is a function parameter. | 303 /// True if this is a function parameter. |
| 294 bool get isFunction => parameters != null; | 304 bool get isFunction => parameters != null; |
| 295 } | 305 } |
| 296 | 306 |
| 297 // EXPRESSIONS | 307 // EXPRESSIONS |
| 298 | 308 |
| 299 class FunctionExpression extends Expression { | 309 class FunctionExpression extends Expression implements ExecutableDefinition { |
| 300 final TypeAnnotation returnType; | 310 final TypeAnnotation returnType; |
| 301 String name; | 311 String name; |
| 302 final Parameters parameters; | 312 final Parameters parameters; |
| 303 final Statement body; | 313 final Statement body; |
| 304 final bool isGetter; | 314 final bool isGetter; |
| 305 final bool isSetter; | 315 final bool isSetter; |
| 306 | 316 |
| 307 elements.FunctionElement element; | 317 elements.FunctionElement element; |
| 308 | 318 |
| 309 FunctionExpression(this.parameters, | 319 FunctionExpression(this.parameters, |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 final StringChunk previous; | 1545 final StringChunk previous; |
| 1536 final tree.StringQuoting quoting; | 1546 final tree.StringQuoting quoting; |
| 1537 num cost; | 1547 num cost; |
| 1538 | 1548 |
| 1539 OpenStringChunk(this.previous, this.quoting, this.cost); | 1549 OpenStringChunk(this.previous, this.quoting, this.cost); |
| 1540 | 1550 |
| 1541 StringChunk end(int endIndex) { | 1551 StringChunk end(int endIndex) { |
| 1542 return new StringChunk(previous, quoting, endIndex); | 1552 return new StringChunk(previous, quoting, endIndex); |
| 1543 } | 1553 } |
| 1544 } | 1554 } |
| OLD | NEW |