Skip to content

Commit

Permalink
Version 3.3.0-157.0.dev
Browse files Browse the repository at this point in the history
Merge a356828 into dev
  • Loading branch information
Dart CI committed Nov 21, 2023
2 parents a437244 + a356828 commit c6a0122
Show file tree
Hide file tree
Showing 42 changed files with 1,211 additions and 86 deletions.
7 changes: 7 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ enum ExperimentalFlag {
experimentEnabledVersion: const Version(3, 0),
experimentReleasedVersion: const Version(3, 0)),

resourceIdentifiers(
name: 'resource-identifiers',
isEnabledByDefault: false,
isExpired: false,
experimentEnabledVersion: defaultLanguageVersion,
experimentReleasedVersion: defaultLanguageVersion),

sealedClass(
name: 'sealed-class',
isEnabledByDefault: true,
Expand Down
20 changes: 20 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12557,6 +12557,26 @@ const MessageCode messageRequiredParameterWithDefault = const MessageCode(
correctionMessage:
r"""Try removing the default value or making the parameter optional.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeResourceIdentifiersMultiple =
messageResourceIdentifiersMultiple;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageResourceIdentifiersMultiple = const MessageCode(
"ResourceIdentifiersMultiple",
problemMessage:
r"""Only one resource identifier pragma can be used at a time.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeResourceIdentifiersNotStatic =
messageResourceIdentifiersNotStatic;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageResourceIdentifiersNotStatic = const MessageCode(
"ResourceIdentifiersNotStatic",
problemMessage:
r"""Resource identifier pragma can be used on a static method only.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeRestPatternInMapPattern = messageRestPatternInMapPattern;

Expand Down
40 changes: 32 additions & 8 deletions pkg/analyzer/lib/src/dart/analysis/experiments.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final _knownFeatures = <String, ExperimentalFeature>{
ExperimentalFeatures.nonfunction_type_aliases,
EnableString.patterns: ExperimentalFeatures.patterns,
EnableString.records: ExperimentalFeatures.records,
EnableString.resource_identifiers: ExperimentalFeatures.resource_identifiers,
EnableString.sealed_class: ExperimentalFeatures.sealed_class,
EnableString.set_literals: ExperimentalFeatures.set_literals,
EnableString.spread_collections: ExperimentalFeatures.spread_collections,
Expand Down Expand Up @@ -104,6 +105,9 @@ class EnableString {
/// String to enable the experiment "records"
static const String records = 'records';

/// String to enable the experiment "resource-identifiers"
static const String resource_identifiers = 'resource-identifiers';

/// String to enable the experiment "sealed-class"
static const String sealed_class = 'sealed-class';

Expand Down Expand Up @@ -314,8 +318,18 @@ class ExperimentalFeatures {
releaseVersion: Version.parse('3.0.0'),
);

static final sealed_class = ExperimentalFeature(
static final resource_identifiers = ExperimentalFeature(
index: 18,
enableString: EnableString.resource_identifiers,
isEnabledByDefault: IsEnabledByDefault.resource_identifiers,
isExpired: IsExpired.resource_identifiers,
documentation: 'Output arguments used by static functions.',
experimentalReleaseVersion: null,
releaseVersion: null,
);

static final sealed_class = ExperimentalFeature(
index: 19,
enableString: EnableString.sealed_class,
isEnabledByDefault: IsEnabledByDefault.sealed_class,
isExpired: IsExpired.sealed_class,
Expand All @@ -325,7 +339,7 @@ class ExperimentalFeatures {
);

static final set_literals = ExperimentalFeature(
index: 19,
index: 20,
enableString: EnableString.set_literals,
isEnabledByDefault: IsEnabledByDefault.set_literals,
isExpired: IsExpired.set_literals,
Expand All @@ -335,7 +349,7 @@ class ExperimentalFeatures {
);

static final spread_collections = ExperimentalFeature(
index: 20,
index: 21,
enableString: EnableString.spread_collections,
isEnabledByDefault: IsEnabledByDefault.spread_collections,
isExpired: IsExpired.spread_collections,
Expand All @@ -345,7 +359,7 @@ class ExperimentalFeatures {
);

static final super_parameters = ExperimentalFeature(
index: 21,
index: 22,
enableString: EnableString.super_parameters,
isEnabledByDefault: IsEnabledByDefault.super_parameters,
isExpired: IsExpired.super_parameters,
Expand All @@ -355,7 +369,7 @@ class ExperimentalFeatures {
);

static final test_experiment = ExperimentalFeature(
index: 22,
index: 23,
enableString: EnableString.test_experiment,
isEnabledByDefault: IsEnabledByDefault.test_experiment,
isExpired: IsExpired.test_experiment,
Expand All @@ -366,7 +380,7 @@ class ExperimentalFeatures {
);

static final triple_shift = ExperimentalFeature(
index: 23,
index: 24,
enableString: EnableString.triple_shift,
isEnabledByDefault: IsEnabledByDefault.triple_shift,
isExpired: IsExpired.triple_shift,
Expand All @@ -376,7 +390,7 @@ class ExperimentalFeatures {
);

static final unnamed_libraries = ExperimentalFeature(
index: 24,
index: 25,
enableString: EnableString.unnamed_libraries,
isEnabledByDefault: IsEnabledByDefault.unnamed_libraries,
isExpired: IsExpired.unnamed_libraries,
Expand All @@ -386,7 +400,7 @@ class ExperimentalFeatures {
);

static final variance = ExperimentalFeature(
index: 25,
index: 26,
enableString: EnableString.variance,
isEnabledByDefault: IsEnabledByDefault.variance,
isExpired: IsExpired.variance,
Expand Down Expand Up @@ -453,6 +467,9 @@ class IsEnabledByDefault {
/// Default state of the experiment "records"
static const bool records = true;

/// Default state of the experiment "resource-identifiers"
static const bool resource_identifiers = false;

/// Default state of the experiment "sealed-class"
static const bool sealed_class = true;

Expand Down Expand Up @@ -536,6 +553,9 @@ class IsExpired {
/// Expiration status of the experiment "records"
static const bool records = true;

/// Expiration status of the experiment "resource-identifiers"
static const bool resource_identifiers = false;

/// Expiration status of the experiment "sealed-class"
static const bool sealed_class = true;

Expand Down Expand Up @@ -624,6 +644,10 @@ mixin _CurrentState {
/// Current state for the flag "records"
bool get records => isEnabled(ExperimentalFeatures.records);

/// Current state for the flag "resource-identifiers"
bool get resource_identifiers =>
isEnabled(ExperimentalFeatures.resource_identifiers);

/// Current state for the flag "sealed-class"
bool get sealed_class => isEnabled(ExperimentalFeatures.sealed_class);

Expand Down
98 changes: 96 additions & 2 deletions pkg/analyzer/lib/src/wolf/ir/ast_to_ir.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/dart/element/type_system.dart';
import 'package:analyzer/src/wolf/ir/call_descriptor.dart';
Expand Down Expand Up @@ -140,19 +141,28 @@ class _AstToIRVisitor extends ThrowingAstVisitor<_LValueTemplates> {
return result;
}

void instanceCall(MethodElement? staticElement, String name,
List<DartType> typeArguments, ArgumentNamesRef argumentNames) {
if (staticElement == null) throw UnimplementedError('TODO(paulberry)');
ir.call(
ir.encodeCallDescriptor(
ElementCallDescriptor(staticElement, typeArguments: typeArguments)),
argumentNames);
}

void instanceGet(PropertyAccessorElement? staticElement, String name) {
if (staticElement == null) {
throw UnimplementedError('TODO(paulberry): dynamic instance get');
}
ir.call(ir.encodeCallDescriptor(InstanceGetDescriptor(staticElement)),
ir.call(ir.encodeCallDescriptor(ElementCallDescriptor(staticElement)),
oneArgument);
}

void instanceSet(PropertyAccessorElement? staticElement, String name) {
if (staticElement == null) {
throw UnimplementedError('TODO(paulberry): dynamic instance set');
}
ir.call(ir.encodeCallDescriptor(InstanceSetDescriptor(staticElement)),
ir.call(ir.encodeCallDescriptor(ElementCallDescriptor(staticElement)),
twoArguments);
}

Expand Down Expand Up @@ -382,6 +392,70 @@ class _AstToIRVisitor extends ThrowingAstVisitor<_LValueTemplates> {
// Stack: value
}

@override
Null visitMethodInvocation(MethodInvocation node) {
var previousNestingLevel = ir.nestingLevel;
var argumentNames = <String?>[];
var target = node.target;
var methodElement = node.methodName.staticElement;
switch (methodElement) {
case FunctionElement(enclosingElement: CompilationUnitElement()):
assert(!node.isNullAware);
_handleInvocationArgs(
argumentList: node.argumentList,
argumentNames: argumentNames,
isNullAware: false,
previousNestingLevel: previousNestingLevel);
// Stack: arguments
if (methodElement.library.isDartCore &&
methodElement.name == 'identical') {
ir.identical();
} else {
ir.call(
ir.encodeCallDescriptor(ElementCallDescriptor(methodElement,
typeArguments: node.typeArgumentTypes!)),
ir.encodeArgumentNames(argumentNames));
}
// Stack: result
case MethodElement(isStatic: false):
if (target == null) {
assert(!node.isNullAware);
this_();
// Stack: this
} else {
dispatchNode(target, terminateNullShorting: false);
// Stack: target
}
argumentNames.add(null);
_handleInvocationArgs(
argumentList: node.argumentList,
argumentNames: argumentNames,
isNullAware: node.isNullAware,
previousNestingLevel: previousNestingLevel);
// Stack: BLOCK(1)? target arguments
instanceCall(methodElement, node.methodName.name,
node.typeArgumentTypes!, ir.encodeArgumentNames(argumentNames));
// Stack: BLOCK(1)? result
case MethodElement(isStatic: true):
assert(!node.isNullAware);
_handleInvocationArgs(
argumentList: node.argumentList,
argumentNames: argumentNames,
isNullAware: false,
previousNestingLevel: previousNestingLevel);
// Stack: arguments
ir.call(
ir.encodeCallDescriptor(ElementCallDescriptor(methodElement,
typeArguments: node.typeArgumentTypes!)),
ir.encodeArgumentNames(argumentNames));
// Stack: result

case dynamic(:var runtimeType):
throw UnimplementedError(
'TODO(paulberry): $runtimeType: $methodElement');
}
}

@override
Null visitNullLiteral(NullLiteral node) {
ir.literal(null_);
Expand Down Expand Up @@ -511,6 +585,26 @@ class _AstToIRVisitor extends ThrowingAstVisitor<_LValueTemplates> {
}
dispatchNode(node.variables);
}

void _handleInvocationArgs(
{required ArgumentList argumentList,
required List<String?> argumentNames,
required bool isNullAware,
required int previousNestingLevel}) {
if (isNullAware) {
nullShortingCheck(previousNestingLevel: previousNestingLevel);
}
// Stack: BLOCK(1)? target
for (var argument in argumentList.arguments) {
if (argument is NamedExpression) {
dispatchNode(argument.expression);
argumentNames.add(argument.name.label.name);
} else {
dispatchNode(argument);
argumentNames.add(null);
}
}
}
}

/// Instruction templates for converting a local variable reference to IR.
Expand Down
45 changes: 14 additions & 31 deletions pkg/analyzer/lib/src/wolf/ir/call_descriptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,31 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';

/// The target of a `call` instruction in the IR.
sealed class CallDescriptor {
String get name;
List<DartType> get typeArguments;
}

/// Call descriptor for an instance (non-static) getter.
class InstanceGetDescriptor extends CallDescriptor {
final PropertyAccessorElement getter;

InstanceGetDescriptor(this.getter) : assert(getter.isGetter);

@override
int get hashCode => getter.hashCode;
/// Call descriptor for a call that resolves to a specific element (i.e., a
/// non-dynamic call).
class ElementCallDescriptor extends CallDescriptor {
final ExecutableElement element;

@override
String get name => getter.name;
final List<DartType> typeArguments;

@override
bool operator ==(Object other) =>
other is InstanceGetDescriptor && getter == other.getter;

@override
String toString() => '${getter.enclosingElement.name}.$name';
}

/// Call descriptor for an instance (non-static) setter.
class InstanceSetDescriptor extends CallDescriptor {
final PropertyAccessorElement setter;

InstanceSetDescriptor(this.setter) : assert(setter.isSetter);

@override
int get hashCode => setter.hashCode;

@override
String get name => setter.name;
ElementCallDescriptor(this.element, {this.typeArguments = const []});

@override
bool operator ==(Object other) =>
other is InstanceSetDescriptor && setter == other.setter;
String get name => element.name;

@override
String toString() => '${setter.enclosingElement.name}.$name';
String toString() => switch (element.enclosingElement) {
InstanceElement(name: var typeName) =>
'${typeName ?? '<unnamed>'}.${element.name}',
_ => element.name
};
}
Loading

0 comments on commit c6a0122

Please sign in to comment.