-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge c433fe1 into dev
- Loading branch information
Showing
142 changed files
with
10,941 additions
and
2,534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'expressions.dart'; | ||
import 'proto.dart'; | ||
|
||
/// Superclass for named and position arguments. | ||
// TODO(johnniwinther): Merge subclasses into one class? | ||
sealed class Argument { | ||
/// Returns the [Argument] corresponding to this [Argument] in | ||
/// which all [UnresolvedIdentifier]s have been resolved within their scope. | ||
/// | ||
/// If this didn't create a new [Argument], `null` is returned. | ||
Argument? resolve(); | ||
} | ||
|
||
class PositionalArgument extends Argument { | ||
final Expression expression; | ||
|
||
PositionalArgument(this.expression); | ||
|
||
@override | ||
String toString() => 'PositionalArgument($expression)'; | ||
|
||
@override | ||
Argument? resolve() { | ||
Expression? newExpression = expression.resolve(); | ||
return newExpression == null ? null : new PositionalArgument(newExpression); | ||
} | ||
} | ||
|
||
class NamedArgument extends Argument { | ||
final String name; | ||
final Expression expression; | ||
|
||
NamedArgument(this.name, this.expression); | ||
|
||
@override | ||
String toString() => 'NamedArgument($name,$expression)'; | ||
|
||
@override | ||
Argument? resolve() { | ||
Expression? newExpression = expression.resolve(); | ||
return newExpression == null | ||
? null | ||
: new NamedArgument(name, newExpression); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
export 'arguments.dart'; | ||
export 'elements.dart'; | ||
export 'expressions.dart'; | ||
export 'formal_parameters.dart'; | ||
export 'proto.dart'; | ||
export 'record_fields.dart'; | ||
export 'references.dart'; | ||
export 'string_literal_parts.dart'; | ||
export 'type_annotations.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'expressions.dart'; | ||
import 'proto.dart'; | ||
|
||
/// Superclass for collection elements. | ||
sealed class Element { | ||
/// Returns the [Element] corresponding to this [Element] in | ||
/// which all [UnresolvedIdentifier]s have been resolved within their scope. | ||
/// | ||
/// If this didn't create a new [Element], `null` is returned. | ||
Element? resolve(); | ||
} | ||
|
||
class ExpressionElement extends Element { | ||
final Expression expression; | ||
final bool isNullAware; | ||
|
||
ExpressionElement(this.expression, {required this.isNullAware}); | ||
|
||
@override | ||
String toString() => | ||
'ExpressionElement($expression,isNullAware=$isNullAware)'; | ||
|
||
@override | ||
Element? resolve() { | ||
Expression? newExpression = expression.resolve(); | ||
return newExpression == null | ||
? null | ||
: new ExpressionElement(newExpression, isNullAware: isNullAware); | ||
} | ||
} | ||
|
||
class MapEntryElement extends Element { | ||
final Expression key; | ||
final Expression value; | ||
final bool isNullAwareKey; | ||
final bool isNullAwareValue; | ||
|
||
MapEntryElement(this.key, this.value, | ||
{required this.isNullAwareKey, required this.isNullAwareValue}); | ||
|
||
@override | ||
String toString() => 'MapEntryElement($key,$value,' | ||
'isNullAwareKey=$isNullAwareValue,isNullAwareValue=$isNullAwareValue)'; | ||
|
||
@override | ||
Element? resolve() { | ||
Expression? newKey = key.resolve(); | ||
Expression? newValue = value.resolve(); | ||
return newKey == null && newValue == null | ||
? null | ||
: new MapEntryElement(newKey ?? key, newValue ?? value, | ||
isNullAwareKey: isNullAwareKey, isNullAwareValue: isNullAwareValue); | ||
} | ||
} | ||
|
||
class SpreadElement extends Element { | ||
final Expression expression; | ||
final bool isNullAware; | ||
|
||
SpreadElement(this.expression, {required this.isNullAware}); | ||
|
||
@override | ||
String toString() => 'SpreadElement($expression,isNullAware=$isNullAware)'; | ||
|
||
@override | ||
Element? resolve() { | ||
Expression? newExpression = expression.resolve(); | ||
return newExpression == null | ||
? null | ||
: new SpreadElement(newExpression, isNullAware: isNullAware); | ||
} | ||
} | ||
|
||
class IfElement extends Element { | ||
final Expression condition; | ||
final Element then; | ||
final Element? otherwise; | ||
|
||
IfElement(this.condition, this.then, [this.otherwise]); | ||
|
||
@override | ||
String toString() => 'IfElement($condition,$then,$otherwise)'; | ||
|
||
@override | ||
Element? resolve() { | ||
Expression? newCondition = condition.resolve(); | ||
Element? newThen = then.resolve(); | ||
Element? newOtherwise = otherwise?.resolve(); | ||
if (otherwise != null) { | ||
return newCondition == null && newThen == null && newOtherwise == null | ||
? null | ||
: new IfElement(newCondition ?? condition, newThen ?? then, | ||
newOtherwise ?? otherwise); | ||
} else { | ||
return newCondition == null && newThen == null | ||
? null | ||
: new IfElement(newCondition ?? condition, newThen ?? then); | ||
} | ||
} | ||
} |
Oops, something went wrong.