| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 elements; | 5 library elements; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/parser/async_modifier.dart' | |
| 8 show AsyncModifier; | |
| 9 | |
| 10 import '../common.dart'; | 7 import '../common.dart'; |
| 11 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
| 12 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
| 13 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| 14 import '../common_elements.dart' show CommonElements; | 11 import '../common_elements.dart' show CommonElements; |
| 15 import '../ordered_typeset.dart' show OrderedTypeSet; | 12 import '../ordered_typeset.dart' show OrderedTypeSet; |
| 16 import '../resolution/scope.dart' show Scope; | 13 import '../resolution/scope.dart' show Scope; |
| 17 import '../resolution/tree_elements.dart' show TreeElements; | 14 import '../resolution/tree_elements.dart' show TreeElements; |
| 18 import '../script.dart'; | 15 import '../script.dart'; |
| 19 import 'package:front_end/src/fasta/scanner.dart' | 16 import 'package:front_end/src/fasta/scanner.dart' |
| (...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 /// The setter corresponding to this getter, if any. | 1332 /// The setter corresponding to this getter, if any. |
| 1336 SetterElement get setter; | 1333 SetterElement get setter; |
| 1337 } | 1334 } |
| 1338 | 1335 |
| 1339 /// A setter. | 1336 /// A setter. |
| 1340 abstract class SetterElement extends AccessorElement { | 1337 abstract class SetterElement extends AccessorElement { |
| 1341 /// The getter corresponding to this setter, if any. | 1338 /// The getter corresponding to this setter, if any. |
| 1342 GetterElement get getter; | 1339 GetterElement get getter; |
| 1343 } | 1340 } |
| 1344 | 1341 |
| 1345 /// Enum for the synchronous/asynchronous function body modifiers. | |
| 1346 class AsyncMarker { | |
| 1347 /// The default function body marker. | |
| 1348 static const AsyncMarker SYNC = const AsyncMarker._(AsyncModifier.Sync); | |
| 1349 | |
| 1350 /// The `sync*` function body marker. | |
| 1351 static const AsyncMarker SYNC_STAR = | |
| 1352 const AsyncMarker._(AsyncModifier.SyncStar, isYielding: true); | |
| 1353 | |
| 1354 /// The `async` function body marker. | |
| 1355 static const AsyncMarker ASYNC = | |
| 1356 const AsyncMarker._(AsyncModifier.Async, isAsync: true); | |
| 1357 | |
| 1358 /// The `async*` function body marker. | |
| 1359 static const AsyncMarker ASYNC_STAR = const AsyncMarker._( | |
| 1360 AsyncModifier.AsyncStar, | |
| 1361 isAsync: true, | |
| 1362 isYielding: true); | |
| 1363 | |
| 1364 /// Is `true` if this marker defines the function body to have an | |
| 1365 /// asynchronous result, that is, either a [Future] or a [Stream]. | |
| 1366 final bool isAsync; | |
| 1367 | |
| 1368 /// Is `true` if this marker defines the function body to have a plural | |
| 1369 /// result, that is, either an [Iterable] or a [Stream]. | |
| 1370 final bool isYielding; | |
| 1371 | |
| 1372 final AsyncModifier asyncParserState; | |
| 1373 | |
| 1374 const AsyncMarker._(this.asyncParserState, | |
| 1375 {this.isAsync: false, this.isYielding: false}); | |
| 1376 | |
| 1377 String toString() { | |
| 1378 return '${isAsync ? 'async' : 'sync'}${isYielding ? '*' : ''}'; | |
| 1379 } | |
| 1380 | |
| 1381 /// Canonical list of marker values. | |
| 1382 /// | |
| 1383 /// Added to make [AsyncMarker] enum-like. | |
| 1384 static const List<AsyncMarker> values = const <AsyncMarker>[ | |
| 1385 SYNC, | |
| 1386 SYNC_STAR, | |
| 1387 ASYNC, | |
| 1388 ASYNC_STAR | |
| 1389 ]; | |
| 1390 | |
| 1391 /// Index to this marker within [values]. | |
| 1392 /// | |
| 1393 /// Added to make [AsyncMarker] enum-like. | |
| 1394 int get index => values.indexOf(this); | |
| 1395 } | |
| 1396 | |
| 1397 /// A top level, static or instance function. | 1342 /// A top level, static or instance function. |
| 1398 abstract class MethodElement extends FunctionElement | 1343 abstract class MethodElement extends FunctionElement |
| 1399 implements MemberElement, FunctionEntity {} | 1344 implements MemberElement, FunctionEntity {} |
| 1400 | 1345 |
| 1401 /// A local function or closure (anonymous local function). | 1346 /// A local function or closure (anonymous local function). |
| 1402 abstract class LocalFunctionElement extends FunctionElement | 1347 abstract class LocalFunctionElement extends FunctionElement |
| 1403 implements LocalElement {} | 1348 implements LocalElement {} |
| 1404 | 1349 |
| 1405 /// A constructor. | 1350 /// A constructor. |
| 1406 abstract class ConstructorElement extends MethodElement | 1351 abstract class ConstructorElement extends MethodElement |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 /// by a field. | 1977 /// by a field. |
| 2033 bool get isDeclaredByField; | 1978 bool get isDeclaredByField; |
| 2034 | 1979 |
| 2035 /// Returns `true` if this member is abstract. | 1980 /// Returns `true` if this member is abstract. |
| 2036 bool get isAbstract; | 1981 bool get isAbstract; |
| 2037 | 1982 |
| 2038 /// If abstract, [implementation] points to the overridden concrete member, | 1983 /// If abstract, [implementation] points to the overridden concrete member, |
| 2039 /// if any. Otherwise [implementation] points to the member itself. | 1984 /// if any. Otherwise [implementation] points to the member itself. |
| 2040 Member get implementation; | 1985 Member get implementation; |
| 2041 } | 1986 } |
| OLD | NEW |