diff --git a/examples/flutter_animations_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart b/examples/flutter_animations_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart index 902cc78a..f4aadca1 100755 --- a/examples/flutter_animations_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart +++ b/examples/flutter_animations_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart @@ -13,10 +13,9 @@ class $InheritedWidget extends InheritedWidget with m.InstanceBridge { : super(key: key, child: child); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "InheritedWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "InheritedWidget"), + ); @override bool updateShouldNotify(covariant InheritedWidget oldWidget) { @@ -45,10 +44,9 @@ class $StatelessWidget extends StatelessWidget implements PreferredSizeWidget { $StatelessWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatelessWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatelessWidget"), + ); @override Widget build(BuildContext context) { @@ -73,10 +71,9 @@ Function _StatefulWidget__$(m.Scope scope$) => ({Key? key}) { class $StatefulWidget extends StatefulWidget with m.InstanceBridge { $StatefulWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatefulWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatefulWidget"), + ); @override State createState() { @@ -95,9 +92,9 @@ Function _State__$(m.Scope scope$) => () { class $State extends State with m.InstanceBridge, TickerProviderStateMixin, RestorationMixin { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), + ); @override Widget build(BuildContext context) { diff --git a/examples/flutter_example_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart b/examples/flutter_example_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart index 902cc78a..f4aadca1 100755 --- a/examples/flutter_example_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart +++ b/examples/flutter_example_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart @@ -13,10 +13,9 @@ class $InheritedWidget extends InheritedWidget with m.InstanceBridge { : super(key: key, child: child); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "InheritedWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "InheritedWidget"), + ); @override bool updateShouldNotify(covariant InheritedWidget oldWidget) { @@ -45,10 +44,9 @@ class $StatelessWidget extends StatelessWidget implements PreferredSizeWidget { $StatelessWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatelessWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatelessWidget"), + ); @override Widget build(BuildContext context) { @@ -73,10 +71,9 @@ Function _StatefulWidget__$(m.Scope scope$) => ({Key? key}) { class $StatefulWidget extends StatefulWidget with m.InstanceBridge { $StatefulWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatefulWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatefulWidget"), + ); @override State createState() { @@ -95,9 +92,9 @@ Function _State__$(m.Scope scope$) => () { class $State extends State with m.InstanceBridge, TickerProviderStateMixin, RestorationMixin { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), + ); @override Widget build(BuildContext context) { diff --git a/examples/flutter_example_gallery/lib/proxy/proxy__package_scoped_model_scoped_model.dart b/examples/flutter_example_gallery/lib/proxy/proxy__package_scoped_model_scoped_model.dart index b0db7361..5ffee7d7 100755 --- a/examples/flutter_example_gallery/lib/proxy/proxy__package_scoped_model_scoped_model.dart +++ b/examples/flutter_example_gallery/lib/proxy/proxy__package_scoped_model_scoped_model.dart @@ -10,9 +10,9 @@ Function _Model__$(m.Scope scope$) => () { class $Model extends Model with m.InstanceBridge { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:scoped_model/scoped_model.dart", "Model"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:scoped_model/scoped_model.dart", "Model"), + ); @override late Map superGetters = {}; diff --git a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart index 70a9d8be..3a2e9643 100755 --- a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart +++ b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart @@ -14,10 +14,10 @@ Function _Listenable__$(m.Scope scope$) => (bool _value) { class $Listenable extends Listenable with m.InstanceBridge { @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/foundation/change_notifier.dart", "Listenable"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef( + "package:flutter/src/foundation/change_notifier.dart", "Listenable"), + ); @override late Map superGetters = {}; diff --git a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart index 93941851..b5f3c930 100755 --- a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart +++ b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart @@ -10,10 +10,10 @@ class $CustomPainter extends CustomPainter with m.InstanceBridge { $CustomPainter({Listenable? repaint}) : super(repaint: repaint); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/rendering/custom_paint.dart", "CustomPainter"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef( + "package:flutter/src/rendering/custom_paint.dart", "CustomPainter"), + ); @override late Map superGetters = { diff --git a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart index 1cc8b194..68a1f8c1 100755 --- a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart +++ b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_framework.dart @@ -20,10 +20,9 @@ class $InheritedWidget extends InheritedWidget with m.InstanceBridge { : super(key: key, child: child); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "InheritedWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "InheritedWidget"), + ); @override bool updateShouldNotify(covariant InheritedWidget oldWidget) { @@ -52,10 +51,9 @@ class $StatelessWidget extends StatelessWidget implements PreferredSizeWidget { $StatelessWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatelessWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatelessWidget"), + ); @override Widget build(BuildContext context) { @@ -80,10 +78,9 @@ Function _StatefulWidget__$(m.Scope scope$) => ({Key? key}) { class $StatefulWidget extends StatefulWidget with m.InstanceBridge { $StatefulWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatefulWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatefulWidget"), + ); @override State createState() { @@ -102,9 +99,9 @@ Function _State__$(m.Scope scope$) => () { class $State extends State with m.InstanceBridge, TickerProviderStateMixin, RestorationMixin { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), + ); @override Widget build(BuildContext context) { diff --git a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart index abef2dd3..e8043a5c 100755 --- a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart +++ b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart @@ -35,10 +35,10 @@ Function _RestorableListenable__$(m.Scope scope$) => () { class $RestorableListenable extends RestorableListenable with m.InstanceBridge { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:flutter/src/widgets/restoration_properties.dart", - "RestorableListenable"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/restoration_properties.dart", + "RestorableListenable"), + ); @override late Map superGetters = {}; diff --git a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart index cff58e98..a4eea17b 100755 --- a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart +++ b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart @@ -13,10 +13,10 @@ class $AnimatedWidget extends AnimatedWidget with m.InstanceBridge { : super(key: key, listenable: listenable); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/transitions.dart", "AnimatedWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef( + "package:flutter/src/widgets/transitions.dart", "AnimatedWidget"), + ); @override late Map superGetters = {}; diff --git a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_scoped_model_scoped_model.dart b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_scoped_model_scoped_model.dart index e0ad7777..551cd74c 100755 --- a/examples/flutter_example_gallery_2/lib/proxy/proxy__package_scoped_model_scoped_model.dart +++ b/examples/flutter_example_gallery_2/lib/proxy/proxy__package_scoped_model_scoped_model.dart @@ -10,9 +10,9 @@ Function _Model__$(m.Scope scope$) => () { class $Model extends Model with m.InstanceBridge { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:scoped_model/scoped_model.dart", "Model"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:scoped_model/scoped_model.dart", "Model"), + ); @override late Map superGetters = {}; diff --git a/micro_dart_compiler/lib/compiler/ast/expression.dart b/micro_dart_compiler/lib/compiler/ast/expression.dart index fe836602..ac3b38ab 100755 --- a/micro_dart_compiler/lib/compiler/ast/expression.dart +++ b/micro_dart_compiler/lib/compiler/ast/expression.dart @@ -368,6 +368,9 @@ int compileIsExpression(MicroCompilerContext context, IsExpression node) { context.externalCallMethods.add(isRef); return context.pushOp(OpCallExternal.make(isRef, true, [], [])); } + } else if (type is FunctionType) { + throw Exception( + "IsExpression type not support : ${type.runtimeType.toString()}"); } else { throw Exception( "IsExpression type not support : ${type.runtimeType.toString()}"); @@ -476,6 +479,11 @@ int compileAsExpression(MicroCompilerContext context, AsExpression node) { "FunctionType not support : ${node.parent?.runtimeType.toString()} ${type.toStringInternal()}"); //throw Exception( // "FunctionType not support : ${node.parent?.runtimeType.toString()} ${type.toStringInternal()}"); + } else if (type is FutureOrType) { + // print( + // "FutureOrType not support : ${node.parent?.runtimeType.toString()} ${type.toStringInternal()}"); + throw Exception( + "AsExpression not support : ${type.runtimeType.toString()}"); } else { throw Exception( "AsExpression not support : ${type.runtimeType.toString()}"); diff --git a/micro_dart_compiler/test/env.dart b/micro_dart_compiler/test/env.dart index 0747d70c..30b4d581 100755 --- a/micro_dart_compiler/test/env.dart +++ b/micro_dart_compiler/test/env.dart @@ -29,6 +29,90 @@ const bool printOp = true; typedef ResultCallback = void Function(dynamic returnValue); +Future singleFileTestEngine( + String fileName, { + String functionName = "main", + String testCasePath = testCasePath1, + bool astOut = true, + bool jsonAstOut = true, + bool opOut = true, + bool constantOut = true, + bool externalMethodsOut = false, + bool typesOut = true, + bool declarationsOut = true, + bool debug = true, + bool isAsync = false, + bool waitClean = false, + Map testLibraryMirrors = libraryMirrors, +}) async { + var file = File("$testCasePath$fileName"); + var sources = {'main.dart': file.readAsStringSync()}; + var program = await compileSource(pluginUriRegExp, options, sources); + + if (astOut) { + writeComponentToText(program.component!, + path: "${testCasePath}_$fileName.ast.txt"); + } + if (jsonAstOut) { + astToJson( + "${testCasePath}_$fileName.json", pluginUriRegExp, program.component); + } + + if (externalMethodsOut) { + File("${testCasePath}_$fileName.externalMethods.txt") + .writeAsStringSync(program.getExternalCallMethods()); + } + + var engine = MicroDartEngine.fromData(program.write().buffer.asByteData()); + engine.setExternalFunctions(testLibraryMirrors); + + if (opOut) { + File("${testCasePath}_$fileName.op.txt") + .writeAsStringSync(engine.getOpcodes()); + } + + if (constantOut) { + File("${testCasePath}_$fileName.constant.txt") + .writeAsStringSync(engine.getConstants()); + } + + if (typesOut) { + File("${testCasePath}_$fileName.types.txt") + .writeAsStringSync(engine.getTypes()); + } + + if (declarationsOut) { + File("${testCasePath}_$fileName.declarations.txt") + .writeAsStringSync(engine.getDeclarations()); + } + + if (debug) { + engine.debug = true; + } + + return engine; +} + +Future run( + MicroDartEngine engine, { + String functionName = "main", + bool isAsync = false, + bool waitClean = false, + ResultCallback? resultCallback, +}) async { + var returnValue = isAsync + ? await await engine + .callStaticFunctionAsync(pluginUri, functionName, [], {}) + : waitClean + ? await engine + .callStaticFunctionWaitClean(pluginUri, functionName, [], {}) + : engine.callStaticFunction(pluginUri, functionName, [], {}); + + resultCallback?.call(returnValue); + + return returnValue; +} + Future singleFileTest( String fileName, { String functionName = "main", @@ -92,10 +176,12 @@ Future singleFileTest( } var returnValue = isAsync - ? await await engine.callStaticFunctionAsync(pluginUri, "main", [], {}) + ? await await engine + .callStaticFunctionAsync(pluginUri, functionName, [], {}) : waitClean - ? await engine.callStaticFunctionWaitClean(pluginUri, "main", [], {}) - : engine.callStaticFunction(pluginUri, "main", [], {}); + ? await engine + .callStaticFunctionWaitClean(pluginUri, functionName, [], {}) + : engine.callStaticFunction(pluginUri, functionName, [], {}); resultCallback?.call(returnValue); diff --git a/micro_dart_compiler/test/test2/argument_test.dart b/micro_dart_compiler/test/test2/argument_test.dart new file mode 100644 index 00000000..9b12b4c1 --- /dev/null +++ b/micro_dart_compiler/test/test2/argument_test.dart @@ -0,0 +1,30 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Argument tests', () { + test(':named_argument_test', () async { + String fileName = "named_argument_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}argument/", + resultCallback: (returnValue) { + expect(returnValue, true); + }); + }); + + test(':named_in_const_creation_test', () async { + String fileName = "named_in_const_creation_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}argument/", + resultCallback: (returnValue) { + expect(returnValue, true); + }); + }); + + test(':positional_option_test', () async { + String fileName = "positional_option_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}argument/", + resultCallback: (returnValue) { + expect(returnValue, 499720164); + }); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/assert_test.dart b/micro_dart_compiler/test/test2/assert_test.dart new file mode 100644 index 00000000..bf195456 --- /dev/null +++ b/micro_dart_compiler/test/test2/assert_test.dart @@ -0,0 +1,51 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Assert tests', () { + test(':assert_test', () async { + String fileName = "assert_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}assert/", + resultCallback: (returnValue) { + expect(returnValue, true); + }); + }); + + test(':assignable_type_test', () async { + String fileName = "assignable_type_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}assert/", + resultCallback: (returnValue) { + expect(returnValue, 327744233); + }); + }); + + test(':initializer_const_error2_runtime_test', () async { + String fileName = "initializer_const_error2_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}assert/", + resultCallback: (returnValue) {}); + }); + + test(':initializer_test', () async { + String fileName = "initializer_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}assert/", + resultCallback: (returnValue) { + expect(returnValue, true); + }); + }); + + test(':trailing_comma_runtime_test', () async { + String fileName = "trailing_comma_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}assert/", + resultCallback: (returnValue) {}); + }); + + test(':with_type_test_or_cast_test', () async { + String fileName = "with_type_test_or_cast_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}assert/", + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/assign_test.dart b/micro_dart_compiler/test/test2/assign_test.dart new file mode 100644 index 00000000..399f7a40 --- /dev/null +++ b/micro_dart_compiler/test/test2/assign_test.dart @@ -0,0 +1,21 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Assign tests', () { + test(':op_test', () async { + String fileName = "op_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}assign/", + resultCallback: (returnValue) {}); + }); + + test(':to_type_runtime_test', () async { + String fileName = "to_type_runtime_test.dart"; + await singleFileTest(fileName, testCasePath: "${testCasePath2}assign/", + resultCallback: (returnValue) { + expect(returnValue, "D"); + }); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/async_test.dart b/micro_dart_compiler/test/test2/async_test.dart new file mode 100644 index 00000000..342e63c2 --- /dev/null +++ b/micro_dart_compiler/test/test2/async_test.dart @@ -0,0 +1,55 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Async tests', () { + test(':and_or_test', () async { + String fileName = "and_or_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}async/", + isAsync: true, resultCallback: (returnValue) { + expect(returnValue, "test complete true"); + }); + }); + + test(':async_test', () async { + String fileName = "async_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}async/", + isAsync: true, resultCallback: (returnValue) { + expect(returnValue, true); + }); + }); + + test(':await_catch_regression_test', () async { + String fileName = "await_catch_regression_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}async/", + isAsync: true, resultCallback: (returnValue) { + expect(returnValue, true); + }); + }); + + test(':await_foreign_test', () async { + String fileName = "await_foreign_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}async/", + isAsync: true, resultCallback: (returnValue) { + expect(returnValue, "test"); + }); + }); + + test(':await_test', () async { + String fileName = "await_test.dart"; + var engine = await singleFileTestEngine( + fileName, + testCasePath: "${testCasePath2}async/", + ); + for (int i = 1; i <= 143; i++) + await run(engine, + functionName: "test$i", + isAsync: true, + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/call_test.dart b/micro_dart_compiler/test/test2/call_test.dart new file mode 100644 index 00000000..c92ff394 --- /dev/null +++ b/micro_dart_compiler/test/test2/call_test.dart @@ -0,0 +1,20 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Call tests', () { + test(':method_function_typed_value_test', () async { + String fileName = "method_function_typed_value_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}call/", + resultCallback: (returnValue) {}); + }); + + test(':method_implicit_invoke_instance_test', () async { + String fileName = "method_implicit_invoke_instance_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}call/", + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/super_test.dart b/micro_dart_compiler/test/test2/super_test.dart new file mode 100644 index 00000000..efed3cf4 --- /dev/null +++ b/micro_dart_compiler/test/test2/super_test.dart @@ -0,0 +1,280 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Super tests', () { + test(':abstract_method_test', () async { + String fileName = "abstract_method_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':all_named_constructor_test', () async { + String fileName = "all_named_constructor_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':bound_closure_test', () async { + String fileName = "bound_closure_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':call_test', () async { + String fileName = "call_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':call2_test', () async { + String fileName = "call2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':call3_runtime_test', () async { + String fileName = "call3_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':call4_test', () async { + String fileName = "call4_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':closure_test', () async { + String fileName = "closure_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':field_2_test', () async { + String fileName = "field_2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':field_2_test', () async { + String fileName = "field_2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':field_access_test', () async { + String fileName = "field_access_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':field_test', () async { + String fileName = "field_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':from_constructor_test', () async { + String fileName = "from_constructor_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':implicit_closure_test', () async { + String fileName = "implicit_closure_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + resultCallback: (returnValue) {}); + }); + + test(':in_async1_test', () async { + String fileName = "in_async1_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_async2_test', () async { + String fileName = "in_async2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_async3_test', () async { + String fileName = "in_async3_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_async4_test', () async { + String fileName = "in_async4_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_async5_test', () async { + String fileName = "in_async5_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_async6_test', () async { + String fileName = "in_async6_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_constructor_test', () async { + String fileName = "in_constructor_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':in_finally_test', () async { + String fileName = "in_finally_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':inferrer_test', () async { + String fileName = "inferrer_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':mixin_test', () async { + String fileName = "mixin_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':no_such_method1_test', () async { + String fileName = "no_such_method1_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':no_such_method2_test', () async { + String fileName = "no_such_method2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':no_such_method3_test', () async { + String fileName = "no_such_method3_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':no_such_method4_runtime_test', () async { + String fileName = "no_such_method4_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':no_such_method5_runtime_test', () async { + String fileName = "no_such_method5_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':operator_index2_test', () async { + String fileName = "operator_index2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':operator_index3_test', () async { + String fileName = "operator_index3_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':operator_index5_test', () async { + String fileName = "operator_index5_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':operator_test', () async { + String fileName = "operator_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':regress47698_test', () async { + String fileName = "regress47698_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':setter_interceptor_test', () async { + String fileName = "setter_interceptor_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + + test(':super_test', () async { + String fileName = "super_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}super/", + isAsync: true, + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/switch_test.dart b/micro_dart_compiler/test/test2/switch_test.dart new file mode 100644 index 00000000..c196367c --- /dev/null +++ b/micro_dart_compiler/test/test2/switch_test.dart @@ -0,0 +1,83 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Switch tests', () { + test(':aborting_switch_case_test', () async { + String fileName = "aborting_switch_case_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':backward_jump_test', () async { + String fileName = "backward_jump_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':bad_case_runtime_test', () async { + String fileName = "bad_case_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':case_expression_with_assignment_runtime_test', () async { + String fileName = "case_expression_with_assignment_runtime_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':case_warn_test', () async { + String fileName = "case_warn_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':label_test', () async { + String fileName = "label_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':label2_test', () async { + String fileName = "label2_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':label3_test', () async { + String fileName = "label3_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':scope_test', () async { + String fileName = "scope_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':switch_test', () async { + String fileName = "switch_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + + test(':switch6_test', () async { + String fileName = "switch6_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}switch/", + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/symbol_test.dart b/micro_dart_compiler/test/test2/symbol_test.dart new file mode 100644 index 00000000..22138ffb --- /dev/null +++ b/micro_dart_compiler/test/test2/symbol_test.dart @@ -0,0 +1,20 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Symbol tests', () { + test(':conflict_test', () async { + String fileName = "conflict_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}symbol/", + resultCallback: (returnValue) {}); + }); + + test(':literal_runtime_1_test', () async { + String fileName = "literal_runtime_1_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}symbol/", + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/syntax_test.dart b/micro_dart_compiler/test/test2/syntax_test.dart new file mode 100644 index 00000000..9cd16ab2 --- /dev/null +++ b/micro_dart_compiler/test/test2/syntax_test.dart @@ -0,0 +1,13 @@ +import '../env.dart'; +import 'package:test/test.dart'; + +void main() { + group('Syntax tests', () { + test(':statement_test', () async { + String fileName = "statement_test.dart"; + await singleFileTest(fileName, + testCasePath: "${testCasePath2}syntax/", + resultCallback: (returnValue) {}); + }); + }); +} diff --git a/micro_dart_compiler/test/test2/test_all.dart b/micro_dart_compiler/test/test2/test_all.dart new file mode 100644 index 00000000..134b0d69 --- /dev/null +++ b/micro_dart_compiler/test/test2/test_all.dart @@ -0,0 +1,25 @@ +import 'abstract_test.dart' as abstract_test; +import 'argument_test.dart' as argument_test; +import 'assert_test.dart' as assert_test; +import 'assign_test.dart' as assign_test; +import 'async_test.dart' as async_test; +import 'call_test.dart' as call_test; +import 'dynamic_test.dart' as dynamic_test; +import 'super_test.dart' as super_test; +import 'switch_test.dart' as switch_test; +import 'symbol_test.dart' as symbol_test; +import 'syntax_test.dart' as syntax_test; + +void main() { + abstract_test.main(); + dynamic_test.main(); + argument_test.main(); + assert_test.main(); + symbol_test.main(); + switch_test.main(); + super_test.main(); + async_test.main(); + assign_test.main(); + call_test.main(); + syntax_test.main(); +} diff --git a/micro_dart_compiler/test/test_all.dart b/micro_dart_compiler/test/test_all.dart new file mode 100755 index 00000000..46470419 --- /dev/null +++ b/micro_dart_compiler/test/test_all.dart @@ -0,0 +1,7 @@ +import 'test1/test_all.dart' as test1; +import 'test2/test_all.dart' as test2; + +void main() { + test1.main(); + test2.main(); +} diff --git a/micro_dart_compiler/test/testcases2/argument/positional_option_test.dart b/micro_dart_compiler/test/testcases2/argument/positional_option_test.dart new file mode 100644 index 00000000..9825d205 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/argument/positional_option_test.dart @@ -0,0 +1,61 @@ +String test1(int a, [int? b]) { + return "test1 $a$b"; +} + +String test2(int a, [int b = 0]) { + return "test2 $a$b"; +} + +String test3(int a, {int? b}) { + return "test3 $a$b"; +} + +String test4(int a, {int b = 0}) { + return "test4 $a$b"; +} + +class A { + final int a; + final int b; + A.test1(this.a, this.b); + A.test2(this.a, {this.b = 0}); + A.test3(this.a, [this.b = 0]); + + String get params { + return "A.params $a$b"; + } +} + +int main() { + var r1 = test1(0); + print("r1: $r1"); + var r2 = test1(1, 1); + print("r2: $r2"); + var r3 = test2(2); + print("r3: $r3"); + var r4 = test2(2, 2); + print("r4: $r4"); + var r5 = test3(3); + print("r5: $r5"); + var r6 = test3(3, b: 3); + print("r6: $r6"); + var r7 = test4(4); + print("r7: $r7"); + var r8 = test4(4, b: 4); + print("r8: $r8"); + var r9 = A.test1(5, 5).params; + print("r9: $r9"); + var r10 = A.test2(6).params; + print("r10: $r10"); + var r11 = A.test2(6, b: 6).params; + print("r11: $r11"); + var r12 = A.test3(7).params; + print("r12: $r12"); + var r13 = A.test3(7, 7).params; + print("r13: $r13"); + + var r = (r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8 + r9 + r10 + r11 + r12 + r13) + .hashCode; + print("r: $r"); + return r; +} diff --git a/micro_dart_compiler/test/testcases2/assert/assert_test.dart b/micro_dart_compiler/test/testcases2/assert/assert_test.dart new file mode 100644 index 00000000..10ea45b6 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assert/assert_test.dart @@ -0,0 +1,88 @@ +int testTrue() { + int i = 0; + try { + assert(true); + } on AssertionError { + i = 1; + } + return i; +} + +int testFalse() { + int i = 0; + try { + assert(false); + } on AssertionError { + i = 1; + } + return i; +} + +dynamic unknown(dynamic a) { + return a ? true : false; +} + +int testBoolean(bool value) { + int i = 0; + try { + assert(value); + } on AssertionError { + i = 1; + } + return i; +} + +int testDynamic(dynamic value) { + int i = 0; + try { + assert(value); + } on AssertionError { + i = 1; + } + return i; +} + +int testImmediatelyInvokedFunctionExpression(bool value) { + int i = 0; + try { + assert((() => value)()); + } on AssertionError { + i = 1; + } + return i; +} + +AssertionError? testMessage(value, message) { + try { + assert(value, message); + } on AssertionError catch (error) { + return error; + } + return null; +} + +bool main() { + var r1 = 0 == testTrue(); + print("r1: $r1"); + var r2 = 0 == testBoolean(true); + print("r2: $r2"); + var r3 = 0 == testDynamic(unknown(true)); + print("r3: $r3"); + var r4 = 0 == testImmediatelyInvokedFunctionExpression(true); + print("r4: $r4"); + var r5 = 1 == testFalse(); + print("r5: $r5"); + var r6 = 1 == testBoolean(false); + print("r6: $r6"); + var r7 = 1 == testDynamic(unknown(false)); + print("r7: $r7"); + var r8 = 1 == testImmediatelyInvokedFunctionExpression(false); + print("r8: $r8"); + var r9 = 1234 == testMessage(false, 1234)?.message; + print("r9: $r9"); + var r10 = 'hi' == testMessage(false, 'hi')?.message; + print("r10: $r10"); + var r = r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9 && r10; + print("r10: $r10"); + return r; +} diff --git a/micro_dart_compiler/test/testcases2/assert/assignable_type_test.dart b/micro_dart_compiler/test/testcases2/assert/assignable_type_test.dart new file mode 100644 index 00000000..57905cb4 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assert/assignable_type_test.dart @@ -0,0 +1,21 @@ +int main() { + var r = testInt64List().join(); + + print(r); + print(r.hashCode); + return r.hashCode; +} + +List testInt64List() { + var array = List.filled(10, null); + testInt64ListImpl(array); + return array; +} + +testInt64ListImpl(array) { + for (int i = 0; i < 10; ++i) {} + int sum = 0; + for (int i = 0; i < 10; ++i) { + array[i] = -0x80000000000000 + i; + } +} diff --git a/micro_dart_compiler/test/testcases2/assert/initializer_const_error2_runtime_test.dart b/micro_dart_compiler/test/testcases2/assert/initializer_const_error2_runtime_test.dart new file mode 100644 index 00000000..0401941f --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assert/initializer_const_error2_runtime_test.dart @@ -0,0 +1,71 @@ +class C { + final int x; + // Const constructors. + const C.cc01(this.x, y) : assert(x < y); + const C.cc02(x, y) + : x = x, + assert(x < y); + const C.cc03(x, y) + : assert(x < y), + x = x; + const C.cc04(this.x, y) + : assert(x < y), + super(); + const C.cc05(x, y) + : x = x, + assert(x < y), + super(); + const C.cc06(x, y) + : assert(x < y), + x = x, + super(); + const C.cc07(x, y) + : assert(x < y), + x = x, + assert(y > x), + super(); + const C.cc08(this.x, y) : assert(x < y, "$x < $y"); + const C.cc09(this.x, y) + : assert( + x < y, + ); + const C.cc10(this.x, y) + : assert( + x < y, + "$x < $y", + ); +} + +main() { + const x = 3; + { + const C.cc01(2, x); + } + { + const C.cc02(2, x); + } + { + const C.cc03(2, x); + } + { + const C.cc04(2, x); + } + { + const C.cc05(2, x); + } + { + const C.cc06(2, x); + } + { + const C.cc07(2, x); + } + { + const C.cc08(2, x); + } + { + const C.cc09(2, x); + } + { + const C.cc10(2, x); + } +} diff --git a/micro_dart_compiler/test/testcases2/assert/initializer_test.dart b/micro_dart_compiler/test/testcases2/assert/initializer_test.dart new file mode 100644 index 00000000..bc91ec38 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assert/initializer_test.dart @@ -0,0 +1,138 @@ +class C { + static bool check(x, y) => x < y; + static bool staticTrue() => true; + final int x; + const C(this.x); + + C.c01(this.x, y) : assert(x < y); + C.c02(x, y) + : x = x, + assert(x < y); + C.c03(x, y) + : assert(x < y), + x = x; + C.c05(this.x, y) + : assert(x < y), + super(); + C.c06(x, y) + : x = x, + assert(x < y), + super(); + C.c07(x, y) + : assert(x < y), + x = x, + super(); + C.c08(x, y) + : assert(x < y), + x = x, + assert(y > x), + super(); + C.c09(this.x, y) : assert(x < y, "$x < $y"); + C.c10(this.x, y) + : assert( + x < y, + ); + C.c11(this.x, y) + : assert( + x < y, + "$x < $y", + ); + + const C.cc01(this.x, y) : assert(x < y); + const C.cc02(x, y) + : x = x, + assert(x < y); + const C.cc03(x, y) + : assert(x < y), + x = x; + const C.cc05(this.x, y) + : assert(x < y), + super(); + const C.cc06(x, y) + : x = x, + assert(x < y), + super(); + const C.cc07(x, y) + : assert(x < y), + x = x, + super(); + const C.cc08(x, y) + : assert(x < y), + x = x, + assert(y > x), + super(); + const C.cc09(this.x, y) : assert(x < y, "$x < $y"); + const C.cc10(this.x, y) + : assert( + x < y, + ); + const C.cc11(this.x, y) + : assert( + x < y, + "$x < $y", + ); +} + +main() { + const c1 = const C(1); + + var r1 = c1 == const C.cc01(1, 2); + print("r1: $r1"); + var r2 = c1 == const C.cc02(1, 2); + print("r2: $r2"); + var r3 = c1 == const C.cc03(1, 2); + print("r3: $r3"); + var r5 = c1 == const C.cc05(1, 2); + print("r5: $r5"); + var r6 = c1 == const C.cc06(1, 2); + print("r6: $r6"); + var r7 = c1 == const C.cc07(1, 2); + print("r7: $r7"); + var r8 = c1 == const C.cc08(1, 2); + print("r8: $r8"); + var r9 = c1 == const C.cc09(1, 2); + print("r9: $r9"); + var r10 = c1 == const C.cc10(1, 2); + print("r10: $r10"); + var r11 = c1 == const C.cc11(1, 2); + print("r11: $r11"); + + var b1 = r1 && r2 && r3 && r5 && r6 && r7 && r8 && r9 && r10 && r11; + print("b1: $b1"); + var r12 = c1 == C.c01(1, 2); + print("r12: $r12"); + var r13 = c1 == C.c02(1, 2); + print("r13: $r13"); + var r14 = c1 == C.c03(1, 2); + print("r14: $r14"); + var r15 = c1 == C.c05(1, 2); + print("r15: $r15"); + var r16 = c1 == C.c06(1, 2); + print("r16: $r16"); + var r17 = c1 == C.c07(1, 2); + print("r17: $r17"); + var r18 = c1 == C.c08(1, 2); + print("r18: $r18"); + var r19 = c1 == C.c09(1, 2); + print("r19: $r19"); + var r20 = c1 == C.c10(1, 2); + print("r20: $r20"); + var r21 = c1 == C.c11(1, 2); + print("r21: $r21"); + + var b2 = !r12 && + !r13 && + !r14 && + !r15 && + !r16 && + !r17 && + !r18 && + !r19 && + !r20 && + !r21; + print("b2: $b2"); + + var r = b1 && b2; + print("r: $r"); + return r; +} diff --git a/micro_dart_compiler/test/testcases2/assert/trailing_comma_runtime_test.dart b/micro_dart_compiler/test/testcases2/assert/trailing_comma_runtime_test.dart new file mode 100644 index 00000000..0ddadaaa --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assert/trailing_comma_runtime_test.dart @@ -0,0 +1,11 @@ +main() { + assert(true); + assert( + true, + ); + assert(true, "message"); + assert( + true, + "message", + ); +} diff --git a/micro_dart_compiler/test/testcases2/assert/with_type_test_or_cast_test.dart b/micro_dart_compiler/test/testcases2/assert/with_type_test_or_cast_test.dart new file mode 100644 index 00000000..7c1e680d --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assert/with_type_test_or_cast_test.dart @@ -0,0 +1,15 @@ +main() { + var names = []; + + // Generic type test. + assert(names is List); + + // Negated generic type test. + assert(names is! List); + + // Generic type cast. + assert((names as List).length == 0); + + // Generic type test inside expression. + assert((names is List)); +} diff --git a/micro_dart_compiler/test/testcases2/assign/op_test.dart b/micro_dart_compiler/test/testcases2/assign/op_test.dart new file mode 100644 index 00000000..3eeac552 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/assign/op_test.dart @@ -0,0 +1,86 @@ +class AssignOpTest { + AssignOpTest() {} + + static var f; + var instf; + + static testMain() { + var b = 0; + b += 1; + assert(1 == b); + b *= 5; + assert(5 == b); + b -= 1; + assert(4 == b); + b ~/= 2; + assert(2 == b); + + f = 0; + f += 1; + assert(1 == f); + f *= 5; + assert(5 == f); + f -= 1; + assert(4 == f); + f ~/= 2; + assert(2 == f); + f /= 4; + assert(.5 == f); + + AssignOpTest.f = 0; + AssignOpTest.f += 1; + assert(1 == AssignOpTest.f); + AssignOpTest.f *= 5; + assert(5 == AssignOpTest.f); + AssignOpTest.f -= 1; + assert(4 == AssignOpTest.f); + AssignOpTest.f ~/= 2; + assert(2 == AssignOpTest.f); + AssignOpTest.f /= 4; + assert(.5 == AssignOpTest.f); + + var o = new AssignOpTest(); + o.instf = 0; + o.instf += 1; + assert(1 == o.instf); + o.instf *= 5; + assert(5 == o.instf); + o.instf -= 1; + assert(4 == o.instf); + o.instf ~/= 2; + assert(2 == o.instf); + o.instf /= 4; + assert(0.5 == o.instf); + + var x = 0xFF; + x >>= 3; + assert(0x1F == x); + x <<= 3; + assert(0xF8 == x); + x |= 0xF00; + assert(0xFF8 == x); + x &= 0xF0; + assert(0xF0 == x); + x ^= 0x11; + assert(0xE1 == x); + + var y = 100; + y += 1 << 3; + assert(108 == y); + y *= 2 + 1; + assert(324 == y); + y -= 3 - 2; + assert(323 == y); + y += 3 * 4; + assert(335 == y); + + var a = [1, 2, 3]; + var ix = 0; + a[ix] |= 12; + assert(13 == a[ix]); + } +} + +main() { + AssignOpTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/assign/test1.dart b/micro_dart_compiler/test/testcases2/assign/to_type_runtime_test.dart similarity index 79% rename from micro_dart_compiler/test/testcases2/assign/test1.dart rename to micro_dart_compiler/test/testcases2/assign/to_type_runtime_test.dart index 3f409f5d..9780fd89 100644 --- a/micro_dart_compiler/test/testcases2/assign/test1.dart +++ b/micro_dart_compiler/test/testcases2/assign/to_type_runtime_test.dart @@ -1,6 +1,6 @@ class C { String f() { - return T.runtimeType.toString(); + return T.toString(); } } diff --git a/micro_dart_compiler/test/testcases2/async/await_foreign_test.dart b/micro_dart_compiler/test/testcases2/async/await_foreign_test.dart new file mode 100644 index 00000000..41b9f50e --- /dev/null +++ b/micro_dart_compiler/test/testcases2/async/await_foreign_test.dart @@ -0,0 +1,7 @@ +Future main() async { + var t = () async { + return "test"; + }(); + + return await t; +} diff --git a/micro_dart_compiler/test/testcases2/async/await_test.dart b/micro_dart_compiler/test/testcases2/async/await_test.dart new file mode 100644 index 00000000..83a1646a --- /dev/null +++ b/micro_dart_compiler/test/testcases2/async/await_test.dart @@ -0,0 +1,2051 @@ +import "dart:async"; + +typedef dynamic DynamicToDynamic(dynamic d); + +Future test1() { + f() async { + return id(42); + } + + return expect42(f()); +} + +Future test2() { + // Calling an "async" function starts immediately. + var result = []; + f() async { + result.add(1); + return id(42); + } + + ; + var future = f(); + result.add(0); + return future.whenComplete(() { + expect(result, equals([1, 0])); + }); +} + +Future test3() { + f() async { + var v = await new Future.value(42); + return v; + } + + ; + return expect42(f()); +} + +Future test4() { + f() async { + var v = await id(42); + return v; + } + + ; + return expect42(f()); +} + +Future test5() { + f() async { + var v = await null; + expect(v, equals(null)); + } + + ; + return f(); +} + +Future test6() { + f() async { + return await await new Future.value(42); + } + + return expect42(f()); +} + +Future test7() { + f() async { + return await Future.value(42); + } + + return expect42(f()); +} + +Future test8() { + f() async { + return await Future.error("err"); + } + + return throwsErr(f()); +} + +Future test9() { + f() async { + bool x = false; + scheduleMicrotask(() { + x = true; + }); + var y = await true; + expect(x, equals(y)); + } + + return f(); +} + +Future test10() { + f(v) async { + assert(v == 87); + return await new Future.microtask(() => 42); + } + + return f(42).then((_) { + fail("assert didn't throw"); + }, onError: (e, s) { + expect(e is AssertionError, isTrue); + }); +} + +Future test11() { + f(v) async { + var x = await new Future.microtask(() => 42); + assert(v == 87); + return x; + } + + return f(42).then((_) { + fail("assert didn't throw"); + }, onError: (e, s) { + expect(e is AssertionError, isTrue); + }); +} + +Future test12() { + f() async { + await new Future.error("err"); + return id(42); + } + + return throwsErr(f()); +} + +Future test13() { + f() async { + return new Future.value(42); // Not awaited. + } + + ; + return f().then((v) { + expect(v, equals(42)); // And not a Future with value 42. + }); +} + +Future test14() { + f() async { + return new Future.error("err"); // Not awaited. + } + + return throwsErr(f()); +} + +Future test15() { + f(Stream s) async { + int i = 0; + await for (int v in s) { + i += v; + } + return i; + } + + return f(mkStream()).then((v) { + expect(v, equals(45)); // 0 + 1 + ... + 9 + }); +} + +Future test16() { + f(Stream s) async { + int i = 0; + await for (int v in s) { + i += await new Future.value(v); + } + return i; + } + + return f(mkStream()).then((v) { + expect(v, equals(45)); // 0 + 1 + ... + 9 + }); +} + +Future test17() { + f(Stream s) async { + int v = 0; + await for (int i in s) { + v += i; + } + return v; + } + + var s = (new StreamController()..close()).stream; + return f(s).then((v) { + expect(v, equals(0)); + }); +} + +Future test18() { + f(Stream s) async { + int i = 0; + await for (int v in s) { + i += await new Future.microtask(() => v); + assert(v < 8); + } + return i; + } + + return f(mkStream()).then((v) { + fail("assert didn't throw"); + }, onError: (e, s) { + expect(e is AssertionError, isTrue); + }); +} + +Future test19() { + f() async { + int v = 0; + for (int i = 0; i < 10; i++) { + v += await new Future.value(42); + } + return v; + } + + return f().then((v) { + expect(v, equals(10 * id(42))); + }); +} + +Future test20() { + f() async { + int v = 0; + for (int i = 0; i < 10; i++) { + v += await new Future.value(42); + } + return v; + } + + return f().then((v) { + expect(v, equals(10 * id(42))); + }); +} + +Future test21() { + f() async { + int v = 0; + for (int i = await new Future.value(42); i >= 0; i -= 10) { + v += 10; + } + return v; + } + + return f().then((v) { + expect(v, equals(10 * 5)); + }); +} + +Future test22() { + f() async { + int v = 0; + for (int i = 0; i < 100; i += await new Future.value(42)) { + v += 10; + } + return v; + } + + return f().then((v) { + expect(v, equals(10 * 3)); + }); +} + +Future test23() { + f() async { + int v = 0; + for (int i = await new Future.error("err"); i >= 0; i -= 10) { + v += 10; + } + return v; + } + + return throwsErr(f()); +} + +Future test24() { + f() async { + int v = 0; + for (int i = 0; i < 10; i++) { + v += await new Future.error("err"); + } + return v; + } + + return throwsErr(f()); +} + +Future test25() { + f() async { + int v = 0; + for (int i = 0; i < await new Future.error("err"); i += 10) { + v += 10; + } + return v; + } + + return throwsErr(f()); +} + +Future test26() { + f() async { + int v = 0; + for (int i = 0; i > 0; i += 1) { + v += await new Future.value(42); + } + return v; + } + + return f().then((v) { + expect(v, equals(0)); + }); +} + +Future test27() { + f() async { + int v = 0; + for (int i = 0; i < 100; i += await new Future.error("err")) { + v += 10; + } + return v; + } + + return throwsErr(f()); +} + +Future test28() { + f() async { + int v = 0; + for (int i = 0; i > 0; i += await new Future.value(1)) { + v += 1; + } + return v; + } + + return f().then((v) { + expect(v, equals(0)); + }); +} + +Future test29() { + f() async { + int v = 0; + for (int i = 0; i < 10; i += 1) { + if (i == 2) break; + v += await new Future.value(42); + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 2)); + }); +} + +Future test30() { + f() async { + int v = 0; + for (int i = 0; i < 10; i += await new Future.value(1)) { + if (i == 2) break; + v += id(42) as int; + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 2)); + }); +} + +Future test31() { + f() async { + int v = 0; + for (int i = 0; i < 10; i += 1) { + if (i == 2) continue; + v += await new Future.value(42); + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 9)); + }); +} + +Future test32() { + f() async { + int v = 0; + for (int i = 0; i < 10; i += 1) { + var j = await new Future.value(42); + if (i == 2) continue; + v += j; + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 9)); + }); +} + +Future test33() { + f() async { + int v = 0; + int i = 0; + while (i < 10) { + v += await new Future.value(42); + i++; + } + return v; + } + + return f().then((v) { + expect(v, equals(10 * id(42))); + }); +} + +Future test34() { + f() async { + int v = 0; + int i = 0; + while (i < await new Future.value(42)) { + v += 10; + i += 10; + } + return v; + } + + return f().then((v) { + expect(v, equals(10 * 5)); + }); +} + +Future test35() { + f() async { + int v = 0; + int i = 0; + while (i < 10) { + v += await new Future.error("err"); + i++; + } + return v; + } + + return throwsErr(f()); +} + +Future test36() { + f() async { + int v = 0; + int i = 0; + while (i < await new Future.error("err")) { + v += 10; + i += 10; + } + return v; + } + + return throwsErr(f()); +} + +Future test37() { + f() async { + int v = 0; + int i = 0; + while (i < 10) { + if (i == 2) break; + v += await new Future.value(42); + i += 1; + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 2)); + }); +} + +Future test38() { + f() async { + int v = 0; + int i = 0; + while (i < 10) { + v += await new Future.value(42); + if (i == 2) break; + i += 1; + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 3)); + }); +} + +Future test39() { + f() async { + int v = 0; + int i = 0; + while (i < 10) { + i += 1; + if (i == 2) continue; + v += await new Future.value(42); + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 9)); + }); +} + +Future test40() { + f() async { + int v = 0; + int i = 0; + while (i < 10) { + i += 1; + int j = await new Future.value(42); + if (i == 2) continue; + v += j; + } + return v; + } + + return f().then((v) { + expect(v, equals(42 * 9)); + }); +} + +Future test41() { + f() async { + int v = 0; + int i = 0; + do { + v += await new Future.value(42); + i++; + } while (i < 10); + return v; + } + + return f().then((v) { + expect(v, equals(10 * id(42))); + }); +} + +Future test42() { + f() async { + int v = 0; + int i = 0; + do { + v += 10; + i += 10; + } while (i < await new Future.value(42)); + return v; + } + + return f().then((v) { + expect(v, equals(10 * 5)); + }); +} + +Future test43() { + f() async { + int v = 0; + int i = 0; + do { + v += await new Future.error("err"); + i++; + } while (i < 10); + return v; + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test44() { + f() async { + int v = 0; + int i = 0; + do { + v += 10; + i += 10; + } while (i < await new Future.error("err")); + return v; + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test45() { + f() async { + int v = 0; + int i = 0; + do { + if (i == 2) break; + v += await new Future.value(42); + i += 1; + } while (i < 10); + return v; + } + + return f().then((v) { + expect(v, equals(42 * 2)); + }); +} + +Future test46() { + f() async { + int v = 0; + int i = 0; + do { + v += await new Future.value(42); + if (i == 2) break; + i += 1; + } while (i < 10); + return v; + } + + return f().then((v) { + expect(v, equals(42 * 3)); + }); +} + +Future test47() { + f() async { + int v = 0; + int i = 0; + do { + i += 1; + if (i == 2) continue; + v += await new Future.value(42); + } while (i < 10); + return v; + } + + return f().then((v) { + expect(v, equals(42 * 9)); + }); +} + +Future test48() { + f() async { + int v = 0; + int i = 0; + do { + i += 1; + int j = await new Future.value(42); + if (i == 2) continue; + v += j; + } while (i < 10); + return v; + } + + return f().then((v) { + expect(v, equals(42 * 9)); + }); +} + +Future test49() { + f() async { + var v = 0; + for (var fut in [1, 2, 3].map((v) => new Future.value(v))) { + v += await fut; + } + return v; + } + + return f().then((v) { + expect(v, equals(6)); + }); +} + +Future test50() { + f() async { + var v = 0; + for (var i in await new Future.value([1, 2, 3])) { + v += i; + } + return v; + } + + return f().then((v) { + expect(v, equals(6)); + }); +} + +Future test51() { + f() async { + int v = 0; + for (Future fut in ([1, 2, 3].map>( + (v) => (v != 1) ? Future.value(v) : Future.error("err")))) { + v += await fut; + } + return v; + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test52() { + f() async { + int v = 0; + for (int i in await Future.error("err")) { + v += i; + } + return v; + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test53() { + f() async { + var v = 0; + for (var fut in [1, 2, 3].map((v) => new Future.value(v))) { + if (v == 3) break; + v += await fut; + } + return v; + } + + return f().then((v) { + expect(v, equals(3)); + }); +} + +Future test54() { + f() async { + try { + return await id(42); + } catch (e) { + return 37; + } + } + + return expect42(f()); +} + +Future test55() { + f() async { + try { + await new Future.error(42); + } catch (e) { + return e; + } + } + + return expect42(f()); +} + +Future test56() { + int i = id(0); + f() async { + try { + if (i >= 0) throw id(42); + return await new Future.value(10); + } catch (e) { + return e; + } + } + + return expect42(f()); +} + +Future test57() { + f() async { + try { + throw id(42); + } catch (e) { + return await new Future.value(e); + } + } + + return expect42(f()); +} + +Future test58() { + f() async { + try { + throw id(42); + } catch (e) { + await new Future.error("err"); + } + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test59() { + f() async { + try { + await new Future.error("err"); + } catch (e) { + if (e == id(42)) return; + rethrow; + } + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test60() { + f() async { + try { + return await new Future.value(42); + } finally { + // Don't do anything. + } + } + + return expect42(f()); +} + +Future test61() { + var x = 0; + f() async { + try { + return id(42); + } finally { + x = await new Future.value(37); + } + } + + return f().then((v) { + expect(v, equals(42)); + expect(x, equals(37)); + }); +} + +Future test62() { + f() async { + try { + return await new Future.error("err"); + } finally { + // Don't do anything. + } + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test63() { + f() async { + try { + return id(42); + } finally { + await new Future.error("err"); + } + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +Future test64() { + f() async { + try { + await new Future.error("not err"); + } finally { + await new Future.error("err"); + } + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +test65() { + f() async { + try { + return await new Future.error("err"); + } finally { + return id(42); + } + } + + return expect42(f()); +} + +test66() { + f() async { + label: + try { + return await new Future.value(37); + } finally { + break label; + } + return id(42); + } + + return expect42(f()); +} + +test67() { + var x = 0; + f() async { + label: + try { + return 87; + } finally { + x = await new Future.value(37); + break label; + } + return id(42); + } + + return f().then((v) { + expect(v, equals(42)); + expect(x, equals(37)); + }); +} + +test68() { + var x = 0; + f() async { + label: + try { + throw "err"; + } finally { + x = await new Future.value(37); + break label; + } + return id(42); + } + + return f().then((v) { + expect(v, equals(42)); + expect(x, equals(37)); + }); +} + +test69() { + f() async { + label: + try { + return await new Future.error("err"); + } finally { + break label; + } + return id(42); + } + + return expect42(f()); +} + +test70() { + f() async { + for (int i = 0; i < 10; i++) { + try { + return await i; + } finally { + continue; + } + } + return id(42); + } + + return expect42(f()); +} + +test71() { + f() async { + int i = 0; + for (; i < 10; i++) { + try { + break; + } finally { + await new Future.value(42); + continue; + } + } + return id(i); + } + + return f().then((v) { + expect(v, equals(10)); + }); +} + +test72() { + f() async { + int i = 0; + for (; i < 10; i++) { + try { + continue; + } finally { + await new Future.value(42); + break; + } + } + return id(i); + } + + return f().then((v) { + expect(v, equals(0)); + }); +} + +test73() { + f() async { + for (int i = 0; i < 10; i++) { + try { + return i; + } finally { + if (i >= 0) continue; + await new Future.value(42); + } + } + return id(42); + } + + return expect42(f()); +} + +test74() { + f() async { + for (int i = 0; i < 10; i++) { + try { + return i; + } finally { + await new Future.value(42); + continue; + } + } + return id(42); + } + + return expect42(f()); +} + +test75() { + var x = 0; + f() async { + try { + try { + return 42; + } finally { + x = await new Future.value(37); + } + } finally { + x += await new Future.value(37); + } + } + + return f().then((v) { + expect(v, equals(42)); + expect(x, equals(74)); + }); +} + +test76() { + var x = 0; + f() async { + label: + try { + try { + break label; + } finally { + x = await new Future.value(37); + } + } finally { + x += await new Future.value(37); + } + return 42; + } + + return f().then((v) { + expect(v, equals(42)); + expect(x, equals(74)); + }); +} + +test77() { + var x = 0; + f() async { + label: + try { + try { + break label; + } finally { + return await new Future.value(42); + } + } finally { + break label; + } + return 42; + } + + return expect42(f()); +} + +test78() { + var x = 0; + f() async { + try { + try { + throw "err"; + } finally { + x = await new Future.value(37); + } + } finally { + x += await new Future.value(37); + } + } + + return f().then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + expect(x, equals(2 * 37)); + }); +} + +test79() { + f() async { + try { + return await new Future.value(42); + } catch (e) { + throw Future.value(null); + } finally { + if (id(42) == id(10)) return 10; + } + } + + return expect42(f()); +} + +test80() { + f() async { + try { + return id(42); + } catch (e) { + await new Future.error("err"); + } finally { + if (id(42) == id(10)) return 10; + } + } + + return expect42(f()); +} + +test81() { + f() async { + try { + return throw id(42); + } catch (e) { + return await new Future.value(e); + } finally { + if (id(42) == id(10)) return 10; + } + } + + return expect42(f()); +} + +test82() { + var x = 0; + f() async { + try { + return id(42); + } catch (e) { + throw Future.value(null); + } finally { + x = await new Future.value(37); + if (id(42) == id(10)) return 10; + } + } + + return f().then((v) { + expect(v, equals(42)); + expect(x, equals(37)); + }); +} + +test83() { + f(v) async { + switch (await new Future.value(v)) { + case 1: + return 1; + case 2: + return 42; + default: + return 3; + } + } + + return expect42(f(2)); +} + +test84() { + f(v) async { + switch (await new Future.error("err")) { + case 1: + return 1; + case 2: + return 42; + default: + return 3; + } + } + + return throwsErr(f(2)); +} + +test85() { + f(v) async { + if (await new Future.value(v)) { + return 42; + } else { + return 37; + } + } + + return expect42(f(true)); +} + +test86() { + f(v) async { + switch (v) { + case 1: + return 1; + case 2: + return await new Future.value(42); + default: + return 3; + } + } + + return expect42(f(2)); +} + +test87() { + f(v) async { + switch (v) { + case 1: + return 1; + case 2: + return await new Future.error("err"); + default: + return 3; + } + } + + return throwsErr(f(2)); +} + +test88() { + f(v) async { + if (await new Future.error("err")) { + return 42; + } else { + return 37; + } + } + + return throwsErr(f(true)); +} + +test89() { + f(v) async { + if (v) { + return await new Future.value(42); + } + return 37; + } + + return expect42(f(true)); +} + +test90() { + f(v) async { + if (v) { + return await new Future.error("err"); + } + return 37; + } + + return throwsErr(f(true)); +} + +test91() { + f(v) async { + if (v) { + return await new Future.value(42); + } else { + return 87; + } + } + + return expect42(f(true)); +} + +test92() { + f(v) async { + if (v) { + return await new Future.error("err"); + } else { + return 87; + } + } + + return throwsErr(f(true)); +} + +test93() { + f(v) async { + if (v) { + return 37; + } else { + return await new Future.error("err"); + } + } + + return throwsErr(f(false)); +} + +test94() { + f(v) async { + if (v) { + return 37; + } else { + return await new Future.value(42); + } + } + + return expect42(f(false)); +} + +test95() { + f(v) async { + if (v) { + return 37; + } else if (!await new Future.value(v)) { + return 42; + } else { + return 37; + } + } + + return expect42(f(false)); +} + +test96() { + f(v) async { + if (v) { + return 37; + } else if (!v) { + return await new Future.value(42); + } else { + return 37; + } + } + + return expect42(f(false)); +} + +test97() { + f(v) async { + return (await new Future.value(v)) ? 42 : 37; + } + + return expect42(f(true)); +} + +test98() { + f(v) async { + return (await new Future.error("err")) ? 42 : 37; + } + + return throwsErr(f(true)); +} + +test99() { + f() async { + throw "err"; + } + + return throwsErr(f()); +} + +test100() { + f() async { + await (throw "err"); // Check grammar: Are parentheses necessary? + } + + return throwsErr(f()); +} + +test101() { + f() async { + await (throw "err"); // Check grammar: Are parentheses necessary? + } + + return throwsErr(f()); +} + +test102() { + f(v) async { + return v ? (await new Future.value(42)) : 37; + } + + return expect42(f(true)); +} + +test103() { + f(v) async { + return v ? (await new Future.error("err")) : 37; + } + + return throwsErr(f(true)); +} + +test104() { + f(v) async { + return v ? 37 : (await new Future.value(42)); + } + + return expect42(f(false)); +} + +test105() { + f(v) async { + return v ? 37 : (await new Future.error("err")); + } + + return throwsErr(f(false)); +} + +test106() { + var f42 = new Future.value(42); + expect42(topMethod(f42)); + expect42(topArrowMethod(f42)); + expect42(topGetter); + expect42(topArrowGetter); + expect42(topLocal(f42)); + expect42(topArrowLocal(f42)); + expect42(topExpression(f42)); + expect42(topArrowExpression(f42)); + expect42(topVarExpression(f42)); + expect42(topVarArrowExpression(f42)); + expect42(Async.staticMethod(f42)); + expect42(Async.staticArrowMethod(f42)); + expect42(Async.staticGetter); + expect42(Async.staticArrowGetter); + expect42(Async.staticLocal(f42)); + expect42(Async.staticArrowLocal(f42)); + expect42(Async.staticExpression(f42)); + expect42(Async.staticArrowExpression(f42)); + expect42(Async.staticVarExpression(f42)); + expect42(Async.staticVarArrowExpression(f42)); + + // Instance declarations or local declarations in instance functions. + var async = new Async(); + expect42(async.instanceMethod(f42)); + expect42(async.instanceArrowMethod(f42)); + expect42(async.instanceGetter); + expect42(async.instanceArrowGetter); + expect42(async.instanceLocal(f42)); + expect42(async.instanceArrowLocal(f42)); + expect42(async.instanceExpression(f42)); + expect42(async.instanceArrowExpression(f42)); + expect42(async.instanceVarExpression(f42)); + expect42(async.instanceVarArrowExpression(f42)); +} + +test107() { + var f42 = new Future.value(42); + var async = new Async.initializer(f42); + return expect42(async.initValue); +} + +test108() { + var f42 = new Future.value(42); + var async = new Async.initializerArrow(f42); + return expect42(async.initValue); +} + +test109() { + var f42 = new Future.value(42); + return expect42(asyncInAsync(f42)); +} + +test110() { + var f42 = new Future.value(42); + return expect42(syncInAsync(f42)); +} + +test111() { + var f42 = new Future.value(42); + return expect42(asyncInSync(f42)); +} + +test112() { + var f42 = new Future.value(42); + var async = new Async(); + expect(async.instanceMethod, equals(async.instanceMethod)); + expect(Async.staticMethod, same(Async.staticMethod)); + expect(topMethod, same(topMethod)); +} + +test113() { + var l42 = 42; + f() async { + return await l42; + } + + return expect42(f()); +} + +test114() { + f(p) async { + return await p; + } + + return expect42(f(42)); +} + +const c42 = 42; +final v42 = 42; + +test115() { + f() async { + return await v42; + } + + return expect42(f()); +} + +test116() { + f() async { + return await c42; + } + + return expect42(f()); +} + +test117() { + f() async { + return -await -42; + } + + return expect42(f()); +} + +test118() { + f() async { + var v = [42]; + return await v[0]; + } + + return expect42(f()); +} + +test119() { + f() async { + var x = 42; + return await x++; + } + + return expect42(f()); +} + +test120() { + f() async { + var v = [42]; + return await v[0]++; + } + + return expect42(f()); +} + +test121() { + f() async { + var v = [42]; + return await v[await 0]++; + } + + return expect42(f()); +} + +test122() { + f() async { + var v = [42]; + return await v[await 0]++; + } + + return expect42(f()); +} + +test123() { + f() async { + var x = 41; + return await ++x; + } + + return expect42(f()); +} + +test124() { + f() async { + var v = [41]; + return await ++v[0]; + } + + return expect42(f()); +} + +test125() { + f() async { + var x = 37; + return await (x = 42); + } + + return expect42(f()); +} + +test126() { + f() async { + var x = 37; + return await (x += 5); + } + + return expect42(f()); +} + +test127() { + f() async { + return await (10 + 11) + await (10 + 11); + } + + return expect42(f()); +} + +test128() { + f(v) async { + return await ((v == 10) ? new Future.value(42) : 37); + } + + return expect42(f(10)); +} + +test129() { + f() async { + return await topMethod(42); + } + + return expect42(f()); +} + +test130() { + f() async { + return await Async.staticMethod(42); + } + + return expect42(f()); +} + +test131() { + f() async { + var a = new Async(); + return await a.instanceMethod(42); + } + + return expect42(f()); +} + +test132() { + f() async { + return await topMethod(await 42); + } + + return expect42(f()); +} + +test133() { + f() async { + return await Async.staticMethod(await 42); + } + + return expect42(f()); +} + +test134() { + f() async { + var a = new Async(); + return await a.instanceMethod(await 42); + } + + return expect42(f()); +} + +test135() { + f() async { + return await topGetter; + } + + return expect42(f()); +} + +test136() { + f() async { + return await Async.staticGetter; + } + + return expect42(f()); +} + +test137() { + f() async { + var a = new Async(); + return await a.instanceGetter; + } + + return expect42(f()); +} + +test138() { + f() async { + assert(await new Future.microtask(() => true)); + return 42; + } + + return expect42(f()); +} + +test139() { + // //# 03: continued + f() async { + // //# 03: continued + assert(await new Future.microtask(() => false)); // //# 03: continued + return 42; // //# 03: continued + } // //# 03: continued + + return f().then((_) { + // //# 03: continued + fail("assert didn't throw"); // //# 03: continued + }, onError: (e, s) { + // //# 03: continued + expect(e is AssertionError, isTrue); // //# 03: continued + }); // //# 03: continued +} + +test140() { + // //# 03: continued + f() async { + // //# 03: continued + assert(await new Future.microtask(() => false)); // //# 03: continued + return 42; // //# 03: continued + } // //# 03: continued + + return f().then((_) { + // //# 03: continued + fail("assert didn't throw"); // //# 03: continued + }, onError: (e, s) { + // //# 03: continued + expect(e is AssertionError, isTrue); // //# 03: continued + }); // //# 03: continued +} + +test141() { + // Valid identifiers outside of async function. + var async = 42; + expect(async, equals(42)); +} + +test142() { + // //# 02: ok + // Valid identifiers outside of async function. // //# 02: continued + var await = 42; // //# 02: continued + expect(await, equals(42)); // //# 02: continued +} + +test143() { + // Valid identifiers outside of async function. + var yield = 42; + expect(yield, equals(42)); +} + +expect(value, expectation) { + if (expectation is bool) { + assert(value == expectation); + return; + } + if (expectation is List) { + assert(value == expectation); + return; + } + if (expectation is Function(Object, String)) { + assert(value == expectation); + return; + } + assert(value == expectation); +} + +equals(x) => x; +final isTrue = true; +same(v) => (Object o, String name) => v == o; +fail(message) { + print("fail $message"); + return message; +} + +// End mock. + +// Attempt to obfuscates value to avoid too much constant folding. +id(v) { + try { + if (v != null) throw v; + } catch (e) { + return e; + } + return null; +} + +// Create a stream for testing "async for-in". +Stream mkStream() { + StreamController c = StreamController(); + int i = 0; + next() { + c.add(i++); + if (i == 10) { + c.close(); + } else { + scheduleMicrotask(next); + } + } + + c = new StreamController(onListen: () { + scheduleMicrotask(next); + }); + return c.stream; +} + +// Check that future contains the error "err". +Future throwsErr(Future future) { + return future.then((v) { + fail("didn't throw"); + }, onError: (e) { + expect(e, equals("err")); + }); +} + +// Check that future contains the value 42. +Future expect42(Future future) { + return future.then((v) { + expect(v, equals(42)); + }); +} + +// Various async declarations. + +Future topMethod(f) async { + return await f; +} + +Future topArrowMethod(f) async => await f; + +Future get topGetter async { + return await new Future.value(42); +} + +Future get topArrowGetter async => await new Future.value(42); + +Future topLocal(f) { + local() async { + return await f; + } + + return local(); +} + +Future topArrowLocal(f) { + local() async => await f; + return local(); +} + +Future topExpression(f) { + return () async { + return await f; + }(); +} + +Future topArrowExpression(f) { + return (() async => await f)(); +} + +DynamicToDynamic topVarExpression = (f) async { + return await f; +}; + +var topVarArrowExpression = (f) async => await f; + +class Async { + var initValue; + Async(); + + Async.initializer(f) + : initValue = (() async { + return await f; + }()); + + Async.initializerArrow(f) : initValue = ((() async => await f)()); + + /* static */ + static Future staticMethod(f) async { + return await f; + } + + static Future staticArrowMethod(f) async => await f; + + static Future get staticGetter async { + return await new Future.value(42); + } + + static Future get staticArrowGetter async => await new Future.value(42); + + static Future staticLocal(f) { + local() async { + return await f; + } + + return local(); + } + + static Future staticArrowLocal(f) { + local() async => await f; + return local(); + } + + static Future staticExpression(f) { + return () async { + return await f; + }(); + } + + static Future staticArrowExpression(f) { + return (() async => await f)(); + } + + static DynamicToDynamic staticVarExpression = (f) async { + return await f; + }; + + static var staticVarArrowExpression = (f) async => await f; + + /* instance */ + Future instanceMethod(f) async { + return await f; + } + + Future instanceArrowMethod(f) async => await f; + + Future get instanceGetter async { + return await new Future.value(42); + } + + Future get instanceArrowGetter async => await new Future.value(42); + + Future instanceLocal(f) { + local() async { + return await f; + } + + return local(); + } + + Future instanceArrowLocal(f) { + local() async => await f; + return local(); + } + + Future instanceExpression(f) { + return () async { + return await f; + }(); + } + + Future instanceArrowExpression(f) { + return (() async => await f)(); + } + + DynamicToDynamic instanceVarExpression = (f) async { + return await f; + }; + + var instanceVarArrowExpression = (f) async => await f; +} + +Future asyncInAsync(f) async { + inner(f) async { + return await f; + } + + return await inner(f); +} + +Future asyncInSync(f) { + inner(f) async { + return await f; + } + + return inner(f); +} + +Future syncInAsync(f) async { + inner(f) { + return f; + } + + return await inner(f); +} + +typedef OnErrorCallback2 = dynamic Function(Object, StackTrace); +typedef OnErrorCallback1 = dynamic Function(Object); diff --git a/micro_dart_compiler/test/testcases2/call/method_function_typed_value_test.dart b/micro_dart_compiler/test/testcases2/call/method_function_typed_value_test.dart new file mode 100644 index 00000000..f1ccbd21 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/call/method_function_typed_value_test.dart @@ -0,0 +1,18 @@ +int f(int i) => 2 * i; + +typedef int IntToInt(int x); + +main() { + assert(f.call(1) == 2); + assert(f.call == f); + IntToInt f2 = f; + assert(f2.call(1) == 2); + assert(f2.call == f); + + Function f3 = f; + assert(f3.call(1) == 2); + assert(f3.call == f); + dynamic d = f; + assert(d.call(1) == 2); + assert(d.call == f); +} diff --git a/micro_dart_compiler/test/testcases2/call/method_implicit_invoke_instance_test.dart b/micro_dart_compiler/test/testcases2/call/method_implicit_invoke_instance_test.dart new file mode 100644 index 00000000..0f60833e --- /dev/null +++ b/micro_dart_compiler/test/testcases2/call/method_implicit_invoke_instance_test.dart @@ -0,0 +1,34 @@ +class C1 { + int call(int i) => 2 * i; +} + +class C2 implements Function { + int call(int i) => 2 * i; +} + +class D { + C1 c1 = C1(); + dynamic d1 = C1(); + C2 c2 = C2(); + dynamic d2 = C2(); + + void test() { + assert(c1(1) == 2); + assert(d1(1) == 2); + assert(c2(1) == 2); + assert(d2(1) == 2); + } +} + +main() { + D().test(); + assert(D().c1(1) == 2); + assert(D().d1(1) == 2); + assert(D().c2(1) == 2); + assert(D().d2(1) == 2); + D d = new D(); + assert(d.c1(1) == 2); + assert(d.d1(1) == 2); + assert(d.c2(1) == 2); + assert(d.d2(1) == 2); +} diff --git a/micro_dart_compiler/test/testcases2/procedure/test1.dart b/micro_dart_compiler/test/testcases2/procedure/test1.dart new file mode 100644 index 00000000..43e33757 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/procedure/test1.dart @@ -0,0 +1,64 @@ +class A { + String method1(num o) { + return "A method1 $o"; + } + + String method2(T o) { + return "A method2 $o"; + } +} + +class B { + String method1(covariant int o) { + return "B method1 $o"; + } + + String method2(int o) { + return "B method2 $o"; + } +} + +class C implements A, B { + // Abstract forwarding stub needed because the parameter is + // covariant in `B.method1` but not in `A.method1`. + + @override + String method1(covariant num o) { + return "C method1 $o"; + } + + // Abstract forwarding stub needed because the parameter is a + // generic covariant impl in `A.method2` but not in `B.method2`. + + @override + String method2(/*generic-covariant-impl*/ int o) { + return "C method2 $o"; + } +} + +class C2 extends A implements B { + // Abstract forwarding stub needed because the parameter is + // covariant in `B.method1` but not in `A.method1`. + + @override + String method1(covariant num o) { + return "C2 method1 $o"; + } + + // Abstract forwarding stub needed because the parameter is a + // generic covariant impl in `A.method2` but not in `B.method2`. + + @override + String method2(/*generic-covariant-impl*/ int o) { + return "C2 method2 $o"; + } +} + +String main() { + var c = C(); + var s1 = c.method1(1.1); + var s2 = c.method2(2); + var r = "$s1$s2"; + print(r); + return r; +} diff --git a/micro_dart_compiler/test/testcases2/super/abstract_method_test.dart b/micro_dart_compiler/test/testcases2/super/abstract_method_test.dart new file mode 100644 index 00000000..7e851db4 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/abstract_method_test.dart @@ -0,0 +1,18 @@ +class Base { + foo() => 42; +} + +abstract class A extends Base { + foo(); +} + +class B extends A { + testSuperCall() => super.foo(); + foo() => + 42; // required since if is removed, then a warning is introduced on 'B' above +} + +main() { + assert(42 == B().foo()); + assert(42 == B().testSuperCall()); +} diff --git a/micro_dart_compiler/test/testcases2/super/all_named_constructor_test.dart b/micro_dart_compiler/test/testcases2/super/all_named_constructor_test.dart new file mode 100644 index 00000000..e04040dd --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/all_named_constructor_test.dart @@ -0,0 +1,18 @@ +int res = 0; + +class A { + A([int v = 1]) { + res += v; + } +} + +class B extends A { + B([int v = 2]) { + res += v; + } +} + +main() { + B(); + assert(3 == res); +} diff --git a/micro_dart_compiler/test/testcases2/super/bound_closure_test.dart b/micro_dart_compiler/test/testcases2/super/bound_closure_test.dart new file mode 100644 index 00000000..64364991 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/bound_closure_test.dart @@ -0,0 +1,146 @@ +class A { + bar([var optional = 1]) => 498 + optional; + bar2({namedOptional: 2}) => 40 + namedOptional; + bar3(x, [var optional = 3]) => x + 498 + optional; + bar4(x, {namedOptional: 4}) => 422 + x + namedOptional; + + // Gee is the same as bar, but we make sure that gee is used. Potentially + // this yields different code if the redirecting stub exists. + gee([var optional = 1]) => 498 + optional; + gee2({namedOptional: 2}) => 40 + namedOptional; + gee3(x, [var optional = 3]) => x + 498 + optional; + gee4(x, {namedOptional: 4}) => 422 + x + namedOptional; + + // Use identifiers that could be intercepted. + add([var optional = 33]) => 1234 + optional; + trim({namedOptional: 22}) => 1313 + namedOptional; + sublist(x, [optional = 44]) => 4321 + optional + x; + splitMapJoin(x, {onMatch: 55, onNonMatch: 66}) => + 111 + x + onMatch + onNonMatch; + + // Other interceptable identifiers, but all of them are used. + shuffle([var optional = 121]) => 12342 + optional; + toList({growable: 2233}) => 13131 + growable; + lastIndexOf(x, [optional = 424]) => 14321 + optional + x; + lastWhere(x, {orElse: 555}) => x + 1213 + 555; +} + +class B extends A { + // The closure `super.bar` is invoked without the optional argument. + // Dart2js must not generate a `bar$0 => bar$1(null)` closure, since that + // would redirect to B's `bar$1`. Instead it must enforce that `bar$0` in + // `A` redirects to A's bar$1. + foo() => confuse(super.bar)(); + foo2() => confuse(super.bar)(2); + foo3() => confuse(super.bar2)(); + foo4() => confuse(super.bar2)(namedOptional: 77); + foo5() => confuse(super.bar3)(-3); + foo6() => confuse(super.bar3)(-11, -19); + foo7() => confuse(super.bar4)(0); + foo8() => confuse(super.bar4)(3, namedOptional: 77); + + fooGee() => confuse(super.gee)(); + fooGee2() => confuse(super.gee)(2); + fooGee3() => confuse(super.gee2)(); + fooGee4() => confuse(super.gee2)(namedOptional: 77); + fooGee5() => confuse(super.gee3)(-3); + fooGee6() => confuse(super.gee3)(-11, -19); + fooGee7() => confuse(super.gee4)(0); + fooGee8() => confuse(super.gee4)(3, namedOptional: 77); + + fooIntercept() => confuse(super.add)(); + fooIntercept2() => confuse(super.add)(2); + fooIntercept3() => confuse(super.trim)(); + fooIntercept4() => confuse(super.trim)(namedOptional: 77); + fooIntercept5() => confuse(super.sublist)(-3); + fooIntercept6() => confuse(super.sublist)(-11, -19); + fooIntercept7() => confuse(super.splitMapJoin)(0); + fooIntercept8() => confuse(super.splitMapJoin)(3, onMatch: 77, onNonMatch: 8); + + fooIntercept21() => confuse(super.shuffle)(); + fooIntercept22() => confuse(super.shuffle)(2); + fooIntercept23() => confuse(super.toList)(); + fooIntercept24() => confuse(super.toList)(growable: 77); + fooIntercept25() => confuse(super.lastIndexOf)(-3); + fooIntercept26() => confuse(super.lastIndexOf)(-11, -19); + fooIntercept27() => confuse(super.lastWhere)(0); + fooIntercept28() => confuse(super.lastWhere)(3, orElse: 77); + + // Warning: overrides should not change default parameter values. + bar([var optional]) => -1; // //# 01: ok + bar2({namedOptional}) => -1; // //# 01: continued + bar3(x, [var optional]) => -1; // //# 01: continued + bar4(x, {namedOptional}) => -1; //# 01: continued + + gee([var optional]) => -1; // //# 01: continued + gee2({namedOptional}) => -1; // //# 01: continued + gee3(x, [var optional]) => -1; // //# 01: continued + gee4(x, {namedOptional}) => -1; //# 01: continued + + add([var optional = 33]) => -1; + trim({namedOptional: 22}) => -1; + sublist(x, [optional = 44]) => -1; + splitMapJoin(x, {onMatch: 55, onNonMatch: 66}) => -1; + + shuffle([var optional = 121]) => -1; + toList({growable: 2233}) => -1; + lastIndexOf(x, [optional = 424]) => -1; + lastWhere(x, {orElse: 555}) => -1; +} + +confuse(x) { + if (new DateTime.now().millisecondsSinceEpoch == 42) return confuse(x - 1); + return x; +} + +main() { + var list = [new A(), new B(), [], "foo"]; + var a = list[confuse(0)]; + dynamic b = list[confuse(1)]; + var ignored = list[confuse(2)]; + var ignored2 = list[confuse(3)]; + + var t = b.gee() + b.gee2() + b.gee3(9) + b.gee4(19); + assert(-4 == t); + t = b.shuffle() + b.toList() + b.lastIndexOf(1) + b.lastWhere(2); + + assert(-4 == t); + assert(499 == b.foo()); + assert(500 == b.foo()); + + assert(499 == b.foo()); // //# 01: continued + assert(500 == b.foo2()); //# 01: continued + assert(42 == b.foo3()); // //# 01: continued + assert(117 == b.foo4()); //# 01: continued + assert(498 == b.foo5()); //# 01: continued + assert(468 == b.foo6()); //# 01: continued + assert(426 == b.foo7()); //# 01: continued + assert(502 == b.foo8()); //# 01: continued + + assert(499 == b.fooGee()); // //# 01: continued + assert(500 == b.fooGee2()); //# 01: continued + assert(42 == b.fooGee3()); // //# 01: continued + assert(117 == b.fooGee4()); //# 01: continued + assert(498 == b.fooGee5()); //# 01: continued + assert(468 == b.fooGee6()); //# 01: continued + assert(426 == b.fooGee7()); //# 01: continued + assert(502 == b.fooGee8()); //# 01: continued + + assert(1267 == b.fooIntercept()); + assert(1236 == b.fooIntercept2()); + assert(1335 == b.fooIntercept3()); + assert(1390 == b.fooIntercept4()); + assert(4362 == b.fooIntercept5()); + assert(4291 == b.fooIntercept6()); + assert(232 == b.fooIntercept7()); + assert(199 == b.fooIntercept8()); + + assert(12463 == b.fooIntercept21()); + assert(12344 == b.fooIntercept22()); + assert(15364 == b.fooIntercept23()); + assert(13208 == b.fooIntercept24()); + assert(14742 == b.fooIntercept25()); + assert(14291 == b.fooIntercept26()); + assert(1768 == b.fooIntercept27()); + assert(1771 == b.fooIntercept28()); +} diff --git a/micro_dart_compiler/test/testcases2/super/call2_test.dart b/micro_dart_compiler/test/testcases2/super/call2_test.dart new file mode 100644 index 00000000..2f262e47 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/call2_test.dart @@ -0,0 +1,29 @@ +class C { + foo(T a) {} +} + +class D extends C { + foo(T a) { + super.foo(a); // used to be resolved incorrectly and generate this.foo(a). + } +} + +class A { + static int? _value; + Function foo = (int x) => _value = x + 1; +} + +class B extends A { + void m(int x) { + super.foo(x); + } +} + +main() { + var d = new D(); + d.foo(null); + + var b = new B(); + b.m(41); + assert(42 == A._value); +} diff --git a/micro_dart_compiler/test/testcases2/super/call3_runtime_test.dart b/micro_dart_compiler/test/testcases2/super/call3_runtime_test.dart new file mode 100644 index 00000000..9f93652b --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/call3_runtime_test.dart @@ -0,0 +1,34 @@ +class A { + A(); + final foo = 499; +} + +class B extends A {} + +class B2 extends A { + B2(); + B2.named() : this.x = 499; + var x; +} + +class C { + C(); + final foo = 499; +} + +class D extends C {} + +class D2 extends C { + D2(); + D2.named() : this.x = 499; + var x; +} + +main() { + assert(499 == new B().foo); + assert(499 == new B2().foo); + assert(499 == new B2.named().foo); + assert(499 == new D().foo); + assert(499 == new D2().foo); + assert(499 == new D2.named().foo); +} diff --git a/micro_dart_compiler/test/testcases2/super/call4_test.dart b/micro_dart_compiler/test/testcases2/super/call4_test.dart new file mode 100644 index 00000000..05bcfd48 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/call4_test.dart @@ -0,0 +1,39 @@ +class C { + bool foo(); + bool bar(int a); + bool baz({int b}); + bool boz(int a, {int c}); + + bool noSuchMethod(Invocation im) => true; +} + +class D extends C { + bool noSuchMethod(Invocation im) => false; + + // `super.foo()` et al. will statically use [C]'s [noSuchMethod] forwarder, + // but the forwarder will (virtually) call [D]'s [noSuchMethod] at runtime. + + test1() { + return super.foo(); + } + + test2() { + return super.bar(1); + } + + test3() { + return super.baz(b: 2); + } + + test4() { + return super.boz(1, c: 2); + } +} + +main() { + var d = new D(); + assert(d.test1() == false); + assert(d.test2() == false); + assert(d.test3() == false); + assert(d.test4() == false); +} diff --git a/micro_dart_compiler/test/testcases2/super/call_test.dart b/micro_dart_compiler/test/testcases2/super/call_test.dart new file mode 100644 index 00000000..73485395 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/call_test.dart @@ -0,0 +1,37 @@ +class A { + A() : field = 0 {} + int field; + incrField() { + field++; + } + + timesX(v) { + return v * 2; + } +} + +class B extends A { + incrField() { + field++; + super.incrField(); + } + + timesX(v) { + return super.timesX(v) * 3; + } + + B() : super() {} +} + +class SuperCallTest { + static testMain() { + var b = new B(); + b.incrField(); + assert(2 == b.field); + assert(12 == b.timesX(2)); + } +} + +main() { + SuperCallTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/super/closure_test.dart b/micro_dart_compiler/test/testcases2/super/closure_test.dart new file mode 100644 index 00000000..23250609 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/closure_test.dart @@ -0,0 +1,19 @@ +class Super { + var superX = "super"; + get x => superX; +} + +class Sub extends Super { + var subX = "sub"; + get x => subX; + + buildClosures() => [() => x, () => this.x, () => super.x]; +} + +main() { + var closures = new Sub().buildClosures(); + assert(3 == closures.length); + assert("sub" == closures[0]()); + assert("sub" == closures[1]()); + assert("super" == closures[2]()); +} diff --git a/micro_dart_compiler/test/testcases2/super/field_2_test.dart b/micro_dart_compiler/test/testcases2/super/field_2_test.dart new file mode 100644 index 00000000..ddb49586 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/field_2_test.dart @@ -0,0 +1,79 @@ +class A { + var foo; + A(this.foo); + + B_Sfoo() => 'A.B_Sfoo()'; +} + +class B extends A { + B(x) : super(x); + + B_Sfoo() => super.foo; + BC_Sfoo() => super.foo; + BCD_Sfoo() => super.foo; +} + +class C extends B { + var foo; + C(x, this.foo) : super(x); + + BC_Sfoo() => super.foo; + BCD_Sfoo() => super.foo; +} + +class D extends C { + D(x, y) : super(x, y); + + BCD_Sfoo() => super.foo; +} + +var inscrutable; + +main() { + inscrutable = (x) => x; + + var b = new B('Ba'); + var c = new C('Ca', 'Cc'); + var d = new D('Da', 'Dc'); + + // Check access via plain getter. + var b_bc = inscrutable(true) ? b : c; // B, but compiler thinks can also be C + var c_bc = inscrutable(true) ? c : b; // C, but compiler thinks can also be B + + assert('Ba' == b.foo); + assert('Cc' == c.foo); + assert('Dc' == d.foo); + assert('Ba' == b_bc.foo); + assert('Cc' == c_bc.foo); + + assert('Ba' == inscrutable(b).foo); + assert('Cc' == inscrutable(c).foo); + assert('Dc' == inscrutable(d).foo); + assert('Ba' == inscrutable(b_bc).foo); + assert('Cc' == inscrutable(c_bc).foo); + + // Check access via super.foo in various contexts + assert('Ba' == b.B_Sfoo()); + assert('Ca' == c.B_Sfoo()); + assert('Da' == d.B_Sfoo()); + + assert('Ba' == b.BC_Sfoo()); + assert('Ca' == c.BC_Sfoo()); + assert('Da' == d.BC_Sfoo()); + + assert('Ba' == b.BCD_Sfoo()); + assert('Ca' == c.BCD_Sfoo()); + assert('Dc' == d.BCD_Sfoo()); + + assert('Ba' == inscrutable(b).B_Sfoo()); + assert('Ca' == inscrutable(c).B_Sfoo()); + assert('Da' == inscrutable(d).B_Sfoo()); + + assert('Ba' == inscrutable(b).BC_Sfoo()); + assert('Ca' == inscrutable(c).BC_Sfoo()); + assert('Da' == inscrutable(d).BC_Sfoo()); + + assert('Ba' == inscrutable(b).BCD_Sfoo()); + assert('Ca' == inscrutable(c).BCD_Sfoo()); + assert('Dc' == inscrutable(d).BCD_Sfoo()); +} diff --git a/micro_dart_compiler/test/testcases2/super/field_access_test.dart b/micro_dart_compiler/test/testcases2/super/field_access_test.dart new file mode 100644 index 00000000..fe8ebedc --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/field_access_test.dart @@ -0,0 +1,35 @@ +class A { + int foo; + A(this.foo); + + raw$foo() => foo; + this$foo() => this.foo; +} + +class B extends A { + int foo; + B.b1(x, this.foo) : super(x); + B.b2(x, y) + : this.foo = y, + super(x); + B.b3(x, y) + : this.foo = y, + super(x); + + super$foo() => super.foo; + sum() => foo + super.foo; +} + +test(b) { + assert(10 == b.foo); + assert(10 == b.raw$foo()); + assert(10 == b.this$foo()); + assert(100 == b.super$foo()); + assert(110 == b.sum()); +} + +main() { + test(new B.b1(100, 10)); + test(new B.b2(100, 10)); + test(new B.b3(100, 10)); +} diff --git a/micro_dart_compiler/test/testcases2/super/field_test.dart b/micro_dart_compiler/test/testcases2/super/field_test.dart new file mode 100644 index 00000000..3dcf1a87 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/field_test.dart @@ -0,0 +1,48 @@ +class A { + late String city; + A() { + city = "Bern"; + } + String greeting() { + return "Gruezi"; + } +} + +class B extends A { + B() : super() {} + String greeting() { + return "Hola " + super.greeting(); + } +} + +class C extends B { + C() : super() {} + String greeting() { + return "Servus " + super.greeting(); + } + + String get city { + return "Basel " + super.city; + } +} + +class SuperFieldTest { + static testMain() { + A a = new A(); + B b = new B(); + C c = new C(); + assert("Gruezi" == a.greeting()); + assert("Hola Gruezi" == b.greeting()); + assert("Servus Hola Gruezi" == c.greeting()); + + assert("Bern" == a.city); + assert("Bern" == b.city); + assert("Basel Bern" == c.city); + c.city = "Zurich"; + assert("Basel Zurich" == c.city); + } +} + +main() { + SuperFieldTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/super/from_constructor_test.dart b/micro_dart_compiler/test/testcases2/super/from_constructor_test.dart new file mode 100644 index 00000000..014d9393 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/from_constructor_test.dart @@ -0,0 +1,46 @@ +final results = []; + +int invoke(int f()) => f(); + +class Base { + var f; + var z; + + m(x) => results.add(x); + + int g() { + return 42; + } +} + +class C extends Base { + final Iterable _iter; + + C(this._iter) { + _iter.map((x) => super.m(x)).toList(); + super.f = _iter; + z = invoke(super.g); + } + + int g() { + return -1; + } +} + +main() { + var c = new C([1, 2, 3]); + listEquals([1, 2, 3], results); + listEquals([1, 2, 3], c.f); + equals(42, c.z); +} + +void listEquals(List a, List b) { + assert(a.length == b.length); + for (int i = 0; i < a.length; i++) { + assert(a[i] == b[i]); + } +} + +void equals(a, b) { + assert(a == b); +} diff --git a/micro_dart_compiler/test/testcases2/super/implicit_closure_test.dart b/micro_dart_compiler/test/testcases2/super/implicit_closure_test.dart new file mode 100644 index 00000000..265e9070 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/implicit_closure_test.dart @@ -0,0 +1,37 @@ +class BaseClass { + BaseClass(this._i) {} + int foo() { + return _i; + } + + int _i; +} + +class DerivedClass extends BaseClass { + DerivedClass(this._y, int j) : super(j) {} + int foo() { + return _y; + } + + getSuper() { + return super.foo; + } + + int _y; +} + +class SuperImplicitClosureTest { + static void testMain() { + DerivedClass obj = new DerivedClass(20, 10); + + var ib = obj.foo; + assert(obj._y == ib()); + + ib = obj.getSuper(); + assert(obj._i == ib()); + } +} + +main() { + SuperImplicitClosureTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_async1_test.dart b/micro_dart_compiler/test/testcases2/super/in_async1_test.dart new file mode 100644 index 00000000..4dc912ed --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_async1_test.dart @@ -0,0 +1,16 @@ +import 'dart:async'; + +class A { + Future foo() async => 42; +} + +class B extends A { + Future foo() async { + var x = await super.foo(); + return x + 1; + } +} + +Future main() async { + assert(43 == await new B().foo()); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_async2_test.dart b/micro_dart_compiler/test/testcases2/super/in_async2_test.dart new file mode 100644 index 00000000..b88e65a2 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_async2_test.dart @@ -0,0 +1,17 @@ +import 'dart:async'; + +class A { + Future foo() async => 42; +} + +class B extends A { + Future foo() async { + var x = await super.foo(); + var y = await super.foo(); + return x + y; + } +} + +Future main() async { + assert(84 == await new B().foo()); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_async3_test.dart b/micro_dart_compiler/test/testcases2/super/in_async3_test.dart new file mode 100644 index 00000000..3ff3080f --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_async3_test.dart @@ -0,0 +1,16 @@ +import 'dart:async'; + +class A { + Future foo(T x) async => x; +} + +class B extends A { + Future bar() async { + var x = await super.foo(41); + return x + 1; + } +} + +Future main() async { + assert(42 == await new B().bar()); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_async4_test.dart b/micro_dart_compiler/test/testcases2/super/in_async4_test.dart new file mode 100644 index 00000000..e50836be --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_async4_test.dart @@ -0,0 +1,16 @@ +import 'dart:async'; + +class A { + Future foo({required T x}) async => x; +} + +class B extends A { + Future bar() async { + var x = await super.foo(x: 41); + return x + 1; + } +} + +Future main() async { + assert(42 == await new B().bar()); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_async5_test.dart b/micro_dart_compiler/test/testcases2/super/in_async5_test.dart new file mode 100644 index 00000000..1238decf --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_async5_test.dart @@ -0,0 +1,14 @@ +class A { + Future get foo async => 42; +} + +class B extends A { + Future bar() async { + var x = await super.foo; + return x + 1; + } +} + +main() async { + assert(43 == await new B().bar()); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_async6_test.dart b/micro_dart_compiler/test/testcases2/super/in_async6_test.dart new file mode 100644 index 00000000..bb846456 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_async6_test.dart @@ -0,0 +1,16 @@ +import 'dart:async'; + +class A { + Future foo(int x, int y, int z) async => x + y + z; +} + +class B extends A { + Future foo(int x, int y, int z) async { + var w = await super.foo(x, y, z); + return w + 1; + } +} + +main() async { + assert(7 == await new B().foo(1, 2, 3)); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_constructor_test.dart b/micro_dart_compiler/test/testcases2/super/in_constructor_test.dart new file mode 100644 index 00000000..481453db --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_constructor_test.dart @@ -0,0 +1,19 @@ +class Foo { + bool myBoolean = false; + + void set foo(bool b) { + print("Setting foo in Foo"); + myBoolean = b; + } +} + +class Baz extends Foo { + Baz() { + super.foo = true; + assert(true == super.myBoolean); + } +} + +main() { + new Baz(); +} diff --git a/micro_dart_compiler/test/testcases2/super/in_finally_test.dart b/micro_dart_compiler/test/testcases2/super/in_finally_test.dart new file mode 100644 index 00000000..c6a9cf2f --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/in_finally_test.dart @@ -0,0 +1,18 @@ +class A { + T foo({required T x}) => x; +} + +class B extends A { + int bar() { + try { + throw 'bar'; + } finally { + var x = super.foo(x: 41); + return x + 1; + } + } +} + +main() { + assert(42 == new B().bar()); +} diff --git a/micro_dart_compiler/test/testcases2/super/inferrer_test.dart b/micro_dart_compiler/test/testcases2/super/inferrer_test.dart new file mode 100644 index 00000000..d44b6811 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/inferrer_test.dart @@ -0,0 +1,28 @@ +class A { + foo(a) => a + 42; +} + +class B extends A { + bar() { + super.foo(null); + } +} + +var a = [new A()]; + +main() { + analyzeFirst(); + analyzeSecond(); +} + +analyzeFirst() { + assert(84 == a[0].foo(42)); +} + +analyzeSecond() { + try { + B().bar(); + } catch (e, s) { + print(e.toString()); + } +} diff --git a/micro_dart_compiler/test/testcases2/super/mixin_test.dart b/micro_dart_compiler/test/testcases2/super/mixin_test.dart new file mode 100644 index 00000000..f31195c3 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/mixin_test.dart @@ -0,0 +1,13 @@ +class Mixin { + get getter => 42; +} + +class Superclass {} + +class Subclass extends Superclass with Mixin { + method() => super.getter; +} + +void main() { + assert(42 == new Subclass().method()); +} diff --git a/micro_dart_compiler/test/testcases2/super/no_such_method1_test.dart b/micro_dart_compiler/test/testcases2/super/no_such_method1_test.dart new file mode 100644 index 00000000..7bc4f607 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/no_such_method1_test.dart @@ -0,0 +1,14 @@ +class A { + int foo(); + noSuchMethod(im) => 42; +} + +class B extends A { + noSuchMethod(im) => 87; + + int foo() => super.foo(); +} + +main() { + assert(87 == new B().foo()); +} diff --git a/micro_dart_compiler/test/testcases2/super/no_such_method2_test.dart b/micro_dart_compiler/test/testcases2/super/no_such_method2_test.dart new file mode 100644 index 00000000..541bdc6a --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/no_such_method2_test.dart @@ -0,0 +1,14 @@ +class A { + int get foo; + noSuchMethod(im) => 42; +} + +class B extends A { + noSuchMethod(im) => 87; + + get foo => super.foo; +} + +main() { + assert(87 == new B().foo); +} diff --git a/micro_dart_compiler/test/testcases2/super/no_such_method3_test.dart b/micro_dart_compiler/test/testcases2/super/no_such_method3_test.dart new file mode 100644 index 00000000..68ef0698 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/no_such_method3_test.dart @@ -0,0 +1,22 @@ +var result; + +class A { + set foo(int a); + + noSuchMethod(im) { + result = 42; + } +} + +class B extends A { + noSuchMethod(im) { + result = 87; + } + + set foo(v) => super.foo = v; +} + +main() { + new B().foo = 0; + assert(87 == result); +} diff --git a/micro_dart_compiler/test/testcases2/super/no_such_method4_runtime_test.dart b/micro_dart_compiler/test/testcases2/super/no_such_method4_runtime_test.dart new file mode 100644 index 00000000..efb68597 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/no_such_method4_runtime_test.dart @@ -0,0 +1,13 @@ +class A { + int foo(); + + noSuchMethod(im) => 42; +} + +class B extends Object with A { + noSuchMethod(im) => 87; +} + +main() { + assert(87 == new B().foo()); +} diff --git a/micro_dart_compiler/test/testcases2/super/no_such_method5_runtime_test.dart b/micro_dart_compiler/test/testcases2/super/no_such_method5_runtime_test.dart new file mode 100644 index 00000000..268797ee --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/no_such_method5_runtime_test.dart @@ -0,0 +1,11 @@ +class A { + int foo(); + + noSuchMethod(im) => 42; +} + +class B extends Object with A {} + +main() { + assert(42 == new B().foo()); +} diff --git a/micro_dart_compiler/test/testcases2/super/operator_index2_test.dart b/micro_dart_compiler/test/testcases2/super/operator_index2_test.dart new file mode 100644 index 00000000..57aa8c29 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/operator_index2_test.dart @@ -0,0 +1,21 @@ +class A { + var map = new Map(); + operator []=(a, b) { + map[a] = b; + } + + operator [](a) => map[a]; +} + +class B extends A { + foo() { + super[4] = 42; + assert(42 == super[4]); + super[4] += 5; + assert(47 == super[4]); + } +} + +main() { + new B().foo(); +} diff --git a/micro_dart_compiler/test/testcases2/super/operator_index3_test.dart b/micro_dart_compiler/test/testcases2/super/operator_index3_test.dart new file mode 100644 index 00000000..4591d97a --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/operator_index3_test.dart @@ -0,0 +1,31 @@ +class A { + var indexField = new List.filled(2, null); + operator []=(index, value) { + indexField[index] = value; + } +} + +class B extends A { + operator [](index) => indexField[index]; +} + +class C extends B { + test() { + super[0] = 42; + assert(42 == super[0]); + super[0] += 1; + assert(43 == super[0]); + super[0]++; + assert(44 == super[0]); + super[0] = 2; + assert(2 == super[0]); + super[0] += 1; + assert(3 == super[0]); + super[0]++; + assert(4 == super[0]); + } +} + +main() { + new C().test(); +} diff --git a/micro_dart_compiler/test/testcases2/super/operator_index5_test.dart b/micro_dart_compiler/test/testcases2/super/operator_index5_test.dart new file mode 100644 index 00000000..82dfbda4 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/operator_index5_test.dart @@ -0,0 +1,41 @@ +class A { + var indexField = new List.filled(2, null); + operator [](index) => indexField[index]; + + operator []=(index, value); + + noSuchMethod(Invocation im) { + if (im.memberName == const Symbol('[]=')) { + assert(2 == im.positionalArguments.length); + indexField[im.positionalArguments[0]] = im.positionalArguments[1]; + } else if (im.memberName == const Symbol('[]')) { + assert(1 == im.positionalArguments.length); + return indexField[im.positionalArguments[0]]; + } else { + print('Should not reach here'); + } + } +} + +class B extends A { + test() { + super[0] = 42; + assert(42 == super[0]); + super[0] += 1; + assert(43 == super[0]); + super[0]++; + + assert(44 == super[0]); + + super[0] = 2; + assert(2 == super[0]); + super[0] += 1; + assert(3 == super[0]); + super[0]++; + assert(4 == super[0]); + } +} + +main() { + new B().test(); +} diff --git a/micro_dart_compiler/test/testcases2/super/operator_test.dart b/micro_dart_compiler/test/testcases2/super/operator_test.dart new file mode 100644 index 00000000..5785c32c --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/operator_test.dart @@ -0,0 +1,56 @@ +class A { + String val = ""; + List things; + + A() : things = ['D', 'a', 'r', 't', 42]; + + operator +(String s) { + val = "${val}${s}"; + return this; + } + + operator [](i) { + return things[i]; + } + + operator []=(i, val) { + return things[i] = val; + } +} + +class B extends A { + operator +(String s) { + super + ("${s}${s}"); // Call A.operator+(this, "${s}${s}"). + return this; + } + + operator [](i) { + var temp = super[i]; + if (temp is String) { + return "$temp$temp"; + } + return temp + temp; + } + + operator []=(i, val) { + // Make sure the index expression is only evaluated + // once in the presence of a compound assignment. + return super[i++] += val; + } +} + +main() { + var a = new A(); + a = a + "William"; // operator + of class A. + assert("William" == a.val); + assert("r" == a[2]); // operator [] of class A. + + a = new B(); + a += "Tell"; // operator + of class B. + assert("TellTell" == a.val); + assert("rr" == a[2]); // operator [] of class B. + + a[4] = 1; // operator []= of class B. + assert(43 == a.things[4]); + assert(86 == a[4]); +} diff --git a/micro_dart_compiler/test/testcases2/super/regress47698_test.dart b/micro_dart_compiler/test/testcases2/super/regress47698_test.dart new file mode 100644 index 00000000..ce13c08a --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/regress47698_test.dart @@ -0,0 +1,56 @@ +// Regression test for https://github.com/dart-lang/sdk/issues/47698. + +// Exposes a class field. +class A { + int i; + A(this.i); +} + +// Exposes a getter/setter pair. +class B { + int _j; + int get j => _j; + set j(int x) => _j = x; + B(this._j); +} + +// A super class field used in constructor as getter and setter. +class C extends A { + C(int val) : super(val) { + var x = super.i + 10; // Getter is used first. + super.i = x + 100; // Boom! Missing setter. + } +} + +class D extends A { + D(int val) : super(val) { + super.i = 100; // Setter is used first. + super.i = super.i + 10 + val; // Boom! Missing getter. + } +} + +// Actual super getter and setter used in constructor +class E extends B { + E(int val) : super(val) { + var x = super.j + 10; // Getter is used first. + super.j = x + 100; // Boom! Missing setter. + } +} + +class F extends B { + F(int val) : super(val) { + super.j = 100; // Setter is used first. + super.j = super.j + 10 + val; // Boom! Missing getter. + } +} + +void main() { + var c = C(1); + assert(c.i == 111); + var d = D(1); + assert(d.i == 111); + var e = E(1); + assert(e.j == 111); + var f = F(1); + assert(f.j == 111); +} diff --git a/micro_dart_compiler/test/testcases2/super/setter_interceptor_test.dart b/micro_dart_compiler/test/testcases2/super/setter_interceptor_test.dart new file mode 100644 index 00000000..34c607b6 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/setter_interceptor_test.dart @@ -0,0 +1,33 @@ +var expected; + +class A { + set length(a) { + assert(expected == a); + } + + get length => 41; +} + +class B extends A { + test() { + expected = 42; + super.length = 42; + expected = 42; + super.length += 1; + expected = 42; + assert(42 == ++super.length); + expected = 40; + assert(40 == --super.length); + expected = 42; + assert(41 == super.length++); + expected = 40; + assert(41 == super.length--); + assert(41 == super.length); + } +} + +main() { + // Ensures the list class is instantiated. + print([]); + new B().test(); +} diff --git a/micro_dart_compiler/test/testcases2/super/super_test.dart b/micro_dart_compiler/test/testcases2/super/super_test.dart new file mode 100644 index 00000000..7c8bc3cc --- /dev/null +++ b/micro_dart_compiler/test/testcases2/super/super_test.dart @@ -0,0 +1,54 @@ +int i = 0; + +// Tests super calls and constructors. +main() { + Sub sub = new Sub(1, 2); + assert(1 == sub.x); + assert(2 == sub.y); + assert(3 == sub.z); + assert(1 == sub.v); + assert(2 == sub.w); + assert(3 == sub.u); + + sub = new Sub.stat(); + assert(2 == sub.x); + assert(3 == sub.y); + assert(0 == sub.v); + assert(1 == sub.w); + assert(4 == sub.z); + assert(5 == sub.u); +} + +class Sup { + var x, y, z; + + Sup(a, b) + : this.x = a, + this.y = b { + z = a + b; + } + + Sup.stat() + : this.x = i++, + this.y = i++ { + z = i++; + } +} + +class Sub extends Sup { + var u, v, w; + + Sub(a, b) + : this.v = a, + this.w = b, + super(a, b) { + u = a + b; + } + + Sub.stat() + : this.v = i++, + this.w = i++, + super.stat() { + u = i++; + } +} diff --git a/micro_dart_compiler/test/testcases2/switch/aborting_switch_case_test.dart b/micro_dart_compiler/test/testcases2/switch/aborting_switch_case_test.dart new file mode 100644 index 00000000..08f492c7 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/aborting_switch_case_test.dart @@ -0,0 +1,18 @@ +foo() { + throw 42; +} + +main() { + var exception; + try { + switch (42) { + case 42: + foo(); + foo(); + break; + } + } catch (e) { + exception = e; + } + assert(42 == exception); +} diff --git a/micro_dart_compiler/test/testcases2/switch/backward_jump_test.dart b/micro_dart_compiler/test/testcases2/switch/backward_jump_test.dart new file mode 100644 index 00000000..181ce2b3 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/backward_jump_test.dart @@ -0,0 +1,35 @@ +main() { + assert(test(5) == 'a'); + assert(test(10) == 'a through b'); + assert(test(7) == 'b'); +} + +String test(int i) { + switch (i) { + a: + case 5: + { + if (i == 10) { + return 'a through b'; + } + if (i == 0) { + return 'a'; + } + i -= 1; + continue a; // backward jump to non-default self + } + + b: + default: + { + if (i == 10) { + continue a; // backward jump to non-default + } + if (i == 0) { + return 'b'; + } + i -= 1; + continue b; // backward jump to default + } + } +} diff --git a/micro_dart_compiler/test/testcases2/switch/bad_case_runtime_test.dart b/micro_dart_compiler/test/testcases2/switch/bad_case_runtime_test.dart new file mode 100644 index 00000000..686c3b71 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/bad_case_runtime_test.dart @@ -0,0 +1,19 @@ +void main() { + assert("IV" == caesarSays(4)); + assert(null == caesarSays(2)); + assert(null == archimedesSays(3.14)); +} + +caesarSays(n) { + switch (n) { + case 1: + return "I"; + case 4: + return "IV"; + } + return null; +} + +archimedesSays(n) { + return null; +} diff --git a/micro_dart_compiler/test/testcases2/switch/case_expression_with_assignment_runtime_test.dart b/micro_dart_compiler/test/testcases2/switch/case_expression_with_assignment_runtime_test.dart new file mode 100644 index 00000000..b5497b31 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/case_expression_with_assignment_runtime_test.dart @@ -0,0 +1,20 @@ +const ERROR_A = 0; +const ERROR_B = 1; + +errorToString(error) { + switch (error) { + case ERROR_A: + return "ERROR_A"; + + case ERROR_B: + return "ERROR_B"; + default: + return "Unknown error"; + } +} + +main() { + assert(errorToString(ERROR_A), "ERROR_A"); + assert(errorToString(ERROR_B), "ERROR_B"); + assert(errorToString(55), "Unknown error"); +} diff --git a/micro_dart_compiler/test/testcases2/switch/case_warn_test.dart b/micro_dart_compiler/test/testcases2/switch/case_warn_test.dart new file mode 100644 index 00000000..cf137551 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/case_warn_test.dart @@ -0,0 +1,210 @@ +// Copyright (c) 2016, 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. +// Test switch statement. + +// Tests some switch-case statements blocks that should and should not +// cause static warnings. +// This test is not testing runtime behavior, only static warnings. + +// None of the cases blocks should cause a warning. +void testSwitch(int x) { + // Catch all control flow leaving the switch. + // Run switch in catch clause to check rethrow. + TRY: + try { + throw x; + } catch (x) { + // Add loop as break/continue target. + LOOP: + do { + switch (x) { + case 0: + case 1: + nop(x); + break; // Break switch. + case 2: + nop(x); + break LOOP; + case 3: + nop(x); + continue; // Continue loop. + case 4: + nop(x); + continue LOOP; + case 5: + nop(x); + continue LAST; + // Avoid warning for "return;"" and "return e;" in same function. + case 6: // //# retnon: ok + nop(x); // //# retnon: continued + return; // //# retnon: continued + case 8: + nop(x); + throw x; + case 9: + nop(x); + rethrow; + case 10: + case 11: + { + nop(x); + break; // Break switch. + } + case 12: + { + nop(x); + break LOOP; + } + case 13: + { + nop(x); + continue; // Continue loop. + } + case 14: + { + nop(x); + continue LOOP; + } + case 15: + { + nop(x); + continue LAST; + } + case 16: + { + // //# retnon: continued + nop(x); // //# retnon: continued + return; // //# retnon: continued + } // //# retnon: continued + + case 18: + { + nop(x); + throw x; + } + case 19: + { + nop(x); + rethrow; + } + LAST: + case 20: + { + nop(x); + // Fallthrough allowed on last statements. + } + } + } while (false); + } finally { + // Catch all control flow leaving the switch and ignore it. + // Use break instead of return to avoid warning for `return` and `return e` + // in same function. + break TRY; + } +} + +// All these switch cases should cause warnings. +void testSwitchWarn(x) { + // Catch all control flow from the switch and ignore it. + TRY: + try { + throw 0; + } catch (e) { + // Wrap in loop as target for continue/break. + LOOP: + do { + switch (x) { + case 0: // //# 01: compile-time error + case 1: + { + // //# 01: continued + { + // //# 01: continued + nop(x); // //# 01: continued + break; // Break switch. // //# 01: continued + } // //# 01: continued + } // //# 01: continued + case 2: + { + // //# 02: compile-time error + { + // //# 02: continued + nop(x); // //# 02: continued + break LOOP; // //# 02: continued + } // //# 02: continued + } // //# 02: continued + case 3: + { + // //# 03: compile-time error + { + // //# 03: continued + nop(x); // //# 03: continued + continue; // Continue loop. //# 03: continued + } // //# 03: continued + } // //# 03: continued + case 4: + { + // //# 04: compile-time error + { + // //# 04: continued + nop(x); // //# 04: continued + continue LOOP; // //# 04: continued + } // //# 04: continued + } // //# 04: continued + case 5: + { + // //# 05: compile-time error + { + // //# 05: continued + nop(x); // //# 05: continued + continue LAST; // //# 05: continued + } // //# 05: continued + } // //# 05: continued + case 6: + { + // //# 06: compile-time error + { + // //# 06: continued + nop(x); // //# 06: continued + return; // //# 06: continued + } // //# 06: continued + } // //# 06: continued + case 7: + { + // //# 07: compile-time error + { + // //# 07: continued + nop(x); // //# 07: continued + return x; // //# 07: continued + } // //# 07: continued + } // //# 07: continued + + case 17: // //# 17: compile-time error + L: + break; // //# 17: continued + LAST: + case 99: + // Last case can't cause static warning. + } + } while (false); + } finally { + // Catch all control flow leaving the switch and ignore it. + // Use break instead of return to avoid warning for `return` and `return e` + // in same function. + break TRY; + } +} + +main() { + // Ensure that all the cases compile and run (even if they might throw). + for (int i = 0; i <= 20; i++) { + testSwitch(i); // Just make sure it runs. + } + for (int i = 0; i <= 18; i++) { + testSwitchWarn(i); + } +} + +/// Don't make it obvious that a switch case isn't doing anything. +void nop(x) {} diff --git a/micro_dart_compiler/test/testcases2/switch/label2_test.dart b/micro_dart_compiler/test/testcases2/switch/label2_test.dart new file mode 100644 index 00000000..2e575602 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/label2_test.dart @@ -0,0 +1,34 @@ +void main() { + doSwitch(0, [0, 2]); + doSwitch(1, [1]); + doSwitch(2, [2]); + doSwitch(3, [3, 1]); +} + +void doSwitch(int target, List expect) { + List list = []; + switch (target) { + case 0: + list.add(0); + continue case2; + case1: + case 1: + list.add(1); + break; + case2: + case 2: + list.add(2); + break; + case 3: + list.add(3); + continue case1; + } + listEquals(expect, list); +} + +void listEquals(List a, List b) { + assert(a.length == b.length); + for (int i = 0; i < a.length; i++) { + assert(a[i] == b[i]); + } +} diff --git a/micro_dart_compiler/test/testcases2/switch/label3_test.dart b/micro_dart_compiler/test/testcases2/switch/label3_test.dart new file mode 100644 index 00000000..57ac782b --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/label3_test.dart @@ -0,0 +1,33 @@ +enum Color { red, green, blue } + +enum Taste { sweet, sour, salty, bitter, umami } + +void main() { + assert(getValue(Taste.sweet, Color.blue) == 1); + assert(getValue(Taste.bitter, Color.blue) == 1); + assert(getValue(Taste.salty, Color.red) == 2); + assert(getValue(Taste.salty, Color.blue) == 4); + assert(getValue(Taste.salty, Color.green) == 3); + assert(getValue(Taste.umami, Color.red) == 4); +} + +int getValue(Taste taste, Color color) { + switch (taste) { + case Taste.sweet: + case Taste.sour: + case Taste.bitter: + return 1; + case Taste.salty: + switch (color) { + case Color.red: + return 2; + case Color.blue: + continue LABEL; + case Color.green: + return 3; + } + LABEL: + case Taste.umami: + return 4; + } +} diff --git a/micro_dart_compiler/test/testcases2/switch/label_test.dart b/micro_dart_compiler/test/testcases2/switch/label_test.dart new file mode 100644 index 00000000..ba51a6d0 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/label_test.dart @@ -0,0 +1,96 @@ +class Switcher { + Switcher() {} + + say1(sound) { + var x = 0; + switch (sound) { + MOO: + case "moo": + x = 100; + break; + case "woof": + x = 200; + continue MOO; + default: + x = 300; + break; + } + return x; + } + + say2(sound) { + var x = 0; + switch (sound) { + WOOF: + case "woof": + x = 200; + break; + case "moo": + x = 100; + continue WOOF; + default: + x = 300; + break; + } + return x; + } + + // forward label to outer switch + say3(animal, sound) { + var x = 0; + switch (animal) { + case "cow": + switch (sound) { + case "moo": + x = 100; + break; + case "muh": + x = 200; + break; + default: + continue NIX_UNDERSTAND; + } + break; + case "dog": + if (sound == "woof") { + x = 300; + } else { + continue NIX_UNDERSTAND; + } + break; + NIX_UNDERSTAND: + case "unicorn": + x = 400; + break; + default: + x = 500; + break; + } + return x; + } +} + +class SwitchLabelTest { + static testMain() { + Switcher s = new Switcher(); + assert(100 == s.say1("moo")); + assert(100 == s.say1("woof")); + assert(300 == s.say1("cockadoodledoo")); + + assert(200 == s.say2("moo")); + assert(200 == s.say2("woof")); + assert(300 == s.say2("")); // Dead unicorn says nothing. + + assert(100 == s.say3("cow", "moo")); + assert(200 == s.say3("cow", "muh")); + assert(400 == s.say3("cow", "boeh")); // Don't ask. + assert(300 == s.say3("dog", "woof")); + assert(400 == s.say3("dog", "boj")); // Ĉu vi parolas Esperanton? + assert(400 == s.say3("unicorn", "")); // Still dead. + assert(500 == s.say3("angry bird", "whoooo")); + } +} + +main() { + SwitchLabelTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/switch/scope_test.dart b/micro_dart_compiler/test/testcases2/switch/scope_test.dart new file mode 100644 index 00000000..b39b711c --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/scope_test.dart @@ -0,0 +1,20 @@ +class SwitchScopeTest { + static testMain() { + switch (1) { + case 1: + final v = 1; + break; + case 2: + final v = 2; + assert(2 == v); + break; + default: + final v = 3; + break; + } + } +} + +main() { + SwitchScopeTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/switch/switch6_test.dart b/micro_dart_compiler/test/testcases2/switch/switch6_test.dart new file mode 100644 index 00000000..aa1033dd --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/switch6_test.dart @@ -0,0 +1,21 @@ +class Switch6Test { + static testMain() { + var a = 0; + var x = -1; + switch (a) { + case 0: + { + x = 0; + break; + } + case 1: + x = 1; + break; + } + assert(0 == x); + } +} + +main() { + Switch6Test.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/switch/switch_test.dart b/micro_dart_compiler/test/testcases2/switch/switch_test.dart new file mode 100644 index 00000000..efd83e3b --- /dev/null +++ b/micro_dart_compiler/test/testcases2/switch/switch_test.dart @@ -0,0 +1,161 @@ +class Switcher { + Switcher() {} + + test1(val) { + var x = 0; + switch (val) { + case 1: + x = 100; + break; + case 2: + case 3: + x = 200; + break; + case 4: + default: + { + x = 400; + break; + } + } + return x; + } + + test2(val) { + switch (val) { + case 1: + return 200; + default: + return 400; + } + } +} + +class SwitchTest { + static testMain() { + Switcher s = new Switcher(); + assert(100 == s.test1(1)); + assert(200 == s.test1(2)); + assert(200 == s.test1(3)); + assert(400 == s.test1(4)); + assert(400 == s.test1(5)); + + assert(200 == s.test2(1)); + assert(400 == s.test2(2)); + } +} + +class Enum { + static const Enum e1 = const Enum(1); + static const Enum e2 = const Enum(2); + static const Enum e3 = const Enum(3); + final int id; + const Enum(this.id); +} + +void testSwitchEnum(Enum? input, int expect) { + int? result = null; + switch (input) { + case Enum.e1: + result = 10; + break; + case Enum.e2: + result = 20; + break; + case Enum.e3: + result = 30; + break; + default: + result = 40; + } + assert(expect == result); +} + +const int ic1 = 1; +const int ic2 = 2; +void testSwitchIntExpression(int? input, int? expect) { + int? result = null; + switch (input) { + case 1 + 1: // 2 + case ic1 + 2: // 3 + result = 11; + break; + case ic2 * 2: // 4 + case 1 * 5: // 5 + result = 21; + break; + case ic1 % ic2 + 5: // 6 + result = 31; + break; + } + assert(expect == result); +} + +void testSwitchBool(bool input, int expect) { + int? result = null; + switch (input) { + case true: + result = 12; + break; + case false: + result = 22; + } + assert(expect == result); +} + +void testSwitchString(String? input, int? expect) { + int? result = null; + switch (input) { + case 'one': + result = 1; + break; + case 'two': + result = 2; + break; + } + assert(expect == result); +} + +switchConstString() { + const c = 'a'; + switch (c) { + case 'a': + return 'aa'; + case 'b': + return 'bb'; + case 'c': + return 'cc'; + case 'd': + return 'dd'; + case 'e': + return 'ee'; + case 'f': + return 'ff'; + } +} + +main() { + SwitchTest.testMain(); + + testSwitchEnum(Enum.e1, 10); + testSwitchEnum(Enum.e2, 20); + testSwitchEnum(Enum.e3, 30); + testSwitchEnum(null, 40); + + testSwitchIntExpression(2, 11); + testSwitchIntExpression(3, 11); + testSwitchIntExpression(4, 21); + testSwitchIntExpression(5, 21); + testSwitchIntExpression(6, 31); + testSwitchIntExpression(7, null); + + testSwitchBool(true, 12); + testSwitchBool(false, 22); + + testSwitchString(null, null); + testSwitchString('one', 1); + testSwitchString('two', 2); + testSwitchString('three', null); + + assert('aa' == switchConstString()); +} diff --git a/micro_dart_compiler/test/testcases2/symbol/conflict_test.dart b/micro_dart_compiler/test/testcases2/symbol/conflict_test.dart new file mode 100644 index 00000000..56e1b29c --- /dev/null +++ b/micro_dart_compiler/test/testcases2/symbol/conflict_test.dart @@ -0,0 +1,2807 @@ +class A { + noSuchMethod(invocation) { + assert(oneAndTwoCharacterSymbols.contains(invocation.memberName) == false); + } +} + +main() { + var a = new A() as dynamic; + a.foo = 23; + a.foo; + a.bar; + a.longer; + a.anotherOne; + a.add(1); + a.isEmpty; +} + +/** + The following constant was generated with the following program: + + const RESERVED_WORDS = const [ + 'assert', 'break', 'case', 'catch', 'class', 'const', 'continue', + 'default', 'do', 'else', 'enum', 'extends', 'false', 'final', + 'finally', 'for', 'if', 'in', 'is', 'new', 'null', 'rethrow', + 'return', 'super', 'switch', 'this', 'throw', 'true', 'try', + 'var', 'void', 'while', 'with']; + + get chars sync* { + for (int i = "a".codeUnitAt(0); i <= "z".codeUnitAt(0); i++) { + yield new String.fromCharCodes([i]); + } + for (int i = "A".codeUnitAt(0); i <= "Z".codeUnitAt(0); i++) { + yield new String.fromCharCodes([i]); + } + } + + main() { + print("const oneAndTwoCharacterSymbols = const ["); + // One character symbols. + for (String c in chars) { + print(" const Symbol('$c'),"); + } + // Two character symbols. + for (String c1 in chars) { + for (String c2 in chars) { + if (!RESERVED_WORDS.contains('$c1$c2')) { + print(" const Symbol('$c1$c2'),"); + } + } + } + print("];"); + } +*/ +const oneAndTwoCharacterSymbols = const [ + const Symbol('a'), + const Symbol('b'), + const Symbol('c'), + const Symbol('d'), + const Symbol('e'), + const Symbol('f'), + const Symbol('g'), + const Symbol('h'), + const Symbol('i'), + const Symbol('j'), + const Symbol('k'), + const Symbol('l'), + const Symbol('m'), + const Symbol('n'), + const Symbol('o'), + const Symbol('p'), + const Symbol('q'), + const Symbol('r'), + const Symbol('s'), + const Symbol('t'), + const Symbol('u'), + const Symbol('v'), + const Symbol('w'), + const Symbol('x'), + const Symbol('y'), + const Symbol('z'), + const Symbol('A'), + const Symbol('B'), + const Symbol('C'), + const Symbol('D'), + const Symbol('E'), + const Symbol('F'), + const Symbol('G'), + const Symbol('H'), + const Symbol('I'), + const Symbol('J'), + const Symbol('K'), + const Symbol('L'), + const Symbol('M'), + const Symbol('N'), + const Symbol('O'), + const Symbol('P'), + const Symbol('Q'), + const Symbol('R'), + const Symbol('S'), + const Symbol('T'), + const Symbol('U'), + const Symbol('V'), + const Symbol('W'), + const Symbol('X'), + const Symbol('Y'), + const Symbol('Z'), + const Symbol('aa'), + const Symbol('ab'), + const Symbol('ac'), + const Symbol('ad'), + const Symbol('ae'), + const Symbol('af'), + const Symbol('ag'), + const Symbol('ah'), + const Symbol('ai'), + const Symbol('aj'), + const Symbol('ak'), + const Symbol('al'), + const Symbol('am'), + const Symbol('an'), + const Symbol('ao'), + const Symbol('ap'), + const Symbol('aq'), + const Symbol('ar'), + const Symbol('as'), + const Symbol('at'), + const Symbol('au'), + const Symbol('av'), + const Symbol('aw'), + const Symbol('ax'), + const Symbol('ay'), + const Symbol('az'), + const Symbol('aA'), + const Symbol('aB'), + const Symbol('aC'), + const Symbol('aD'), + const Symbol('aE'), + const Symbol('aF'), + const Symbol('aG'), + const Symbol('aH'), + const Symbol('aI'), + const Symbol('aJ'), + const Symbol('aK'), + const Symbol('aL'), + const Symbol('aM'), + const Symbol('aN'), + const Symbol('aO'), + const Symbol('aP'), + const Symbol('aQ'), + const Symbol('aR'), + const Symbol('aS'), + const Symbol('aT'), + const Symbol('aU'), + const Symbol('aV'), + const Symbol('aW'), + const Symbol('aX'), + const Symbol('aY'), + const Symbol('aZ'), + const Symbol('ba'), + const Symbol('bb'), + const Symbol('bc'), + const Symbol('bd'), + const Symbol('be'), + const Symbol('bf'), + const Symbol('bg'), + const Symbol('bh'), + const Symbol('bi'), + const Symbol('bj'), + const Symbol('bk'), + const Symbol('bl'), + const Symbol('bm'), + const Symbol('bn'), + const Symbol('bo'), + const Symbol('bp'), + const Symbol('bq'), + const Symbol('br'), + const Symbol('bs'), + const Symbol('bt'), + const Symbol('bu'), + const Symbol('bv'), + const Symbol('bw'), + const Symbol('bx'), + const Symbol('by'), + const Symbol('bz'), + const Symbol('bA'), + const Symbol('bB'), + const Symbol('bC'), + const Symbol('bD'), + const Symbol('bE'), + const Symbol('bF'), + const Symbol('bG'), + const Symbol('bH'), + const Symbol('bI'), + const Symbol('bJ'), + const Symbol('bK'), + const Symbol('bL'), + const Symbol('bM'), + const Symbol('bN'), + const Symbol('bO'), + const Symbol('bP'), + const Symbol('bQ'), + const Symbol('bR'), + const Symbol('bS'), + const Symbol('bT'), + const Symbol('bU'), + const Symbol('bV'), + const Symbol('bW'), + const Symbol('bX'), + const Symbol('bY'), + const Symbol('bZ'), + const Symbol('ca'), + const Symbol('cb'), + const Symbol('cc'), + const Symbol('cd'), + const Symbol('ce'), + const Symbol('cf'), + const Symbol('cg'), + const Symbol('ch'), + const Symbol('ci'), + const Symbol('cj'), + const Symbol('ck'), + const Symbol('cl'), + const Symbol('cm'), + const Symbol('cn'), + const Symbol('co'), + const Symbol('cp'), + const Symbol('cq'), + const Symbol('cr'), + const Symbol('cs'), + const Symbol('ct'), + const Symbol('cu'), + const Symbol('cv'), + const Symbol('cw'), + const Symbol('cx'), + const Symbol('cy'), + const Symbol('cz'), + const Symbol('cA'), + const Symbol('cB'), + const Symbol('cC'), + const Symbol('cD'), + const Symbol('cE'), + const Symbol('cF'), + const Symbol('cG'), + const Symbol('cH'), + const Symbol('cI'), + const Symbol('cJ'), + const Symbol('cK'), + const Symbol('cL'), + const Symbol('cM'), + const Symbol('cN'), + const Symbol('cO'), + const Symbol('cP'), + const Symbol('cQ'), + const Symbol('cR'), + const Symbol('cS'), + const Symbol('cT'), + const Symbol('cU'), + const Symbol('cV'), + const Symbol('cW'), + const Symbol('cX'), + const Symbol('cY'), + const Symbol('cZ'), + const Symbol('da'), + const Symbol('db'), + const Symbol('dc'), + const Symbol('dd'), + const Symbol('de'), + const Symbol('df'), + const Symbol('dg'), + const Symbol('dh'), + const Symbol('di'), + const Symbol('dj'), + const Symbol('dk'), + const Symbol('dl'), + const Symbol('dm'), + const Symbol('dn'), + const Symbol('dp'), + const Symbol('dq'), + const Symbol('dr'), + const Symbol('ds'), + const Symbol('dt'), + const Symbol('du'), + const Symbol('dv'), + const Symbol('dw'), + const Symbol('dx'), + const Symbol('dy'), + const Symbol('dz'), + const Symbol('dA'), + const Symbol('dB'), + const Symbol('dC'), + const Symbol('dD'), + const Symbol('dE'), + const Symbol('dF'), + const Symbol('dG'), + const Symbol('dH'), + const Symbol('dI'), + const Symbol('dJ'), + const Symbol('dK'), + const Symbol('dL'), + const Symbol('dM'), + const Symbol('dN'), + const Symbol('dO'), + const Symbol('dP'), + const Symbol('dQ'), + const Symbol('dR'), + const Symbol('dS'), + const Symbol('dT'), + const Symbol('dU'), + const Symbol('dV'), + const Symbol('dW'), + const Symbol('dX'), + const Symbol('dY'), + const Symbol('dZ'), + const Symbol('ea'), + const Symbol('eb'), + const Symbol('ec'), + const Symbol('ed'), + const Symbol('ee'), + const Symbol('ef'), + const Symbol('eg'), + const Symbol('eh'), + const Symbol('ei'), + const Symbol('ej'), + const Symbol('ek'), + const Symbol('el'), + const Symbol('em'), + const Symbol('en'), + const Symbol('eo'), + const Symbol('ep'), + const Symbol('eq'), + const Symbol('er'), + const Symbol('es'), + const Symbol('et'), + const Symbol('eu'), + const Symbol('ev'), + const Symbol('ew'), + const Symbol('ex'), + const Symbol('ey'), + const Symbol('ez'), + const Symbol('eA'), + const Symbol('eB'), + const Symbol('eC'), + const Symbol('eD'), + const Symbol('eE'), + const Symbol('eF'), + const Symbol('eG'), + const Symbol('eH'), + const Symbol('eI'), + const Symbol('eJ'), + const Symbol('eK'), + const Symbol('eL'), + const Symbol('eM'), + const Symbol('eN'), + const Symbol('eO'), + const Symbol('eP'), + const Symbol('eQ'), + const Symbol('eR'), + const Symbol('eS'), + const Symbol('eT'), + const Symbol('eU'), + const Symbol('eV'), + const Symbol('eW'), + const Symbol('eX'), + const Symbol('eY'), + const Symbol('eZ'), + const Symbol('fa'), + const Symbol('fb'), + const Symbol('fc'), + const Symbol('fd'), + const Symbol('fe'), + const Symbol('ff'), + const Symbol('fg'), + const Symbol('fh'), + const Symbol('fi'), + const Symbol('fj'), + const Symbol('fk'), + const Symbol('fl'), + const Symbol('fm'), + const Symbol('fn'), + const Symbol('fo'), + const Symbol('fp'), + const Symbol('fq'), + const Symbol('fr'), + const Symbol('fs'), + const Symbol('ft'), + const Symbol('fu'), + const Symbol('fv'), + const Symbol('fw'), + const Symbol('fx'), + const Symbol('fy'), + const Symbol('fz'), + const Symbol('fA'), + const Symbol('fB'), + const Symbol('fC'), + const Symbol('fD'), + const Symbol('fE'), + const Symbol('fF'), + const Symbol('fG'), + const Symbol('fH'), + const Symbol('fI'), + const Symbol('fJ'), + const Symbol('fK'), + const Symbol('fL'), + const Symbol('fM'), + const Symbol('fN'), + const Symbol('fO'), + const Symbol('fP'), + const Symbol('fQ'), + const Symbol('fR'), + const Symbol('fS'), + const Symbol('fT'), + const Symbol('fU'), + const Symbol('fV'), + const Symbol('fW'), + const Symbol('fX'), + const Symbol('fY'), + const Symbol('fZ'), + const Symbol('ga'), + const Symbol('gb'), + const Symbol('gc'), + const Symbol('gd'), + const Symbol('ge'), + const Symbol('gf'), + const Symbol('gg'), + const Symbol('gh'), + const Symbol('gi'), + const Symbol('gj'), + const Symbol('gk'), + const Symbol('gl'), + const Symbol('gm'), + const Symbol('gn'), + const Symbol('go'), + const Symbol('gp'), + const Symbol('gq'), + const Symbol('gr'), + const Symbol('gs'), + const Symbol('gt'), + const Symbol('gu'), + const Symbol('gv'), + const Symbol('gw'), + const Symbol('gx'), + const Symbol('gy'), + const Symbol('gz'), + const Symbol('gA'), + const Symbol('gB'), + const Symbol('gC'), + const Symbol('gD'), + const Symbol('gE'), + const Symbol('gF'), + const Symbol('gG'), + const Symbol('gH'), + const Symbol('gI'), + const Symbol('gJ'), + const Symbol('gK'), + const Symbol('gL'), + const Symbol('gM'), + const Symbol('gN'), + const Symbol('gO'), + const Symbol('gP'), + const Symbol('gQ'), + const Symbol('gR'), + const Symbol('gS'), + const Symbol('gT'), + const Symbol('gU'), + const Symbol('gV'), + const Symbol('gW'), + const Symbol('gX'), + const Symbol('gY'), + const Symbol('gZ'), + const Symbol('ha'), + const Symbol('hb'), + const Symbol('hc'), + const Symbol('hd'), + const Symbol('he'), + const Symbol('hf'), + const Symbol('hg'), + const Symbol('hh'), + const Symbol('hi'), + const Symbol('hj'), + const Symbol('hk'), + const Symbol('hl'), + const Symbol('hm'), + const Symbol('hn'), + const Symbol('ho'), + const Symbol('hp'), + const Symbol('hq'), + const Symbol('hr'), + const Symbol('hs'), + const Symbol('ht'), + const Symbol('hu'), + const Symbol('hv'), + const Symbol('hw'), + const Symbol('hx'), + const Symbol('hy'), + const Symbol('hz'), + const Symbol('hA'), + const Symbol('hB'), + const Symbol('hC'), + const Symbol('hD'), + const Symbol('hE'), + const Symbol('hF'), + const Symbol('hG'), + const Symbol('hH'), + const Symbol('hI'), + const Symbol('hJ'), + const Symbol('hK'), + const Symbol('hL'), + const Symbol('hM'), + const Symbol('hN'), + const Symbol('hO'), + const Symbol('hP'), + const Symbol('hQ'), + const Symbol('hR'), + const Symbol('hS'), + const Symbol('hT'), + const Symbol('hU'), + const Symbol('hV'), + const Symbol('hW'), + const Symbol('hX'), + const Symbol('hY'), + const Symbol('hZ'), + const Symbol('ia'), + const Symbol('ib'), + const Symbol('ic'), + const Symbol('id'), + const Symbol('ie'), + const Symbol('ig'), + const Symbol('ih'), + const Symbol('ii'), + const Symbol('ij'), + const Symbol('ik'), + const Symbol('il'), + const Symbol('im'), + const Symbol('io'), + const Symbol('ip'), + const Symbol('iq'), + const Symbol('ir'), + const Symbol('it'), + const Symbol('iu'), + const Symbol('iv'), + const Symbol('iw'), + const Symbol('ix'), + const Symbol('iy'), + const Symbol('iz'), + const Symbol('iA'), + const Symbol('iB'), + const Symbol('iC'), + const Symbol('iD'), + const Symbol('iE'), + const Symbol('iF'), + const Symbol('iG'), + const Symbol('iH'), + const Symbol('iI'), + const Symbol('iJ'), + const Symbol('iK'), + const Symbol('iL'), + const Symbol('iM'), + const Symbol('iN'), + const Symbol('iO'), + const Symbol('iP'), + const Symbol('iQ'), + const Symbol('iR'), + const Symbol('iS'), + const Symbol('iT'), + const Symbol('iU'), + const Symbol('iV'), + const Symbol('iW'), + const Symbol('iX'), + const Symbol('iY'), + const Symbol('iZ'), + const Symbol('ja'), + const Symbol('jb'), + const Symbol('jc'), + const Symbol('jd'), + const Symbol('je'), + const Symbol('jf'), + const Symbol('jg'), + const Symbol('jh'), + const Symbol('ji'), + const Symbol('jj'), + const Symbol('jk'), + const Symbol('jl'), + const Symbol('jm'), + const Symbol('jn'), + const Symbol('jo'), + const Symbol('jp'), + const Symbol('jq'), + const Symbol('jr'), + const Symbol('js'), + const Symbol('jt'), + const Symbol('ju'), + const Symbol('jv'), + const Symbol('jw'), + const Symbol('jx'), + const Symbol('jy'), + const Symbol('jz'), + const Symbol('jA'), + const Symbol('jB'), + const Symbol('jC'), + const Symbol('jD'), + const Symbol('jE'), + const Symbol('jF'), + const Symbol('jG'), + const Symbol('jH'), + const Symbol('jI'), + const Symbol('jJ'), + const Symbol('jK'), + const Symbol('jL'), + const Symbol('jM'), + const Symbol('jN'), + const Symbol('jO'), + const Symbol('jP'), + const Symbol('jQ'), + const Symbol('jR'), + const Symbol('jS'), + const Symbol('jT'), + const Symbol('jU'), + const Symbol('jV'), + const Symbol('jW'), + const Symbol('jX'), + const Symbol('jY'), + const Symbol('jZ'), + const Symbol('ka'), + const Symbol('kb'), + const Symbol('kc'), + const Symbol('kd'), + const Symbol('ke'), + const Symbol('kf'), + const Symbol('kg'), + const Symbol('kh'), + const Symbol('ki'), + const Symbol('kj'), + const Symbol('kk'), + const Symbol('kl'), + const Symbol('km'), + const Symbol('kn'), + const Symbol('ko'), + const Symbol('kp'), + const Symbol('kq'), + const Symbol('kr'), + const Symbol('ks'), + const Symbol('kt'), + const Symbol('ku'), + const Symbol('kv'), + const Symbol('kw'), + const Symbol('kx'), + const Symbol('ky'), + const Symbol('kz'), + const Symbol('kA'), + const Symbol('kB'), + const Symbol('kC'), + const Symbol('kD'), + const Symbol('kE'), + const Symbol('kF'), + const Symbol('kG'), + const Symbol('kH'), + const Symbol('kI'), + const Symbol('kJ'), + const Symbol('kK'), + const Symbol('kL'), + const Symbol('kM'), + const Symbol('kN'), + const Symbol('kO'), + const Symbol('kP'), + const Symbol('kQ'), + const Symbol('kR'), + const Symbol('kS'), + const Symbol('kT'), + const Symbol('kU'), + const Symbol('kV'), + const Symbol('kW'), + const Symbol('kX'), + const Symbol('kY'), + const Symbol('kZ'), + const Symbol('la'), + const Symbol('lb'), + const Symbol('lc'), + const Symbol('ld'), + const Symbol('le'), + const Symbol('lf'), + const Symbol('lg'), + const Symbol('lh'), + const Symbol('li'), + const Symbol('lj'), + const Symbol('lk'), + const Symbol('ll'), + const Symbol('lm'), + const Symbol('ln'), + const Symbol('lo'), + const Symbol('lp'), + const Symbol('lq'), + const Symbol('lr'), + const Symbol('ls'), + const Symbol('lt'), + const Symbol('lu'), + const Symbol('lv'), + const Symbol('lw'), + const Symbol('lx'), + const Symbol('ly'), + const Symbol('lz'), + const Symbol('lA'), + const Symbol('lB'), + const Symbol('lC'), + const Symbol('lD'), + const Symbol('lE'), + const Symbol('lF'), + const Symbol('lG'), + const Symbol('lH'), + const Symbol('lI'), + const Symbol('lJ'), + const Symbol('lK'), + const Symbol('lL'), + const Symbol('lM'), + const Symbol('lN'), + const Symbol('lO'), + const Symbol('lP'), + const Symbol('lQ'), + const Symbol('lR'), + const Symbol('lS'), + const Symbol('lT'), + const Symbol('lU'), + const Symbol('lV'), + const Symbol('lW'), + const Symbol('lX'), + const Symbol('lY'), + const Symbol('lZ'), + const Symbol('ma'), + const Symbol('mb'), + const Symbol('mc'), + const Symbol('md'), + const Symbol('me'), + const Symbol('mf'), + const Symbol('mg'), + const Symbol('mh'), + const Symbol('mi'), + const Symbol('mj'), + const Symbol('mk'), + const Symbol('ml'), + const Symbol('mm'), + const Symbol('mn'), + const Symbol('mo'), + const Symbol('mp'), + const Symbol('mq'), + const Symbol('mr'), + const Symbol('ms'), + const Symbol('mt'), + const Symbol('mu'), + const Symbol('mv'), + const Symbol('mw'), + const Symbol('mx'), + const Symbol('my'), + const Symbol('mz'), + const Symbol('mA'), + const Symbol('mB'), + const Symbol('mC'), + const Symbol('mD'), + const Symbol('mE'), + const Symbol('mF'), + const Symbol('mG'), + const Symbol('mH'), + const Symbol('mI'), + const Symbol('mJ'), + const Symbol('mK'), + const Symbol('mL'), + const Symbol('mM'), + const Symbol('mN'), + const Symbol('mO'), + const Symbol('mP'), + const Symbol('mQ'), + const Symbol('mR'), + const Symbol('mS'), + const Symbol('mT'), + const Symbol('mU'), + const Symbol('mV'), + const Symbol('mW'), + const Symbol('mX'), + const Symbol('mY'), + const Symbol('mZ'), + const Symbol('na'), + const Symbol('nb'), + const Symbol('nc'), + const Symbol('nd'), + const Symbol('ne'), + const Symbol('nf'), + const Symbol('ng'), + const Symbol('nh'), + const Symbol('ni'), + const Symbol('nj'), + const Symbol('nk'), + const Symbol('nl'), + const Symbol('nm'), + const Symbol('nn'), + const Symbol('no'), + const Symbol('np'), + const Symbol('nq'), + const Symbol('nr'), + const Symbol('ns'), + const Symbol('nt'), + const Symbol('nu'), + const Symbol('nv'), + const Symbol('nw'), + const Symbol('nx'), + const Symbol('ny'), + const Symbol('nz'), + const Symbol('nA'), + const Symbol('nB'), + const Symbol('nC'), + const Symbol('nD'), + const Symbol('nE'), + const Symbol('nF'), + const Symbol('nG'), + const Symbol('nH'), + const Symbol('nI'), + const Symbol('nJ'), + const Symbol('nK'), + const Symbol('nL'), + const Symbol('nM'), + const Symbol('nN'), + const Symbol('nO'), + const Symbol('nP'), + const Symbol('nQ'), + const Symbol('nR'), + const Symbol('nS'), + const Symbol('nT'), + const Symbol('nU'), + const Symbol('nV'), + const Symbol('nW'), + const Symbol('nX'), + const Symbol('nY'), + const Symbol('nZ'), + const Symbol('oa'), + const Symbol('ob'), + const Symbol('oc'), + const Symbol('od'), + const Symbol('oe'), + const Symbol('of'), + const Symbol('og'), + const Symbol('oh'), + const Symbol('oi'), + const Symbol('oj'), + const Symbol('ok'), + const Symbol('ol'), + const Symbol('om'), + const Symbol('on'), + const Symbol('oo'), + const Symbol('op'), + const Symbol('oq'), + const Symbol('or'), + const Symbol('os'), + const Symbol('ot'), + const Symbol('ou'), + const Symbol('ov'), + const Symbol('ow'), + const Symbol('ox'), + const Symbol('oy'), + const Symbol('oz'), + const Symbol('oA'), + const Symbol('oB'), + const Symbol('oC'), + const Symbol('oD'), + const Symbol('oE'), + const Symbol('oF'), + const Symbol('oG'), + const Symbol('oH'), + const Symbol('oI'), + const Symbol('oJ'), + const Symbol('oK'), + const Symbol('oL'), + const Symbol('oM'), + const Symbol('oN'), + const Symbol('oO'), + const Symbol('oP'), + const Symbol('oQ'), + const Symbol('oR'), + const Symbol('oS'), + const Symbol('oT'), + const Symbol('oU'), + const Symbol('oV'), + const Symbol('oW'), + const Symbol('oX'), + const Symbol('oY'), + const Symbol('oZ'), + const Symbol('pa'), + const Symbol('pb'), + const Symbol('pc'), + const Symbol('pd'), + const Symbol('pe'), + const Symbol('pf'), + const Symbol('pg'), + const Symbol('ph'), + const Symbol('pi'), + const Symbol('pj'), + const Symbol('pk'), + const Symbol('pl'), + const Symbol('pm'), + const Symbol('pn'), + const Symbol('po'), + const Symbol('pp'), + const Symbol('pq'), + const Symbol('pr'), + const Symbol('ps'), + const Symbol('pt'), + const Symbol('pu'), + const Symbol('pv'), + const Symbol('pw'), + const Symbol('px'), + const Symbol('py'), + const Symbol('pz'), + const Symbol('pA'), + const Symbol('pB'), + const Symbol('pC'), + const Symbol('pD'), + const Symbol('pE'), + const Symbol('pF'), + const Symbol('pG'), + const Symbol('pH'), + const Symbol('pI'), + const Symbol('pJ'), + const Symbol('pK'), + const Symbol('pL'), + const Symbol('pM'), + const Symbol('pN'), + const Symbol('pO'), + const Symbol('pP'), + const Symbol('pQ'), + const Symbol('pR'), + const Symbol('pS'), + const Symbol('pT'), + const Symbol('pU'), + const Symbol('pV'), + const Symbol('pW'), + const Symbol('pX'), + const Symbol('pY'), + const Symbol('pZ'), + const Symbol('qa'), + const Symbol('qb'), + const Symbol('qc'), + const Symbol('qd'), + const Symbol('qe'), + const Symbol('qf'), + const Symbol('qg'), + const Symbol('qh'), + const Symbol('qi'), + const Symbol('qj'), + const Symbol('qk'), + const Symbol('ql'), + const Symbol('qm'), + const Symbol('qn'), + const Symbol('qo'), + const Symbol('qp'), + const Symbol('qq'), + const Symbol('qr'), + const Symbol('qs'), + const Symbol('qt'), + const Symbol('qu'), + const Symbol('qv'), + const Symbol('qw'), + const Symbol('qx'), + const Symbol('qy'), + const Symbol('qz'), + const Symbol('qA'), + const Symbol('qB'), + const Symbol('qC'), + const Symbol('qD'), + const Symbol('qE'), + const Symbol('qF'), + const Symbol('qG'), + const Symbol('qH'), + const Symbol('qI'), + const Symbol('qJ'), + const Symbol('qK'), + const Symbol('qL'), + const Symbol('qM'), + const Symbol('qN'), + const Symbol('qO'), + const Symbol('qP'), + const Symbol('qQ'), + const Symbol('qR'), + const Symbol('qS'), + const Symbol('qT'), + const Symbol('qU'), + const Symbol('qV'), + const Symbol('qW'), + const Symbol('qX'), + const Symbol('qY'), + const Symbol('qZ'), + const Symbol('ra'), + const Symbol('rb'), + const Symbol('rc'), + const Symbol('rd'), + const Symbol('re'), + const Symbol('rf'), + const Symbol('rg'), + const Symbol('rh'), + const Symbol('ri'), + const Symbol('rj'), + const Symbol('rk'), + const Symbol('rl'), + const Symbol('rm'), + const Symbol('rn'), + const Symbol('ro'), + const Symbol('rp'), + const Symbol('rq'), + const Symbol('rr'), + const Symbol('rs'), + const Symbol('rt'), + const Symbol('ru'), + const Symbol('rv'), + const Symbol('rw'), + const Symbol('rx'), + const Symbol('ry'), + const Symbol('rz'), + const Symbol('rA'), + const Symbol('rB'), + const Symbol('rC'), + const Symbol('rD'), + const Symbol('rE'), + const Symbol('rF'), + const Symbol('rG'), + const Symbol('rH'), + const Symbol('rI'), + const Symbol('rJ'), + const Symbol('rK'), + const Symbol('rL'), + const Symbol('rM'), + const Symbol('rN'), + const Symbol('rO'), + const Symbol('rP'), + const Symbol('rQ'), + const Symbol('rR'), + const Symbol('rS'), + const Symbol('rT'), + const Symbol('rU'), + const Symbol('rV'), + const Symbol('rW'), + const Symbol('rX'), + const Symbol('rY'), + const Symbol('rZ'), + const Symbol('sa'), + const Symbol('sb'), + const Symbol('sc'), + const Symbol('sd'), + const Symbol('se'), + const Symbol('sf'), + const Symbol('sg'), + const Symbol('sh'), + const Symbol('si'), + const Symbol('sj'), + const Symbol('sk'), + const Symbol('sl'), + const Symbol('sm'), + const Symbol('sn'), + const Symbol('so'), + const Symbol('sp'), + const Symbol('sq'), + const Symbol('sr'), + const Symbol('ss'), + const Symbol('st'), + const Symbol('su'), + const Symbol('sv'), + const Symbol('sw'), + const Symbol('sx'), + const Symbol('sy'), + const Symbol('sz'), + const Symbol('sA'), + const Symbol('sB'), + const Symbol('sC'), + const Symbol('sD'), + const Symbol('sE'), + const Symbol('sF'), + const Symbol('sG'), + const Symbol('sH'), + const Symbol('sI'), + const Symbol('sJ'), + const Symbol('sK'), + const Symbol('sL'), + const Symbol('sM'), + const Symbol('sN'), + const Symbol('sO'), + const Symbol('sP'), + const Symbol('sQ'), + const Symbol('sR'), + const Symbol('sS'), + const Symbol('sT'), + const Symbol('sU'), + const Symbol('sV'), + const Symbol('sW'), + const Symbol('sX'), + const Symbol('sY'), + const Symbol('sZ'), + const Symbol('ta'), + const Symbol('tb'), + const Symbol('tc'), + const Symbol('td'), + const Symbol('te'), + const Symbol('tf'), + const Symbol('tg'), + const Symbol('th'), + const Symbol('ti'), + const Symbol('tj'), + const Symbol('tk'), + const Symbol('tl'), + const Symbol('tm'), + const Symbol('tn'), + const Symbol('to'), + const Symbol('tp'), + const Symbol('tq'), + const Symbol('tr'), + const Symbol('ts'), + const Symbol('tt'), + const Symbol('tu'), + const Symbol('tv'), + const Symbol('tw'), + const Symbol('tx'), + const Symbol('ty'), + const Symbol('tz'), + const Symbol('tA'), + const Symbol('tB'), + const Symbol('tC'), + const Symbol('tD'), + const Symbol('tE'), + const Symbol('tF'), + const Symbol('tG'), + const Symbol('tH'), + const Symbol('tI'), + const Symbol('tJ'), + const Symbol('tK'), + const Symbol('tL'), + const Symbol('tM'), + const Symbol('tN'), + const Symbol('tO'), + const Symbol('tP'), + const Symbol('tQ'), + const Symbol('tR'), + const Symbol('tS'), + const Symbol('tT'), + const Symbol('tU'), + const Symbol('tV'), + const Symbol('tW'), + const Symbol('tX'), + const Symbol('tY'), + const Symbol('tZ'), + const Symbol('ua'), + const Symbol('ub'), + const Symbol('uc'), + const Symbol('ud'), + const Symbol('ue'), + const Symbol('uf'), + const Symbol('ug'), + const Symbol('uh'), + const Symbol('ui'), + const Symbol('uj'), + const Symbol('uk'), + const Symbol('ul'), + const Symbol('um'), + const Symbol('un'), + const Symbol('uo'), + const Symbol('up'), + const Symbol('uq'), + const Symbol('ur'), + const Symbol('us'), + const Symbol('ut'), + const Symbol('uu'), + const Symbol('uv'), + const Symbol('uw'), + const Symbol('ux'), + const Symbol('uy'), + const Symbol('uz'), + const Symbol('uA'), + const Symbol('uB'), + const Symbol('uC'), + const Symbol('uD'), + const Symbol('uE'), + const Symbol('uF'), + const Symbol('uG'), + const Symbol('uH'), + const Symbol('uI'), + const Symbol('uJ'), + const Symbol('uK'), + const Symbol('uL'), + const Symbol('uM'), + const Symbol('uN'), + const Symbol('uO'), + const Symbol('uP'), + const Symbol('uQ'), + const Symbol('uR'), + const Symbol('uS'), + const Symbol('uT'), + const Symbol('uU'), + const Symbol('uV'), + const Symbol('uW'), + const Symbol('uX'), + const Symbol('uY'), + const Symbol('uZ'), + const Symbol('va'), + const Symbol('vb'), + const Symbol('vc'), + const Symbol('vd'), + const Symbol('ve'), + const Symbol('vf'), + const Symbol('vg'), + const Symbol('vh'), + const Symbol('vi'), + const Symbol('vj'), + const Symbol('vk'), + const Symbol('vl'), + const Symbol('vm'), + const Symbol('vn'), + const Symbol('vo'), + const Symbol('vp'), + const Symbol('vq'), + const Symbol('vr'), + const Symbol('vs'), + const Symbol('vt'), + const Symbol('vu'), + const Symbol('vv'), + const Symbol('vw'), + const Symbol('vx'), + const Symbol('vy'), + const Symbol('vz'), + const Symbol('vA'), + const Symbol('vB'), + const Symbol('vC'), + const Symbol('vD'), + const Symbol('vE'), + const Symbol('vF'), + const Symbol('vG'), + const Symbol('vH'), + const Symbol('vI'), + const Symbol('vJ'), + const Symbol('vK'), + const Symbol('vL'), + const Symbol('vM'), + const Symbol('vN'), + const Symbol('vO'), + const Symbol('vP'), + const Symbol('vQ'), + const Symbol('vR'), + const Symbol('vS'), + const Symbol('vT'), + const Symbol('vU'), + const Symbol('vV'), + const Symbol('vW'), + const Symbol('vX'), + const Symbol('vY'), + const Symbol('vZ'), + const Symbol('wa'), + const Symbol('wb'), + const Symbol('wc'), + const Symbol('wd'), + const Symbol('we'), + const Symbol('wf'), + const Symbol('wg'), + const Symbol('wh'), + const Symbol('wi'), + const Symbol('wj'), + const Symbol('wk'), + const Symbol('wl'), + const Symbol('wm'), + const Symbol('wn'), + const Symbol('wo'), + const Symbol('wp'), + const Symbol('wq'), + const Symbol('wr'), + const Symbol('ws'), + const Symbol('wt'), + const Symbol('wu'), + const Symbol('wv'), + const Symbol('ww'), + const Symbol('wx'), + const Symbol('wy'), + const Symbol('wz'), + const Symbol('wA'), + const Symbol('wB'), + const Symbol('wC'), + const Symbol('wD'), + const Symbol('wE'), + const Symbol('wF'), + const Symbol('wG'), + const Symbol('wH'), + const Symbol('wI'), + const Symbol('wJ'), + const Symbol('wK'), + const Symbol('wL'), + const Symbol('wM'), + const Symbol('wN'), + const Symbol('wO'), + const Symbol('wP'), + const Symbol('wQ'), + const Symbol('wR'), + const Symbol('wS'), + const Symbol('wT'), + const Symbol('wU'), + const Symbol('wV'), + const Symbol('wW'), + const Symbol('wX'), + const Symbol('wY'), + const Symbol('wZ'), + const Symbol('xa'), + const Symbol('xb'), + const Symbol('xc'), + const Symbol('xd'), + const Symbol('xe'), + const Symbol('xf'), + const Symbol('xg'), + const Symbol('xh'), + const Symbol('xi'), + const Symbol('xj'), + const Symbol('xk'), + const Symbol('xl'), + const Symbol('xm'), + const Symbol('xn'), + const Symbol('xo'), + const Symbol('xp'), + const Symbol('xq'), + const Symbol('xr'), + const Symbol('xs'), + const Symbol('xt'), + const Symbol('xu'), + const Symbol('xv'), + const Symbol('xw'), + const Symbol('xx'), + const Symbol('xy'), + const Symbol('xz'), + const Symbol('xA'), + const Symbol('xB'), + const Symbol('xC'), + const Symbol('xD'), + const Symbol('xE'), + const Symbol('xF'), + const Symbol('xG'), + const Symbol('xH'), + const Symbol('xI'), + const Symbol('xJ'), + const Symbol('xK'), + const Symbol('xL'), + const Symbol('xM'), + const Symbol('xN'), + const Symbol('xO'), + const Symbol('xP'), + const Symbol('xQ'), + const Symbol('xR'), + const Symbol('xS'), + const Symbol('xT'), + const Symbol('xU'), + const Symbol('xV'), + const Symbol('xW'), + const Symbol('xX'), + const Symbol('xY'), + const Symbol('xZ'), + const Symbol('ya'), + const Symbol('yb'), + const Symbol('yc'), + const Symbol('yd'), + const Symbol('ye'), + const Symbol('yf'), + const Symbol('yg'), + const Symbol('yh'), + const Symbol('yi'), + const Symbol('yj'), + const Symbol('yk'), + const Symbol('yl'), + const Symbol('ym'), + const Symbol('yn'), + const Symbol('yo'), + const Symbol('yp'), + const Symbol('yq'), + const Symbol('yr'), + const Symbol('ys'), + const Symbol('yt'), + const Symbol('yu'), + const Symbol('yv'), + const Symbol('yw'), + const Symbol('yx'), + const Symbol('yy'), + const Symbol('yz'), + const Symbol('yA'), + const Symbol('yB'), + const Symbol('yC'), + const Symbol('yD'), + const Symbol('yE'), + const Symbol('yF'), + const Symbol('yG'), + const Symbol('yH'), + const Symbol('yI'), + const Symbol('yJ'), + const Symbol('yK'), + const Symbol('yL'), + const Symbol('yM'), + const Symbol('yN'), + const Symbol('yO'), + const Symbol('yP'), + const Symbol('yQ'), + const Symbol('yR'), + const Symbol('yS'), + const Symbol('yT'), + const Symbol('yU'), + const Symbol('yV'), + const Symbol('yW'), + const Symbol('yX'), + const Symbol('yY'), + const Symbol('yZ'), + const Symbol('za'), + const Symbol('zb'), + const Symbol('zc'), + const Symbol('zd'), + const Symbol('ze'), + const Symbol('zf'), + const Symbol('zg'), + const Symbol('zh'), + const Symbol('zi'), + const Symbol('zj'), + const Symbol('zk'), + const Symbol('zl'), + const Symbol('zm'), + const Symbol('zn'), + const Symbol('zo'), + const Symbol('zp'), + const Symbol('zq'), + const Symbol('zr'), + const Symbol('zs'), + const Symbol('zt'), + const Symbol('zu'), + const Symbol('zv'), + const Symbol('zw'), + const Symbol('zx'), + const Symbol('zy'), + const Symbol('zz'), + const Symbol('zA'), + const Symbol('zB'), + const Symbol('zC'), + const Symbol('zD'), + const Symbol('zE'), + const Symbol('zF'), + const Symbol('zG'), + const Symbol('zH'), + const Symbol('zI'), + const Symbol('zJ'), + const Symbol('zK'), + const Symbol('zL'), + const Symbol('zM'), + const Symbol('zN'), + const Symbol('zO'), + const Symbol('zP'), + const Symbol('zQ'), + const Symbol('zR'), + const Symbol('zS'), + const Symbol('zT'), + const Symbol('zU'), + const Symbol('zV'), + const Symbol('zW'), + const Symbol('zX'), + const Symbol('zY'), + const Symbol('zZ'), + const Symbol('Aa'), + const Symbol('Ab'), + const Symbol('Ac'), + const Symbol('Ad'), + const Symbol('Ae'), + const Symbol('Af'), + const Symbol('Ag'), + const Symbol('Ah'), + const Symbol('Ai'), + const Symbol('Aj'), + const Symbol('Ak'), + const Symbol('Al'), + const Symbol('Am'), + const Symbol('An'), + const Symbol('Ao'), + const Symbol('Ap'), + const Symbol('Aq'), + const Symbol('Ar'), + const Symbol('As'), + const Symbol('At'), + const Symbol('Au'), + const Symbol('Av'), + const Symbol('Aw'), + const Symbol('Ax'), + const Symbol('Ay'), + const Symbol('Az'), + const Symbol('AA'), + const Symbol('AB'), + const Symbol('AC'), + const Symbol('AD'), + const Symbol('AE'), + const Symbol('AF'), + const Symbol('AG'), + const Symbol('AH'), + const Symbol('AI'), + const Symbol('AJ'), + const Symbol('AK'), + const Symbol('AL'), + const Symbol('AM'), + const Symbol('AN'), + const Symbol('AO'), + const Symbol('AP'), + const Symbol('AQ'), + const Symbol('AR'), + const Symbol('AS'), + const Symbol('AT'), + const Symbol('AU'), + const Symbol('AV'), + const Symbol('AW'), + const Symbol('AX'), + const Symbol('AY'), + const Symbol('AZ'), + const Symbol('Ba'), + const Symbol('Bb'), + const Symbol('Bc'), + const Symbol('Bd'), + const Symbol('Be'), + const Symbol('Bf'), + const Symbol('Bg'), + const Symbol('Bh'), + const Symbol('Bi'), + const Symbol('Bj'), + const Symbol('Bk'), + const Symbol('Bl'), + const Symbol('Bm'), + const Symbol('Bn'), + const Symbol('Bo'), + const Symbol('Bp'), + const Symbol('Bq'), + const Symbol('Br'), + const Symbol('Bs'), + const Symbol('Bt'), + const Symbol('Bu'), + const Symbol('Bv'), + const Symbol('Bw'), + const Symbol('Bx'), + const Symbol('By'), + const Symbol('Bz'), + const Symbol('BA'), + const Symbol('BB'), + const Symbol('BC'), + const Symbol('BD'), + const Symbol('BE'), + const Symbol('BF'), + const Symbol('BG'), + const Symbol('BH'), + const Symbol('BI'), + const Symbol('BJ'), + const Symbol('BK'), + const Symbol('BL'), + const Symbol('BM'), + const Symbol('BN'), + const Symbol('BO'), + const Symbol('BP'), + const Symbol('BQ'), + const Symbol('BR'), + const Symbol('BS'), + const Symbol('BT'), + const Symbol('BU'), + const Symbol('BV'), + const Symbol('BW'), + const Symbol('BX'), + const Symbol('BY'), + const Symbol('BZ'), + const Symbol('Ca'), + const Symbol('Cb'), + const Symbol('Cc'), + const Symbol('Cd'), + const Symbol('Ce'), + const Symbol('Cf'), + const Symbol('Cg'), + const Symbol('Ch'), + const Symbol('Ci'), + const Symbol('Cj'), + const Symbol('Ck'), + const Symbol('Cl'), + const Symbol('Cm'), + const Symbol('Cn'), + const Symbol('Co'), + const Symbol('Cp'), + const Symbol('Cq'), + const Symbol('Cr'), + const Symbol('Cs'), + const Symbol('Ct'), + const Symbol('Cu'), + const Symbol('Cv'), + const Symbol('Cw'), + const Symbol('Cx'), + const Symbol('Cy'), + const Symbol('Cz'), + const Symbol('CA'), + const Symbol('CB'), + const Symbol('CC'), + const Symbol('CD'), + const Symbol('CE'), + const Symbol('CF'), + const Symbol('CG'), + const Symbol('CH'), + const Symbol('CI'), + const Symbol('CJ'), + const Symbol('CK'), + const Symbol('CL'), + const Symbol('CM'), + const Symbol('CN'), + const Symbol('CO'), + const Symbol('CP'), + const Symbol('CQ'), + const Symbol('CR'), + const Symbol('CS'), + const Symbol('CT'), + const Symbol('CU'), + const Symbol('CV'), + const Symbol('CW'), + const Symbol('CX'), + const Symbol('CY'), + const Symbol('CZ'), + const Symbol('Da'), + const Symbol('Db'), + const Symbol('Dc'), + const Symbol('Dd'), + const Symbol('De'), + const Symbol('Df'), + const Symbol('Dg'), + const Symbol('Dh'), + const Symbol('Di'), + const Symbol('Dj'), + const Symbol('Dk'), + const Symbol('Dl'), + const Symbol('Dm'), + const Symbol('Dn'), + const Symbol('Do'), + const Symbol('Dp'), + const Symbol('Dq'), + const Symbol('Dr'), + const Symbol('Ds'), + const Symbol('Dt'), + const Symbol('Du'), + const Symbol('Dv'), + const Symbol('Dw'), + const Symbol('Dx'), + const Symbol('Dy'), + const Symbol('Dz'), + const Symbol('DA'), + const Symbol('DB'), + const Symbol('DC'), + const Symbol('DD'), + const Symbol('DE'), + const Symbol('DF'), + const Symbol('DG'), + const Symbol('DH'), + const Symbol('DI'), + const Symbol('DJ'), + const Symbol('DK'), + const Symbol('DL'), + const Symbol('DM'), + const Symbol('DN'), + const Symbol('DO'), + const Symbol('DP'), + const Symbol('DQ'), + const Symbol('DR'), + const Symbol('DS'), + const Symbol('DT'), + const Symbol('DU'), + const Symbol('DV'), + const Symbol('DW'), + const Symbol('DX'), + const Symbol('DY'), + const Symbol('DZ'), + const Symbol('Ea'), + const Symbol('Eb'), + const Symbol('Ec'), + const Symbol('Ed'), + const Symbol('Ee'), + const Symbol('Ef'), + const Symbol('Eg'), + const Symbol('Eh'), + const Symbol('Ei'), + const Symbol('Ej'), + const Symbol('Ek'), + const Symbol('El'), + const Symbol('Em'), + const Symbol('En'), + const Symbol('Eo'), + const Symbol('Ep'), + const Symbol('Eq'), + const Symbol('Er'), + const Symbol('Es'), + const Symbol('Et'), + const Symbol('Eu'), + const Symbol('Ev'), + const Symbol('Ew'), + const Symbol('Ex'), + const Symbol('Ey'), + const Symbol('Ez'), + const Symbol('EA'), + const Symbol('EB'), + const Symbol('EC'), + const Symbol('ED'), + const Symbol('EE'), + const Symbol('EF'), + const Symbol('EG'), + const Symbol('EH'), + const Symbol('EI'), + const Symbol('EJ'), + const Symbol('EK'), + const Symbol('EL'), + const Symbol('EM'), + const Symbol('EN'), + const Symbol('EO'), + const Symbol('EP'), + const Symbol('EQ'), + const Symbol('ER'), + const Symbol('ES'), + const Symbol('ET'), + const Symbol('EU'), + const Symbol('EV'), + const Symbol('EW'), + const Symbol('EX'), + const Symbol('EY'), + const Symbol('EZ'), + const Symbol('Fa'), + const Symbol('Fb'), + const Symbol('Fc'), + const Symbol('Fd'), + const Symbol('Fe'), + const Symbol('Ff'), + const Symbol('Fg'), + const Symbol('Fh'), + const Symbol('Fi'), + const Symbol('Fj'), + const Symbol('Fk'), + const Symbol('Fl'), + const Symbol('Fm'), + const Symbol('Fn'), + const Symbol('Fo'), + const Symbol('Fp'), + const Symbol('Fq'), + const Symbol('Fr'), + const Symbol('Fs'), + const Symbol('Ft'), + const Symbol('Fu'), + const Symbol('Fv'), + const Symbol('Fw'), + const Symbol('Fx'), + const Symbol('Fy'), + const Symbol('Fz'), + const Symbol('FA'), + const Symbol('FB'), + const Symbol('FC'), + const Symbol('FD'), + const Symbol('FE'), + const Symbol('FF'), + const Symbol('FG'), + const Symbol('FH'), + const Symbol('FI'), + const Symbol('FJ'), + const Symbol('FK'), + const Symbol('FL'), + const Symbol('FM'), + const Symbol('FN'), + const Symbol('FO'), + const Symbol('FP'), + const Symbol('FQ'), + const Symbol('FR'), + const Symbol('FS'), + const Symbol('FT'), + const Symbol('FU'), + const Symbol('FV'), + const Symbol('FW'), + const Symbol('FX'), + const Symbol('FY'), + const Symbol('FZ'), + const Symbol('Ga'), + const Symbol('Gb'), + const Symbol('Gc'), + const Symbol('Gd'), + const Symbol('Ge'), + const Symbol('Gf'), + const Symbol('Gg'), + const Symbol('Gh'), + const Symbol('Gi'), + const Symbol('Gj'), + const Symbol('Gk'), + const Symbol('Gl'), + const Symbol('Gm'), + const Symbol('Gn'), + const Symbol('Go'), + const Symbol('Gp'), + const Symbol('Gq'), + const Symbol('Gr'), + const Symbol('Gs'), + const Symbol('Gt'), + const Symbol('Gu'), + const Symbol('Gv'), + const Symbol('Gw'), + const Symbol('Gx'), + const Symbol('Gy'), + const Symbol('Gz'), + const Symbol('GA'), + const Symbol('GB'), + const Symbol('GC'), + const Symbol('GD'), + const Symbol('GE'), + const Symbol('GF'), + const Symbol('GG'), + const Symbol('GH'), + const Symbol('GI'), + const Symbol('GJ'), + const Symbol('GK'), + const Symbol('GL'), + const Symbol('GM'), + const Symbol('GN'), + const Symbol('GO'), + const Symbol('GP'), + const Symbol('GQ'), + const Symbol('GR'), + const Symbol('GS'), + const Symbol('GT'), + const Symbol('GU'), + const Symbol('GV'), + const Symbol('GW'), + const Symbol('GX'), + const Symbol('GY'), + const Symbol('GZ'), + const Symbol('Ha'), + const Symbol('Hb'), + const Symbol('Hc'), + const Symbol('Hd'), + const Symbol('He'), + const Symbol('Hf'), + const Symbol('Hg'), + const Symbol('Hh'), + const Symbol('Hi'), + const Symbol('Hj'), + const Symbol('Hk'), + const Symbol('Hl'), + const Symbol('Hm'), + const Symbol('Hn'), + const Symbol('Ho'), + const Symbol('Hp'), + const Symbol('Hq'), + const Symbol('Hr'), + const Symbol('Hs'), + const Symbol('Ht'), + const Symbol('Hu'), + const Symbol('Hv'), + const Symbol('Hw'), + const Symbol('Hx'), + const Symbol('Hy'), + const Symbol('Hz'), + const Symbol('HA'), + const Symbol('HB'), + const Symbol('HC'), + const Symbol('HD'), + const Symbol('HE'), + const Symbol('HF'), + const Symbol('HG'), + const Symbol('HH'), + const Symbol('HI'), + const Symbol('HJ'), + const Symbol('HK'), + const Symbol('HL'), + const Symbol('HM'), + const Symbol('HN'), + const Symbol('HO'), + const Symbol('HP'), + const Symbol('HQ'), + const Symbol('HR'), + const Symbol('HS'), + const Symbol('HT'), + const Symbol('HU'), + const Symbol('HV'), + const Symbol('HW'), + const Symbol('HX'), + const Symbol('HY'), + const Symbol('HZ'), + const Symbol('Ia'), + const Symbol('Ib'), + const Symbol('Ic'), + const Symbol('Id'), + const Symbol('Ie'), + const Symbol('If'), + const Symbol('Ig'), + const Symbol('Ih'), + const Symbol('Ii'), + const Symbol('Ij'), + const Symbol('Ik'), + const Symbol('Il'), + const Symbol('Im'), + const Symbol('In'), + const Symbol('Io'), + const Symbol('Ip'), + const Symbol('Iq'), + const Symbol('Ir'), + const Symbol('Is'), + const Symbol('It'), + const Symbol('Iu'), + const Symbol('Iv'), + const Symbol('Iw'), + const Symbol('Ix'), + const Symbol('Iy'), + const Symbol('Iz'), + const Symbol('IA'), + const Symbol('IB'), + const Symbol('IC'), + const Symbol('ID'), + const Symbol('IE'), + const Symbol('IF'), + const Symbol('IG'), + const Symbol('IH'), + const Symbol('II'), + const Symbol('IJ'), + const Symbol('IK'), + const Symbol('IL'), + const Symbol('IM'), + const Symbol('IN'), + const Symbol('IO'), + const Symbol('IP'), + const Symbol('IQ'), + const Symbol('IR'), + const Symbol('IS'), + const Symbol('IT'), + const Symbol('IU'), + const Symbol('IV'), + const Symbol('IW'), + const Symbol('IX'), + const Symbol('IY'), + const Symbol('IZ'), + const Symbol('Ja'), + const Symbol('Jb'), + const Symbol('Jc'), + const Symbol('Jd'), + const Symbol('Je'), + const Symbol('Jf'), + const Symbol('Jg'), + const Symbol('Jh'), + const Symbol('Ji'), + const Symbol('Jj'), + const Symbol('Jk'), + const Symbol('Jl'), + const Symbol('Jm'), + const Symbol('Jn'), + const Symbol('Jo'), + const Symbol('Jp'), + const Symbol('Jq'), + const Symbol('Jr'), + const Symbol('Js'), + const Symbol('Jt'), + const Symbol('Ju'), + const Symbol('Jv'), + const Symbol('Jw'), + const Symbol('Jx'), + const Symbol('Jy'), + const Symbol('Jz'), + const Symbol('JA'), + const Symbol('JB'), + const Symbol('JC'), + const Symbol('JD'), + const Symbol('JE'), + const Symbol('JF'), + const Symbol('JG'), + const Symbol('JH'), + const Symbol('JI'), + const Symbol('JJ'), + const Symbol('JK'), + const Symbol('JL'), + const Symbol('JM'), + const Symbol('JN'), + const Symbol('JO'), + const Symbol('JP'), + const Symbol('JQ'), + const Symbol('JR'), + const Symbol('JS'), + const Symbol('JT'), + const Symbol('JU'), + const Symbol('JV'), + const Symbol('JW'), + const Symbol('JX'), + const Symbol('JY'), + const Symbol('JZ'), + const Symbol('Ka'), + const Symbol('Kb'), + const Symbol('Kc'), + const Symbol('Kd'), + const Symbol('Ke'), + const Symbol('Kf'), + const Symbol('Kg'), + const Symbol('Kh'), + const Symbol('Ki'), + const Symbol('Kj'), + const Symbol('Kk'), + const Symbol('Kl'), + const Symbol('Km'), + const Symbol('Kn'), + const Symbol('Ko'), + const Symbol('Kp'), + const Symbol('Kq'), + const Symbol('Kr'), + const Symbol('Ks'), + const Symbol('Kt'), + const Symbol('Ku'), + const Symbol('Kv'), + const Symbol('Kw'), + const Symbol('Kx'), + const Symbol('Ky'), + const Symbol('Kz'), + const Symbol('KA'), + const Symbol('KB'), + const Symbol('KC'), + const Symbol('KD'), + const Symbol('KE'), + const Symbol('KF'), + const Symbol('KG'), + const Symbol('KH'), + const Symbol('KI'), + const Symbol('KJ'), + const Symbol('KK'), + const Symbol('KL'), + const Symbol('KM'), + const Symbol('KN'), + const Symbol('KO'), + const Symbol('KP'), + const Symbol('KQ'), + const Symbol('KR'), + const Symbol('KS'), + const Symbol('KT'), + const Symbol('KU'), + const Symbol('KV'), + const Symbol('KW'), + const Symbol('KX'), + const Symbol('KY'), + const Symbol('KZ'), + const Symbol('La'), + const Symbol('Lb'), + const Symbol('Lc'), + const Symbol('Ld'), + const Symbol('Le'), + const Symbol('Lf'), + const Symbol('Lg'), + const Symbol('Lh'), + const Symbol('Li'), + const Symbol('Lj'), + const Symbol('Lk'), + const Symbol('Ll'), + const Symbol('Lm'), + const Symbol('Ln'), + const Symbol('Lo'), + const Symbol('Lp'), + const Symbol('Lq'), + const Symbol('Lr'), + const Symbol('Ls'), + const Symbol('Lt'), + const Symbol('Lu'), + const Symbol('Lv'), + const Symbol('Lw'), + const Symbol('Lx'), + const Symbol('Ly'), + const Symbol('Lz'), + const Symbol('LA'), + const Symbol('LB'), + const Symbol('LC'), + const Symbol('LD'), + const Symbol('LE'), + const Symbol('LF'), + const Symbol('LG'), + const Symbol('LH'), + const Symbol('LI'), + const Symbol('LJ'), + const Symbol('LK'), + const Symbol('LL'), + const Symbol('LM'), + const Symbol('LN'), + const Symbol('LO'), + const Symbol('LP'), + const Symbol('LQ'), + const Symbol('LR'), + const Symbol('LS'), + const Symbol('LT'), + const Symbol('LU'), + const Symbol('LV'), + const Symbol('LW'), + const Symbol('LX'), + const Symbol('LY'), + const Symbol('LZ'), + const Symbol('Ma'), + const Symbol('Mb'), + const Symbol('Mc'), + const Symbol('Md'), + const Symbol('Me'), + const Symbol('Mf'), + const Symbol('Mg'), + const Symbol('Mh'), + const Symbol('Mi'), + const Symbol('Mj'), + const Symbol('Mk'), + const Symbol('Ml'), + const Symbol('Mm'), + const Symbol('Mn'), + const Symbol('Mo'), + const Symbol('Mp'), + const Symbol('Mq'), + const Symbol('Mr'), + const Symbol('Ms'), + const Symbol('Mt'), + const Symbol('Mu'), + const Symbol('Mv'), + const Symbol('Mw'), + const Symbol('Mx'), + const Symbol('My'), + const Symbol('Mz'), + const Symbol('MA'), + const Symbol('MB'), + const Symbol('MC'), + const Symbol('MD'), + const Symbol('ME'), + const Symbol('MF'), + const Symbol('MG'), + const Symbol('MH'), + const Symbol('MI'), + const Symbol('MJ'), + const Symbol('MK'), + const Symbol('ML'), + const Symbol('MM'), + const Symbol('MN'), + const Symbol('MO'), + const Symbol('MP'), + const Symbol('MQ'), + const Symbol('MR'), + const Symbol('MS'), + const Symbol('MT'), + const Symbol('MU'), + const Symbol('MV'), + const Symbol('MW'), + const Symbol('MX'), + const Symbol('MY'), + const Symbol('MZ'), + const Symbol('Na'), + const Symbol('Nb'), + const Symbol('Nc'), + const Symbol('Nd'), + const Symbol('Ne'), + const Symbol('Nf'), + const Symbol('Ng'), + const Symbol('Nh'), + const Symbol('Ni'), + const Symbol('Nj'), + const Symbol('Nk'), + const Symbol('Nl'), + const Symbol('Nm'), + const Symbol('Nn'), + const Symbol('No'), + const Symbol('Np'), + const Symbol('Nq'), + const Symbol('Nr'), + const Symbol('Ns'), + const Symbol('Nt'), + const Symbol('Nu'), + const Symbol('Nv'), + const Symbol('Nw'), + const Symbol('Nx'), + const Symbol('Ny'), + const Symbol('Nz'), + const Symbol('NA'), + const Symbol('NB'), + const Symbol('NC'), + const Symbol('ND'), + const Symbol('NE'), + const Symbol('NF'), + const Symbol('NG'), + const Symbol('NH'), + const Symbol('NI'), + const Symbol('NJ'), + const Symbol('NK'), + const Symbol('NL'), + const Symbol('NM'), + const Symbol('NN'), + const Symbol('NO'), + const Symbol('NP'), + const Symbol('NQ'), + const Symbol('NR'), + const Symbol('NS'), + const Symbol('NT'), + const Symbol('NU'), + const Symbol('NV'), + const Symbol('NW'), + const Symbol('NX'), + const Symbol('NY'), + const Symbol('NZ'), + const Symbol('Oa'), + const Symbol('Ob'), + const Symbol('Oc'), + const Symbol('Od'), + const Symbol('Oe'), + const Symbol('Of'), + const Symbol('Og'), + const Symbol('Oh'), + const Symbol('Oi'), + const Symbol('Oj'), + const Symbol('Ok'), + const Symbol('Ol'), + const Symbol('Om'), + const Symbol('On'), + const Symbol('Oo'), + const Symbol('Op'), + const Symbol('Oq'), + const Symbol('Or'), + const Symbol('Os'), + const Symbol('Ot'), + const Symbol('Ou'), + const Symbol('Ov'), + const Symbol('Ow'), + const Symbol('Ox'), + const Symbol('Oy'), + const Symbol('Oz'), + const Symbol('OA'), + const Symbol('OB'), + const Symbol('OC'), + const Symbol('OD'), + const Symbol('OE'), + const Symbol('OF'), + const Symbol('OG'), + const Symbol('OH'), + const Symbol('OI'), + const Symbol('OJ'), + const Symbol('OK'), + const Symbol('OL'), + const Symbol('OM'), + const Symbol('ON'), + const Symbol('OO'), + const Symbol('OP'), + const Symbol('OQ'), + const Symbol('OR'), + const Symbol('OS'), + const Symbol('OT'), + const Symbol('OU'), + const Symbol('OV'), + const Symbol('OW'), + const Symbol('OX'), + const Symbol('OY'), + const Symbol('OZ'), + const Symbol('Pa'), + const Symbol('Pb'), + const Symbol('Pc'), + const Symbol('Pd'), + const Symbol('Pe'), + const Symbol('Pf'), + const Symbol('Pg'), + const Symbol('Ph'), + const Symbol('Pi'), + const Symbol('Pj'), + const Symbol('Pk'), + const Symbol('Pl'), + const Symbol('Pm'), + const Symbol('Pn'), + const Symbol('Po'), + const Symbol('Pp'), + const Symbol('Pq'), + const Symbol('Pr'), + const Symbol('Ps'), + const Symbol('Pt'), + const Symbol('Pu'), + const Symbol('Pv'), + const Symbol('Pw'), + const Symbol('Px'), + const Symbol('Py'), + const Symbol('Pz'), + const Symbol('PA'), + const Symbol('PB'), + const Symbol('PC'), + const Symbol('PD'), + const Symbol('PE'), + const Symbol('PF'), + const Symbol('PG'), + const Symbol('PH'), + const Symbol('PI'), + const Symbol('PJ'), + const Symbol('PK'), + const Symbol('PL'), + const Symbol('PM'), + const Symbol('PN'), + const Symbol('PO'), + const Symbol('PP'), + const Symbol('PQ'), + const Symbol('PR'), + const Symbol('PS'), + const Symbol('PT'), + const Symbol('PU'), + const Symbol('PV'), + const Symbol('PW'), + const Symbol('PX'), + const Symbol('PY'), + const Symbol('PZ'), + const Symbol('Qa'), + const Symbol('Qb'), + const Symbol('Qc'), + const Symbol('Qd'), + const Symbol('Qe'), + const Symbol('Qf'), + const Symbol('Qg'), + const Symbol('Qh'), + const Symbol('Qi'), + const Symbol('Qj'), + const Symbol('Qk'), + const Symbol('Ql'), + const Symbol('Qm'), + const Symbol('Qn'), + const Symbol('Qo'), + const Symbol('Qp'), + const Symbol('Qq'), + const Symbol('Qr'), + const Symbol('Qs'), + const Symbol('Qt'), + const Symbol('Qu'), + const Symbol('Qv'), + const Symbol('Qw'), + const Symbol('Qx'), + const Symbol('Qy'), + const Symbol('Qz'), + const Symbol('QA'), + const Symbol('QB'), + const Symbol('QC'), + const Symbol('QD'), + const Symbol('QE'), + const Symbol('QF'), + const Symbol('QG'), + const Symbol('QH'), + const Symbol('QI'), + const Symbol('QJ'), + const Symbol('QK'), + const Symbol('QL'), + const Symbol('QM'), + const Symbol('QN'), + const Symbol('QO'), + const Symbol('QP'), + const Symbol('QQ'), + const Symbol('QR'), + const Symbol('QS'), + const Symbol('QT'), + const Symbol('QU'), + const Symbol('QV'), + const Symbol('QW'), + const Symbol('QX'), + const Symbol('QY'), + const Symbol('QZ'), + const Symbol('Ra'), + const Symbol('Rb'), + const Symbol('Rc'), + const Symbol('Rd'), + const Symbol('Re'), + const Symbol('Rf'), + const Symbol('Rg'), + const Symbol('Rh'), + const Symbol('Ri'), + const Symbol('Rj'), + const Symbol('Rk'), + const Symbol('Rl'), + const Symbol('Rm'), + const Symbol('Rn'), + const Symbol('Ro'), + const Symbol('Rp'), + const Symbol('Rq'), + const Symbol('Rr'), + const Symbol('Rs'), + const Symbol('Rt'), + const Symbol('Ru'), + const Symbol('Rv'), + const Symbol('Rw'), + const Symbol('Rx'), + const Symbol('Ry'), + const Symbol('Rz'), + const Symbol('RA'), + const Symbol('RB'), + const Symbol('RC'), + const Symbol('RD'), + const Symbol('RE'), + const Symbol('RF'), + const Symbol('RG'), + const Symbol('RH'), + const Symbol('RI'), + const Symbol('RJ'), + const Symbol('RK'), + const Symbol('RL'), + const Symbol('RM'), + const Symbol('RN'), + const Symbol('RO'), + const Symbol('RP'), + const Symbol('RQ'), + const Symbol('RR'), + const Symbol('RS'), + const Symbol('RT'), + const Symbol('RU'), + const Symbol('RV'), + const Symbol('RW'), + const Symbol('RX'), + const Symbol('RY'), + const Symbol('RZ'), + const Symbol('Sa'), + const Symbol('Sb'), + const Symbol('Sc'), + const Symbol('Sd'), + const Symbol('Se'), + const Symbol('Sf'), + const Symbol('Sg'), + const Symbol('Sh'), + const Symbol('Si'), + const Symbol('Sj'), + const Symbol('Sk'), + const Symbol('Sl'), + const Symbol('Sm'), + const Symbol('Sn'), + const Symbol('So'), + const Symbol('Sp'), + const Symbol('Sq'), + const Symbol('Sr'), + const Symbol('Ss'), + const Symbol('St'), + const Symbol('Su'), + const Symbol('Sv'), + const Symbol('Sw'), + const Symbol('Sx'), + const Symbol('Sy'), + const Symbol('Sz'), + const Symbol('SA'), + const Symbol('SB'), + const Symbol('SC'), + const Symbol('SD'), + const Symbol('SE'), + const Symbol('SF'), + const Symbol('SG'), + const Symbol('SH'), + const Symbol('SI'), + const Symbol('SJ'), + const Symbol('SK'), + const Symbol('SL'), + const Symbol('SM'), + const Symbol('SN'), + const Symbol('SO'), + const Symbol('SP'), + const Symbol('SQ'), + const Symbol('SR'), + const Symbol('SS'), + const Symbol('ST'), + const Symbol('SU'), + const Symbol('SV'), + const Symbol('SW'), + const Symbol('SX'), + const Symbol('SY'), + const Symbol('SZ'), + const Symbol('Ta'), + const Symbol('Tb'), + const Symbol('Tc'), + const Symbol('Td'), + const Symbol('Te'), + const Symbol('Tf'), + const Symbol('Tg'), + const Symbol('Th'), + const Symbol('Ti'), + const Symbol('Tj'), + const Symbol('Tk'), + const Symbol('Tl'), + const Symbol('Tm'), + const Symbol('Tn'), + const Symbol('To'), + const Symbol('Tp'), + const Symbol('Tq'), + const Symbol('Tr'), + const Symbol('Ts'), + const Symbol('Tt'), + const Symbol('Tu'), + const Symbol('Tv'), + const Symbol('Tw'), + const Symbol('Tx'), + const Symbol('Ty'), + const Symbol('Tz'), + const Symbol('TA'), + const Symbol('TB'), + const Symbol('TC'), + const Symbol('TD'), + const Symbol('TE'), + const Symbol('TF'), + const Symbol('TG'), + const Symbol('TH'), + const Symbol('TI'), + const Symbol('TJ'), + const Symbol('TK'), + const Symbol('TL'), + const Symbol('TM'), + const Symbol('TN'), + const Symbol('TO'), + const Symbol('TP'), + const Symbol('TQ'), + const Symbol('TR'), + const Symbol('TS'), + const Symbol('TT'), + const Symbol('TU'), + const Symbol('TV'), + const Symbol('TW'), + const Symbol('TX'), + const Symbol('TY'), + const Symbol('TZ'), + const Symbol('Ua'), + const Symbol('Ub'), + const Symbol('Uc'), + const Symbol('Ud'), + const Symbol('Ue'), + const Symbol('Uf'), + const Symbol('Ug'), + const Symbol('Uh'), + const Symbol('Ui'), + const Symbol('Uj'), + const Symbol('Uk'), + const Symbol('Ul'), + const Symbol('Um'), + const Symbol('Un'), + const Symbol('Uo'), + const Symbol('Up'), + const Symbol('Uq'), + const Symbol('Ur'), + const Symbol('Us'), + const Symbol('Ut'), + const Symbol('Uu'), + const Symbol('Uv'), + const Symbol('Uw'), + const Symbol('Ux'), + const Symbol('Uy'), + const Symbol('Uz'), + const Symbol('UA'), + const Symbol('UB'), + const Symbol('UC'), + const Symbol('UD'), + const Symbol('UE'), + const Symbol('UF'), + const Symbol('UG'), + const Symbol('UH'), + const Symbol('UI'), + const Symbol('UJ'), + const Symbol('UK'), + const Symbol('UL'), + const Symbol('UM'), + const Symbol('UN'), + const Symbol('UO'), + const Symbol('UP'), + const Symbol('UQ'), + const Symbol('UR'), + const Symbol('US'), + const Symbol('UT'), + const Symbol('UU'), + const Symbol('UV'), + const Symbol('UW'), + const Symbol('UX'), + const Symbol('UY'), + const Symbol('UZ'), + const Symbol('Va'), + const Symbol('Vb'), + const Symbol('Vc'), + const Symbol('Vd'), + const Symbol('Ve'), + const Symbol('Vf'), + const Symbol('Vg'), + const Symbol('Vh'), + const Symbol('Vi'), + const Symbol('Vj'), + const Symbol('Vk'), + const Symbol('Vl'), + const Symbol('Vm'), + const Symbol('Vn'), + const Symbol('Vo'), + const Symbol('Vp'), + const Symbol('Vq'), + const Symbol('Vr'), + const Symbol('Vs'), + const Symbol('Vt'), + const Symbol('Vu'), + const Symbol('Vv'), + const Symbol('Vw'), + const Symbol('Vx'), + const Symbol('Vy'), + const Symbol('Vz'), + const Symbol('VA'), + const Symbol('VB'), + const Symbol('VC'), + const Symbol('VD'), + const Symbol('VE'), + const Symbol('VF'), + const Symbol('VG'), + const Symbol('VH'), + const Symbol('VI'), + const Symbol('VJ'), + const Symbol('VK'), + const Symbol('VL'), + const Symbol('VM'), + const Symbol('VN'), + const Symbol('VO'), + const Symbol('VP'), + const Symbol('VQ'), + const Symbol('VR'), + const Symbol('VS'), + const Symbol('VT'), + const Symbol('VU'), + const Symbol('VV'), + const Symbol('VW'), + const Symbol('VX'), + const Symbol('VY'), + const Symbol('VZ'), + const Symbol('Wa'), + const Symbol('Wb'), + const Symbol('Wc'), + const Symbol('Wd'), + const Symbol('We'), + const Symbol('Wf'), + const Symbol('Wg'), + const Symbol('Wh'), + const Symbol('Wi'), + const Symbol('Wj'), + const Symbol('Wk'), + const Symbol('Wl'), + const Symbol('Wm'), + const Symbol('Wn'), + const Symbol('Wo'), + const Symbol('Wp'), + const Symbol('Wq'), + const Symbol('Wr'), + const Symbol('Ws'), + const Symbol('Wt'), + const Symbol('Wu'), + const Symbol('Wv'), + const Symbol('Ww'), + const Symbol('Wx'), + const Symbol('Wy'), + const Symbol('Wz'), + const Symbol('WA'), + const Symbol('WB'), + const Symbol('WC'), + const Symbol('WD'), + const Symbol('WE'), + const Symbol('WF'), + const Symbol('WG'), + const Symbol('WH'), + const Symbol('WI'), + const Symbol('WJ'), + const Symbol('WK'), + const Symbol('WL'), + const Symbol('WM'), + const Symbol('WN'), + const Symbol('WO'), + const Symbol('WP'), + const Symbol('WQ'), + const Symbol('WR'), + const Symbol('WS'), + const Symbol('WT'), + const Symbol('WU'), + const Symbol('WV'), + const Symbol('WW'), + const Symbol('WX'), + const Symbol('WY'), + const Symbol('WZ'), + const Symbol('Xa'), + const Symbol('Xb'), + const Symbol('Xc'), + const Symbol('Xd'), + const Symbol('Xe'), + const Symbol('Xf'), + const Symbol('Xg'), + const Symbol('Xh'), + const Symbol('Xi'), + const Symbol('Xj'), + const Symbol('Xk'), + const Symbol('Xl'), + const Symbol('Xm'), + const Symbol('Xn'), + const Symbol('Xo'), + const Symbol('Xp'), + const Symbol('Xq'), + const Symbol('Xr'), + const Symbol('Xs'), + const Symbol('Xt'), + const Symbol('Xu'), + const Symbol('Xv'), + const Symbol('Xw'), + const Symbol('Xx'), + const Symbol('Xy'), + const Symbol('Xz'), + const Symbol('XA'), + const Symbol('XB'), + const Symbol('XC'), + const Symbol('XD'), + const Symbol('XE'), + const Symbol('XF'), + const Symbol('XG'), + const Symbol('XH'), + const Symbol('XI'), + const Symbol('XJ'), + const Symbol('XK'), + const Symbol('XL'), + const Symbol('XM'), + const Symbol('XN'), + const Symbol('XO'), + const Symbol('XP'), + const Symbol('XQ'), + const Symbol('XR'), + const Symbol('XS'), + const Symbol('XT'), + const Symbol('XU'), + const Symbol('XV'), + const Symbol('XW'), + const Symbol('XX'), + const Symbol('XY'), + const Symbol('XZ'), + const Symbol('Ya'), + const Symbol('Yb'), + const Symbol('Yc'), + const Symbol('Yd'), + const Symbol('Ye'), + const Symbol('Yf'), + const Symbol('Yg'), + const Symbol('Yh'), + const Symbol('Yi'), + const Symbol('Yj'), + const Symbol('Yk'), + const Symbol('Yl'), + const Symbol('Ym'), + const Symbol('Yn'), + const Symbol('Yo'), + const Symbol('Yp'), + const Symbol('Yq'), + const Symbol('Yr'), + const Symbol('Ys'), + const Symbol('Yt'), + const Symbol('Yu'), + const Symbol('Yv'), + const Symbol('Yw'), + const Symbol('Yx'), + const Symbol('Yy'), + const Symbol('Yz'), + const Symbol('YA'), + const Symbol('YB'), + const Symbol('YC'), + const Symbol('YD'), + const Symbol('YE'), + const Symbol('YF'), + const Symbol('YG'), + const Symbol('YH'), + const Symbol('YI'), + const Symbol('YJ'), + const Symbol('YK'), + const Symbol('YL'), + const Symbol('YM'), + const Symbol('YN'), + const Symbol('YO'), + const Symbol('YP'), + const Symbol('YQ'), + const Symbol('YR'), + const Symbol('YS'), + const Symbol('YT'), + const Symbol('YU'), + const Symbol('YV'), + const Symbol('YW'), + const Symbol('YX'), + const Symbol('YY'), + const Symbol('YZ'), + const Symbol('Za'), + const Symbol('Zb'), + const Symbol('Zc'), + const Symbol('Zd'), + const Symbol('Ze'), + const Symbol('Zf'), + const Symbol('Zg'), + const Symbol('Zh'), + const Symbol('Zi'), + const Symbol('Zj'), + const Symbol('Zk'), + const Symbol('Zl'), + const Symbol('Zm'), + const Symbol('Zn'), + const Symbol('Zo'), + const Symbol('Zp'), + const Symbol('Zq'), + const Symbol('Zr'), + const Symbol('Zs'), + const Symbol('Zt'), + const Symbol('Zu'), + const Symbol('Zv'), + const Symbol('Zw'), + const Symbol('Zx'), + const Symbol('Zy'), + const Symbol('Zz'), + const Symbol('ZA'), + const Symbol('ZB'), + const Symbol('ZC'), + const Symbol('ZD'), + const Symbol('ZE'), + const Symbol('ZF'), + const Symbol('ZG'), + const Symbol('ZH'), + const Symbol('ZI'), + const Symbol('ZJ'), + const Symbol('ZK'), + const Symbol('ZL'), + const Symbol('ZM'), + const Symbol('ZN'), + const Symbol('ZO'), + const Symbol('ZP'), + const Symbol('ZQ'), + const Symbol('ZR'), + const Symbol('ZS'), + const Symbol('ZT'), + const Symbol('ZU'), + const Symbol('ZV'), + const Symbol('ZW'), + const Symbol('ZX'), + const Symbol('ZY'), + const Symbol('ZZ'), +]; diff --git a/micro_dart_compiler/test/testcases2/symbol/literal_runtime_1_test.dart b/micro_dart_compiler/test/testcases2/symbol/literal_runtime_1_test.dart new file mode 100644 index 00000000..099340ad --- /dev/null +++ b/micro_dart_compiler/test/testcases2/symbol/literal_runtime_1_test.dart @@ -0,0 +1,38 @@ +library symbol_literal_test; + +foo(a, b) => identical(a, b) == true; + +var check = foo; // Indirection used to avoid inlining. + +testSwitch(Symbol s) { + switch (s) { + case #abc: + return 1; + case const Symbol("def"): + return 2; + default: + return 0; + } +} + +main() { + bool doChecks = false; + doChecks = true; + if (doChecks) { + check(const Symbol("a"), #a); + check(const Symbol("a"), #a); + check(const Symbol("ab"), #ab); + check(const Symbol("ab"), #ab); + check(const Symbol("a.b"), #a.b); + check(const Symbol("a.b"), #a.b); + check(const Symbol("=="), #==); + check(const Symbol("=="), #==); + check(const Symbol("a.toString"), #a.toString); + } + assert(1 == testSwitch(#abc)); + + const m = const {#A: 0, #B: 1}; + assert(1 == m[#B]); + + // Tries to call the symbol literal #a.toString +} diff --git a/micro_dart_compiler/test/testcases2/syntax/statement_test.dart b/micro_dart_compiler/test/testcases2/syntax/statement_test.dart new file mode 100644 index 00000000..7d0c0690 --- /dev/null +++ b/micro_dart_compiler/test/testcases2/syntax/statement_test.dart @@ -0,0 +1,217 @@ +// Tests all statement types. Not an exhaustive test of all statement semantics. +class StatementTest { + StatementTest() {} + + static testMain() { + var test = new StatementTest(); + test.testIfStatement(); + test.testForLoop(); + test.testWhileLoops(); + test.testSwitch(); + test.testExceptions(); + test.testBreak(); + test.testContinue(); + test.testFunction(); + test.testReturn(); + } + + testIfStatement() { + // Basic if statements. + if (true) { + assert(true == true); + } else { + assert(false == true); + } + + if (false) { + assert(false == true); + } else { + assert(true, true); + } + } + + testForLoop() { + int count = 0, count2; + + // Basic for loop. + for (int i = 0; i < 10; ++i) { + ++count; + } + assert(10 == count); + + // For loop with no 'var'. + count2 = 0; + for (count = 0; count < 5; ++count) { + ++count2; + } + assert(5 == count); + assert(5 == count2); + + // For loop with no initializer. + count = count2 = 0; + for (; count < 10; ++count) { + ++count2; + } + assert(10 == count); + assert(10 == count2); + + // For loop with no increment. + for (count = 0; count < 5;) { + ++count; + } + assert(5 == count); + + // For loop with no test. + for (count = 0;; ++count) { + if (count == 10) { + break; + } + } + assert(10 == count); + + // For loop with no nothing. + count = 0; + for (;;) { + if (count == 5) { + break; + } + ++count; + } + assert(5 == count); + } + + testWhileLoops() { + // Basic while loop. + int count = 0; + while (count < 10) { + ++count; + } + assert(10 == count); + + // Basic do loop. + count = 0; + do { + ++count; + } while (count < 5); + assert(5 == count); + } + + testSwitch() { + // Int switch. + bool? hit0, hit1, hitDefault; + for (int x = 0; x < 3; ++x) { + switch (x) { + case 0: + hit0 = true; + break; + case 1: + hit1 = true; + break; + default: + hitDefault = true; + break; + } + } + assert(true == hit0); + assert(true == hit1); + assert(true == hitDefault); + + // String switch. + var strings = ['a', 'b', 'c']; + bool? hitA, hitB; + hitDefault = false; + for (int x = 0; x < 3; ++x) { + switch (strings[x]) { + case 'a': + hitA = true; + break; + case 'b': + hitB = true; + break; + default: + hitDefault = true; + break; + } + } + assert(true == hitA); + assert(true == hitB); + assert(true == hitDefault); + } + + testExceptions() { + // TODO(jgw): Better tests once all the exception semantics are worked out. + bool hitCatch, hitFinally; + try { + throw "foo"; + } catch (e) { + assert(true, e == "foo"); + hitCatch = true; + } finally { + hitFinally = true; + } + + assert(true, hitCatch); + assert(true, hitFinally); + } + + testBreak() { + var ints = [ + [32, 87, 3, 589], + [12, 1076, 2000, 8], + [622, 127, 77, 955] + ]; + int i, j = 0; + bool foundIt = false; + + search: + for (i = 0; i < ints.length; i++) { + for (j = 0; j < ints[i].length; j++) { + if (ints[i][j] == 12) { + foundIt = true; + break search; + } + } + } + assert(true, foundIt); + } + + testContinue() { + String searchMe = "Look for a substring in me"; + String substring = "sub"; + bool foundIt = false; + int max = searchMe.length - substring.length; + + test: + for (int i = 0; i <= max; i++) { + int n = substring.length; + int j = i; + int k = 0; + while (n-- != 0) { + if (searchMe[j++] != substring[k++]) { + continue test; + } + } + foundIt = true; + break test; + } + } + + testFunction() { + int foo() { + return 42; + } + + assert(42 == foo()); + } + + void testReturn() { + if (true) { + return; + } + assert(true, false); + } +} + +main() { + StatementTest.testMain(); +} diff --git a/micro_dart_compiler/test/testcases2/test_all.dart b/micro_dart_compiler/test/testcases2/test_all.dart new file mode 100644 index 00000000..e69de29b diff --git a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart index 70a9d8be..3a2e9643 100755 --- a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart +++ b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_foundation_change_notifier.dart @@ -14,10 +14,10 @@ Function _Listenable__$(m.Scope scope$) => (bool _value) { class $Listenable extends Listenable with m.InstanceBridge { @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/foundation/change_notifier.dart", "Listenable"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef( + "package:flutter/src/foundation/change_notifier.dart", "Listenable"), + ); @override late Map superGetters = {}; diff --git a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart index 93941851..b5f3c930 100755 --- a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart +++ b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_rendering_custom_paint.dart @@ -10,10 +10,10 @@ class $CustomPainter extends CustomPainter with m.InstanceBridge { $CustomPainter({Listenable? repaint}) : super(repaint: repaint); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/rendering/custom_paint.dart", "CustomPainter"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef( + "package:flutter/src/rendering/custom_paint.dart", "CustomPainter"), + ); @override late Map superGetters = { diff --git a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_framework.dart b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_framework.dart index 902cc78a..1ebed806 100755 --- a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_framework.dart +++ b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_framework.dart @@ -13,10 +13,9 @@ class $InheritedWidget extends InheritedWidget with m.InstanceBridge { : super(key: key, child: child); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "InheritedWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "InheritedWidget"), + ); @override bool updateShouldNotify(covariant InheritedWidget oldWidget) { @@ -25,9 +24,8 @@ class $InheritedWidget extends InheritedWidget with m.InstanceBridge { this, type.getCallRef("updateShouldNotify", false, false), [oldWidget], - {}, () { - return updateShouldNotify(oldWidget); - }); + {}, + null); } @override @@ -45,10 +43,9 @@ class $StatelessWidget extends StatelessWidget implements PreferredSizeWidget { $StatelessWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatelessWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatelessWidget"), + ); @override Widget build(BuildContext context) { @@ -73,10 +70,9 @@ Function _StatefulWidget__$(m.Scope scope$) => ({Key? key}) { class $StatefulWidget extends StatefulWidget with m.InstanceBridge { $StatefulWidget({Key? key}) : super(key: key); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/framework.dart", "StatefulWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "StatefulWidget"), + ); @override State createState() { @@ -95,9 +91,9 @@ Function _State__$(m.Scope scope$) => () { class $State extends State with m.InstanceBridge, TickerProviderStateMixin, RestorationMixin { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/framework.dart", "State"), + ); @override Widget build(BuildContext context) { @@ -139,7 +135,7 @@ class $State extends State @override String? get restorationId { return $child!.engine.callFunction(scope, this, - type.getCallRef("restorationId", false, false), [], {}, () {}); + type.getCallRef("restorationId", false, false), [], {}, null); } @override @@ -150,6 +146,6 @@ class $State extends State type.getCallRef("restoreState", false, false), [oldBucket, initialRestore], {}, - () {}); + null); } } diff --git a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart index bde1696a..ac04e5f4 100755 --- a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart +++ b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_restoration_properties.dart @@ -10,10 +10,10 @@ Function _RestorableListenable__$(m.Scope scope$) => () { class $RestorableListenable extends RestorableListenable with m.InstanceBridge { @override - m.CType bridgeType = const m.CType( - m.ClassRef("package:flutter/src/widgets/restoration_properties.dart", - "RestorableListenable"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef("package:flutter/src/widgets/restoration_properties.dart", + "RestorableListenable"), + ); @override late Map superGetters = {}; diff --git a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart index cff58e98..a4eea17b 100755 --- a/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart +++ b/micro_dart_flutter/lib/proxy/proxy__package_flutter_src_widgets_transitions.dart @@ -13,10 +13,10 @@ class $AnimatedWidget extends AnimatedWidget with m.InstanceBridge { : super(key: key, listenable: listenable); @override - m.CType bridgeType = const m.CType( - m.ClassRef( - "package:flutter/src/widgets/transitions.dart", "AnimatedWidget"), - isExternal: true); + m.CType bridgeType = const m.CType.external( + m.ClassRef( + "package:flutter/src/widgets/transitions.dart", "AnimatedWidget"), + ); @override late Map superGetters = {}; diff --git a/micro_dart_runtime/lib/flags.dart b/micro_dart_runtime/lib/flags.dart new file mode 100644 index 00000000..917622ac --- /dev/null +++ b/micro_dart_runtime/lib/flags.dart @@ -0,0 +1,445 @@ +class Flags { + //Constructor + // bool isConst = false, + // bool isExternal = false, + // bool isSynthetic = false, + + //Initializer + //bool isSynthetic + + //Initializer + //isSynthetic + + //DartType + // Nullability + // nonNullable + // nullable + // legacy + // undetermined + + //Class + //static const int FlagAbstract = 1 << 0; + //static const int FlagEnum = 1 << 1; + //static const int FlagAnonymousMixin = 1 << 2; + //static const int FlagEliminatedMixin = 1 << 3; + //static const int FlagMixinDeclaration = 1 << 4; + //static const int FlagHasConstConstructor = 1 << 5; + //static const int FlagMacro = 1 << 6; + //static const int FlagSealed = 1 << 7; + //static const int FlagMixinClass = 1 << 8; + //static const int FlagBase = 1 << 9; + //static const int FlagInterface = 1 << 10; + //static const int FlagFinal = 1 << 11; + + //Extension + //static const int FlagExtensionTypeDeclaration = 1 << 12; + //static const int FlagUnnamedExtension = 1 << 13; + + //ExtensionMemberKind + //enum ExtensionMemberKind { + // Field, + // Method, + // Getter, + // Setter, + // Operator, + // TearOff, + //} + + //ExtensionMemberKind + //enum ExtensionMemberKind { + // Field, + // Method, + // Getter, + // Setter, + // Operator, + // TearOff, + //} + + //ExtensionMemberDescriptor + // FlagStatic + + //enum CallSiteAccessKind { + // methodInvocation, + // getterInvocation, + // setterInvocation, + // operatorInvocation, + //} + + //Member + //isAbstract + //isConst + //hasGetter + //hasSetter + //isInstanceMember + //isExternal + //isExtensionMember + //isInlineClassMember + //isNonNullableByDefault + //isInternalImplementation + + //Field + //static const int FlagFinal = 1 << 0; // Must match serialized bit positions. + + //static const int FlagConst = 1 << 14; + //static const int FlagStatic = 1 << 15; + //static const int FlagCovariant = 1 << 16; + //static const int FlagCovariantByClass = 1 << 17; + //static const int FlagLate = 1 << 5; + //static const int FlagExtensionMember = 1 << 18; + //static const int FlagNonNullableByDefault = 1 << 19; + //static const int FlagInternalImplementation = 1 << 20; + //static const int FlagEnumElement = 1 << 21; + //static const int FlagInlineClassMember = 1 << 22; + + //static const int FlagExternal = 1 << 23; + //static const int FlagRedirectingFactory = 1 << 24; + //static const int FlagSynthetic = 1 << 25; + //static const int FlagIsAbstractFieldAccessor = 1 << 26; + //static const int FlagInlineMember = 1 << 27; + //static const int FlagHasWeakTearoffReferencePragma = 1 << 28; + //static const int FlagInvariant = 1 << 29; + //static const int FlagBoundsSafe = 1 << 30; + //static const int FlagTypeError = 1 << 31; + //static const int FlagCovarianceCheck = 1 << 32; + //static const int FlagForDynamic = 1 << 33; + //static const int FlagForNonNullableByDefault = 1 << 34; + //static const int FlagUnchecked = 1 << 35; + //static const int FlagYieldStar = 1 << 36; + //static const int FlagHasDeclaredInitializer = 1 << 37; + //static const int FlagInitializingFormal = 1 << 38; + //static const int FlagRequired = 1 << 39; + //static const int FlagCovariantByDeclaration = 1 << 40; + //static const int FlagLowered = 1 << 41; + //static const int FlagSynthesized = 1 << 42; + //static const int FlagHoisted = 1 << 43; + //static const int FlagRequiredNamedType = 1 << 44; + + // RedirectingFactory + //static const int FlagConst = 1 << 0; // Must match serialized bit positions. + //static const int FlagExternal = 1 << 1; + //static const int FlagNonNullableByDefault = 1 << 2; + + // Procedure + // ProcedureKind + // Method, + // Getter, + // Setter, + // Operator, + // Factory, + + // ProcedureStubKind + // Regular + // AbstractForwardingStub + // ConcreteForwardingStub + // NoSuchMethodForwarder + // MemberSignature + // AbstractMixinStub + // ConcreteMixinStub + + // + //static const int FlagStatic = 1 << 0; // Must match serialized bit positions. + //static const int FlagAbstract = 1 << 1; + //static const int FlagExternal = 1 << 2; + //static const int FlagConst = 1 << 3; // Only for external const factories. + //static const int FlagRedirectingFactory = 1 << 4; + //static const int FlagExtensionMember = 1 << 5; + //static const int FlagNonNullableByDefault = 1 << 6; + //static const int FlagSynthetic = 1 << 7; + //static const int FlagInternalImplementation = 1 << 8; + //static const int FlagIsAbstractFieldAccessor = 1 << 9; + //static const int FlagInlineMember = 1 << 10; + //static const int FlagHasWeakTearoffReferencePragma = 1 << 11; + + //FunctionNode + //AsyncMarker + //Sync, + //SyncStar, + //Async, + //AsyncStar, + + //DynamicAccessKind + //Dynamic + //Never + //Invalid + //Unresolved + + //InstanceAccessKind + //Instance + //Object + //Inapplicable + //Nullable + + //InstanceInvocation + //static const int FlagInvariant = 1 << 0; + //static const int FlagBoundsSafe = 1 << 1; + + //FunctionAccessKind + //Function + //FunctionType + //Inapplicable + //Nullable + + //AsExpression + //static const int FlagTypeError = 1 << 0; + //static const int FlagCovarianceCheck = 1 << 1; + //static const int FlagForDynamic = 1 << 2; + //static const int FlagForNonNullableByDefault = 1 << 3; + //static const int FlagUnchecked = 1 << 4; + + //YieldStatement + //static const int FlagYieldStar = 1 << 0; + + //VariableDeclaration + //static const int FlagFinal = 1 << 0; // Must match serialized bit positions. + //static const int FlagConst = 1 << 1; + //static const int FlagHasDeclaredInitializer = 1 << 2; + //static const int FlagInitializingFormal = 1 << 3; + //static const int FlagCovariantByClass = 1 << 4; + //static const int FlagLate = 1 << 5; + //static const int FlagRequired = 1 << 6; + //static const int FlagCovariantByDeclaration = 1 << 7; + //static const int FlagLowered = 1 << 8; + //static const int FlagSynthesized = 1 << 9; + //static const int FlagHoisted = 1 << 10; + + //NamedType + //static const int FlagRequiredNamedType = 1 << 0; + + //bool get isCovariantByClass => flags & FlagCovariantByClass != 0; + + //Flags: + static const int flagsBit = 0; + static const int flagStatic = 1 << (flagsBit); + static const int flagPrivate = 1 << (flagsBit + 1); + static const int flagConst = 1 << (flagsBit + 2); + static const int flagRedirectingConstructor = 1 << (flagsBit + 3); + static const int flagAbstract = 1 << (flagsBit + 4); + static const int flagFinal = 1 << (flagsBit + 5); + static const int flagHasDefaultValue = 1 << (flagsBit + 6); + static const int flagOptional = 1 << (flagsBit + 7); + static const int flagNamed = 1 << (flagsBit + 8); + static const int flagVoid = 1 << (flagsBit + 9); + static const int flagDynamic = 1 << (flagsBit + 10); + static const int flagNever = 1 << (flagsBit + 11); + static const int flagClassType = 1 << (flagsBit + 12); + static const int flagVoidReturnType = 1 << (flagsBit + 13); + static const int flagDynamicReturnType = 1 << (flagsBit + 14); + static const int flagNeverReturnType = 1 << (flagsBit + 15); + static const int flagClassReturnType = 1 << (flagsBit + 16); + static const int flagEnum = 1 << (flagsBit + 17); + static const int flagTopLevel = 1 << (flagsBit + 18); + static const int flagGenericType = 1 << (flagsBit + 19); + static const int flagGenericReturnType = 1 << (flagsBit + 20); + static const int flagNullable = 1 << (flagsBit + 21); + static const int flagNonNullable = 1 << (flagsBit + 22); + + static const int flagGetter = 1 << (flagsBit + 23); + static const int flagSetter = 1 << (flagsBit + 24); + static const int flagAsync = 1 << (flagsBit + 25); + static const int flagHasArgs = 1 << (flagsBit + 26); + static const int flagExternal = 1 << (flagsBit + 27); + static const int flagAnonymousMixin = 1 << (flagsBit + 28); + static const int flagMixinDeclaration = 1 << (flagsBit + 29); + + static const int external = 134217728; + + static int generateFlags({ + bool isStatic = false, + bool isPrivate = false, + bool isSynthetic = false, + bool isConst = false, + bool isRedirectingConstructor = false, + bool isAbstract = false, + bool isFinal = false, + bool hasDefaultValue = false, + bool isOptional = false, + bool isNamed = false, + bool isVoid = false, + bool isDynamic = false, + bool isNever = false, + bool isClassType = false, + bool isVoidReturnType = false, + bool isDynamicReturnType = false, + bool isNeverReturnType = false, + bool isClassReturnType = false, + bool isEnum = false, + bool isTopLevel = false, + bool isGenericType = false, + bool isGenericReturnType = false, + bool isNullable = false, + bool isNonNullable = false, + bool isGetter = false, + bool isSetter = false, + bool isAsync = false, + bool hasArgs = false, + bool isExternal = false, + bool isAnonymousMixin = false, + bool isMixinDeclaration = false, + }) { + int flags = 0; + + if (isStatic) flags |= flagStatic; + if (isPrivate) flags |= flagPrivate; + //if (isSynthetic) flags |= flagSynthetic; + if (isConst) flags |= flagConst; + if (isRedirectingConstructor) flags |= flagRedirectingConstructor; + if (isAbstract) flags |= flagAbstract; + if (isFinal) flags |= flagFinal; + if (hasDefaultValue) flags |= flagHasDefaultValue; + if (isOptional) flags |= flagOptional; + if (isNamed) flags |= flagNamed; + if (isVoid) flags |= flagVoid; + if (isDynamic) flags |= flagDynamic; + if (isNever) flags |= flagNever; + if (isClassType) flags |= flagClassType; + if (isVoidReturnType) flags |= flagVoidReturnType; + if (isDynamicReturnType) flags |= flagDynamicReturnType; + if (isNeverReturnType) flags |= flagNeverReturnType; + if (isClassReturnType) flags |= flagClassReturnType; + if (isEnum) flags |= flagEnum; + if (isTopLevel) flags |= flagTopLevel; + if (isGenericType) flags |= flagGenericType; + if (isGenericReturnType) flags |= flagGenericReturnType; + if (isNullable) flags |= flagNullable; + if (isNonNullable) flags |= flagNonNullable; + + if (isGetter) flags |= flagGetter; + if (isSetter) flags |= flagSetter; + if (isAsync) flags |= flagAsync; + if (hasArgs) flags |= flagHasArgs; + + if (isExternal) flags |= flagExternal; + if (isAnonymousMixin) flags |= flagAnonymousMixin; + if (isMixinDeclaration) flags |= flagMixinDeclaration; + + return flags; + } + + static bool isMixinDeclaration(int flags) { + return (flags & flagMixinDeclaration != 0); + } + + static bool isAnonymousMixin(int flags) { + return (flags & flagAnonymousMixin != 0); + } + + static bool isExternal(int flags) { + return (flags & flagExternal != 0); + } + + static bool isGetter(int flags) { + return (flags & flagGetter != 0); + } + + static bool isSetter(int flags) { + return (flags & flagSetter != 0); + } + + static bool isAsync(int flags) { + return (flags & flagAsync != 0); + } + + static bool hasArgs(int flags) { + return (flags & flagHasArgs != 0); + } + + static int getKind(int flags) { + return flags & ((1 << flagsBit) - 1); + } + + static bool isStatic(int flags) { + return (flags & flagStatic != 0); + } + + static bool isPrivate(int flags) { + return (flags & flagPrivate != 0); + } + + // static bool isSynthetic(int flags) { + // return (flags & flagSynthetic != 0); + // } + + static bool isConst(int flags) { + return (flags & flagConst != 0); + } + + static bool isRedirectingConstructor(int flags) { + return (flags & flagRedirectingConstructor != 0); + } + + static bool isAbstract(int flags) { + return (flags & flagAbstract != 0); + } + + static bool isFinal(int flags) { + return (flags & flagFinal != 0); + } + + static bool hasDefaultValue(int flags) { + return (flags & flagHasDefaultValue != 0); + } + + static bool isOptional(int flags) { + return (flags & flagOptional != 0); + } + + static bool isNamed(int flags) { + return (flags & flagNamed != 0); + } + + static bool isVoid(int flags) { + return (flags & flagVoid != 0); + } + + static bool isDynamic(int flags) { + return (flags & flagDynamic != 0); + } + + static bool isNever(int flags) { + return (flags & flagNever != 0); + } + + static bool isClassType(int flags) { + return (flags & flagClassType != 0); + } + + static bool isVoidReturnType(int flags) { + return (flags & flagVoidReturnType != 0); + } + + static bool isDynamicReturnType(int flags) { + return (flags & flagDynamicReturnType != 0); + } + + static bool isNeverReturnType(int flags) { + return (flags & flagNeverReturnType != 0); + } + + static bool isClassReturnType(int flags) { + return (flags & flagClassReturnType != 0); + } + + static bool isEnum(int flags) { + return (flags & flagEnum != 0); + } + + static bool isTopLevel(int flags) { + return (flags & flagTopLevel != 0); + } + + static bool isGenericType(int flags) { + return (flags & flagGenericType != 0); + } + + static bool isGenericReturnType(int flags) { + return (flags & flagGenericReturnType != 0); + } + + static bool isNullable(int flags) { + return (flags & flagNullable != 0); + } + + static bool isNonNullable(int flags) { + return (flags & flagNonNullable != 0); + } +} diff --git a/micro_dart_runtime/lib/ops/op_await.dart b/micro_dart_runtime/lib/ops/op_await.dart index a9bc743b..ec9c0bb4 100755 --- a/micro_dart_runtime/lib/ops/op_await.dart +++ b/micro_dart_runtime/lib/ops/op_await.dart @@ -19,8 +19,12 @@ class OpAwait implements Op { @override Future run(Scope scope) async { - final instance = scope.popFrame() as Future; - scope.pushFrame(await instance); + final instance = scope.popFrame(); + if (instance is Future) { + scope.pushFrame(await instance); + } else { + scope.pushFrame(instance); + } } @override diff --git a/micro_dart_runtime/lib/ops/op_call_dynamic.dart b/micro_dart_runtime/lib/ops/op_call_dynamic.dart index 081f5920..e1852416 100755 --- a/micro_dart_runtime/lib/ops/op_call_dynamic.dart +++ b/micro_dart_runtime/lib/ops/op_call_dynamic.dart @@ -1,3 +1,4 @@ +import 'package:micro_dart_runtime/flags.dart'; import 'package:micro_dart_runtime/micro_dart_runtime.dart'; class OpCallDynamicAsync extends OpCallDynamic { @@ -8,15 +9,7 @@ class OpCallDynamicAsync extends OpCallDynamic { : super.make(ref, isStatic, isGetter, isSetter, isAsync, hasArgs); @override - List bytes(ConstantPool pool) => [ - Ops.opCallDynamicAsync, - ..._ref.bytes(pool), - ...Ops.i8b(_isStatic ? 1 : 0), - ...Ops.i8b(_isGetter ? 1 : 0), - ...Ops.i8b(_isSetter ? 1 : 0), - ...Ops.i8b(_isAsync ? 1 : 0), - ...Ops.i8b(_hasArgs ? 1 : 0) - ]; + int get opIndex => Ops.opCallDynamicAsync; @override Future run(Scope scope) { @@ -25,71 +18,68 @@ class OpCallDynamicAsync extends OpCallDynamic { if (scope.engine.declarations.containsKey(ref)) { int pointer = scope.engine.declarations[ref]!; return scope.engine - .callPointerAsync(scope, ref.callName, _hasArgs, _isAsync, pointer); + .callPointerAsync(scope, ref.callName, hasArgs, isAsync, pointer); } else { throw Exception("currently not support external function "); } } @override - String toString() => 'OpCallAsync($_ref,$_isStatic,$_isGetter,$_isSetter)'; + String toString() => 'OpCallAsync($_ref,$isStatic,$isGetter,$isSetter)'; } ///调用外部方法 class OpCallDynamic implements Op { + final int _flags; + final CallRef _ref; OpCallDynamic(MicroDartEngine engine) : _ref = CallRef.fromEngine(engine), - _isStatic = engine.readUint8() == 1 ? true : false, - _isGetter = engine.readUint8() == 1 ? true : false, - _isSetter = engine.readUint8() == 1 ? true : false, - _isAsync = engine.readUint8() == 1 ? true : false, - _hasArgs = engine.readUint8() == 1 ? true : false; + _flags = engine.readInt32(); - final CallRef _ref; - final bool _isGetter; - final bool _isSetter; - final bool _isStatic; - final bool _isAsync; - final bool _hasArgs; + bool get isGetter => Flags.isGetter(_flags); + bool get isSetter => Flags.isSetter(_flags); + bool get isStatic => Flags.isStatic(_flags); + bool get isAsync => Flags.isAsync(_flags); + bool get hasArgs => Flags.hasArgs(_flags); OpCallDynamic.make( this._ref, - this._isStatic, - this._isGetter, - this._isSetter, - this._isAsync, - this._hasArgs, - ); + bool _isStatic, + bool _isGetter, + bool _isSetter, + bool _isAsync, + bool _hasArgs, + ) : _flags = Flags.generateFlags( + isStatic: _isStatic, + isGetter: _isGetter, + isSetter: _isSetter, + isAsync: _isAsync, + hasArgs: _hasArgs); @override - int get opLen => Ops.lenBegin + CallRef.byteLen + Ops.lenI8 * 5; + int get opLen => Ops.lenBegin + CallRef.byteLen + Ops.lenU32; + + int get opIndex => Ops.opCallDynamic; @override - List bytes(ConstantPool pool) => [ - Ops.opCallDynamic, - ..._ref.bytes(pool), - ...Ops.i8b(_isStatic ? 1 : 0), - ...Ops.i8b(_isGetter ? 1 : 0), - ...Ops.i8b(_isSetter ? 1 : 0), - ...Ops.i8b(_isAsync ? 1 : 0), - ...Ops.i8b(_hasArgs ? 1 : 0) - ]; + List bytes(ConstantPool pool) => + [opIndex, ..._ref.bytes(pool), ...Ops.i32b(_flags)]; @override void run(Scope scope) { - if (!_isStatic) { + if (!isStatic) { var args = scope.getFrame() as List; var instance = args.first as Instance; var ref = scope.engine - .getCallRefByType(instance.type, _ref.name, _isSetter, _isStatic); + .getCallRefByType(instance.type, _ref.name, isSetter, isStatic); int pointer = scope.engine.declarations[ref]!; - scope.engine.callPointer(scope, ref!.callName, _hasArgs, pointer); + scope.engine.callPointer(scope, ref!.callName, hasArgs, pointer); return; } if (scope.engine.declarations.containsKey(_ref)) { int pointer = scope.engine.declarations[_ref]!; - scope.engine.callPointer(scope, _ref.callName, _hasArgs, pointer); + scope.engine.callPointer(scope, _ref.callName, hasArgs, pointer); } else { throw Exception("currently not support external function $_ref"); } @@ -97,15 +87,15 @@ class OpCallDynamic implements Op { CallRef? _getKey(Scope scope) { //我们不能确定调用的方法一定就是内部的,因为有时候可能是super的方法,调用的是父类的方法,而父类可能是外部的类 - if (!_isStatic) { + if (!isStatic) { var args = scope.getFrame() as List; var instance = args.first as Instance; return scope.engine - .getCallRefByType(instance.type, _ref.name, _isSetter, _isStatic); + .getCallRefByType(instance.type, _ref.name, isSetter, isStatic); } return null; } @override - String toString() => 'OpCall($_ref,$_isStatic,$_isGetter,$_isSetter)'; + String toString() => 'OpCall($_ref,$isStatic,$isGetter,$isSetter,$hasArgs)'; } diff --git a/micro_dart_runtime/lib/ops/op_call_external.dart b/micro_dart_runtime/lib/ops/op_call_external.dart index 6a2688c3..27e3f8bb 100755 --- a/micro_dart_runtime/lib/ops/op_call_external.dart +++ b/micro_dart_runtime/lib/ops/op_call_external.dart @@ -44,10 +44,10 @@ class OpCallExternal implements Op { var value = args.removeLast(); namedArguments[key] = value; } - int posationalLength = args.removeLast() as int; + int positionalLength = args.removeLast() as int; final List positionalArguments = - List.filled(posationalLength, null, growable: false); - for (int i = 0; i < posationalLength; i++) { + List.filled(positionalLength, null, growable: false); + for (int i = 0; i < positionalLength; i++) { var value = args.removeLast(); positionalArguments[i] = value; } diff --git a/micro_dart_runtime/lib/ops/op_call_pointer.dart b/micro_dart_runtime/lib/ops/op_call_pointer.dart index a2fee2cb..420988e4 100755 --- a/micro_dart_runtime/lib/ops/op_call_pointer.dart +++ b/micro_dart_runtime/lib/ops/op_call_pointer.dart @@ -5,13 +5,13 @@ import 'package:micro_dart_runtime/micro_dart_runtime.dart'; class OpCallPointerAsync extends OpCallPointer { OpCallPointerAsync(MicroDartEngine engine) : super(engine); - OpCallPointerAsync.make(int argmentLength, String name, bool isAsync) - : super.make(argmentLength, name, isAsync); + OpCallPointerAsync.make(int argumentLength, String name, bool isAsync) + : super.make(argumentLength, name, isAsync); @override List bytes(ConstantPool pool) => [ Ops.opCallPointerAsync, - ...Ops.i32b(_argmentLength), + ...Ops.i32b(_argumentLength), ...Ops.str(_name, pool), ...Ops.i8b(_isAsync ? 1 : 0) ]; @@ -28,19 +28,19 @@ class OpCallPointerAsync extends OpCallPointer { } @override - String toString() => 'OpCallPointerAsync($_argmentLength,$_name,$_isAsync)'; + String toString() => 'OpCallPointerAsync($_argumentLength,$_name,$_isAsync)'; } ///调用方法 class OpCallPointer implements Op { OpCallPointer(MicroDartEngine engine) - : _argmentLength = engine.readInt32(), + : _argumentLength = engine.readInt32(), _name = engine.readString(), _isAsync = engine.readUint8() == 1 ? true : false; - OpCallPointer.make(this._argmentLength, this._name, this._isAsync); + OpCallPointer.make(this._argumentLength, this._name, this._isAsync); - final int _argmentLength; + final int _argumentLength; final String _name; final bool _isAsync; @@ -50,7 +50,7 @@ class OpCallPointer implements Op { @override List bytes(ConstantPool pool) => [ Ops.opCallPointer, - ...Ops.i32b(_argmentLength), + ...Ops.i32b(_argumentLength), ...Ops.i32b(pool.addOrGet(_name)), ...Ops.i8b(_isAsync ? 1 : 0) ]; @@ -66,5 +66,5 @@ class OpCallPointer implements Op { } @override - String toString() => 'OpCallPointer($_argmentLength,$_name,$_isAsync)'; + String toString() => 'OpCallPointer($_argumentLength,$_name,$_isAsync)'; } diff --git a/micro_dart_runtime/lib/ops/op_call_super.dart b/micro_dart_runtime/lib/ops/op_call_super.dart index 3c60d531..ea707724 100755 --- a/micro_dart_runtime/lib/ops/op_call_super.dart +++ b/micro_dart_runtime/lib/ops/op_call_super.dart @@ -1,3 +1,4 @@ +import 'package:micro_dart_runtime/flags.dart'; import 'package:micro_dart_runtime/micro_dart_runtime.dart'; ///调用外部方法 @@ -17,17 +18,7 @@ class OpCallSuperAsync extends OpCallSuper { positionalLength, namedList); @override - List bytes(ConstantPool pool) => [ - Ops.opCallSuperAsync, - ..._super.bytes(pool), - ...Ops.str(_name, pool), - ...Ops.i8b(_isGetter ? 1 : 0), - ...Ops.i8b(_isSetter ? 1 : 0), - ...Ops.i8b(_isAsync ? 1 : 0), - ...Ops.i8b(_isMixinDeclaration ? 1 : 0), - ...Ops.i32b(_positionalLength), - ...Ops.strlist(_namedList, pool) - ]; + int get opIndex => Ops.opCallSuperAsync; @override Future run(Scope scope) async { @@ -55,10 +46,7 @@ class OpCallSuper implements Op { OpCallSuper(MicroDartEngine engine) : _super = ClassRef.fromEngine(engine), _name = engine.readString(), - _isGetter = engine.readUint8() == 1 ? true : false, - _isSetter = engine.readUint8() == 1 ? true : false, - _isAsync = engine.readUint8() == 1 ? true : false, - _isMixinDeclaration = engine.readUint8() == 1 ? true : false, + _flags = engine.readInt32(), _positionalLength = engine.readInt32(), _namedList = engine.readStringList(); @@ -66,21 +54,26 @@ class OpCallSuper implements Op { final String _name; final int _positionalLength; final List _namedList; - final bool _isGetter; - final bool _isSetter; - final bool _isAsync; - final bool _isMixinDeclaration; + final int _flags; + bool get _isGetter => Flags.isGetter(_flags); + bool get _isSetter => Flags.isSetter(_flags); + bool get _isAsync => Flags.isAsync(_flags); + bool get _isMixinDeclaration => Flags.isMixinDeclaration(_flags); OpCallSuper.make( this._super, this._name, - this._isGetter, - this._isSetter, - this._isAsync, - this._isMixinDeclaration, + bool _isGetter, + bool _isSetter, + bool _isAsync, + bool _isMixinDeclaration, this._positionalLength, this._namedList, - ); + ) : _flags = Flags.generateFlags( + isGetter: _isGetter, + isSetter: _isSetter, + isAsync: _isAsync, + isMixinDeclaration: _isMixinDeclaration); @override int get opLen => @@ -91,15 +84,14 @@ class OpCallSuper implements Op { Ops.lenI32 + Ops.lenStrlist(_namedList); + int get opIndex => Ops.opCallSuper; + @override List bytes(ConstantPool pool) => [ - Ops.opCallSuper, + opIndex, ..._super.bytes(pool), ...Ops.str(_name, pool), - ...Ops.i8b(_isGetter ? 1 : 0), - ...Ops.i8b(_isSetter ? 1 : 0), - ...Ops.i8b(_isAsync ? 1 : 0), - ...Ops.i8b(_isMixinDeclaration ? 1 : 0), + ...Ops.i32b(_flags), ...Ops.i32b(_positionalLength), ...Ops.strlist(_namedList, pool) ]; diff --git a/micro_dart_runtime/lib/ops/ops.dart b/micro_dart_runtime/lib/ops/ops.dart index f6f7c056..a31cec7c 100755 --- a/micro_dart_runtime/lib/ops/ops.dart +++ b/micro_dart_runtime/lib/ops/ops.dart @@ -165,6 +165,7 @@ class Ops { static const lenI8 = 1; static const lenI16 = 2; static const lenI32 = 4; + static const lenU32 = 4; static const lenF32 = 4; static const lenI64 = 8; static const lenF64 = 8; diff --git a/micro_dart_runtime/lib/runtime/engine.dart b/micro_dart_runtime/lib/runtime/engine.dart index 6c8bd4e6..6bd744ca 100755 --- a/micro_dart_runtime/lib/runtime/engine.dart +++ b/micro_dart_runtime/lib/runtime/engine.dart @@ -68,6 +68,12 @@ class MicroDartEngine { return i; } + int readUInt32() { + final i = _data!.getUint32(_fileOffset); + _fileOffset += 4; + return i; + } + double readFloat32() { final i = _data!.getFloat32(_fileOffset); _fileOffset += 4; @@ -379,17 +385,19 @@ class MicroDartEngine { return scope.returnValue; } - dynamic callFunction(Scope scope, Instance instance, CallRef ref, - List positional, Map named, dynamic Function()? alse) { + dynamic callFunction( + Scope scope, + Instance instance, + CallRef ref, + List positional, + Map named, + dynamic Function()? otherwise) { //获取当前操作数指针 var pointer = declarations[ref]; var newScope = scope.createFromParent(ref.callName, true, false, maxScopeDeep); if (pointer == null) { - if (alse != null) { - return alse(); - } - return null; + return otherwise?.call(); } List args = [instance]; diff --git a/micro_dart_runtime/lib/runtime/type.dart b/micro_dart_runtime/lib/runtime/type.dart index 866f41f1..8ee69263 100755 --- a/micro_dart_runtime/lib/runtime/type.dart +++ b/micro_dart_runtime/lib/runtime/type.dart @@ -1,57 +1,15 @@ +import 'package:micro_dart_runtime/flags.dart'; import 'package:micro_dart_runtime/micro_dart_runtime.dart'; class CTypes {} -abstract class MDartType {} - -class MDynamicType extends MDartType { - @override - final int hashCode = 54321; - - @override - bool operator ==(Object other) { - return other is MDynamicType && hashCode == other.hashCode; - } -} - -class MInvalidType extends MDartType { - @override - final int hashCode = 12345; - - @override - bool operator ==(Object other) { - return other is MInvalidType && hashCode == other.hashCode; - } -} - -class MVoidType extends MDartType { - @override - final int hashCode = 123121; - - @override - bool operator ==(Object other) { - return other is MVoidType && hashCode == other.hashCode; - } -} - -class MNeverType extends MDartType {} - -class MNullType extends MDartType { - @override - final int hashCode = 123121; - - @override - bool operator ==(Object other) { - return other is MDynamicType && hashCode == other.hashCode; - } -} - class CallRef { final String library; final String className; final String name; - final bool isSetter; - final bool isStatic; + final int flags; + bool get isSetter => Flags.isSetter(flags); + bool get isStatic => Flags.isStatic(flags); String nameWithTypes(List types) { if (types.isEmpty) { @@ -75,8 +33,13 @@ class CallRef { return "$className<$typeStr>"; } - CallRef( - this.library, this.className, this.name, this.isSetter, this.isStatic); + CallRef._(this.library, this.className, this.name, this.flags); + + factory CallRef(String library, String className, String name, bool isSetter, + bool isStatic) { + return CallRef._(library, className, name, + Flags.generateFlags(isSetter: isSetter, isStatic: isStatic)); + } String get callName { if (className.isEmpty) { @@ -89,32 +52,22 @@ class CallRef { return "$library@$className@$name"; } - CallRef copyOfIsSetter(bool isSetter) { - return CallRef(library, className, name, isSetter, isStatic); + CallRef copyOfIsSetter(bool newIsSetter) { + return CallRef(library, className, name, newIsSetter, isStatic); } - CallRef copyOfIsStatic(bool isStatic) { - return CallRef(library, className, name, isSetter, isStatic); + CallRef copyOfIsStatic(bool newIsStatic) { + return CallRef(library, className, name, isSetter, newIsStatic); } factory CallRef.name(String name) { - return CallRef( - "", - "", - name, - false, - false, - ); + return CallRef._( + "", "", name, Flags.generateFlags(isSetter: false, isStatic: false)); } factory CallRef.fromList(List list, List constants) { - return CallRef( - constants[list[0]], - constants[list[1]], - constants[list[2]], - list[3] == 1 ? true : false, - list[4] == 1 ? true : false, - ); + return CallRef._( + constants[list[0]], constants[list[1]], constants[list[2]], list[3]); } List toList(ConstantPool pool) { @@ -122,18 +75,16 @@ class CallRef { pool.addOrGet(library), pool.addOrGet(className), pool.addOrGet(name), - isSetter ? 1 : 0, - isStatic ? 1 : 0, + flags ]; } factory CallRef.fromEngine(MicroDartEngine engine) { - return CallRef( + return CallRef._( engine.constants[engine.readInt32()], engine.constants[engine.readInt32()], engine.constants[engine.readInt32()], - engine.readUint8() == 1 ? true : false, - engine.readUint8() == 1 ? true : false); + engine.readUInt32()); } static const int byteLen = Ops.lenI32 * 3 + Ops.lenI8 * 2; @@ -143,8 +94,7 @@ class CallRef { ...Ops.i32b(pool.addOrGet(library)), ...Ops.i32b(pool.addOrGet(className)), ...Ops.i32b(pool.addOrGet(name)), - ...Ops.u8b(isSetter ? 1 : 0), - ...Ops.u8b(isStatic ? 1 : 0), + ...Ops.i32b(flags) ]; } @@ -237,58 +187,84 @@ class CType { final List getters; final List setters; final List constructors; - final bool isExternal; - final bool isAnonymousMixin; - final bool isMixinDeclaration; - const CType(this.ref, + final int flags; + bool get isExternal => Flags.isExternal(flags); + bool get isAnonymousMixin => Flags.isAnonymousMixin(flags); + bool get isMixinDeclaration => Flags.isMixinDeclaration(flags); + + const CType._(this.ref, {this.superType, this.mixinType, this.implementTypes = const [], this.getters = const [], this.setters = const [], this.constructors = const [], - this.isExternal = false, - this.isAnonymousMixin = false, - this.isMixinDeclaration = false}); + this.flags = 0}); - CType copyWithGetters(List getters) { - return CType(ref, + const CType.external(this.ref, + {this.superType, + this.mixinType, + this.implementTypes = const [], + this.getters = const [], + this.setters = const [], + this.constructors = const [], + this.flags = Flags.external}); + + factory CType(ClassRef ref, + {ClassRef? superType, + ClassRef? mixinType, + List implementTypes = const [], + List getters = const [], + List setters = const [], + List constructors = const [], + bool isExternal = false, + bool isAnonymousMixin = false, + bool isMixinDeclaration = false}) { + return CType._(ref, superType: superType, mixinType: mixinType, implementTypes: implementTypes, getters: getters, setters: setters, constructors: constructors, - isExternal: isExternal, - isAnonymousMixin: isAnonymousMixin, - isMixinDeclaration: isMixinDeclaration); + flags: Flags.generateFlags( + isExternal: isExternal, + isAnonymousMixin: isAnonymousMixin, + isMixinDeclaration: isMixinDeclaration)); } - CType copyWithSetters(List setters) { - return CType(ref, + CType copyWithGetters(List newGetters) { + return CType._(ref, superType: superType, mixinType: mixinType, implementTypes: implementTypes, getters: getters, - setters: setters, + setters: newGetters, constructors: constructors, - isExternal: isExternal, - isAnonymousMixin: isAnonymousMixin, - isMixinDeclaration: isMixinDeclaration); + flags: flags); } - CType copyWithConstructors(List constructors) { - return CType(ref, + CType copyWithSetters(List newSetters) { + return CType._(ref, superType: superType, mixinType: mixinType, implementTypes: implementTypes, getters: getters, - setters: setters, + setters: newSetters, constructors: constructors, - isExternal: isExternal, - isAnonymousMixin: isAnonymousMixin, - isMixinDeclaration: isMixinDeclaration); + flags: flags); + } + + CType copyWithConstructors(List newConstructors) { + return CType._(ref, + superType: superType, + mixinType: mixinType, + implementTypes: implementTypes, + getters: getters, + setters: setters, + constructors: newConstructors, + flags: flags); } bool isType(CType cType, MicroDartEngine engine) { @@ -321,14 +297,12 @@ class CType { getters.map((e) => pool.addOrGet(e)).toList(), setters.map((e) => pool.addOrGet(e)).toList(), constructors.map((e) => pool.addOrGet(e)).toList(), - isExternal, - isAnonymousMixin, - isMixinDeclaration, + flags ]; } factory CType.fromList(List list, List constants) { - return CType( + return CType._( ClassRef.fromList(list[0], constants), superType: list[1] == null ? null : ClassRef.fromList(list[1], constants), mixinType: list[2] == null ? null : ClassRef.fromList(list[2], constants), @@ -338,9 +312,7 @@ class CType { getters: (list[4] as List).map((e) => constants[e]).toList(), setters: (list[5] as List).map((e) => constants[e]).toList(), constructors: (list[6] as List).map((e) => constants[e]).toList(), - isExternal: list[7], - isAnonymousMixin: list[8], - isMixinDeclaration: list[9], + flags: list[7], ); } @@ -360,20 +332,11 @@ class CType { return "CType($ref,$superType,$mixinType)"; } - CallRef getCallRef(String name, bool isSetter, bool isStatic) { - return CallRef(ref.library, ref.className, name, isSetter, isStatic); + CallRef getCallRef(String name, bool newIsSetter, bool newIsStatic) { + return CallRef(ref.library, ref.className, name, newIsSetter, newIsStatic); } @override - int get hashCode => Object.hash( - ref, - superType, - mixinType, - implementTypes, - getters, - setters, - constructors, - isExternal, - isAnonymousMixin, - isMixinDeclaration); + int get hashCode => Object.hash(ref, superType, mixinType, implementTypes, + getters, setters, constructors, flags); } diff --git a/micro_dart_runtime/test/test1.dart b/micro_dart_runtime/test/test1.dart new file mode 100644 index 00000000..bf2b33ec --- /dev/null +++ b/micro_dart_runtime/test/test1.dart @@ -0,0 +1,7 @@ +import 'package:micro_dart_runtime/flags.dart'; + +void main() { + int flags = Flags.generateFlags(isExternal: true); + + print(flags); +}