Version 2.10.0-137.0.dev
Merge commit '7da89dadafc7719b0feb7cd82518afe244019c15' into 'dev'
diff --git a/DEPS b/DEPS
index 973a186..7c82485 100644
--- a/DEPS
+++ b/DEPS
@@ -142,7 +142,7 @@
"source_map_stack_trace_rev": "1c3026f69d9771acf2f8c176a1ab750463309cce",
"source_maps-0.9.4_rev": "38524",
"source_maps_rev": "53eb92ccfe6e64924054f83038a534b959b12b3e",
- "source_span_rev": "94833d6cbf4552ebe5d2aa6714acecd93834e53a",
+ "source_span_rev": "cc7c4288a83f71ecef3414199947b52a8c112c65",
"sse_tag": "e5cf68975e8e87171a3dc297577aa073454a91dc",
"stack_trace_tag": "d3813ca0a77348e0faf0d6af0cc17913e36afa39",
"stagehand_tag": "v3.3.9",
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for.dart
index 35a845a..f9d2545 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for.dart
@@ -23,7 +23,7 @@
}
}
-/*member: forEachWithDeclaration:declared={a, b, c}, assigned={a, b, c}*/
+/*member: forEachWithDeclaration:declared={a, b, c}, assigned={a, b}*/
forEachWithDeclaration(int a, int b) {
/*assigned={b}*/ for (var c in [a = 0]) {
b = 0;
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for_element.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for_element.dart
index 86b2e15..8259c35 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for_element.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/for_element.dart
@@ -19,7 +19,7 @@
];
}
-/*member: forEachWithDeclaration:declared={a, b, c}, assigned={a, b, c}*/
+/*member: forEachWithDeclaration:declared={a, b, c}, assigned={a, b}*/
forEachWithDeclaration(int a, int b) {
[
/*assigned={b}*/ for (var c in [a = 0]) (b = 0)
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/bug43136.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/bug43136.dart
new file mode 100644
index 0000000..297392b
--- /dev/null
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/bug43136.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2020, 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.
+
+List<int Function()> f(List<num> nums) {
+ List<int Function()> result = [];
+ for (var n in nums) {
+ if (n is int) {
+ result.add(() => /*int*/ n);
+ }
+ }
+ return result;
+}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index 6583dcd..cc05f18 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -786,7 +786,8 @@
void suggestNamedArgument(ParameterElement parameter,
{@required bool appendColon, @required bool appendComma}) {
var name = parameter.name;
- var type = parameter.type?.getDisplayString(withNullability: false);
+ var type = parameter.type?.getDisplayString(
+ withNullability: request.libraryElement.isNonNullableByDefault);
var completion = name;
if (appendColon) {
@@ -1286,7 +1287,8 @@
var paramType = parameter.type;
// Gracefully degrade if type not resolved yet
return paramType != null
- ? paramType.getDisplayString(withNullability: false)
+ ? paramType.getDisplayString(
+ withNullability: request.libraryElement.isNonNullableByDefault)
: 'var';
}).toList();
diff --git a/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart b/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
index 8316e43..3be9cd3 100644
--- a/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
@@ -115,6 +115,8 @@
} else if (type is InterfaceType) {
Element element = type.element;
if (element == null || element.isSynthetic) {
+ assert(false, "untested branch may print nullable types wrong");
+ // TODO: test this, use the the library's nullability (not tracked yet).
buffer.write(type.getDisplayString(withNullability: false));
} else {
// String uri = element.library.source.uri.toString();
@@ -132,7 +134,9 @@
}
}
} else {
- // Handle `void` and `dynamic`.
+ // Handle `void` and `dynamic`. Nullability doesn't affect this.
+ assert(type.getDisplayString(withNullability: false) ==
+ type.getDisplayString(withNullability: true));
buffer.write(type.getDisplayString(withNullability: false));
}
}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart
index e40be74..7ff448e 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart
@@ -23,19 +23,18 @@
final String extendedType;
/// The value extractor used to compute the value of the type argument.
- final ValueExtractor value;
+ final ValueExtractor argumentValue;
/// Initialize a newly created change to describe adding a type parameter to a
/// type or a function.
- // TODO(brianwilkerson) Support adding multiple type parameters.
AddTypeParameter(
{@required this.index,
@required this.name,
- @required this.value,
+ @required this.argumentValue,
this.extendedType})
: assert(index >= 0),
assert(name != null),
- assert(value != null);
+ assert(argumentValue != null);
@override
void apply(DartFileEditBuilder builder, DataDrivenFix fix, _Data data) {
@@ -54,7 +53,7 @@
if (node is NamedType) {
// wrong_number_of_type_arguments
// wrong_number_of_type_arguments_constructor
- var argument = value.from(node, fix.utils);
+ var argument = argumentValue.from(node, fix.utils);
if (argument == null) {
return null;
}
@@ -67,7 +66,7 @@
var parent = node.parent;
if (parent is InvocationExpression) {
// wrong_number_of_type_arguments_method
- var argument = value.from(parent, fix.utils);
+ var argument = argumentValue.from(parent, fix.utils);
if (argument == null) {
return null;
}
@@ -86,7 +85,7 @@
return _TypeParameterData(typeParameters, parent.name.end);
} else if (node is TypeArgumentList && parent is ExtensionOverride) {
// wrong_number_of_type_arguments_extension
- var argument = value.from(node, fix.utils);
+ var argument = argumentValue.from(node, fix.utils);
if (argument == null) {
return null;
}
@@ -120,6 +119,8 @@
void _applyToTypeParameters(
DartFileEditBuilder builder, _TypeParameterData data) {
+ // TODO(brianwilkerson) Define a `bound` to use in the declaration of the
+ // parameter.
var argumentValue =
extendedType == null ? name : '$name extends $extendedType';
var typeParameters = data.typeParameters;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_parser.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_parser.dart
index b34c637..0175537 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_parser.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_parser.dart
@@ -61,7 +61,6 @@
static const String _transformsKey = 'transforms';
static const String _typedefKey = 'typedef';
static const String _urisKey = 'uris';
- static const String _valueKey = 'value';
static const String _versionKey = 'version';
/// A table mapping top-level keys for member elements to the list of keys for
@@ -261,18 +260,24 @@
/// add-type-parameter change.
AddTypeParameter _translateAddTypeParameterChange(YamlMap node) {
_reportUnsupportedKeys(
- node, const {_indexKey, _kindKey, _nameKey, _valueKey});
+ node, const {_indexKey, _kindKey, _nameKey, _argumentValueKey});
var index = _translateInteger(node.valueAt(_indexKey),
ErrorContext(key: _indexKey, parentNode: node));
var name = _translateString(
node.valueAt(_nameKey), ErrorContext(key: _nameKey, parentNode: node));
- var value = _translateValueExtractor(node.valueAt(_valueKey),
- ErrorContext(key: _valueKey, parentNode: node));
- if (index == null || name == null || value == null) {
+ // TODO(brianwilkerson) In order to support adding multiple type parameters
+ // we might need to introduce a `TypeParameterModification` change, similar
+ // to `ParameterModification`. That becomes more likely if we add support
+ // for removing type parameters.
+ var argumentValue = _translateValueExtractor(
+ node.valueAt(_argumentValueKey),
+ ErrorContext(key: _argumentValueKey, parentNode: node));
+ if (index == null || name == null || argumentValue == null) {
// The error has already been reported.
return null;
}
- return AddTypeParameter(index: index, name: name, value: value);
+ return AddTypeParameter(
+ index: index, name: name, argumentValue: argumentValue);
}
/// Translate the [node] into a value extractor. Return the resulting
diff --git a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
index e8ae0d7..197842e 100644
--- a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
@@ -4,6 +4,7 @@
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analysis_server/src/services/completion/dart/arglist_contributor.dart';
+import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -1077,6 +1078,50 @@
assertNoSuggestions();
}
+ Future<void> test_ArgumentList_nnbd_function_named_param() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ addTestSource(r'''
+f({int? nullable, int nonnullable}) {}
+main() { f(^);}');
+''');
+ await computeSuggestions();
+ assertSuggestArgumentsAndTypes(namedArgumentsWithTypes: {
+ 'nullable': 'int?',
+ 'nonnullable': 'int',
+ });
+ }
+
+ Future<void> test_ArgumentList_nnbd_function_named_param_imported() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ addSource('/home/test/lib/a.dart', '''
+f({int? nullable, int nonnullable}) {}''');
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ addTestSource(r'''
+import "a.dart";
+main() { f(^);}');
+''');
+ await computeSuggestions();
+ assertSuggestArgumentsAndTypes(namedArgumentsWithTypes: {
+ 'nullable': 'int?',
+ 'nonnullable': 'int',
+ });
+ }
+
+ Future<void> test_ArgumentList_nnbd_function_named_param_legacy() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ addSource('/home/test/lib/a.dart', '''
+// @dart = 2.8
+f({int named}) {}''');
+ addTestSource(r'''
+import "a.dart";
+main() { f(^);}');
+''');
+ await computeSuggestions();
+ assertSuggestArgumentsAndTypes(namedArgumentsWithTypes: {
+ 'named': 'int*',
+ });
+ }
+
Future<void> test_superConstructorInvocation() async {
addTestSource('''
class A {
diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
index 7e7ce51..1ae4849 100644
--- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
@@ -5,6 +5,7 @@
import 'package:analysis_server/src/protocol_server.dart';
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analysis_server/src/services/completion/dart/imported_reference_contributor.dart';
+import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -2302,6 +2303,69 @@
expect(suggestion.hasNamedParameters, true);
}
+ Future<void> test_function_parameters_nnbd_required() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ resolveSource('/home/test/lib/a.dart', '''
+void m(int? nullable, int nonNullable) {}
+''');
+ addTestSource('''
+import 'a.dart';
+
+main() {^}
+''');
+ await computeSuggestions();
+ var suggestion = assertSuggestFunction('m', 'void');
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'nullable');
+ expect(suggestion.parameterTypes[0], 'int?');
+ expect(suggestion.parameterNames[1], 'nonNullable');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 2);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
+ Future<void> test_function_parameters_nnbd_required_into_legacy() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ resolveSource('/home/test/lib/a.dart', '''
+void m(int? nullable, int nonNullable) {}
+''');
+ addTestSource('''
+// @dart = 2.8
+import 'a.dart';
+
+main() {^}
+''');
+ await computeSuggestions();
+ var suggestion = assertSuggestFunction('m', 'void');
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'nullable');
+ expect(suggestion.parameterTypes[0], 'int');
+ expect(suggestion.parameterNames[1], 'nonNullable');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 2);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
+ Future<void> test_function_parameters_nnbd_required_legacy() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ resolveSource('/home/test/lib/a.dart', '''
+// @dart = 2.8
+void m(int param) {}
+''');
+ addTestSource('''
+import 'a.dart';
+
+main() {^}
+''');
+ await computeSuggestions();
+ var suggestion = assertSuggestFunction('m', 'void');
+ expect(suggestion.parameterNames, hasLength(1));
+ expect(suggestion.parameterNames[0], 'param');
+ expect(suggestion.parameterTypes[0], 'int*');
+ expect(suggestion.requiredParameterCount, 1);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
Future<void> test_function_parameters_none() async {
resolveSource('/home/test/lib/a.dart', '''
void m() {}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/add_type_parameter_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/add_type_parameter_test.dart
index 5a29c7a..3ac8426 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/add_type_parameter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/add_type_parameter_test.dart
@@ -468,6 +468,6 @@
extendedType: extendedType,
index: index,
name: 'T',
- value: LiteralExtractor('String')),
+ argumentValue: LiteralExtractor('String')),
]);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/invalid_value_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/invalid_value_test.dart
index 40aa4d0..1bd6446 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/invalid_value_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/invalid_value_test.dart
@@ -152,9 +152,9 @@
- kind: 'addTypeParameter'
index: 1
name: 'T'
- value: 'int'
+ argumentValue: 'int'
''', [
- error(TransformSetErrorCode.invalidValue, 198, 5),
+ error(TransformSetErrorCode.invalidValue, 206, 5),
]);
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/missing_key_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/missing_key_test.dart
index 8080470..148f8a4 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/missing_key_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/diagnostics/missing_key_test.dart
@@ -97,6 +97,24 @@
]);
}
+ void test_addTypeParameterChange_argumentValue() {
+ assertErrors('''
+version: 1
+transforms:
+- title: ''
+ date: 2020-09-14
+ element:
+ uris: ['test.dart']
+ function: 'f'
+ changes:
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'a'
+''', [
+ error(TransformSetErrorCode.missingKey, 124, 56),
+ ]);
+ }
+
void test_addTypeParameterChange_index() {
assertErrors('''
version: 1
@@ -109,11 +127,11 @@
changes:
- kind: 'addTypeParameter'
name: 'a'
- value:
+ argumentValue:
kind: 'argument'
index: 0
''', [
- error(TransformSetErrorCode.missingKey, 124, 96),
+ error(TransformSetErrorCode.missingKey, 124, 104),
]);
}
@@ -129,29 +147,11 @@
changes:
- kind: 'addTypeParameter'
index: 0
- value:
+ argumentValue:
kind: 'argument'
index: 0
''', [
- error(TransformSetErrorCode.missingKey, 124, 95),
- ]);
- }
-
- void test_addTypeParameterChange_value() {
- assertErrors('''
-version: 1
-transforms:
-- title: ''
- date: 2020-09-14
- element:
- uris: ['test.dart']
- function: 'f'
- changes:
- - kind: 'addTypeParameter'
- index: 0
- name: 'a'
-''', [
- error(TransformSetErrorCode.missingKey, 124, 56),
+ error(TransformSetErrorCode.missingKey, 124, 103),
]);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/end_to_end_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/end_to_end_test.dart
index 36e1c68..0608b29 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/end_to_end_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/end_to_end_test.dart
@@ -74,7 +74,7 @@
- kind: 'addTypeParameter'
index: 1
name: 'T'
- value:
+ argumentValue:
kind: 'argument'
index: 0
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_parser_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_parser_test.dart
index 16dc6a9..e944316 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_parser_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_parser_test.dart
@@ -174,7 +174,7 @@
- kind: 'addTypeParameter'
index: 0
name: 'T'
- value:
+ argumentValue:
kind: 'argument'
name: 'p'
''');
@@ -186,7 +186,7 @@
var change = transform.changes[0] as AddTypeParameter;
expect(change.index, 0);
expect(change.name, 'T');
- var value = change.value as ArgumentExtractor;
+ var value = change.argumentValue as ArgumentExtractor;
var parameter = value.parameter as NamedParameterReference;
expect(parameter.name, 'p');
}
@@ -205,7 +205,7 @@
- kind: 'addTypeParameter'
index: 0
name: 'T'
- value:
+ argumentValue:
kind: 'argument'
index: 2
''');
@@ -217,7 +217,7 @@
var change = transform.changes[0] as AddTypeParameter;
expect(change.index, 0);
expect(change.name, 'T');
- var value = change.value as ArgumentExtractor;
+ var value = change.argumentValue as ArgumentExtractor;
var parameter = value.parameter as PositionalParameterReference;
expect(parameter.index, 2);
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
index 915f509..be06c78 100644
--- a/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
@@ -576,7 +576,6 @@
} else if (forLoopParts is ForEachPartsWithDeclaration) {
var variable = forLoopParts.loopVariable.declaredElement;
assignedVariables.declare(variable);
- assignedVariables.write(variable);
} else {
throw StateError('Unrecognized for loop parts');
}
diff --git a/pkg/dartdev/lib/dartdev.dart b/pkg/dartdev/lib/dartdev.dart
index 41f0901..2ed2c66 100644
--- a/pkg/dartdev/lib/dartdev.dart
+++ b/pkg/dartdev/lib/dartdev.dart
@@ -85,11 +85,10 @@
orElse: () => null,
);
if (launchDdsArg != null) {
- // TODO(bkonyi): uncomment after 2.10 branch.
- // RunCommand.launchDds = true;
- // final ddsUrl = (launchDdsArg.split('=')[1]).split(':');
- // RunCommand.ddsHost = ddsUrl[0];
- // RunCommand.ddsPort = ddsUrl[1];
+ RunCommand.launchDds = true;
+ final ddsUrl = (launchDdsArg.split('=')[1]).split(':');
+ RunCommand.ddsHost = ddsUrl[0];
+ RunCommand.ddsPort = ddsUrl[1];
}
String commandName;
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 8a9fa88..96029ef 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -820,19 +820,34 @@
return base;
}
+ /// Returns the "actual" superclass of [c].
+ ///
+ /// Walks up the superclass chain looking for the first actual class
+ /// skipping any synthetic classes inserted by the CFE.
+ Class superClassAsWritten(Class c) {
+ var superclass = c.superclass;
+ while (superclass.isAnonymousMixin) {
+ superclass = superclass.superclass;
+ }
+ return superclass;
+ }
+
// Find the real (user declared) superclass and the list of mixins.
// We'll use this to unroll the intermediate classes.
//
// TODO(jmesserly): consider using Kernel's mixin unrolling.
- var mixinClasses = <Class>[];
- var superclass = getSuperclassAndMixins(c, mixinClasses);
+ var superclass = superClassAsWritten(c);
var supertype = identical(c.superclass, superclass)
? c.supertype.asInterfaceType
: _hierarchy.getClassAsInstanceOf(c, superclass).asInterfaceType;
- mixinClasses = mixinClasses.reversed.toList();
- var mixins = mixinClasses
- .map((m) => _hierarchy.getClassAsInstanceOf(c, m).asInterfaceType)
- .toList();
+ // All mixins (real and anonymous) classes applied to c.
+ var mixinApplications = [
+ if (c.mixedInClass != null) c.mixedInClass,
+ for (var sc = c.superclass;
+ sc.isAnonymousMixin && sc.mixedInClass != null;
+ sc = sc.superclass)
+ sc,
+ ].reversed.toList();
var hasUnnamedSuper = _hasUnnamedInheritedConstructor(superclass);
@@ -873,7 +888,7 @@
if (shouldDefer(supertype)) {
deferredSupertypes.add(runtimeStatement('setBaseClass(#, #)', [
- getBaseClass(isMixinAliasClass(c) ? 0 : mixins.length),
+ getBaseClass(isMixinAliasClass(c) ? 0 : mixinApplications.length),
emitDeferredType(supertype),
]));
// Refers to 'supertype' without any type arguments.
@@ -924,29 +939,43 @@
// classes lack required synthetic members, such as constructors.
//
// Also, we need to generate one extra level of nesting for alias classes.
- for (var i = 0; i < mixins.length; i++) {
- var m = mixins[i];
+ for (var i = 0; i < mixinApplications.length; i++) {
+ var m = mixinApplications[i];
+ var mixinClass = m.isAnonymousMixin ? m.mixedInClass : m;
+ var mixinType =
+ _hierarchy.getClassAsInstanceOf(c, mixinClass).asInterfaceType;
var mixinName =
- getLocalClassName(superclass) + '_' + getLocalClassName(m.classNode);
+ getLocalClassName(superclass) + '_' + getLocalClassName(mixinClass);
var mixinId = _emitTemporaryId(mixinName + '\$');
+ // Collect all forwarding stubs from anonymous mixins classes. These will
+ // contain covariant parameter checks that need to be applied.
+ var forwardingMethodStubs = [
+ for (var procedure in m.procedures)
+ if (procedure.isForwardingStub && !procedure.isAbstract)
+ _emitMethodDeclaration(procedure)
+ ];
+
// Bind the mixin class to a name to workaround a V8 bug with es6 classes
// and anonymous function names.
// TODO(leafp:) Eliminate this once the bug is fixed:
// https://bugs.chromium.org/p/v8/issues/detail?id=7069
body.add(js.statement('const # = #', [
mixinId,
- js_ast.ClassExpression(_emitTemporaryId(mixinName), baseClass, [])
+ js_ast.ClassExpression(
+ _emitTemporaryId(mixinName), baseClass, forwardingMethodStubs)
]));
- emitMixinConstructors(mixinId, m);
- hasUnnamedSuper = hasUnnamedSuper || _hasUnnamedConstructor(m.classNode);
+ emitMixinConstructors(mixinId, mixinType);
+ hasUnnamedSuper = hasUnnamedSuper || _hasUnnamedConstructor(mixinClass);
- if (shouldDefer(m)) {
- deferredSupertypes.add(runtimeStatement('applyMixin(#, #)',
- [getBaseClass(mixins.length - i), emitDeferredType(m)]));
+ if (shouldDefer(mixinType)) {
+ deferredSupertypes.add(runtimeStatement('applyMixin(#, #)', [
+ getBaseClass(mixinApplications.length - i),
+ emitDeferredType(mixinType)
+ ]));
} else {
- body.add(
- runtimeStatement('applyMixin(#, #)', [mixinId, emitClassRef(m)]));
+ body.add(runtimeStatement(
+ 'applyMixin(#, #)', [mixinId, emitClassRef(mixinType)]));
}
baseClass = mixinId;
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index f643d50..b009d4a 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -5053,7 +5053,6 @@
// reported by the parser.
lvalue.isLate = false;
elements.explicitVariableDeclaration = lvalue;
- typeInferrer?.assignedVariables?.write(lvalue);
if (lvalue.isConst) {
elements.expressionProblem = buildProblem(
fasta.messageForInLoopWithConstVariable,
diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart
index 3ebeaee..7e6f18d 100644
--- a/pkg/test_runner/lib/src/options.dart
+++ b/pkg/test_runner/lib/src/options.dart
@@ -448,13 +448,24 @@
// option. Use it as a test selector pattern.
var patterns = options.putIfAbsent("selectors", () => <String>[]);
+ var allSuiteDirectories = [
+ ...testSuiteDirectories,
+ "tests/co19",
+ "tests/co19_2",
+ ];
// Allow passing in the full relative path to a test or directory and
// infer the selector from it. This lets users use tab completion on
// the command line.
- for (var suiteDirectory in testSuiteDirectories) {
+ for (var suiteDirectory in allSuiteDirectories) {
var path = suiteDirectory.toString();
if (arg.startsWith("$path/") || arg.startsWith("$path\\")) {
arg = arg.substring(path.lastIndexOf("/") + 1);
+
+ // Remove the `src/` subdirectories from the co19 and co19_2
+ // directories that do not appear in the test names.
+ if (arg.startsWith("co19")) {
+ arg = arg.replaceFirst(RegExp("src[/\]"), "");
+ }
break;
}
}
diff --git a/pkg/wasm/lib/src/function.dart b/pkg/wasm/lib/src/function.dart
index c138e48..4ac694e 100644
--- a/pkg/wasm/lib/src/function.dart
+++ b/pkg/wasm/lib/src/function.dart
@@ -16,9 +16,9 @@
Pointer<WasmerValue> _args;
Pointer<WasmerValue> _result;
- WasmFunction(this._name, this._func, this._argTypes, this._returnType) {
- _args = allocate<WasmerValue>(count: _argTypes.length);
- _result = allocate<WasmerValue>();
+ WasmFunction(this._name, this._func, this._argTypes, this._returnType)
+ : _args = allocate<WasmerValue>(count: _argTypes.length),
+ _result = allocate<WasmerValue>() {
for (var i = 0; i < _argTypes.length; ++i) {
_args[i].tag = _argTypes[i];
}
@@ -43,6 +43,7 @@
_args[i].f64 = arg;
return true;
}
+ return false;
}
dynamic apply(List<dynamic> args) {
diff --git a/pkg/wasm/lib/src/module.dart b/pkg/wasm/lib/src/module.dart
index d8ed0d9..4013966 100644
--- a/pkg/wasm/lib/src/module.dart
+++ b/pkg/wasm/lib/src/module.dart
@@ -14,9 +14,7 @@
Pointer<WasmerModule> _module;
/// Compile a module.
- WasmModule(Uint8List data) {
- _module = WasmRuntime().compile(data);
- }
+ WasmModule(Uint8List data) : _module = WasmRuntime().compile(data) {}
/// Instantiate the module with the given imports.
WasmInstance instantiate(WasmImports imports) {
@@ -49,9 +47,9 @@
int _length;
/// Create an imports object.
- WasmImports([this._capacity = 4]) : _length = 0 {
- _imports = allocate<WasmerImport>(count: this._capacity);
- }
+ WasmImports([this._capacity = 4])
+ : _imports = allocate<WasmerImport>(count: _capacity),
+ _length = 0 {}
/// Returns the number of imports.
int get length => _length;
@@ -61,12 +59,13 @@
class WasmInstance {
Pointer<WasmerModule> _module;
Pointer<WasmerInstance> _instance;
- Map<String, WasmFunction> _functions;
+ Pointer<WasmerMemory>? _exportedMemory;
+ Map<String, WasmFunction> _functions = {};
- WasmInstance(this._module, WasmImports imports) {
+ WasmInstance(this._module, WasmImports imports)
+ : _instance = WasmRuntime()
+ .instantiate(_module, imports._imports, imports.length) {
var runtime = WasmRuntime();
- _instance = runtime.instantiate(_module, imports._imports, imports.length);
- _functions = {};
var exps = runtime.exports(_instance);
for (var e in exps) {
var kind = runtime.exportKind(e);
@@ -75,6 +74,9 @@
var f = runtime.exportToFunction(e);
_functions[name] = WasmFunction(
name, f, runtime.getArgTypes(f), runtime.getReturnType(f));
+ } else if (kind == WasmerImpExpKindMemory) {
+ // WASM currently allows only one memory per module.
+ _exportedMemory = runtime.exportToMemory(e);
}
}
}
@@ -84,4 +86,55 @@
dynamic lookupFunction(String name) {
return _functions[name];
}
+
+ /// Returns the memory exported from this instance.
+ WasmMemory get memory {
+ if (_exportedMemory == null) {
+ throw Exception("Wasm module did not export its memory.");
+ }
+ return WasmMemory._fromExport(_exportedMemory as Pointer<WasmerMemory>);
+ }
+}
+
+/// WasmMemory contains the memory of a WasmInstance.
+class WasmMemory {
+ Pointer<WasmerMemory> _mem;
+ late Uint8List _view;
+
+ WasmMemory._fromExport(this._mem) {
+ _view = WasmRuntime().memoryView(_mem);
+ }
+
+ /// Create a new memory with the given number of initial pages, and optional
+ /// maximum number of pages.
+ WasmMemory(int pages, [int? maxPages])
+ : _mem = WasmRuntime().newMemory(pages, maxPages) {
+ _view = WasmRuntime().memoryView(_mem);
+ }
+
+ /// The WASM spec defines the page size as 64KiB.
+ static const int kPageSizeInBytes = 64 * 1024;
+
+ /// Returns the length of the memory in pages.
+ int get lengthInPages {
+ return WasmRuntime().memoryLength(_mem);
+ }
+
+ /// Returns the length of the memory in bytes.
+ int get lengthInBytes => _view.lengthInBytes;
+
+ /// Returns the byte at the given index.
+ int operator [](int index) => _view[index];
+
+ /// Sets the byte at the given index to value.
+ void operator []=(int index, int value) {
+ _view[index] = value;
+ }
+
+ /// Grow the memory by deltaPages.
+ void grow(int deltaPages) {
+ var runtime = WasmRuntime();
+ runtime.growMemory(_mem, deltaPages);
+ _view = runtime.memoryView(_mem);
+ }
}
diff --git a/pkg/wasm/lib/src/runtime.dart b/pkg/wasm/lib/src/runtime.dart
index 6c8759a..4ddec1d 100644
--- a/pkg/wasm/lib/src/runtime.dart
+++ b/pkg/wasm/lib/src/runtime.dart
@@ -24,41 +24,47 @@
}
class WasmRuntime {
- static WasmRuntime _inst;
+ static WasmRuntime? _inst;
DynamicLibrary _lib;
- WasmerCompileFn _compile;
- WasmerInstantiateFn _instantiate;
- WasmerInstanceExportsFn _instance_exports;
- WasmerExportsLenFn _exports_len;
- WasmerExportsGetFn _exports_get;
- WasmerExportKindFn _export_kind;
- WasmerExportToFuncFn _export_to_func;
- WasmerExportFuncReturnsArityFn _export_func_returns_arity;
- WasmerExportFuncReturnsFn _export_func_returns;
- WasmerExportFuncParamsArityFn _export_func_params_arity;
- WasmerExportFuncParamsFn _export_func_params;
- WasmerExportFuncCallFn _export_func_call;
- WasmerExportNamePtrFn _export_name_ptr;
- WasmerExportDescriptorsFn _export_descriptors;
- WasmerExportDescriptorsDestroyFn _export_descriptors_destroy;
- WasmerExportDescriptorsLenFn _export_descriptors_len;
- WasmerExportDescriptorsGetFn _export_descriptors_get;
- WasmerExportDescriptorKindFn _export_descriptor_kind;
- WasmerExportDescriptorNamePtrFn _export_descriptor_name_ptr;
- WasmerImportDescriptorModuleNamePtrFn _import_descriptor_module_name_ptr;
- WasmerImportDescriptorNamePtrFn _import_descriptor_name_ptr;
- WasmerImportDescriptorsFn _import_descriptors;
- WasmerImportDescriptorsDestroyFn _import_descriptors_destroy;
- WasmerImportDescriptorsLenFn _import_descriptors_len;
- WasmerImportDescriptorsGetFn _import_descriptors_get;
- WasmerImportDescriptorKindFn _import_descriptor_kind;
+ late WasmerCompileFn _compile;
+ late WasmerInstantiateFn _instantiate;
+ late WasmerInstanceExportsFn _instance_exports;
+ late WasmerExportsLenFn _exports_len;
+ late WasmerExportsGetFn _exports_get;
+ late WasmerExportKindFn _export_kind;
+ late WasmerExportToFuncFn _export_to_func;
+ late WasmerExportFuncReturnsArityFn _export_func_returns_arity;
+ late WasmerExportFuncReturnsFn _export_func_returns;
+ late WasmerExportFuncParamsArityFn _export_func_params_arity;
+ late WasmerExportFuncParamsFn _export_func_params;
+ late WasmerExportFuncCallFn _export_func_call;
+ late WasmerExportNamePtrFn _export_name_ptr;
+ late WasmerExportDescriptorsFn _export_descriptors;
+ late WasmerExportDescriptorsDestroyFn _export_descriptors_destroy;
+ late WasmerExportDescriptorsLenFn _export_descriptors_len;
+ late WasmerExportDescriptorsGetFn _export_descriptors_get;
+ late WasmerExportDescriptorKindFn _export_descriptor_kind;
+ late WasmerExportDescriptorNamePtrFn _export_descriptor_name_ptr;
+ late WasmerImportDescriptorModuleNamePtrFn _import_descriptor_module_name_ptr;
+ late WasmerImportDescriptorNamePtrFn _import_descriptor_name_ptr;
+ late WasmerImportDescriptorsFn _import_descriptors;
+ late WasmerImportDescriptorsDestroyFn _import_descriptors_destroy;
+ late WasmerImportDescriptorsLenFn _import_descriptors_len;
+ late WasmerImportDescriptorsGetFn _import_descriptors_get;
+ late WasmerImportDescriptorKindFn _import_descriptor_kind;
+ late WasmerExportToMemoryFn _export_to_memory;
+ late WasmerMemoryNewPtrFn _memory_new_ptr;
+ late WasmerMemoryGrowFn _memory_grow;
+ late WasmerMemoryLengthFn _memory_length;
+ late WasmerMemoryDataFn _memory_data;
+ late WasmerMemoryDataLengthFn _memory_data_length;
factory WasmRuntime() {
if (_inst == null) {
_inst = WasmRuntime._init();
}
- return _inst;
+ return _inst as WasmRuntime;
}
static String _getLibName() {
@@ -96,9 +102,8 @@
return commonLibDir;
}
- WasmRuntime._init() {
- var libPath = path.join(_getLibDir(), _getLibName());
- _lib = DynamicLibrary.open(libPath);
+ WasmRuntime._init()
+ : _lib = DynamicLibrary.open(path.join(_getLibDir(), _getLibName())) {
_compile = _lib.lookupFunction<NativeWasmerCompileFn, WasmerCompileFn>(
'wasmer_compile');
_instantiate =
@@ -171,6 +176,22 @@
_import_descriptor_name_ptr = _lib.lookupFunction<
NativeWasmerImportDescriptorNamePtrFn,
WasmerImportDescriptorNamePtrFn>('wasmer_import_descriptor_name_ptr');
+ _export_to_memory = _lib.lookupFunction<NativeWasmerExportToMemoryFn,
+ WasmerExportToMemoryFn>('wasmer_export_to_memory');
+ _memory_new_ptr =
+ _lib.lookupFunction<NativeWasmerMemoryNewPtrFn, WasmerMemoryNewPtrFn>(
+ 'wasmer_memory_new_ptr');
+ _memory_grow =
+ _lib.lookupFunction<NativeWasmerMemoryGrowFn, WasmerMemoryGrowFn>(
+ 'wasmer_memory_grow');
+ _memory_length =
+ _lib.lookupFunction<NativeWasmerMemoryLengthFn, WasmerMemoryLengthFn>(
+ 'wasmer_memory_length');
+ _memory_data =
+ _lib.lookupFunction<NativeWasmerMemoryDataFn, WasmerMemoryDataFn>(
+ 'wasmer_memory_data');
+ _memory_data_length = _lib.lookupFunction<NativeWasmerMemoryDataLengthFn,
+ WasmerMemoryDataLengthFn>('wasmer_memory_data_length');
}
Pointer<WasmerModule> compile(Uint8List data) {
@@ -331,4 +352,48 @@
throw Exception("Failed to call WASM function");
}
}
+
+ Pointer<WasmerMemory> exportToMemory(Pointer<WasmerExport> export) {
+ var memPtrPtr = allocate<Pointer<WasmerMemory>>();
+ var result = _export_to_memory(export, memPtrPtr);
+ if (result != WasmerResultOk) {
+ free(memPtrPtr);
+ throw Exception("Failed to get exported memory");
+ }
+ Pointer<WasmerMemory> memPtr = memPtrPtr.value;
+ free(memPtrPtr);
+ return memPtr;
+ }
+
+ Pointer<WasmerMemory> newMemory(int pages, int? maxPages) {
+ var memPtrPtr = allocate<Pointer<WasmerMemory>>();
+ var limPtr = allocate<WasmerLimits>();
+ limPtr.ref.min = pages;
+ limPtr.ref.has_max = maxPages != null ? 1 : 0;
+ limPtr.ref.max = maxPages ?? 0;
+ var result = _memory_new_ptr(memPtrPtr, limPtr);
+ free(limPtr);
+ if (result != WasmerResultOk) {
+ free(memPtrPtr);
+ throw Exception("Failed to create memory");
+ }
+ Pointer<WasmerMemory> memPtr = memPtrPtr.value;
+ free(memPtrPtr);
+ return memPtr;
+ }
+
+ void growMemory(Pointer<WasmerMemory> memory, int deltaPages) {
+ var result = _memory_grow(memory, deltaPages);
+ if (result != WasmerResultOk) {
+ throw Exception("Failed to grow memory");
+ }
+ }
+
+ int memoryLength(Pointer<WasmerMemory> memory) {
+ return _memory_length(memory);
+ }
+
+ Uint8List memoryView(Pointer<WasmerMemory> memory) {
+ return _memory_data(memory).asTypedList(_memory_data_length(memory));
+ }
}
diff --git a/pkg/wasm/lib/src/wasmer_api.dart b/pkg/wasm/lib/src/wasmer_api.dart
index 2f54b53..94dd651 100644
--- a/pkg/wasm/lib/src/wasmer_api.dart
+++ b/pkg/wasm/lib/src/wasmer_api.dart
@@ -67,34 +67,37 @@
// wasmer_import_descriptor_t
class WasmerImportDescriptor extends Struct {}
+// wasmer_memory_t
+class WasmerMemory extends Struct {}
+
// wasmer_import_t
class WasmerImport extends Struct {
- Pointer<Uint8> module_name;
+ external Pointer<Uint8> module_name;
@Uint32()
- int module_name_length;
+ external int module_name_length;
- Pointer<Uint8> import_name;
+ external Pointer<Uint8> import_name;
@Uint32()
- int import_name_length;
+ external int import_name_length;
// wasmer_import_export_kind
@Uint32()
- int tag;
+ external int tag;
// wasmer_import_export_value, which is a union of wasmer_import_func_t*,
// wasmer_table_t*, wasmer_memory_t*, and wasmer_global_t*. The tag determines
// which type it is.
- Pointer<Void> value;
+ external Pointer<Void> value;
}
// wasmer_byte_array
class WasmerByteArray extends Struct {
- Pointer<Uint8> bytes;
+ external Pointer<Uint8> bytes;
@Uint32()
- int length;
+ external int length;
Uint8List get list => bytes.asTypedList(length);
String get string => utf8.decode(list);
@@ -104,13 +107,13 @@
class WasmerValue extends Struct {
// wasmer_value_tag
@Uint32()
- int tag;
+ external int tag;
// wasmer_value, which is a union of int32_t, int64_t, float, and double. The
// tag determines which type it is. It's declared as an int64_t because that's
// large enough to hold all the types. We use ByteData to get the other types.
@Int64()
- int value;
+ external int value;
int get _off32 => Endian.host == Endian.little ? 0 : 4;
int get i64 => value;
@@ -122,8 +125,10 @@
set i64(int val) => value = val;
set _val(ByteData bytes) => value = bytes.getInt64(0, Endian.host);
set i32(int val) => _val = ByteData(8)..setInt32(_off32, val, Endian.host);
- set f32(num val) => _val = ByteData(8)..setFloat32(_off32, val, Endian.host);
- set f64(num val) => _val = ByteData(8)..setFloat64(0, val, Endian.host);
+ set f32(num val) =>
+ _val = ByteData(8)..setFloat32(_off32, val as double, Endian.host);
+ set f64(num val) =>
+ _val = ByteData(8)..setFloat64(0, val as double, Endian.host);
bool get isI32 => tag == WasmerValueTagI32;
bool get isI64 => tag == WasmerValueTagI64;
@@ -131,6 +136,19 @@
bool get isF64 => tag == WasmerValueTagF64;
}
+// wasmer_limits_t
+class WasmerLimits extends Struct {
+ @Uint32()
+ external int min;
+
+ // bool
+ @Uint8()
+ external int has_max;
+
+ @Uint32()
+ external int max;
+}
+
// wasmer_compile
typedef NativeWasmerCompileFn = Uint32 Function(
Pointer<Pointer<WasmerModule>>, Pointer<Uint8>, Uint32);
@@ -286,3 +304,33 @@
Uint32);
typedef WasmerExportFuncCallFn = int Function(Pointer<WasmerExportFunc>,
Pointer<WasmerValue>, int, Pointer<WasmerValue>, int);
+
+// wasmer_export_to_memory
+typedef NativeWasmerExportToMemoryFn = Uint32 Function(
+ Pointer<WasmerExport>, Pointer<Pointer<WasmerMemory>>);
+typedef WasmerExportToMemoryFn = int Function(
+ Pointer<WasmerExport>, Pointer<Pointer<WasmerMemory>>);
+
+// wasmer_memory_new_ptr
+typedef NativeWasmerMemoryNewPtrFn = Uint32 Function(
+ Pointer<Pointer<WasmerMemory>>, Pointer<WasmerLimits>);
+typedef WasmerMemoryNewPtrFn = int Function(
+ Pointer<Pointer<WasmerMemory>>, Pointer<WasmerLimits>);
+
+// wasmer_memory_grow
+typedef NativeWasmerMemoryGrowFn = Uint32 Function(
+ Pointer<WasmerMemory>, Uint32);
+typedef WasmerMemoryGrowFn = int Function(Pointer<WasmerMemory>, int);
+
+// wasmer_memory_length
+typedef NativeWasmerMemoryLengthFn = Uint32 Function(Pointer<WasmerMemory>);
+typedef WasmerMemoryLengthFn = int Function(Pointer<WasmerMemory>);
+
+// wasmer_memory_data
+typedef NativeWasmerMemoryDataFn = Pointer<Uint8> Function(
+ Pointer<WasmerMemory>);
+typedef WasmerMemoryDataFn = Pointer<Uint8> Function(Pointer<WasmerMemory>);
+
+// wasmer_memory_data_length
+typedef NativeWasmerMemoryDataLengthFn = Uint32 Function(Pointer<WasmerMemory>);
+typedef WasmerMemoryDataLengthFn = int Function(Pointer<WasmerMemory>);
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 2cc3c84..4b51532 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -544,11 +544,8 @@
result = Dart_SetDeferredLoadHandler(Loader::DeferredLoadHandler);
CHECK_RESULT(result);
- // TODO(bkonyi): remove after 2.10 branch.
- const bool disable_dds = true;
-
int vm_service_server_port = INVALID_VM_SERVICE_SERVER_PORT;
- if (Options::disable_dart_dev() || disable_dds) {
+ if (Options::disable_dart_dev()) {
vm_service_server_port = Options::vm_service_server_port();
} else if (Options::vm_service_server_port() !=
INVALID_VM_SERVICE_SERVER_PORT) {
@@ -556,15 +553,14 @@
}
// Load embedder specific bits and return.
- if (!VmService::Setup((Options::disable_dart_dev() || disable_dds)
- ? Options::vm_service_server_ip()
- : DEFAULT_VM_SERVICE_SERVER_IP,
- vm_service_server_port, Options::vm_service_dev_mode(),
- Options::vm_service_auth_disabled(),
- Options::vm_write_service_info_filename(),
- Options::trace_loading(), Options::deterministic(),
- Options::enable_service_port_fallback(),
- !Options::disable_dart_dev() && !disable_dds)) {
+ if (!VmService::Setup(
+ Options::disable_dart_dev() ? Options::vm_service_server_ip()
+ : DEFAULT_VM_SERVICE_SERVER_IP,
+ vm_service_server_port, Options::vm_service_dev_mode(),
+ Options::vm_service_auth_disabled(),
+ Options::vm_write_service_info_filename(), Options::trace_loading(),
+ Options::deterministic(), Options::enable_service_port_fallback(),
+ !Options::disable_dart_dev())) {
*error = Utils::StrDup(VmService::GetErrorMessage());
return NULL;
}
diff --git a/tests/language/mixin/implicit_covariance_test.dart b/tests/language/mixin/implicit_covariance_test.dart
index 5606bd7..87d3ddd 100644
--- a/tests/language/mixin/implicit_covariance_test.dart
+++ b/tests/language/mixin/implicit_covariance_test.dart
@@ -13,7 +13,7 @@
class C {
foo(num x) {
if (x is! num) {
- throw "Soudness issue: expected x to be num, got ${x.runtimeType}.";
+ throw "Soundness issue: expected x to be num, got ${x.runtimeType}.";
}
}
}
diff --git a/tests/language_2/mixin/implicit_covariance_test.dart b/tests/language_2/mixin/implicit_covariance_test.dart
index 5606bd7..87d3ddd 100644
--- a/tests/language_2/mixin/implicit_covariance_test.dart
+++ b/tests/language_2/mixin/implicit_covariance_test.dart
@@ -13,7 +13,7 @@
class C {
foo(num x) {
if (x is! num) {
- throw "Soudness issue: expected x to be num, got ${x.runtimeType}.";
+ throw "Soundness issue: expected x to be num, got ${x.runtimeType}.";
}
}
}
diff --git a/tests/lib/wasm/memory_error_test.dart b/tests/lib/wasm/memory_error_test.dart
index e866bf0..3a172d8 100644
--- a/tests/lib/wasm/memory_error_test.dart
+++ b/tests/lib/wasm/memory_error_test.dart
@@ -5,11 +5,13 @@
// Test errors thrown by WasmMemory.
import "package:expect/expect.dart";
-import "dart:wasm";
+import "package:wasm/wasm.dart";
import "dart:typed_data";
void main() {
- Expect.throwsArgumentError(() => WasmMemory(1000000000));
- var mem = WasmMemory(1000);
- Expect.throwsArgumentError(() => mem.grow(1000000000));
+ Expect.throws(() => WasmMemory(1000000000));
+ var mem = WasmMemory(100);
+ Expect.throws(() => mem.grow(1000000000));
+ mem = WasmMemory(100, 200);
+ Expect.throws(() => mem.grow(300));
}
diff --git a/tests/lib/wasm/memory_test.dart b/tests/lib/wasm/memory_test.dart
index 52d12c3..ecaf433 100644
--- a/tests/lib/wasm/memory_test.dart
+++ b/tests/lib/wasm/memory_test.dart
@@ -5,22 +5,19 @@
// Test that we can create a WasmMemory, edit it, and grow it.
import "package:expect/expect.dart";
-import "dart:wasm";
+import "package:wasm/wasm.dart";
import "dart:typed_data";
void main() {
- var mem = WasmMemory(1000);
- Expect.equals(1000, mem.lengthInPages);
- Expect.equals(1000 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
+ var mem = WasmMemory(100);
+ Expect.equals(100, mem.lengthInPages);
+ Expect.equals(100 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
mem[123] = 45;
Expect.equals(45, mem[123]);
- mem.grow(100);
- Expect.equals(1100, mem.lengthInPages);
- Expect.equals(1100 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
+ mem.grow(10);
+ Expect.equals(110, mem.lengthInPages);
+ Expect.equals(110 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
Expect.equals(45, mem[123]);
-
- Expect.throwsArgumentError(() => WasmMemory(1000000000));
- Expect.throwsArgumentError(() => mem.grow(1000000000));
}
diff --git a/tests/lib_2/wasm/memory_error_test.dart b/tests/lib_2/wasm/memory_error_test.dart
index e866bf0..3a172d8 100644
--- a/tests/lib_2/wasm/memory_error_test.dart
+++ b/tests/lib_2/wasm/memory_error_test.dart
@@ -5,11 +5,13 @@
// Test errors thrown by WasmMemory.
import "package:expect/expect.dart";
-import "dart:wasm";
+import "package:wasm/wasm.dart";
import "dart:typed_data";
void main() {
- Expect.throwsArgumentError(() => WasmMemory(1000000000));
- var mem = WasmMemory(1000);
- Expect.throwsArgumentError(() => mem.grow(1000000000));
+ Expect.throws(() => WasmMemory(1000000000));
+ var mem = WasmMemory(100);
+ Expect.throws(() => mem.grow(1000000000));
+ mem = WasmMemory(100, 200);
+ Expect.throws(() => mem.grow(300));
}
diff --git a/tests/lib_2/wasm/memory_test.dart b/tests/lib_2/wasm/memory_test.dart
index 52d12c3..ecaf433 100644
--- a/tests/lib_2/wasm/memory_test.dart
+++ b/tests/lib_2/wasm/memory_test.dart
@@ -5,22 +5,19 @@
// Test that we can create a WasmMemory, edit it, and grow it.
import "package:expect/expect.dart";
-import "dart:wasm";
+import "package:wasm/wasm.dart";
import "dart:typed_data";
void main() {
- var mem = WasmMemory(1000);
- Expect.equals(1000, mem.lengthInPages);
- Expect.equals(1000 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
+ var mem = WasmMemory(100);
+ Expect.equals(100, mem.lengthInPages);
+ Expect.equals(100 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
mem[123] = 45;
Expect.equals(45, mem[123]);
- mem.grow(100);
- Expect.equals(1100, mem.lengthInPages);
- Expect.equals(1100 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
+ mem.grow(10);
+ Expect.equals(110, mem.lengthInPages);
+ Expect.equals(110 * WasmMemory.kPageSizeInBytes, mem.lengthInBytes);
Expect.equals(45, mem[123]);
-
- Expect.throwsArgumentError(() => WasmMemory(1000000000));
- Expect.throwsArgumentError(() => mem.grow(1000000000));
}
diff --git a/third_party/wasmer/wasmer_wrapper.cc b/third_party/wasmer/wasmer_wrapper.cc
index b014268..cdfaa69 100644
--- a/third_party/wasmer/wasmer_wrapper.cc
+++ b/third_party/wasmer/wasmer_wrapper.cc
@@ -36,4 +36,10 @@
wasmer_byte_array* out_name) {
*out_name = wasmer_import_descriptor_name(import_descriptor);
}
+
+// Wraps wasmer_memory_new.
+wasmer_result_t wasmer_memory_new_ptr(wasmer_memory_t** memory,
+ wasmer_limits_t* limits) {
+ return wasmer_memory_new(memory, *limits);
+}
}
diff --git a/tools/VERSION b/tools/VERSION
index d2bf2b9..52e320d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 10
PATCH 0
-PRERELEASE 136
+PRERELEASE 137
PRERELEASE_PATCH 0
\ No newline at end of file