| 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; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 [ this.defaultValue ]) : type = returnType { | 299 [ this.defaultValue ]) : type = returnType { |
| 300 assert(parameters != null); | 300 assert(parameters != null); |
| 301 } | 301 } |
| 302 | 302 |
| 303 /// True if this is a function parameter. | 303 /// True if this is a function parameter. |
| 304 bool get isFunction => parameters != null; | 304 bool get isFunction => parameters != null; |
| 305 } | 305 } |
| 306 | 306 |
| 307 // EXPRESSIONS | 307 // EXPRESSIONS |
| 308 | 308 |
| 309 abstract class Initializer extends Expression {} |
| 310 |
| 311 class FieldInitializer extends Initializer { |
| 312 final elements.FieldElement element; |
| 313 final Expression body; |
| 314 |
| 315 FieldInitializer(this.element, this.body); |
| 316 } |
| 317 |
| 318 class SuperInitializer extends Initializer { |
| 319 final elements.ConstructorElement target; |
| 320 final List<Argument> arguments; |
| 321 |
| 322 SuperInitializer(this.target, this.arguments); |
| 323 } |
| 324 |
| 309 class FunctionExpression extends Expression implements ExecutableDefinition { | 325 class FunctionExpression extends Expression implements ExecutableDefinition { |
| 310 final TypeAnnotation returnType; | 326 final TypeAnnotation returnType; |
| 311 String name; | 327 String name; |
| 312 final Parameters parameters; | 328 final Parameters parameters; |
| 313 final Statement body; | 329 final Statement body; |
| 314 final bool isGetter; | 330 final bool isGetter; |
| 315 final bool isSetter; | 331 final bool isSetter; |
| 316 | 332 |
| 317 elements.FunctionElement element; | 333 elements.FunctionElement element; |
| 318 | 334 |
| 319 FunctionExpression(this.parameters, | 335 FunctionExpression(this.parameters, |
| 320 this.body, | 336 this.body, |
| 321 { this.name, | 337 { this.name, |
| 322 this.returnType, | 338 this.returnType, |
| 323 this.isGetter: false, | 339 this.isGetter: false, |
| 324 this.isSetter: false }) { | 340 this.isSetter: false }) { |
| 325 // Function must have a name if it has a return type | 341 // Function must have a name if it has a return type |
| 326 assert(returnType == null || name != null); | 342 assert(returnType == null || name != null); |
| 327 } | 343 } |
| 328 } | 344 } |
| 329 | 345 |
| 346 class ConstructorDefinition extends FunctionExpression { |
| 347 final List<Initializer> initializers; |
| 348 final bool isConst; |
| 349 |
| 350 ConstructorDefinition(Parameters parameters, Statement body, |
| 351 this.initializers, String name, this.isConst) |
| 352 : super(parameters, body, name: name); |
| 353 } |
| 354 |
| 330 class Conditional extends Expression { | 355 class Conditional extends Expression { |
| 331 final Expression condition; | 356 final Expression condition; |
| 332 final Expression thenExpression; | 357 final Expression thenExpression; |
| 333 final Expression elseExpression; | 358 final Expression elseExpression; |
| 334 | 359 |
| 335 Conditional(this.condition, this.thenExpression, this.elseExpression); | 360 Conditional(this.condition, this.thenExpression, this.elseExpression); |
| 336 } | 361 } |
| 337 | 362 |
| 338 /// An identifier expression. | 363 /// An identifier expression. |
| 339 /// The unparser does not concern itself with scoping rules, and it is the | 364 /// The unparser does not concern itself with scoping rules, and it is the |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 final StringChunk previous; | 1570 final StringChunk previous; |
| 1546 final tree.StringQuoting quoting; | 1571 final tree.StringQuoting quoting; |
| 1547 num cost; | 1572 num cost; |
| 1548 | 1573 |
| 1549 OpenStringChunk(this.previous, this.quoting, this.cost); | 1574 OpenStringChunk(this.previous, this.quoting, this.cost); |
| 1550 | 1575 |
| 1551 StringChunk end(int endIndex) { | 1576 StringChunk end(int endIndex) { |
| 1552 return new StringChunk(previous, quoting, endIndex); | 1577 return new StringChunk(previous, quoting, endIndex); |
| 1553 } | 1578 } |
| 1554 } | 1579 } |
| OLD | NEW |