From 989da057a7b68bd9edcc72b6c15473df71490339 Mon Sep 17 00:00:00 2001 From: nixo Date: Sat, 21 Nov 2020 21:29:19 +0100 Subject: [PATCH] Make it compile with older dart version --- build/config/compiler/BUILD.gn | 6 +- build/config/gcc/BUILD.gn | 2 +- build/dart/dart_action.gni | 6 +- .../lib/src/analyzer/code_generator.dart | 64 +++---- .../lib/src/analyzer/property_model.dart | 18 +- .../lib/src/analyzer/type_utilities.dart | 4 +- .../lib/src/compiler/js_metalet.dart | 8 +- .../lib/src/compiler/js_names.dart | 2 +- .../lib/src/compiler/module_builder.dart | 14 +- .../lib/src/compiler/shared_compiler.dart | 10 +- pkg/dev_compiler/lib/src/js_ast/builder.dart | 158 +++++++++--------- pkg/dev_compiler/lib/src/js_ast/nodes.dart | 16 +- pkg/dev_compiler/lib/src/js_ast/printer.dart | 14 +- pkg/dev_compiler/lib/src/js_ast/template.dart | 118 ++++++------- pkg/dev_compiler/lib/src/kernel/compiler.dart | 122 +++++++------- .../lib/src/kernel/constants.dart | 12 +- .../lib/src/kernel/native_types.dart | 6 +- .../lib/src/kernel/nullable_inference.dart | 8 +- .../lib/src/kernel/property_model.dart | 10 +- pkg/dev_compiler/lib/src/kernel/target.dart | 20 +-- .../lib/src/kernel/type_table.dart | 4 +- pkg/dev_compiler/tool/kernel_sdk.dart | 16 +- pkg/dev_compiler/tool/patch_sdk.dart | 36 ++-- pkg/front_end/tool/fasta | 2 +- pkg/js_ast/lib/src/builder.dart | 2 +- runtime/BUILD.gn | 6 +- sdk/BUILD.gn | 68 ++++---- tools/observatory_tool.py | 2 +- utils/application_snapshot.gni | 6 +- utils/dartdevc/BUILD.gn | 8 +- 30 files changed, 385 insertions(+), 383 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 8154e4e9a2..ec56ca353e 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -578,9 +578,9 @@ config("chromium_code") { cflags = [] } else { cflags = [ - "-Wall", - "-Wextra", - "-Werror", + # "-Wall", + # "-Wextra", + # -Werror, ] defines = [] diff --git a/build/config/gcc/BUILD.gn b/build/config/gcc/BUILD.gn index 110f1cceb5..93517f0496 100644 --- a/build/config/gcc/BUILD.gn +++ b/build/config/gcc/BUILD.gn @@ -35,7 +35,7 @@ config("executable_ldconfig") { # Newer binutils don't set DT_RPATH unless you disable "new" dtags # and the new DT_RUNPATH doesn't work without --no-as-needed flag. - "-Wl,--disable-new-dtags", + "-Wl,--enable-new-dtags", ] } } diff --git a/build/dart/dart_action.gni b/build/dart/dart_action.gni index 91f5e293f8..f7e81ac593 100644 --- a/build/dart/dart_action.gni +++ b/build/dart/dart_action.gni @@ -224,12 +224,12 @@ template("prebuilt_dart_action") { forward_variables_from(invoker, "*") if (_is_fuchsia) { binary = prebuilt_dart - dfe = "$prebuilt_dart_sdk/bin/snapshots/kernel-service.dart.snapshot" + # dfe = "$prebuilt_dart_sdk/bin/snapshots/kernel-service.dart.snapshot" } else { binary = "$_dart_root/tools/sdks/$host_os/dart-sdk/bin/dart$executable_suffix" - dfe = - "$_dart_root/tools/sdks/$host_os/dart-sdk/bin/snapshots/kernel-service.dart.snapshot" + # dfe = + # "$_dart_root/tools/sdks/$host_os/dart-sdk/bin/snapshots/kernel-service.dart.snapshot" } target = "$_dart_root/runtime/bin:dart_bootstrap" } diff --git a/pkg/dev_compiler/lib/src/analyzer/code_generator.dart b/pkg/dev_compiler/lib/src/analyzer/code_generator.dart index fdda18f780..6b545ef850 100644 --- a/pkg/dev_compiler/lib/src/analyzer/code_generator.dart +++ b/pkg/dev_compiler/lib/src/analyzer/code_generator.dart @@ -91,10 +91,10 @@ class CodeGenerator extends Object /// /// We sometimes special case codegen for a single library, as it simplifies /// name scoping requirements. - final _libraries = Map(); + final _libraries = new Map(); /// Imported libraries, and the temporaries used to refer to them. - final _imports = Map(); + final _imports = new Map(); /// The list of dart:_runtime SDK functions; these are assumed by other code /// in the SDK to be generated before anything else. @@ -118,10 +118,10 @@ class CodeGenerator extends Object /// In an async* function, this represents the stream controller parameter. JS.TemporaryId _asyncStarController; - final _initializingFormalTemps = HashMap(); + final _initializingFormalTemps = new HashMap(); JS.Identifier _extensionSymbolsModule; - final _extensionSymbols = Map(); + final _extensionSymbols = new Map(); /// The type provider from the current Analysis [context]. final TypeProvider types; @@ -200,9 +200,9 @@ class CodeGenerator extends Object /// Information about virtual fields for all libraries in the current build /// unit. - final virtualFields = VirtualFieldModel(); + final virtualFields = new VirtualFieldModel(); - final _usedCovariantPrivateMembers = HashSet(); + final _usedCovariantPrivateMembers = new HashSet(); CodeGenerator( AnalysisContext c, this.summaryData, this.options, this._extensionTypes) @@ -326,8 +326,8 @@ class CodeGenerator extends Object _extensionSymbolsModule = JS.Identifier('dartx'); } else { // Otherwise allow these to be renamed so users can write them. - runtimeModule = JS.TemporaryId('dart'); - _extensionSymbolsModule = JS.TemporaryId('dartx'); + runtimeModule = new JS.TemporaryId('dart'); + _extensionSymbolsModule = new JS.TemporaryId('dartx'); } _typeTable = TypeTable(runtimeModule); @@ -1147,7 +1147,7 @@ class CodeGenerator extends Object if (isClassSymbol == null) { // TODO(jmesserly): we could export these symbols, if we want to mark // implemented interfaces for user-defined classes. - var id = JS.TemporaryId("_is_${classElem.name}_default"); + var id = new JS.TemporaryId("_is_${classElem.name}_default"); moduleItems.add( js.statement('const # = Symbol(#);', [id, js.string(id.name, "'")])); isClassSymbol = id; @@ -1250,7 +1250,7 @@ class CodeGenerator extends Object .toStatement(); } var classExpr = JS.ClassExpression( - JS.TemporaryId(classElem.name), heritage, methods, + new JS.TemporaryId(classElem.name), heritage, methods, typeParams: typeParams, fields: jsFields); return js.statement('# = #;', [className, classExpr]); } @@ -1378,8 +1378,8 @@ class CodeGenerator extends Object // mixinMembers(C, class C$ extends M { }); mixinBody.add(runtimeStatement('mixinMembers(#, #)', [ classExpr, - JS.ClassExpression( - JS.TemporaryId(classElem.name), mixinClass, methods) + new JS.ClassExpression( + new JS.TemporaryId(classElem.name), mixinClass, methods) ])); } @@ -1391,10 +1391,10 @@ class CodeGenerator extends Object var m = classElem.mixins[i]; var mixinString = classElem.supertype.name + '_' + m.name; - var mixinClassName = JS.TemporaryId(mixinString); - var mixinId = JS.TemporaryId(mixinString + '\$'); + var mixinClassName = new JS.TemporaryId(mixinString); + var mixinId = new JS.TemporaryId(mixinString + '\$'); var mixinClassExpression = - JS.ClassExpression(mixinClassName, baseClass, []); + new JS.ClassExpression(mixinClassName, baseClass, []); // Bind the mixin class to a name to workaround a V8 bug with es6 classes // and anonymous function names. // TODO(leafp:) Eliminate this once the bug is fixed: @@ -1447,10 +1447,10 @@ class CodeGenerator extends Object // Generate setter if (!decl.isFinal) { - var value = JS.TemporaryId('value'); - fn = JS.Fun([value], js.block('{ this.# = #; }', [name, value])); + var value = new JS.TemporaryId('value'); + fn = new JS.Fun([value], js.block('{ this.# = #; }', [name, value])); method = - JS.Method(_declareMemberName(field.setter), fn, isSetter: true); + new JS.Method(_declareMemberName(field.setter), fn, isSetter: true); jsMethods.add(method); } } @@ -2864,8 +2864,8 @@ class CodeGenerator extends Object var name = element.name; JS.Expression gen = genFn; if (name.isNotEmpty) { - gen = JS.NamedFunction( - JS.TemporaryId(JS.friendlyNameForDartOperator[name] ?? name), + gen = new JS.NamedFunction( + new JS.TemporaryId(JS.friendlyNameForDartOperator[name] ?? name), genFn); } gen.sourceInformation = _functionEnd(body); @@ -2916,7 +2916,7 @@ class CodeGenerator extends Object // `await` is generated as `yield`. // // _AsyncStarImpl has an example of the generated code. - var asyncStarParam = JS.TemporaryId('stream'); + var asyncStarParam = new JS.TemporaryId('stream'); var gen = emitGeneratorFn([asyncStarParam], asyncStarParam); var asyncStarImpl = asyncStarImplType.instantiate([returnType]); @@ -3132,11 +3132,11 @@ class CodeGenerator extends Object /// The renamer would handle this, but it would prefer to rename the /// temporary used for the private symbol. Instead rename the parameter. return _initializingFormalTemps.putIfAbsent( - element, () => JS.TemporaryId(element.name.substring(1))); + element, () => new JS.TemporaryId(element.name.substring(1))); } var type = declaration ? emitTypeRef(element.type) : null; - return JS.Identifier(element.name, type: type); + return new JS.Identifier(element.name, type: type); } List _parameterMetadata(FormalParameter p) => @@ -3699,7 +3699,7 @@ class CodeGenerator extends Object ? 'function(x) { super[#] = x; }' : 'function() { return super[#]; }', [jsName]); - return JS.Method(JS.TemporaryId(member.variable.name), fn, + return new JS.Method(new JS.TemporaryId(member.variable.name), fn, isGetter: !isSetter, isSetter: isSetter); } else { var method = member as MethodElement; @@ -3710,17 +3710,17 @@ class CodeGenerator extends Object params.add(namedArgumentTemp); break; } - params.add(JS.Identifier(param.name)); + params.add(new JS.Identifier(param.name)); } var fn = js.fun( 'function(#) { return super[#](#); }', [params, jsName, params]); var name = method.name; name = JS.friendlyNameForDartOperator[name] ?? name; - return JS.Method(JS.TemporaryId(name), fn); + return new JS.Method(new JS.TemporaryId(name), fn); } }); - return JS.PropertyAccess(JS.This(), jsMethod.name); + return new JS.PropertyAccess(new JS.This(), jsMethod.name); } JS.Expression _emitMethodCall(Expression target, MethodInvocation node) { @@ -4900,7 +4900,7 @@ class CodeGenerator extends Object var id = astFactory .simpleIdentifier(StringToken(TokenType.IDENTIFIER, name, -1)); - variable ??= JS.TemporaryId(name); + variable ??= new JS.TemporaryId(name); var idElement = TemporaryVariableElement.forNode(id, variable) ..enclosingElement = _currentElement; @@ -4925,7 +4925,7 @@ class CodeGenerator extends Object // params are available. if (_currentFunction == null || usesTypeParams) return jsExpr; - var temp = JS.TemporaryId('const'); + var temp = new JS.TemporaryId('const'); moduleItems.add(js.statement('let #;', [temp])); return js.call('# || (# = #)', [temp, temp, jsExpr]); } @@ -5462,7 +5462,7 @@ class CodeGenerator extends Object streamIterator.element.unnamedConstructor, streamIterator, () => [_visitExpression(node.iterable)]); - var iter = JS.TemporaryId('iter'); + var iter = new JS.TemporaryId('iter'); var variable = node.identifier ?? node.loopVariable.identifier; var init = _visitExpression(node.identifier); if (init == null) { @@ -6068,7 +6068,7 @@ class CodeGenerator extends Object JS.TemporaryId _getExtensionSymbolInternal(String name) { return _extensionSymbols.putIfAbsent( name, - () => JS.TemporaryId( + () => new JS.TemporaryId( '\$${JS.friendlyNameForDartOperator[name] ?? name}')); } @@ -6141,7 +6141,7 @@ class CodeGenerator extends Object // It's either one of the libraries in this module, or it's an import. return _libraries[library] ?? _imports.putIfAbsent(library, - () => JS.TemporaryId(jsLibraryName(_libraryRoot, library))); + () => new JS.TemporaryId(jsLibraryName(_libraryRoot, library))); } T closureAnnotate( diff --git a/pkg/dev_compiler/lib/src/analyzer/property_model.dart b/pkg/dev_compiler/lib/src/analyzer/property_model.dart index b625554e1c..2f6b38fc46 100644 --- a/pkg/dev_compiler/lib/src/analyzer/property_model.dart +++ b/pkg/dev_compiler/lib/src/analyzer/property_model.dart @@ -22,11 +22,11 @@ import 'extension_types.dart'; /// which members are private and thus, could not be overridden outside of the /// current library. class VirtualFieldModel { - final _modelForLibrary = HashMap(); + final _modelForLibrary = new HashMap(); _LibraryVirtualFieldModel _getModel(LibraryElement library) => _modelForLibrary.putIfAbsent( - library, () => _LibraryVirtualFieldModel.build(library)); + library, () => new _LibraryVirtualFieldModel.build(library)); /// Returns true if a field is virtual. bool isVirtual(FieldElement field) => @@ -41,7 +41,7 @@ class _LibraryVirtualFieldModel { /// /// This means we must generate them as virtual fields using a property pair /// in JavaScript. - final _overriddenPrivateFields = HashSet(); + final _overriddenPrivateFields = new HashSet(); /// Private classes that can be extended outside of this library. /// @@ -55,7 +55,7 @@ class _LibraryVirtualFieldModel { /// class C extends _A {} /// /// The class _A must treat is "x" as virtual, however _B does not. - final _extensiblePrivateClasses = HashSet(); + final _extensiblePrivateClasses = new HashSet(); _LibraryVirtualFieldModel.build(LibraryElement library) { var allTypes = library.units.expand((u) => u.types).toList(); @@ -176,18 +176,18 @@ class ClassPropertyModel { /// The set of inherited getters, used because JS getters/setters are paired, /// so if we're generating a setter we may need to emit a getter that calls /// super. - final inheritedGetters = HashSet(); + final inheritedGetters = new HashSet(); /// The set of inherited setters, used because JS getters/setters are paired, /// so if we're generating a getter we may need to emit a setter that calls /// super. - final inheritedSetters = HashSet(); + final inheritedSetters = new HashSet(); final mockMembers = {}; - final extensionMethods = Set(); + final extensionMethods = new Set(); - final extensionAccessors = Set(); + final extensionAccessors = new Set(); /// Parameters that are covariant due to covariant generics. final Set covariantParameters; @@ -245,7 +245,7 @@ class ClassPropertyModel { covariantParameters != null && covariantParameters.contains(setter.parameters[0]) && covariantPrivateMembers.contains(setter)) { - virtualFields[field] = JS.TemporaryId(name); + virtualFields[field] = new JS.TemporaryId(name); } } } diff --git a/pkg/dev_compiler/lib/src/analyzer/type_utilities.dart b/pkg/dev_compiler/lib/src/analyzer/type_utilities.dart index f1bef3c158..4695e421a1 100644 --- a/pkg/dev_compiler/lib/src/analyzer/type_utilities.dart +++ b/pkg/dev_compiler/lib/src/analyzer/type_utilities.dart @@ -43,7 +43,7 @@ class _CacheTable { // Use a LinkedHashMap to maintain key insertion order so the generated code // is stable under slight perturbation. (If this is not good enough we could // sort by name to canonicalize order.) - final _names = LinkedHashMap( + final _names = new LinkedHashMap( equals: typesAreEqual, hashCode: typeHashCode); Iterable get keys => _names.keys.toList(); @@ -109,7 +109,7 @@ class _CacheTable { /// Heuristically choose a good name for the cache and generator /// variables. JS.TemporaryId chooseTypeName(DartType type) { - return JS.TemporaryId(_typeString(type)); + return new JS.TemporaryId(_typeString(type)); } } diff --git a/pkg/dev_compiler/lib/src/compiler/js_metalet.dart b/pkg/dev_compiler/lib/src/compiler/js_metalet.dart index 65cfe52ca0..57f143d062 100644 --- a/pkg/dev_compiler/lib/src/compiler/js_metalet.dart +++ b/pkg/dev_compiler/lib/src/compiler/js_metalet.dart @@ -213,9 +213,9 @@ class MetaLet extends Expression { substitutions[variable] = init; } else { // Otherwise replace it with a temp, which will be assigned once. - var temp = TemporaryId(variable.displayName); + var temp = new TemporaryId(variable.displayName); substitutions[variable] = temp; - initializers.add(VariableInitialization(temp, init)); + initializers.add(new VariableInitialization(temp, init)); } }); @@ -223,10 +223,10 @@ class MetaLet extends Expression { node = _substitute(node, substitutions); if (initializers.isNotEmpty) { var first = initializers[0]; - node = Block([ + node = new Block([ initializers.length == 1 ? first.value.toVariableDeclaration(first.declaration) - : VariableDeclarationList('let', initializers).toStatement(), + : new VariableDeclarationList('let', initializers).toStatement(), node ]); } diff --git a/pkg/dev_compiler/lib/src/compiler/js_names.dart b/pkg/dev_compiler/lib/src/compiler/js_names.dart index 7de9cf9293..958eb51e74 100644 --- a/pkg/dev_compiler/lib/src/compiler/js_names.dart +++ b/pkg/dev_compiler/lib/src/compiler/js_names.dart @@ -34,7 +34,7 @@ class MaybeQualifiedId extends Expression { /// Helper to create an [Identifier] from something that starts as a property. static Identifier identifier(LiteralString propertyName) => - Identifier(propertyName.valueWithoutQuotes); + new Identifier(propertyName.valueWithoutQuotes); void setQualified(bool qualified) { var name = this.name; diff --git a/pkg/dev_compiler/lib/src/compiler/module_builder.dart b/pkg/dev_compiler/lib/src/compiler/module_builder.dart index a3f41e05a7..88745ae71d 100644 --- a/pkg/dev_compiler/lib/src/compiler/module_builder.dart +++ b/pkg/dev_compiler/lib/src/compiler/module_builder.dart @@ -150,7 +150,7 @@ class LegacyModuleBuilder extends _ModuleBuilder { visitProgram(module); // Build import parameters. - var exportsVar = TemporaryId('exports'); + var exportsVar = new TemporaryId('exports'); var parameters = [exportsVar]; var importNames = []; var importStatements = []; @@ -158,7 +158,7 @@ class LegacyModuleBuilder extends _ModuleBuilder { importNames.add(import.from); // TODO(jmesserly): we could use destructuring here. var moduleVar = - TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); + new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); parameters.add(moduleVar); for (var importName in import.namedImports) { assert(!importName.isStar); // import * not supported in legacy modules. @@ -195,8 +195,8 @@ class LegacyModuleBuilder extends _ModuleBuilder { var functionName = 'load__' + pathToJSIdentifier(module.name.replaceAll('.', '_')); - var resultModule = NamedFunction( - Identifier(functionName), + var resultModule = new NamedFunction( + new Identifier(functionName), js.fun("function(#) { 'use strict'; #; }", [parameters, statements]), true); @@ -224,7 +224,7 @@ class CommonJSModuleBuilder extends _ModuleBuilder { for (var import in imports) { // TODO(jmesserly): we could use destructuring here. var moduleVar = - TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); + new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); importStatements .add(js.statement('const # = require(#);', [moduleVar, import.from])); @@ -240,7 +240,7 @@ class CommonJSModuleBuilder extends _ModuleBuilder { statements.insertAll(0, importStatements); if (exports.isNotEmpty) { - var exportsVar = Identifier('exports'); + var exportsVar = new Identifier('exports'); statements.add(js.comment('Exports:')); for (var export in exports) { var names = export.exportedNames; @@ -274,7 +274,7 @@ class AmdModuleBuilder extends _ModuleBuilder { for (var import in imports) { // TODO(jmesserly): we could use destructuring once Atom supports it. var moduleVar = - TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); + new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); fnParams.add(moduleVar); dependencies.add(import.from); diff --git a/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart b/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart index f716813f98..fce7213524 100644 --- a/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart +++ b/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart @@ -21,9 +21,9 @@ abstract class SharedCompiler { final List _operatorSetResultStack = []; JS.Identifier runtimeModule; - final namedArgumentTemp = JS.TemporaryId('opts'); + final namedArgumentTemp = new JS.TemporaryId('opts'); - final _privateNames = HashMap>(); + final _privateNames = new HashMap>(); /// The list of output module items, in the order they need to be emitted in. final moduleItems = []; @@ -43,7 +43,7 @@ abstract class SharedCompiler { bool Function() isLastParamMutated) { if (name == '[]=') { _operatorSetResultStack.add(isLastParamMutated() - ? JS.TemporaryId((formals.last as JS.Identifier).name) + ? new JS.TemporaryId((formals.last as JS.Identifier).name) : formals.last); } else { _operatorSetResultStack.add(null); @@ -128,13 +128,13 @@ abstract class SharedCompiler { } JS.TemporaryId emitPrivateNameSymbol(Library library, String name) { - return _privateNames.putIfAbsent(library, () => HashMap()).putIfAbsent(name, + return _privateNames.putIfAbsent(library, () => new HashMap()).putIfAbsent(name, () { var idName = name; if (idName.endsWith('=')) { idName = idName.replaceAll('=', '_'); } - var id = JS.TemporaryId(idName); + var id = new JS.TemporaryId(idName); moduleItems.add( js.statement('const # = Symbol(#);', [id, js.string(name, "'")])); return id; diff --git a/pkg/dev_compiler/lib/src/js_ast/builder.dart b/pkg/dev_compiler/lib/src/js_ast/builder.dart index 117f447785..052fb15d66 100644 --- a/pkg/dev_compiler/lib/src/js_ast/builder.dart +++ b/pkg/dev_compiler/lib/src/js_ast/builder.dart @@ -15,7 +15,7 @@ part of js_ast; * TODO(sra): Find the remaining places where js('xxx') used to parse an * unbounded number of expression, or institute a cache policy. */ -TemplateManager templateManager = TemplateManager(); +TemplateManager templateManager = new TemplateManager(); /** @@ -188,7 +188,7 @@ What is not implemented: var # = 1; */ -const JsBuilder js = JsBuilder(); +JsBuilder js = new JsBuilder(); class JsBuilder { const JsBuilder(); @@ -307,7 +307,7 @@ class JsBuilder { // > closing quote code points, U+005C (REVERSE SOLIDUS), // > U+000D (CARRIAGE RETURN), U+2028 (LINE SEPARATOR), // > U+2029 (PARAGRAPH SEPARATOR), and U+000A (LINE FEED). - var re = RegExp('[\n\r$quoteReplace\b\f\t\v\u2028\u2029]'); + var re = new RegExp('[\n\r$quoteReplace\b\f\t\v\u2028\u2029]'); escaped = escaped.replaceAllMapped(re, (m) { switch (m.group(0)) { case "\n": @@ -412,7 +412,7 @@ class MiniJsParserError { // Replace non-tabs with spaces, giving a print indent that matches the text // for tabbing. - String spaces = prefix.replaceAll(RegExp(r'[^\t]'), ' '); + String spaces = prefix.replaceAll(new RegExp(r'[^\t]'), ' '); return 'Error in MiniJsParser:\n${src}\n$spaces^\n$spaces$message\n'; } } @@ -822,28 +822,28 @@ class MiniJsParser { String last = lastToken; if (acceptCategory(ALPHA)) { if (last == "true") { - return LiteralBool(true); + return new LiteralBool(true); } else if (last == "false") { - return LiteralBool(false); + return new LiteralBool(false); } else if (last == "null") { - return LiteralNull(); + return new LiteralNull(); } else if (last == "function") { return parseFunctionExpression(); } else if (last == "this") { - return This(); + return new This(); } else if (last == "super") { - return Super(); + return new Super(); } else if (last == "class") { return parseClass(); } else { - return Identifier(last); + return new Identifier(last); } } else if (acceptCategory(LPAREN)) { return parseExpressionOrArrowFunction(); } else if (acceptCategory(STRING)) { - return LiteralString(last); + return new LiteralString(last); } else if (acceptCategory(NUMERIC)) { - return LiteralNumber(last); + return new LiteralNumber(last); } else if (acceptCategory(LBRACE)) { return parseObjectInitializer(); } else if (acceptCategory(LSQUARE)) { @@ -851,7 +851,7 @@ class MiniJsParser { while (true) { if (acceptCategory(COMMA)) { - values.add(ArrayHole()); + values.add(new ArrayHole()); continue; } if (acceptCategory(RSQUARE)) break; @@ -865,7 +865,7 @@ class MiniJsParser { getToken(); String flags = lastToken; if (!acceptCategory(ALPHA)) flags = ""; - Expression expression = RegExpLiteral(regexp + flags); + Expression expression = new RegExpLiteral(regexp + flags); return expression; } else if (acceptCategory(HASH)) { return parseInterpolatedExpression(); @@ -876,13 +876,13 @@ class MiniJsParser { } InterpolatedExpression parseInterpolatedExpression() { - var expression = InterpolatedExpression(parseHash()); + var expression = new InterpolatedExpression(parseHash()); interpolatedValues.add(expression); return expression; } InterpolatedIdentifier parseInterpolatedIdentifier() { - var id = InterpolatedIdentifier(parseHash()); + var id = new InterpolatedIdentifier(parseHash()); interpolatedValues.add(id); return id; } @@ -891,7 +891,7 @@ class MiniJsParser { if (acceptCategory(HASH)) { return parseInterpolatedIdentifier(); } else { - var id = Identifier(lastToken); + var id = new Identifier(lastToken); expectCategory(ALPHA); return id; } @@ -920,13 +920,13 @@ class MiniJsParser { if (acceptCategory(ELLIPSIS)) { var params = []; _expressionToParameterList(expression, params); - params.add(RestParameter(parseParameter())); + params.add(new RestParameter(parseParameter())); expectCategory(RPAREN); expectCategory(ARROW); return parseArrowFunctionBody(params); } Expression right = parseAssignment(); - expression = Binary(',', expression, right); + expression = new Binary(',', expression, right); } expectCategory(RPAREN); if (acceptCategory(ARROW)) { @@ -952,7 +952,7 @@ class MiniJsParser { _expressionToParameterList(node.left, params); _expressionToParameterList(node.right, params); } else if (node is InterpolatedExpression) { - params.add(InterpolatedParameter(node.nameOrPosition)); + params.add(new InterpolatedParameter(node.nameOrPosition)); } else { error("Expected arrow function parameter list"); } @@ -965,14 +965,14 @@ class MiniJsParser { } else { body = parseAssignment(); } - return ArrowFun(params, body); + return new ArrowFun(params, body); } Expression parseFunctionExpression() { String last = lastToken; if (acceptCategory(ALPHA)) { String functionName = last; - return NamedFunction(Identifier(functionName), parseFun()); + return new NamedFunction(new Identifier(functionName), parseFun()); } return parseFun(); } @@ -984,7 +984,7 @@ class MiniJsParser { if (!acceptCategory(RPAREN)) { for (;;) { if (acceptCategory(ELLIPSIS)) { - params.add(RestParameter(parseParameter())); + params.add(new RestParameter(parseParameter())); expectCategory(RPAREN); break; } @@ -1018,14 +1018,14 @@ class MiniJsParser { Identifier parseParameter() { if (acceptCategory(HASH)) { var nameOrPosition = parseHash(); - var parameter = InterpolatedParameter(nameOrPosition); + var parameter = new InterpolatedParameter(nameOrPosition); interpolatedValues.add(parameter); return parameter; } else { // TODO(jmesserly): validate this is not a keyword String argumentName = lastToken; expectCategory(ALPHA); - return Identifier(argumentName); + return new Identifier(argumentName); } } @@ -1043,7 +1043,7 @@ class MiniJsParser { if (acceptCategory(RBRACE)) break; expectCategory(COMMA); } - return ObjectInitializer(properties); + return new ObjectInitializer(properties); } Expression parseMember() { @@ -1054,7 +1054,7 @@ class MiniJsParser { } else if (acceptCategory(LSQUARE)) { Expression inBraces = parseExpression(); expectCategory(RSQUARE); - receiver = PropertyAccess(receiver, inBraces); + receiver = new PropertyAccess(receiver, inBraces); } else { break; } @@ -1071,7 +1071,7 @@ class MiniJsParser { if (!acceptCategory(RPAREN)) { while (true) { if (acceptCategory(ELLIPSIS)) { - arguments.add(Spread(parseAssignment())); + arguments.add(new Spread(parseAssignment())); expectCategory(RPAREN); break; } @@ -1081,12 +1081,12 @@ class MiniJsParser { } } receiver = - constructor ? New(receiver, arguments) : Call(receiver, arguments); + constructor ? new New(receiver, arguments) : new Call(receiver, arguments); constructor = false; } else if (!constructor && acceptCategory(LSQUARE)) { Expression inBraces = parseExpression(); expectCategory(RSQUARE); - receiver = PropertyAccess(receiver, inBraces); + receiver = new PropertyAccess(receiver, inBraces); } else if (!constructor && acceptCategory(DOT)) { receiver = getDotRhs(receiver); } else { @@ -1101,9 +1101,9 @@ class MiniJsParser { Expression getDotRhs(Expression receiver) { if (acceptCategory(HASH)) { var nameOrPosition = parseHash(); - InterpolatedSelector property = InterpolatedSelector(nameOrPosition); + InterpolatedSelector property = new InterpolatedSelector(nameOrPosition); interpolatedValues.add(property); - return PropertyAccess(receiver, property); + return new PropertyAccess(receiver, property); } String identifier = lastToken; // In ES5 keywords like delete and continue are allowed as property @@ -1139,8 +1139,8 @@ class MiniJsParser { if (lastCategory == SYMBOL && UNARY_OPERATORS.contains(operator) && (acceptString("++") || acceptString("--") || acceptString('await'))) { - if (operator == "await") return Await(parsePostfix()); - return Prefix(operator, parsePostfix()); + if (operator == "await") return new Await(parsePostfix()); + return new Prefix(operator, parsePostfix()); } return parsePostfix(); } @@ -1152,8 +1152,8 @@ class MiniJsParser { operator != "++" && operator != "--") { expectCategory(SYMBOL); - if (operator == "await") return Await(parsePostfix()); - return Prefix(operator, parseUnaryLow()); + if (operator == "await") return new Await(parsePostfix()); + return new Prefix(operator, parseUnaryLow()); } return parseUnaryHigh(); } @@ -1172,17 +1172,17 @@ class MiniJsParser { } expectCategory(SYMBOL); if (rhs == null || BINARY_PRECEDENCE[symbol] >= minPrecedence) { - if (rhs != null) lhs = Binary(lastSymbol, lhs, rhs); + if (rhs != null) lhs = new Binary(lastSymbol, lhs, rhs); minPrecedence = BINARY_PRECEDENCE[symbol]; rhs = parseUnaryLow(); lastSymbol = symbol; } else { Expression higher = parseBinary(BINARY_PRECEDENCE[symbol]); - rhs = Binary(symbol, rhs, higher); + rhs = new Binary(symbol, rhs, higher); } } if (rhs == null) return lhs; - return Binary(lastSymbol, lhs, rhs); + return new Binary(lastSymbol, lhs, rhs); } Expression parseConditional() { @@ -1191,7 +1191,7 @@ class MiniJsParser { Expression ifTrue = parseAssignment(); expectCategory(COLON); Expression ifFalse = parseAssignment(); - return Conditional(lhs, ifTrue, ifFalse); + return new Conditional(lhs, ifTrue, ifFalse); } Expression parseLeftHandSide() => parseConditional(); @@ -1202,7 +1202,7 @@ class MiniJsParser { if (acceptCategory(ASSIGNMENT)) { Expression rhs = parseAssignment(); if (assignmentOperator == "=") { - return Assignment(lhs, rhs); + return new Assignment(lhs, rhs); } else { // Handle +=, -=, etc. String operator = @@ -1217,7 +1217,7 @@ class MiniJsParser { Expression expression = parseAssignment(); while (acceptCategory(COMMA)) { Expression right = parseAssignment(); - expression = Binary(',', expression, right); + expression = new Binary(',', expression, right); } return expression; } @@ -1230,17 +1230,17 @@ class MiniJsParser { do { VariableBinding declarator; if (firstIdentifier != null) { - declarator = Identifier(firstIdentifier); + declarator = new Identifier(firstIdentifier); firstIdentifier = null; } else { declarator = parseVariableBinding(); } var initializer = acceptString("=") ? parseAssignment() : null; - initialization.add(VariableInitialization(declarator, initializer)); + initialization.add(new VariableInitialization(declarator, initializer)); } while (acceptCategory(COMMA)); - return VariableDeclarationList(keyword, initialization); + return new VariableDeclarationList(keyword, initialization); } VariableBinding parseVariableBinding() { @@ -1291,12 +1291,12 @@ class MiniJsParser { if (acceptString("=")) { defaultValue = parseExpression(); } - variables.add(DestructuredVariable( + variables.add(new DestructuredVariable( name: name, structure: structure, defaultValue: defaultValue)); } while (acceptCategory(COMMA)); expectCategory(RSQUARE); - return ArrayBindingPattern(variables); + return new ArrayBindingPattern(variables); } ObjectBindingPattern parseObjectBindingPattern() { @@ -1311,12 +1311,12 @@ class MiniJsParser { } else if (acceptString("=")) { defaultValue = parseExpression(); } - variables.add(DestructuredVariable( + variables.add(new DestructuredVariable( name: name, structure: structure, defaultValue: defaultValue)); } while (acceptCategory(COMMA)); expectCategory(RBRACE); - return ObjectBindingPattern(variables); + return new ObjectBindingPattern(variables); } Expression parseVarDeclarationOrExpression() { @@ -1360,13 +1360,13 @@ class MiniJsParser { Statement statement = parseStatement(); statements.add(statement); } - return Block(statements); + return new Block(statements); } Statement parseStatement() { if (acceptCategory(LBRACE)) return parseBlock(); - if (acceptCategory(SEMICOLON)) return EmptyStatement(); + if (acceptCategory(SEMICOLON)) return new EmptyStatement(); if (lastCategory == ALPHA) { if (acceptString('return')) return parseReturn(); @@ -1374,16 +1374,16 @@ class MiniJsParser { if (acceptString('throw')) return parseThrow(); if (acceptString('break')) { - return parseBreakOrContinue((label) => Break(label)); + return parseBreakOrContinue((label) => new Break(label)); } if (acceptString('continue')) { - return parseBreakOrContinue((label) => Continue(label)); + return parseBreakOrContinue((label) => new Continue(label)); } if (acceptString('debugger')) { expectSemicolon(); - return DebuggerStatement(); + return new DebuggerStatement(); } if (acceptString('if')) return parseIfThenElse(); @@ -1392,7 +1392,7 @@ class MiniJsParser { if (acceptString('function')) return parseFunctionDeclaration(); - if (acceptString('class')) return ClassDeclaration(parseClass()); + if (acceptString('class')) return new ClassDeclaration(parseClass()); if (acceptString('try')) return parseTry(); @@ -1425,7 +1425,7 @@ class MiniJsParser { Expression expression = parseExpression(); if (expression is Identifier && acceptCategory(COLON)) { - return LabeledStatement(expression.name, parseStatement()); + return new LabeledStatement(expression.name, parseStatement()); } expectSemicolon(); @@ -1436,17 +1436,17 @@ class MiniJsParser { if (expression is InterpolatedExpression) { assert(identical(interpolatedValues.last, expression)); InterpolatedStatement statement = - InterpolatedStatement(expression.nameOrPosition); + new InterpolatedStatement(expression.nameOrPosition); interpolatedValues[interpolatedValues.length - 1] = statement; return statement; } } - return ExpressionStatement(expression); + return new ExpressionStatement(expression); } Statement parseReturn() { - if (acceptSemicolon()) return Return(); + if (acceptSemicolon()) return new Return(); Expression expression = parseExpression(); expectSemicolon(); return Return(expression); @@ -1456,14 +1456,14 @@ class MiniJsParser { bool hasStar = acceptString('*'); Expression expression = parseExpression(); expectSemicolon(); - return DartYield(expression, hasStar); + return new DartYield(expression, hasStar); } Statement parseThrow() { if (skippedNewline) error('throw expression must be on same line'); Expression expression = parseExpression(); expectSemicolon(); - return Throw(expression); + return new Throw(expression); } Statement parseBreakOrContinue(Statement Function(String) constructor) { @@ -1484,7 +1484,7 @@ class MiniJsParser { if (acceptString('else')) { // Resolves dangling else by binding 'else' to closest 'if'. Statement elseStatement = parseStatement(); - return If(condition, thenStatement, elseStatement); + return new If(condition, thenStatement, elseStatement); } else { return If.noElse(condition, thenStatement); } @@ -1551,15 +1551,15 @@ class MiniJsParser { static VariableDeclarationList _createVariableDeclarationList( String keyword, String identifier) { - return VariableDeclarationList( - keyword, [VariableInitialization(Identifier(identifier), null)]); + return new VariableDeclarationList( + keyword, [new VariableInitialization(new Identifier(identifier), null)]); } Statement parseFunctionDeclaration() { String name = lastToken; expectCategory(ALPHA); var fun = parseFun(); - return FunctionDeclaration(Identifier(name), fun); + return new FunctionDeclaration(new Identifier(name), fun); } Statement parseTry() { @@ -1574,7 +1574,7 @@ class MiniJsParser { } else { if (catchPart == null) error("expected 'finally'"); } - return Try(body, catchPart, finallyPart); + return new Try(body, catchPart, finallyPart); } SwitchCase parseSwitchClause() { @@ -1594,7 +1594,7 @@ class MiniJsParser { lastToken != 'default') { statements.add(parseStatement()); } - return SwitchCase(expression, Block(statements)); + return new SwitchCase(expression, new Block(statements)); } Statement parseWhile() { @@ -1602,7 +1602,7 @@ class MiniJsParser { Expression condition = parseExpression(); expectCategory(RPAREN); Statement body = parseStatement(); - return While(condition, body); + return new While(condition, body); } Statement parseDo() { @@ -1613,7 +1613,7 @@ class MiniJsParser { Expression condition = parseExpression(); expectCategory(RPAREN); expectSemicolon(); - return Do(body, condition); + return new Do(body, condition); } Statement parseSwitch() { @@ -1626,7 +1626,7 @@ class MiniJsParser { clauses.add(parseSwitchClause()); } expectCategory(RBRACE); - return Switch(key, clauses); + return new Switch(key, clauses); } Catch parseCatch() { @@ -1636,7 +1636,7 @@ class MiniJsParser { expectCategory(RPAREN); expectCategory(LBRACE); Block body = parseBlock(); - return Catch(Identifier(identifier), body); + return new Catch(new Identifier(identifier), body); } ClassExpression parseClass() { @@ -1646,12 +1646,12 @@ class MiniJsParser { heritage = parseConditional(); } expectCategory(LBRACE); - var methods = List(); + var methods = new List(); while (lastCategory != RBRACE) { methods.add(parseMethodOrProperty(onlyMethods: true) as Method); } expectCategory(RBRACE); - return ClassExpression(name, heritage, methods); + return new ClassExpression(name, heritage, methods); } /** @@ -1677,13 +1677,13 @@ class MiniJsParser { if (lastCategory == COLON) { // That wasn't a accessor but the 'get' or 'set' property: retropedal. isGetter = isSetter = false; - name = LiteralString('"$token"'); + name = new LiteralString('"$token"'); } } if (acceptCategory(HASH)) { if (lastCategory != LPAREN && (onlyMethods || lastCategory != COLON)) { // Interpolated method - var member = InterpolatedMethod(parseHash()); + var member = new InterpolatedMethod(parseHash()); interpolatedValues.add(member); return member; } @@ -1694,10 +1694,10 @@ class MiniJsParser { if (!onlyMethods && acceptCategory(COLON)) { Expression value = parseAssignment(); - return Property(name, value); + return new Property(name, value); } else { var fun = parseFun(); - return Method(name, fun, + return new Method(name, fun, isGetter: isGetter, isSetter: isSetter, isStatic: isStatic); } } @@ -1705,10 +1705,10 @@ class MiniJsParser { Expression parsePropertyName() { String identifier = lastToken; if (acceptCategory(STRING)) { - return LiteralString(identifier); + return new LiteralString(identifier); } else if (acceptCategory(ALPHA) || acceptCategory(SYMBOL)) { // ALPHA or a SYMBOL, e.g. void - return LiteralString('"$identifier"'); + return new LiteralString('"$identifier"'); } else if (acceptCategory(LSQUARE)) { var expr = parseAssignment(); expectCategory(RSQUARE); diff --git a/pkg/dev_compiler/lib/src/js_ast/nodes.dart b/pkg/dev_compiler/lib/src/js_ast/nodes.dart index 2af42b14ac..e0a7572b04 100644 --- a/pkg/dev_compiler/lib/src/js_ast/nodes.dart +++ b/pkg/dev_compiler/lib/src/js_ast/nodes.dart @@ -1191,11 +1191,11 @@ class Identifier extends Expression implements Parameter { throw ArgumentError.value(name, "name", "not a valid identifier"); } } - static RegExp _identifierRE = RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); + static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); bool shadows(Set names) => names.contains(name); - Identifier _clone() => Identifier(name, allowRename: allowRename); + Identifier _clone() => new Identifier(name, allowRename: allowRename); T accept(NodeVisitor visitor) => visitor.visitIdentifier(this); int get precedenceLevel => PRIMARY; void visitChildren(NodeVisitor visitor) {} @@ -1806,7 +1806,7 @@ class InterpolatedIdentifier extends Expression T accept(NodeVisitor visitor) => visitor.visitInterpolatedIdentifier(this); void visitChildren(NodeVisitor visitor) {} - InterpolatedIdentifier _clone() => InterpolatedIdentifier(nameOrPosition); + InterpolatedIdentifier _clone() => new InterpolatedIdentifier(nameOrPosition); int get precedenceLevel => PRIMARY; String get name => throw '$runtimeType does not support this member.'; @@ -1826,7 +1826,7 @@ class RegExpLiteral extends Expression { T accept(NodeVisitor visitor) => visitor.visitRegExpLiteral(this); void visitChildren(NodeVisitor visitor) {} - RegExpLiteral _clone() => RegExpLiteral(pattern); + RegExpLiteral _clone() => new RegExpLiteral(pattern); int get precedenceLevel => PRIMARY; } @@ -1846,7 +1846,7 @@ class Await extends Expression { int get precedenceLevel => UNARY; T accept(NodeVisitor visitor) => visitor.visitAwait(this); void visitChildren(NodeVisitor visitor) => expression.accept(visitor); - Await _clone() => Await(expression); + Await _clone() => new Await(expression); } /** @@ -1861,7 +1861,7 @@ class Comment extends Statement { Comment(this.comment); T accept(NodeVisitor visitor) => visitor.visitComment(this); - Comment _clone() => Comment(comment); + Comment _clone() => new Comment(comment); void visitChildren(NodeVisitor visitor) {} } @@ -1880,14 +1880,14 @@ class CommentExpression extends Expression { int get precedenceLevel => PRIMARY; T accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); - CommentExpression _clone() => CommentExpression(comment, expression); + CommentExpression _clone() => new CommentExpression(comment, expression); void visitChildren(NodeVisitor visitor) => expression.accept(visitor); } class DebuggerStatement extends Statement { T accept(NodeVisitor visitor) => visitor.visitDebuggerStatement(this); - DebuggerStatement _clone() => DebuggerStatement(); + DebuggerStatement _clone() => new DebuggerStatement(); void visitChildren(NodeVisitor visitor) {} } diff --git a/pkg/dev_compiler/lib/src/js_ast/printer.dart b/pkg/dev_compiler/lib/src/js_ast/printer.dart index da7274518a..f8a055666c 100644 --- a/pkg/dev_compiler/lib/src/js_ast/printer.dart +++ b/pkg/dev_compiler/lib/src/js_ast/printer.dart @@ -79,15 +79,15 @@ class Printer extends TypeScriptTypePrinter implements NodeVisitor { /// Whether the next call to [indent] should just be a no-op. bool _skipNextIndent = false; - static final identifierCharacterRegExp = RegExp(r'^[a-zA-Z_0-9$]'); - static final expressionContinuationRegExp = RegExp(r'^[-+([]'); + static final identifierCharacterRegExp = new RegExp(r'^[a-zA-Z_0-9$]'); + static final expressionContinuationRegExp = new RegExp(r'^[-+([]'); Printer(JavaScriptPrintingOptions options, JavaScriptPrintingContext context, {LocalNamer localNamer}) : options = options, context = context, shouldCompressOutput = options.shouldCompressOutput, - danglingElseVisitor = DanglingElseVisitor(context), + danglingElseVisitor = new DanglingElseVisitor(context), localNamer = determineRenamer(localNamer, options) { context.printer = this; } @@ -96,8 +96,8 @@ class Printer extends TypeScriptTypePrinter implements NodeVisitor { LocalNamer localNamer, JavaScriptPrintingOptions options) { if (localNamer != null) return localNamer; return (options.shouldCompressOutput && options.minifyLocalVariables) - ? MinifyRenamer() - : IdentityNamer(); + ? new MinifyRenamer() + : new IdentityNamer(); } // The current indentation string. @@ -1671,9 +1671,9 @@ class MinifyRenamer implements LocalNamer { codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); } codes.add(charCodes.$0 + digit); - newName = String.fromCharCodes(codes); + newName = new String.fromCharCodes(codes); } - assert(RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); + assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); maps.last[oldName] = newName; return newName; } diff --git a/pkg/dev_compiler/lib/src/js_ast/template.dart b/pkg/dev_compiler/lib/src/js_ast/template.dart index 6475446fbf..cffb11da50 100644 --- a/pkg/dev_compiler/lib/src/js_ast/template.dart +++ b/pkg/dev_compiler/lib/src/js_ast/template.dart @@ -182,8 +182,8 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { return (arguments) { var value = arguments[nameOrPosition]; if (value is Expression) return value; - if (value is String) return Identifier(value); - throw StateError( + if (value is String) return new Identifier(value); + throw new StateError( 'Interpolated value #$nameOrPosition is not an Expression: $value'); }; } @@ -195,7 +195,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { var value = arguments[nameOrPosition]; Expression toExpression(item) { if (item is Expression) return item; - if (item is String) return Identifier(item); + if (item is String) return new Identifier(item); throw StateError('Interpolated value #$nameOrPosition is not ' 'an Expression or List of Expressions: $value'); } @@ -237,8 +237,8 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Parameter toIdentifier(item) { if (item is Parameter) return item; - if (item is String) return Identifier(item); - throw StateError( + if (item is String) return new Identifier(item); + throw new StateError( 'Interpolated value #$nameOrPosition is not an Identifier' ' or List of Identifiers: $value'); } @@ -295,7 +295,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { return (arguments) { var item = arguments[nameOrPosition]; if (item is Identifier) return item; - if (item is String) return Identifier(item); + if (item is String) return new Identifier(item); throw StateError('Interpolated value #$nameOrPosition is not a ' 'Identifier or String: $item'); }; @@ -322,7 +322,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator visitProgram(Program node) { var instantiators = node.body.map(visitSplayableStatement).toList(); - return (a) => Program(splayStatements(instantiators, a)); + return (a) => new Program(splayStatements(instantiators, a)); } List splayStatements(List instantiators, arguments) { @@ -343,7 +343,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator visitBlock(Block node) { var instantiators = node.statements.map(visitSplayableStatement).toList(); - return (a) => Block(splayStatements(instantiators, a)); + return (a) => new Block(splayStatements(instantiators, a)); } Instantiator visitExpressionStatement(ExpressionStatement node) { @@ -377,7 +377,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { if (value is bool) { return value ? makeThen(arguments) : makeOtherwise(arguments); } - var cond = value is String ? Identifier(value) : value as Expression; + var cond = value is String ? new Identifier(value) : value as Expression; return If(cond, makeThen(arguments), makeOtherwise(arguments)); }; } @@ -386,7 +386,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator makeCondition = visit(node.condition); Instantiator makeThen = visit(node.then); Instantiator makeOtherwise = visit(node.otherwise); - return (a) => If(makeCondition(a), makeThen(a), makeOtherwise(a)); + return (a) => new If(makeCondition(a), makeThen(a), makeOtherwise(a)); } Instantiator visitFor(For node) { @@ -394,7 +394,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator makeCondition = visitNullable(node.condition); Instantiator makeUpdate = visitNullable(node.update); Instantiator makeBody = visit(node.body); - return (a) => For(makeInit(a), makeCondition(a), + return (a) => new For(makeInit(a), makeCondition(a), makeUpdate(a)?.toVoidExpression(), makeBody(a)); } @@ -402,26 +402,26 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator makeLeftHandSide = visit(node.leftHandSide); Instantiator makeObject = visit(node.object); Instantiator makeBody = visit(node.body); - return (a) => ForIn(makeLeftHandSide(a), makeObject(a), makeBody(a)); + return (a) => new ForIn(makeLeftHandSide(a), makeObject(a), makeBody(a)); } Instantiator visitForOf(ForOf node) { Instantiator makeLeftHandSide = visit(node.leftHandSide); Instantiator makeObject = visit(node.iterable); Instantiator makeBody = visit(node.body); - return (a) => ForOf(makeLeftHandSide(a), makeObject(a), makeBody(a)); + return (a) => new ForOf(makeLeftHandSide(a), makeObject(a), makeBody(a)); } Instantiator visitWhile(While node) { Instantiator makeCondition = visit(node.condition); Instantiator makeBody = visit(node.body); - return (a) => While(makeCondition(a), makeBody(a)); + return (a) => new While(makeCondition(a), makeBody(a)); } Instantiator visitDo(Do node) { Instantiator makeBody = visit(node.body); Instantiator makeCondition = visit(node.condition); - return (a) => Do(makeBody(a), makeCondition(a)); + return (a) => new Do(makeBody(a), makeCondition(a)); } Instantiator visitContinue(Continue node) => @@ -432,36 +432,36 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator visitReturn(Return node) { if (node.value == null) return (args) => Return(); Instantiator makeExpression = visit(node.value); - return (a) => makeExpression(a).toReturn(); + return (a) => new makeExpression(a).toReturn(); } Instantiator visitDartYield(DartYield node) { Instantiator makeExpression = visit(node.expression); - return (a) => DartYield(makeExpression(a), node.hasStar); + return (a) => new DartYield(makeExpression(a), node.hasStar); } Instantiator visitThrow(Throw node) { Instantiator makeExpression = visit(node.expression); - return (a) => Throw(makeExpression(a)); + return (a) => new Throw(makeExpression(a)); } Instantiator visitTry(Try node) { Instantiator makeBody = visit(node.body); Instantiator makeCatch = visitNullable(node.catchPart); Instantiator makeFinally = visitNullable(node.finallyPart); - return (a) => Try(makeBody(a), makeCatch(a), makeFinally(a)); + return (a) => new Try(makeBody(a), makeCatch(a), makeFinally(a)); } Instantiator visitCatch(Catch node) { Instantiator makeDeclaration = visit(node.declaration); Instantiator makeBody = visit(node.body); - return (a) => Catch(makeDeclaration(a), makeBody(a)); + return (a) => new Catch(makeDeclaration(a), makeBody(a)); } Instantiator visitSwitch(Switch node) { Instantiator makeKey = visit(node.key); var makeCases = node.cases.map(visitSwitchCase).toList(); - return (a) => Switch(makeKey(a), makeCases.map((m) => m(a)).toList()); + return (a) => new Switch(makeKey(a), makeCases.map((m) => m(a)).toList()); } Instantiator visitSwitchCase(SwitchCase node) { @@ -476,12 +476,12 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { FunctionDeclaration node) { Instantiator makeName = visit(node.name); Instantiator makeFunction = visit(node.function); - return (a) => FunctionDeclaration(makeName(a), makeFunction(a)); + return (a) => new FunctionDeclaration(makeName(a), makeFunction(a)); } Instantiator visitLabeledStatement(LabeledStatement node) { Instantiator makeBody = visit(node.body); - return (a) => LabeledStatement(node.label, makeBody(a)); + return (a) => new LabeledStatement(node.label, makeBody(a)); } Instantiator visitLiteralStatement(LiteralStatement node) => visitNode(node); @@ -492,7 +492,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { VariableDeclarationList node) { var declarationMakers = node.declarations.map(visitVariableInitialization).toList(); - return (a) => VariableDeclarationList( + return (a) => new VariableDeclarationList( node.keyword, declarationMakers.map((m) => m(a)).toList()); } @@ -510,14 +510,14 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { VariableInitialization node) { Instantiator makeDeclaration = visit(node.declaration); Instantiator makeValue = visitNullable(node.value); - return (a) => VariableInitialization(makeDeclaration(a), makeValue(a)); + return (a) => new VariableInitialization(makeDeclaration(a), makeValue(a)); } Instantiator visitConditional(Conditional cond) { Instantiator makeCondition = visit(cond.condition); Instantiator makeThen = visit(cond.then); Instantiator makeOtherwise = visit(cond.otherwise); - return (a) => Conditional(makeCondition(a), makeThen(a), makeOtherwise(a)); + return (a) => new Conditional(makeCondition(a), makeThen(a), makeOtherwise(a)); } Instantiator visitNew(New node) => handleCallOrNew(node, true); @@ -533,7 +533,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { return (a) { var target = makeTarget(a); var callArgs = splayNodes(argumentMakers, a); - return isNew ? New(target, callArgs) : Call(target, callArgs); + return isNew ? new New(target, callArgs) : new Call(target, callArgs); }; } @@ -541,117 +541,117 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator makeLeft = visit(node.left); Instantiator makeRight = visit(node.right); String op = node.op; - return (a) => Binary(op, makeLeft(a), makeRight(a)); + return (a) => new Binary(op, makeLeft(a), makeRight(a)); } Instantiator visitPrefix(Prefix node) { Instantiator makeOperand = visit(node.argument); String op = node.op; - return (a) => Prefix(op, makeOperand(a)); + return (a) => new Prefix(op, makeOperand(a)); } Instantiator visitPostfix(Postfix node) { Instantiator makeOperand = visit(node.argument); String op = node.op; - return (a) => Postfix(op, makeOperand(a)); + return (a) => new Postfix(op, makeOperand(a)); } Instantiator visitThis(This node) => (a) => This(); Instantiator visitSuper(Super node) => (a) => Super(); Instantiator visitIdentifier(Identifier node) => - (a) => Identifier(node.name); + (a) => new Identifier(node.name); Instantiator visitSpread(Spread node) { var maker = visit(node.argument); - return (a) => Spread(maker(a) as Expression); + return (a) => new Spread(maker(a) as Expression); } Instantiator visitYield(Yield node) { var maker = visitNullable(node.value); - return (a) => Yield(maker(a) as Expression, star: node.star); + return (a) => new Yield(maker(a) as Expression, star: node.star); } Instantiator visitRestParameter(RestParameter node) { var maker = visit(node.parameter); - return (a) => RestParameter(maker(a) as Identifier); + return (a) => new RestParameter(maker(a) as Identifier); } Instantiator visitAccess(PropertyAccess node) { Instantiator makeReceiver = visit(node.receiver); Instantiator makeSelector = visit(node.selector); - return (a) => PropertyAccess(makeReceiver(a), makeSelector(a)); + return (a) => new PropertyAccess(makeReceiver(a), makeSelector(a)); } Instantiator visitNamedFunction(NamedFunction node) { Instantiator makeDeclaration = visit(node.name); Instantiator makeFunction = visit(node.function); - return (a) => NamedFunction(makeDeclaration(a), makeFunction(a)); + return (a) => new NamedFunction(makeDeclaration(a), makeFunction(a)); } Instantiator visitFun(Fun node) { var paramMakers = node.params.map(visitSplayable).toList(); Instantiator makeBody = visit(node.body); - return (a) => Fun(splayNodes(paramMakers, a), makeBody(a), + return (a) => new Fun(splayNodes(paramMakers, a), makeBody(a), isGenerator: node.isGenerator, asyncModifier: node.asyncModifier); } Instantiator visitArrowFun(ArrowFun node) { var paramMakers = node.params.map(visitSplayable).toList(); Instantiator makeBody = visit(node.body as Node); - return (a) => ArrowFun(splayNodes(paramMakers, a), makeBody(a)); + return (a) => new ArrowFun(splayNodes(paramMakers, a), makeBody(a)); } Instantiator visitLiteralBool(LiteralBool node) => - (a) => LiteralBool(node.value); + (a) => new LiteralBool(node.value); Instantiator visitLiteralString(LiteralString node) => - (a) => LiteralString(node.value); + (a) => new LiteralString(node.value); Instantiator visitLiteralNumber(LiteralNumber node) => - (a) => LiteralNumber(node.value); + (a) => new LiteralNumber(node.value); Instantiator visitLiteralNull(LiteralNull node) => - (a) => LiteralNull(); + (a) => new LiteralNull(); Instantiator visitArrayInitializer(ArrayInitializer node) { var makers = node.elements.map(visitSplayableExpression).toList(); - return (a) => ArrayInitializer(splayNodes(makers, a)); + return (a) => new ArrayInitializer(splayNodes(makers, a)); } Instantiator visitArrayHole(ArrayHole node) { - return (arguments) => ArrayHole(); + return (arguments) => new ArrayHole(); } Instantiator visitObjectInitializer( ObjectInitializer node) { var propertyMakers = node.properties.map(visitSplayable).toList(); - return (a) => ObjectInitializer(splayNodes(propertyMakers, a)); + return (a) => new ObjectInitializer(splayNodes(propertyMakers, a)); } Instantiator visitProperty(Property node) { Instantiator makeName = visit(node.name); Instantiator makeValue = visit(node.value); - return (a) => Property(makeName(a), makeValue(a)); + return (a) => new Property(makeName(a), makeValue(a)); } Instantiator visitRegExpLiteral(RegExpLiteral node) => - (a) => RegExpLiteral(node.pattern); + (a) => new RegExpLiteral(node.pattern); Instantiator visitTemplateString(TemplateString node) { var makeElements = node.interpolations.map(visit).toList(); - return (a) => TemplateString(node.strings, splayNodes(makeElements, a)); + return (a) => new TemplateString(node.strings, splayNodes(makeElements, a)); } Instantiator visitTaggedTemplate(TaggedTemplate node) { Instantiator makeTag = visit(node.tag); var makeTemplate = visitTemplateString(node.template); - return (a) => TaggedTemplate(makeTag(a), makeTemplate(a)); + return (a) => new TaggedTemplate(makeTag(a), makeTemplate(a)); } Instantiator visitClassDeclaration(ClassDeclaration node) { var makeClass = visitClassExpression(node.classExpr); - return (a) => ClassDeclaration(makeClass(a)); + return (a) => new ClassDeclaration(makeClass(a)); } Instantiator visitClassExpression(ClassExpression node) { @@ -659,31 +659,31 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator makeName = visit(node.name); Instantiator makeHeritage = visit(node.heritage); - return (a) => ClassExpression( + return (a) => new ClassExpression( makeName(a), makeHeritage(a), splayNodes(makeMethods, a)); } Instantiator visitMethod(Method node) { Instantiator makeName = visit(node.name); Instantiator makeFunction = visit(node.function); - return (a) => Method(makeName(a), makeFunction(a), + return (a) => new Method(makeName(a), makeFunction(a), isGetter: node.isGetter, isSetter: node.isSetter, isStatic: node.isStatic); } Instantiator visitComment(Comment node) => - (a) => Comment(node.comment); + (a) => new Comment(node.comment); Instantiator visitCommentExpression( CommentExpression node) { Instantiator makeExpr = visit(node.expression); - return (a) => CommentExpression(node.comment, makeExpr(a)); + return (a) => new CommentExpression(node.comment, makeExpr(a)); } Instantiator visitAwait(Await node) { Instantiator makeExpr = visit(node.expression); - return (a) => Await(makeExpr(a)); + return (a) => new Await(makeExpr(a)); } // Note: these are not supported yet in the interpolation grammar. @@ -734,7 +734,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator makeStructure = visitNullable(node.structure); Instantiator makeDefaultValue = visitNullable(node.defaultValue); - return (a) => DestructuredVariable( + return (a) => new DestructuredVariable( name: makeName(a), property: makeProperty(a), structure: makeStructure(a), @@ -745,18 +745,18 @@ class InstantiatorGeneratorVisitor implements NodeVisitor { Instantiator visitArrayBindingPattern( ArrayBindingPattern node) { List makeVars = node.variables.map(this.visit).toList(); - return (a) => ArrayBindingPattern(splayNodes(makeVars, a)); + return (a) => new ArrayBindingPattern(splayNodes(makeVars, a)); } @override Instantiator visitObjectBindingPattern(ObjectBindingPattern node) { List makeVars = node.variables.map(this.visit).toList(); - return (a) => ObjectBindingPattern(splayNodes(makeVars, a)); + return (a) => new ObjectBindingPattern(splayNodes(makeVars, a)); } @override Instantiator visitSimpleBindingPattern(SimpleBindingPattern node) => - (a) => SimpleBindingPattern(Identifier(node.name.name)); + (a) => new SimpleBindingPattern(Identifier(node.name.name)); } /** diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart index 3d6f202cd7..cd587b1ad4 100644 --- a/pkg/dev_compiler/lib/src/kernel/compiler.dart +++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart @@ -42,17 +42,17 @@ class ProgramCompiler extends Object /// /// We sometimes special case codegen for a single library, as it simplifies /// name scoping requirements. - final _libraries = Map.identity(); + final _libraries = new Map.identity(); /// Maps a library URI import, that is not in [_libraries], to the /// corresponding Kernel summary module we imported it with. - final _importToSummary = Map.identity(); + final _importToSummary = new Map.identity(); /// Maps a summary to the file URI we used to load it from disk. - final _summaryToUri = Map.identity(); + final _summaryToUri = new Map.identity(); /// Imported libraries, and the temporaries used to refer to them. - final _imports = Map(); + final _imports = new Map(); /// The variable for the current catch clause VariableDeclaration _catchParameter; @@ -61,7 +61,7 @@ class ProgramCompiler extends Object JS.TemporaryId _asyncStarController; JS.Identifier _extensionSymbolsModule; - final _extensionSymbols = Map(); + final _extensionSymbols = new Map(); Set _pendingClasses; @@ -119,13 +119,13 @@ class ProgramCompiler extends Object /// Information about virtual fields for all libraries in the current build /// unit. - final virtualFields = VirtualFieldModel(); + final virtualFields = new VirtualFieldModel(); final JSTypeRep _typeRep; bool _superAllowed = true; - final _superHelpers = Map(); + final _superHelpers = new Map(); final bool emitMetadata; final bool enableAsserts; @@ -171,14 +171,14 @@ class ProgramCompiler extends Object /// statement that is not a loop body is the outermost non-labeled statement /// that it encloses. A [BreakStatement] targeting this statement can be /// compiled to `break` either with or without a label. - final _effectiveTargets = HashMap.identity(); + final _effectiveTargets = new HashMap.identity(); /// A map from effective targets to their label names. /// /// If the target needs to be labeled when compiled to JS, because it was /// targeted by a break or continue with a label, then this map contains the /// label name that was assigned to it. - final _labelNames = HashMap.identity(); + final _labelNames = new HashMap.identity(); final Class _jsArrayClass; final Class privateSymbolClass; @@ -201,14 +201,14 @@ class ProgramCompiler extends Object bool replCompile = false, bool enableAsserts = true, Map declaredVariables = const {}}) { - var coreTypes = CoreTypes(component); + var coreTypes = new CoreTypes(component); var types = - TypeSchemaEnvironment(coreTypes, ClassHierarchy(component), true); - var constants = DevCompilerConstants(types, declaredVariables); - var nativeTypes = NativeTypeSet(coreTypes, constants); - var jsTypeRep = JSTypeRep(types); - return ProgramCompiler._(coreTypes, coreTypes.index, nativeTypes, constants, - types, jsTypeRep, NullableInference(jsTypeRep), + new TypeSchemaEnvironment(coreTypes, new ClassHierarchy(component), true); + var constants = new DevCompilerConstants(types, declaredVariables); + var nativeTypes = new NativeTypeSet(coreTypes, constants); + var jsTypeRep = new JSTypeRep(types); + return new ProgramCompiler._(coreTypes, coreTypes.index, nativeTypes, constants, + types, jsTypeRep, new NullableInference(jsTypeRep), emitMetadata: emitMetadata, enableAsserts: enableAsserts, replCompile: replCompile); @@ -237,7 +237,7 @@ class ProgramCompiler extends Object JS.Program emitModule( Component buildUnit, List summaries, List summaryUris) { if (moduleItems.isNotEmpty) { - throw StateError('Can only call emitModule once.'); + throw new StateError('Can only call emitModule once.'); } _component = buildUnit; @@ -257,33 +257,33 @@ class ProgramCompiler extends Object if (ddcRuntime != null) { // Don't allow these to be renamed when we're building the SDK. // There is JS code in dart:* that depends on their names. - runtimeModule = JS.Identifier('dart'); - _extensionSymbolsModule = JS.Identifier('dartx'); + runtimeModule = new JS.Identifier('dart'); + _extensionSymbolsModule = new JS.Identifier('dartx'); _nullableInference.allowNotNullDeclarations = true; } else { // Otherwise allow these to be renamed so users can write them. - runtimeModule = JS.TemporaryId('dart'); - _extensionSymbolsModule = JS.TemporaryId('dartx'); + runtimeModule = new JS.TemporaryId('dart'); + _extensionSymbolsModule = new JS.TemporaryId('dartx'); } - _typeTable = TypeTable(runtimeModule); + _typeTable = new TypeTable(runtimeModule); // Initialize our library variables. var items = []; var exports = []; // TODO(jmesserly): this is a performance optimization for V8 to prevent it // from treating our Dart library objects as JS Maps. - var root = JS.Identifier('_root'); + var root = new JS.Identifier('_root'); items.add(js.statement('const # = Object.create(null)', [root])); void emitLibrary(JS.Identifier id) { items.add(js.statement('const # = Object.create(#)', [id, root])); - exports.add(JS.NameSpecifier(id)); + exports.add(new JS.NameSpecifier(id)); } for (var library in libraries) { var libraryTemp = library == ddcRuntime ? runtimeModule - : JS.TemporaryId(jsLibraryName(library)); + : new JS.TemporaryId(jsLibraryName(library)); _libraries[library] = libraryTemp; emitLibrary(libraryTemp); } @@ -292,7 +292,7 @@ class ProgramCompiler extends Object // TODO(jmesserly): find a cleaner design for this. if (ddcRuntime != null) emitLibrary(_extensionSymbolsModule); - items.add(JS.ExportDeclaration(JS.ExportClause(exports))); + items.add(new JS.ExportDeclaration(new JS.ExportClause(exports))); // Collect all class/type Element -> Node mappings // in case we need to forward declare any classes. @@ -319,7 +319,7 @@ class ProgramCompiler extends Object // Initialize extension symbols _extensionSymbols.forEach((name, id) { JS.Expression value = - JS.PropertyAccess(_extensionSymbolsModule, _propertyName(name)); + new JS.PropertyAccess(_extensionSymbolsModule, _propertyName(name)); if (ddcRuntime != null) { value = js.call('# = Symbol(#)', [value, js.string("dartx.$name")]); } @@ -334,7 +334,7 @@ class ProgramCompiler extends Object _copyAndFlattenBlocks(items, moduleItems); // Build the module. - return JS.Program(items, name: buildUnit.root.name); + return new JS.Program(items, name: buildUnit.root.name); } /// Flattens blocks in [items] to a single list. @@ -356,7 +356,7 @@ class ProgramCompiler extends Object // It's either one of the libraries in this module, or it's an import. return _libraries[library] ?? _imports.putIfAbsent( - library, () => JS.TemporaryId(jsLibraryName(library))); + library, () => new JS.TemporaryId(jsLibraryName(library))); } String _libraryToModule(Library library) { @@ -381,7 +381,7 @@ class ProgramCompiler extends Object } void _finishImports(List items) { - var modules = Map>(); + var modules = new Map>(); for (var import in _imports.keys) { modules.putIfAbsent(_libraryToModule(import), () => []).add(import); @@ -402,13 +402,13 @@ class ProgramCompiler extends Object // import {foo as foo$} from 'foo'; // if rename was needed // var imports = - libraries.map((l) => JS.NameSpecifier(_imports[l])).toList(); + libraries.map((l) => new JS.NameSpecifier(_imports[l])).toList(); if (module == coreModuleName) { - imports.add(JS.NameSpecifier(runtimeModule)); - imports.add(JS.NameSpecifier(_extensionSymbolsModule)); + imports.add(new JS.NameSpecifier(runtimeModule)); + imports.add(new JS.NameSpecifier(_extensionSymbolsModule)); } - items.add(JS.ImportDeclaration( + items.add(new JS.ImportDeclaration( namedImports: imports, from: js.string(module, "'"))); }); } @@ -531,8 +531,8 @@ class ProgramCompiler extends Object // https://github.com/dart-lang/sdk/issues/31003 var className = c.typeParameters.isNotEmpty ? (c == _jsArrayClass - ? JS.Identifier(c.name) - : JS.TemporaryId(getLocalClassName(c))) + ? new JS.Identifier(c.name) + : new JS.TemporaryId(getLocalClassName(c))) : _emitTopLevelName(c); var savedClassProperties = _classProperties; @@ -566,7 +566,7 @@ class ProgramCompiler extends Object _defineExtensionMembers(className, body); _emitClassMetadata(c.annotations, className, body); - var classDef = JS.Statement.from(body); + var classDef = new JS.Statement.from(body); var typeFormals = c.typeParameters; if (typeFormals.isNotEmpty) { classDef = _defineClassTypeArguments( @@ -615,11 +615,11 @@ class ProgramCompiler extends Object JS.Statement _emitClassStatement(Class c, JS.Expression className, JS.Expression heritage, List methods) { if (c.typeParameters.isNotEmpty) { - return JS.ClassExpression(className as JS.Identifier, heritage, methods) + return new JS.ClassExpression(className as JS.Identifier, heritage, methods) .toStatement(); } - var classExpr = JS.ClassExpression( - JS.TemporaryId(getLocalClassName(c)), heritage, methods); + var classExpr = new JS.ClassExpression( + new JS.TemporaryId(getLocalClassName(c)), heritage, methods); return js.statement('# = #;', [className, classExpr]); } @@ -718,7 +718,7 @@ class ProgramCompiler extends Object ctorBody.add(_emitSuperConstructorCall(className, name, jsParams)); } body.add(_addConstructorToClass( - className, name, JS.Fun(jsParams, JS.Block(ctorBody)))); + className, name, new JS.Fun(jsParams, new JS.Block(ctorBody)))); } } @@ -761,8 +761,8 @@ class ProgramCompiler extends Object // mixinMembers(C, class C$ extends M { }); mixinBody.add(runtimeStatement('mixinMembers(#, #)', [ classExpr, - JS.ClassExpression( - JS.TemporaryId(getLocalClassName(c)), mixinClass, methods) + new JS.ClassExpression( + new JS.TemporaryId(getLocalClassName(c)), mixinClass, methods) ])); } @@ -780,14 +780,14 @@ class ProgramCompiler extends Object var m = mixins[i]; var mixinName = getLocalClassName(superclass) + '_' + getLocalClassName(m.classNode); - var mixinId = JS.TemporaryId(mixinName + '\$'); + var mixinId = new JS.TemporaryId(mixinName + '\$'); // Bind the mixin class to a name to workaround a V8 bug with es6 classes // and anonymous function names. // TODO(leafp:) Eliminate this once the bug is fixed: // https://bugs.chromium.org/p/v8/issues/detail?id=7069 body.add(js.statement("const # = #", [ mixinId, - JS.ClassExpression(JS.TemporaryId(mixinName), baseClass, []) + JS.ClassExpression(new JS.TemporaryId(mixinName), baseClass, []) ])); emitMixinConstructors(mixinId, m); @@ -1035,7 +1035,7 @@ class ProgramCompiler extends Object if (isClassSymbol == null) { // TODO(jmesserly): we could export these symbols, if we want to mark // implemented interfaces for user-defined classes. - var id = JS.TemporaryId("_is_${getLocalClassName(c)}_default"); + var id = new JS.TemporaryId("_is_${getLocalClassName(c)}_default"); moduleItems.add( js.statement('const # = Symbol(#);', [id, js.string(id.name, "'")])); isClassSymbol = id; @@ -1583,8 +1583,8 @@ class ProgramCompiler extends Object } } - var getters = Map(); - var setters = Map(); + var getters = new Map(); + var setters = new Map(); for (var m in c.procedures) { if (m.isAbstract) continue; if (m.isGetter) { @@ -1845,13 +1845,13 @@ class ProgramCompiler extends Object var name = getAnnotationName(field, isJSName) ?? field.name.name; // Generate getter - var fn = JS.Fun([], js.block('{ return this.#; }', [name])); - var method = JS.Method(_declareMemberName(field), fn, isGetter: true); + var fn = new JS.Fun([], js.block('{ return this.#; }', [name])); + var method = new JS.Method(_declareMemberName(field), fn, isGetter: true); jsMethods.add(method); // Generate setter if (!field.isFinal) { - var value = JS.TemporaryId('value'); + var value = new JS.TemporaryId('value'); fn = JS.Fun([value], js.block('{ this.# = #; }', [name, value])); method = JS.Method(_declareMemberName(field), fn, isSetter: true); jsMethods.add(method); @@ -2156,7 +2156,7 @@ class ProgramCompiler extends Object JS.TemporaryId _getExtensionSymbolInternal(String name) { return _extensionSymbols.putIfAbsent( name, - () => JS.TemporaryId( + () => new JS.TemporaryId( '\$${JS.friendlyNameForDartOperator[name] ?? name}')); } @@ -2192,7 +2192,7 @@ class ProgramCompiler extends Object return _extensionTypes.isNativeInterface(c); } - var _forwardingCache = HashMap>(); + var _forwardingCache = new HashMap>(); Member _lookupForwardedMember(Class c, String name) { // We only care about public methods. @@ -2681,7 +2681,7 @@ class ProgramCompiler extends Object emitGeneratorFn(List getParameters(JS.Block jsBody)) { var savedController = _asyncStarController; _asyncStarController = function.asyncMarker == AsyncMarker.AsyncStar - ? JS.TemporaryId('stream') + ? new JS.TemporaryId('stream') : null; JS.Expression gen; @@ -2696,8 +2696,8 @@ class ProgramCompiler extends Object // Name the function if possible, to get better stack traces. gen = genFn; if (name != null) { - gen = JS.NamedFunction( - JS.TemporaryId(JS.friendlyNameForDartOperator[name] ?? name), + gen = new JS.NamedFunction( + new JS.TemporaryId(JS.friendlyNameForDartOperator[name] ?? name), genFn); } @@ -3310,7 +3310,7 @@ class ProgramCompiler extends Object .firstWhere((p) => p.isFactory && p.name.name == '')), [_visitExpression(node.iterable)]); - var iter = JS.TemporaryId('iter'); + var iter = new JS.TemporaryId('iter'); return js.statement( '{' ' let # = #;' @@ -3573,7 +3573,7 @@ class ProgramCompiler extends Object var name = v.name; if (name == null || name.startsWith('#')) { name = name == null ? 't${_tempVariables.length}' : name.substring(1); - return _tempVariables.putIfAbsent(v, () => JS.TemporaryId(name)); + return _tempVariables.putIfAbsent(v, () => new JS.TemporaryId(name)); } return JS.Identifier(name); } @@ -4209,7 +4209,7 @@ class ProgramCompiler extends Object : 'function() { return super[#]; }', [jsName]); - return JS.Method(JS.TemporaryId(name), fn, + return new JS.Method(new JS.TemporaryId(name), fn, isGetter: !setter, isSetter: setter); } else { var function = member.function; @@ -4224,7 +4224,7 @@ class ProgramCompiler extends Object var fn = js.fun( 'function(#) { return super[#](#); }', [params, jsName, params]); name = JS.friendlyNameForDartOperator[name] ?? name; - return JS.Method(JS.TemporaryId(name), fn); + return new JS.Method(new JS.TemporaryId(name), fn); } }); return JS.PropertyAccess(JS.This(), jsMethod.name); @@ -4728,7 +4728,7 @@ class ProgramCompiler extends Object // params are available. if (_currentFunction == null || usesTypeParams) return jsExpr; - var temp = JS.TemporaryId('const'); + var temp = new JS.TemporaryId('const'); moduleItems.add(js.statement('let #;', [temp])); return js.call('# || (# = #)', [temp, temp, jsExpr]); } diff --git a/pkg/dev_compiler/lib/src/kernel/constants.dart b/pkg/dev_compiler/lib/src/kernel/constants.dart index 79448fc565..295de9d9d8 100644 --- a/pkg/dev_compiler/lib/src/kernel/constants.dart +++ b/pkg/dev_compiler/lib/src/kernel/constants.dart @@ -18,8 +18,8 @@ class DevCompilerConstants { DevCompilerConstants( TypeEnvironment types, Map declaredVariables) - : _visitor = _ConstantVisitor(types.coreTypes), - _evaluator = _ConstantEvaluator(types, declaredVariables); + : _visitor = new _ConstantVisitor(types.coreTypes), + _evaluator = new _ConstantEvaluator(types, declaredVariables); /// Determines if an expression is constant. bool isConstant(Expression e) => _visitor.isConstant(e); @@ -181,15 +181,15 @@ class _ConstantEvaluator extends ConstantEvaluator { _ConstantEvaluator(TypeEnvironment types, this.declaredVariables, {bool enableAsserts}) - : unavailableConstant = InstanceConstant( + : unavailableConstant = new InstanceConstant( types.coreTypes.index .getClass('dart:core', '_ConstantExpressionError') .reference, [], {}), - super(_ConstantsBackend(types.coreTypes), types, types.coreTypes, true, + super(new _ConstantsBackend(types.coreTypes), types, types.coreTypes, true, enableAsserts, const _ErrorReporter()) { - env = EvaluationEnvironment(); + env = new EvaluationEnvironment(); } @override @@ -305,7 +305,7 @@ class _ConstantsBackend implements ConstantsBackend { @override buildSymbolConstant(StringConstant value) { - return InstanceConstant( + return new InstanceConstant( coreTypes.internalSymbolClass.reference, const [], {symbolNameField.reference: value}); diff --git a/pkg/dev_compiler/lib/src/kernel/native_types.dart b/pkg/dev_compiler/lib/src/kernel/native_types.dart index 1daac64285..cde8c08f45 100644 --- a/pkg/dev_compiler/lib/src/kernel/native_types.dart +++ b/pkg/dev_compiler/lib/src/kernel/native_types.dart @@ -30,11 +30,11 @@ class NativeTypeSet { // Abstract types that may be implemented by both native and non-native // classes. - final _extensibleTypes = HashSet.identity(); + final _extensibleTypes = new HashSet.identity(); // Concrete native types. - final _nativeTypes = HashSet.identity(); - final _pendingLibraries = HashSet.identity(); + final _nativeTypes = new HashSet.identity(); + final _pendingLibraries = new HashSet.identity(); NativeTypeSet(this.coreTypes, this.constants) { // First, core types: diff --git a/pkg/dev_compiler/lib/src/kernel/nullable_inference.dart b/pkg/dev_compiler/lib/src/kernel/nullable_inference.dart index 8e212cfb1b..edf71afc72 100644 --- a/pkg/dev_compiler/lib/src/kernel/nullable_inference.dart +++ b/pkg/dev_compiler/lib/src/kernel/nullable_inference.dart @@ -36,7 +36,7 @@ class NullableInference extends ExpressionVisitor { /// [allowNotNullDeclarations]. bool allowPackageMetaAnnotations = false; - final _variableInference = _NullableVariableInference(); + final _variableInference = new _NullableVariableInference(); NullableInference(this.jsTypeRep) : types = jsTypeRep.types, @@ -276,19 +276,19 @@ class _NullableVariableInference extends RecursiveVisitor { NullableInference _nullInference; /// Variables that are currently believed to be not-null. - final _notNullLocals = HashSet.identity(); + final _notNullLocals = new HashSet.identity(); /// For each variable currently believed to be not-null ([_notNullLocals]), /// this collects variables that it is assigned to, so we update them if we /// later determine that the variable can be null. final _assignedTo = - HashMap>.identity(); + new HashMap>.identity(); /// All functions that have been analyzed with [analyzeFunction]. /// /// In practice this will include the outermost function (typically a /// [Procedure]) as well as an local functions it contains. - final _functions = HashSet.identity(); + final _functions = new HashSet.identity(); /// The current variable we are setting/initializing, so we can track if it /// is [_assignedTo] from another variable. diff --git a/pkg/dev_compiler/lib/src/kernel/property_model.dart b/pkg/dev_compiler/lib/src/kernel/property_model.dart index 4242554bf6..85bc267822 100644 --- a/pkg/dev_compiler/lib/src/kernel/property_model.dart +++ b/pkg/dev_compiler/lib/src/kernel/property_model.dart @@ -21,10 +21,10 @@ import 'native_types.dart'; /// which members are private and thus, could not be overridden outside of the /// current library. class VirtualFieldModel { - final _modelForLibrary = HashMap(); + final _modelForLibrary = new HashMap(); _LibraryVirtualFieldModel _getModel(Library library) => _modelForLibrary - .putIfAbsent(library, () => _LibraryVirtualFieldModel.build(library)); + .putIfAbsent(library, () => new _LibraryVirtualFieldModel.build(library)); /// Returns true if a field is virtual. bool isVirtual(Field field) => @@ -39,7 +39,7 @@ class _LibraryVirtualFieldModel { /// /// This means we must generate them as virtual fields using a property pair /// in JavaScript. - final _overriddenPrivateFields = HashSet(); + final _overriddenPrivateFields = new HashSet(); /// Private classes that can be extended outside of this library. /// @@ -53,7 +53,7 @@ class _LibraryVirtualFieldModel { /// class C extends _A {} /// /// The class _A must treat is "x" as virtual, however _B does not. - final _extensiblePrivateClasses = HashSet(); + final _extensiblePrivateClasses = new HashSet(); _LibraryVirtualFieldModel.build(Library library) { var allClasses = library.classes; @@ -247,7 +247,7 @@ class ClassPropertyModel { fieldModel.isVirtual(field) || field.isCovariant || field.isGenericCovariantImpl) { - virtualFields[field] = JS.TemporaryId(name); + virtualFields[field] = new JS.TemporaryId(name); } } } diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart index 56f5b5f188..3e3ae26b3b 100644 --- a/pkg/dev_compiler/lib/src/kernel/target.dart +++ b/pkg/dev_compiler/lib/src/kernel/target.dart @@ -88,31 +88,31 @@ class DevCompilerTarget extends Target { .getClass('dart:core', '_Invocation') .constructors .firstWhere((c) => c.name.name == name); - return ConstructorInvocation(ctor, Arguments(positional)); + return new ConstructorInvocation(ctor, new Arguments(positional)); } if (name.startsWith('get:')) { - return createInvocation('getter', [SymbolLiteral(name.substring(4))]); + return createInvocation('getter', [new SymbolLiteral(name.substring(4))]); } if (name.startsWith('set:')) { return createInvocation('setter', [ - SymbolLiteral(name.substring(4) + '='), + new SymbolLiteral(name.substring(4) + '='), arguments.positional.single ]); } - var ctorArgs = [SymbolLiteral(name)]; + var ctorArgs = [new SymbolLiteral(name)]; bool isGeneric = arguments.types.isNotEmpty; if (isGeneric) { ctorArgs.add( - ListLiteral(arguments.types.map((t) => TypeLiteral(t)).toList())); + new ListLiteral(arguments.types.map((t) => new TypeLiteral(t)).toList())); } else { - ctorArgs.add(NullLiteral()); + ctorArgs.add(new NullLiteral()); } - ctorArgs.add(ListLiteral(arguments.positional)); + ctorArgs.add(new ListLiteral(arguments.positional)); if (arguments.named.isNotEmpty) { - ctorArgs.add(MapLiteral( + ctorArgs.add(new MapLiteral( arguments.named - .map((n) => MapEntry(SymbolLiteral(n.name), n.value)) + .map((n) => new MapEntry(new SymbolLiteral(n.name), n.value)) .toList(), keyType: coreTypes.symbolClass.rawType)); } @@ -133,6 +133,6 @@ class DevCompilerTarget extends Target { bool isConstructor = false, bool isTopLevel = false}) { // TODO(sigmund): implement; - return InvalidExpression(null); + return new InvalidExpression(null); } } diff --git a/pkg/dev_compiler/lib/src/kernel/type_table.dart b/pkg/dev_compiler/lib/src/kernel/type_table.dart index 313e8c946a..d2d72537a4 100644 --- a/pkg/dev_compiler/lib/src/kernel/type_table.dart +++ b/pkg/dev_compiler/lib/src/kernel/type_table.dart @@ -103,7 +103,7 @@ class _CacheTable { /// Heuristically choose a good name for the cache and generator /// variables. JS.TemporaryId chooseTypeName(DartType type) { - return JS.TemporaryId(_typeString(type)); + return new JS.TemporaryId(_typeString(type)); } } @@ -150,7 +150,7 @@ class TypeTable { /// parameter. final _scopeDependencies = >{}; - TypeTable(JS.Identifier runtime) : _generators = _GeneratorTable(runtime); + TypeTable(JS.Identifier runtime) : _generators = new _GeneratorTable(runtime); /// Emit a list of statements declaring the cache variables and generator /// definitions tracked by the table. If [formals] is present, only diff --git a/pkg/dev_compiler/tool/kernel_sdk.dart b/pkg/dev_compiler/tool/kernel_sdk.dart index 6be14ed63e..ae5273a52b 100755 --- a/pkg/dev_compiler/tool/kernel_sdk.dart +++ b/pkg/dev_compiler/tool/kernel_sdk.dart @@ -18,7 +18,7 @@ import 'package:path/path.dart' as path; Future main(List args) async { // Parse flags. - var parser = ArgParser(); + var parser = new ArgParser(); var parserOptions = parser.parse(args); var rest = parserOptions.rest; @@ -36,8 +36,8 @@ Future main(List args) async { } var inputPath = path.absolute('tool/input_sdk'); - var target = DevCompilerTarget(); - var options = CompilerOptions() + var target = new DevCompilerTarget(); + var options = new CompilerOptions() ..compileSdk = true ..packagesFileUri = path.toUri(path.absolute('../../.packages')) ..sdkRoot = path.toUri(inputPath) @@ -47,10 +47,10 @@ Future main(List args) async { var component = await kernelForComponent(inputs, options); var outputDir = path.dirname(outputPath); - await Directory(outputDir).create(recursive: true); + await new Directory(outputDir).create(recursive: true); await writeComponentToBinary(component, outputPath); - var jsModule = ProgramCompiler(component, declaredVariables: {}) + var jsModule = new ProgramCompiler(component, declaredVariables: {}) .emitModule(component, [], []); var moduleFormats = { 'amd': ModuleFormat.amd, @@ -63,9 +63,9 @@ Future main(List args) async { var format = moduleFormats[name]; var jsDir = path.join(outputDir, name); var jsPath = path.join(jsDir, 'dart_sdk.js'); - await Directory(jsDir).create(); + await new Directory(jsDir).create(); var jsCode = jsProgramToCode(jsModule, format); - await File(jsPath).writeAsString(jsCode.code); - await File('$jsPath.map').writeAsString(json.encode(jsCode.sourceMap)); + await new File(jsPath).writeAsString(jsCode.code); + await new File('$jsPath.map').writeAsString(json.encode(jsCode.sourceMap)); } } diff --git a/pkg/dev_compiler/tool/patch_sdk.dart b/pkg/dev_compiler/tool/patch_sdk.dart index 85060f0315..c8119aba69 100755 --- a/pkg/dev_compiler/tool/patch_sdk.dart +++ b/pkg/dev_compiler/tool/patch_sdk.dart @@ -30,7 +30,7 @@ void main(List argv) { exit(1); } - var selfModifyTime = File(self).lastModifiedSync().millisecondsSinceEpoch; + var selfModifyTime = new File(self).lastModifiedSync().millisecondsSinceEpoch; var repoDir = argv[0]; var patchDir = argv[1]; @@ -43,17 +43,17 @@ void main(List argv) { // Copy libraries.dart, libraries.json and version var librariesDart = path.join(patchDir, 'libraries.dart'); - var libContents = File(librariesDart).readAsStringSync(); + var libContents = new File(librariesDart).readAsStringSync(); // TODO(jmesserly): can we remove this? _writeSync(path.join(sdkOut, '_internal', 'libraries.dart'), libContents); _writeSync(path.join(sdkOut, 'libraries.json'), - File(path.join(patchDir, 'libraries.json')).readAsStringSync()); + new File(path.join(patchDir, 'libraries.json')).readAsStringSync()); _writeSync( path.join( sdkOut, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'), libContents); _writeSync(path.join(sdkOut, '..', 'version'), - File(path.join(repoDir, 'tools', 'VERSION')).readAsStringSync()); + new File(path.join(repoDir, 'tools', 'VERSION')).readAsStringSync()); // Parse libraries.dart var sdkLibraries = _getSdkLibraries(libContents); @@ -71,13 +71,13 @@ void main(List argv) { if (library.path.contains(INTERNAL_PATH)) { libraryIn = path.join(privateIn, library.path.replaceAll(INTERNAL_PATH, '')); - } else if (File(libraryOverride).existsSync()) { + } else if (new File(libraryOverride).existsSync()) { libraryIn = libraryOverride; } else { libraryIn = libraryOut; } - var libraryFile = File(libraryIn); + var libraryFile = new File(libraryIn); if (libraryFile.existsSync()) { var outPaths = [libraryOut]; var libraryContents = libraryFile.readAsStringSync(); @@ -90,7 +90,7 @@ void main(List argv) { var partPath = part.uri.stringValue; outPaths.add(path.join(path.dirname(libraryOut), partPath)); - var partFile = File(path.join(path.dirname(libraryIn), partPath)); + var partFile = new File(path.join(path.dirname(libraryIn), partPath)); partFiles.add(partFile); inputModifyTime = math.max(inputModifyTime, partFile.lastModifiedSync().millisecondsSinceEpoch); @@ -101,7 +101,7 @@ void main(List argv) { var patchPath = path.join( patchIn, path.basenameWithoutExtension(libraryIn) + '_patch.dart'); - var patchFile = File(patchPath); + var patchFile = new File(patchPath); bool patchExists = patchFile.existsSync(); if (patchExists) { inputModifyTime = math.max(inputModifyTime, @@ -116,7 +116,7 @@ void main(List argv) { // Compare output modify time with input modify time. bool needsUpdate = false; for (var outPath in outPaths) { - var outFile = File(outPath); + var outFile = new File(outPath); if (!outFile.existsSync() || outFile.lastModifiedSync().millisecondsSinceEpoch < inputModifyTime) { @@ -147,10 +147,10 @@ void main(List argv) { /// Writes a file, creating the directory if needed. void _writeSync(String filePath, String contents) { - var outDir = Directory(path.dirname(filePath)); + var outDir = new Directory(path.dirname(filePath)); if (!outDir.existsSync()) outDir.createSync(recursive: true); - File(filePath).writeAsStringSync(contents); + new File(filePath).writeAsStringSync(contents); } /// Merges dart:* library code with code from *_patch.dart file. @@ -177,20 +177,20 @@ List _patchLibrary(List partsContents, String patchContents) { // Parse the patch first. We'll need to extract bits of this as we go through // the other files. - var patchFinder = PatchFinder.parseAndVisit(patchContents); + var patchFinder = new PatchFinder.parseAndVisit(patchContents); // Merge `external` declarations with the corresponding `@patch` code. bool failed = false; for (var partContent in partsContents) { - var partEdits = StringEditBuffer(partContent); + var partEdits = new StringEditBuffer(partContent); var partUnit = parseCompilationUnit(partContent); - var patcher = PatchApplier(partEdits, patchFinder); + var patcher = new PatchApplier(partEdits, patchFinder); partUnit.accept(patcher); if (!failed) failed = patcher.patchWasMissing; results.add(partEdits); } if (failed) return null; - return List.from(results.map((e) => e.toString())); + return results.map((e) => e.toString()).toList(); } /// Merge `@patch` declarations into `external` declarations. @@ -395,7 +395,7 @@ class StringEditBuffer { /// Edit the original text, replacing text on the range [begin] and /// exclusive [end] with the [replacement] string. void replace(int begin, int end, String replacement) { - _edits.add(_StringEdit(begin, end, replacement)); + _edits.add(new _StringEdit(begin, end, replacement)); } /// Insert [string] at [offset]. @@ -415,7 +415,7 @@ class StringEditBuffer { /// Throws [UnsupportedError] if the edits were overlapping. If no edits were /// made, the original string will be returned. String toString() { - var sb = StringBuffer(); + var sb = new StringBuffer(); if (_edits.length == 0) return original; // Sort edits by start location. @@ -473,7 +473,7 @@ List _getSdkLibraries(String contents) { // TODO(jmesserly): fix SdkLibrariesReader_LibraryBuilder in Analyzer. // It doesn't understand optional new/const in Dart 2. For now, we keep // redundant `const` in tool/input_sdk/libraries.dart as a workaround. - var libraryBuilder = SdkLibrariesReader_LibraryBuilder(true); + var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); parseCompilationUnit(contents).accept(libraryBuilder); return libraryBuilder.librariesMap.sdkLibraries; } diff --git a/pkg/front_end/tool/fasta b/pkg/front_end/tool/fasta index 32485f4344..c9928da490 100755 --- a/pkg/front_end/tool/fasta +++ b/pkg/front_end/tool/fasta @@ -54,7 +54,7 @@ case "${1//_/-}" in PATCHED_SDK_DIR=$( ls -d {xcodebuild,out}/${DART_CONFIGURATION} 2>/dev/null \ | head -1) - exec "${DART_VM}" --preview_dart_2 -DDFE_VERBOSE=true "$@" + exec "${DART_VM}" -DDFE_VERBOSE=true "$@" ;; testing) SCRIPT="${REPO_DIR}/pkg/testing/bin/testing.dart" diff --git a/pkg/js_ast/lib/src/builder.dart b/pkg/js_ast/lib/src/builder.dart index 1de3981b7d..c5909472b1 100644 --- a/pkg/js_ast/lib/src/builder.dart +++ b/pkg/js_ast/lib/src/builder.dart @@ -183,7 +183,7 @@ What is not implemented: should be splice or is intended as a single value. */ -const JsBuilder js = const JsBuilder(); +JsBuilder js = new JsBuilder(); class JsBuilder { const JsBuilder(); diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 29f6545010..4aef72ce91 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -161,9 +161,9 @@ config("dart_config") { if (!is_win) { cflags = [ - "-Werror", - "-Wall", - "-Wextra", # Also known as -W. + # -Werror, + # -Wall, + # -Wextra, # Also known as -W. "-Wno-unused-parameter", "-Wnon-virtual-dtor", "-Wvla", diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 226f9595f8..676bfb0d1c 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -710,48 +710,48 @@ copy("copy_dev_compiler_js_legacy_kernel") { } # Copies all of the JS artifacts needed by DDC. -group("copy_dev_compiler_js") { - visibility = [ - ":copy_dev_compiler_sdk", - ":copy_dev_compiler_tools", - ] - public_deps = [ - ":copy_dev_compiler_js_amd", - ":copy_dev_compiler_js_amd_kernel", - ":copy_dev_compiler_js_common", - ":copy_dev_compiler_js_common_kernel", - ":copy_dev_compiler_js_es6", - ":copy_dev_compiler_js_es6_kernel", - ":copy_dev_compiler_js_legacy", - ":copy_dev_compiler_js_legacy_kernel", - ] -} +# group("copy_dev_compiler_js") { +# visibility = [ +# ":copy_dev_compiler_sdk", +# ":copy_dev_compiler_tools", +# ] +# public_deps = [ +# ":copy_dev_compiler_js_amd", +# ":copy_dev_compiler_js_amd_kernel", +# ":copy_dev_compiler_js_common", +# ":copy_dev_compiler_js_common_kernel", +# ":copy_dev_compiler_js_es6", +# ":copy_dev_compiler_js_es6_kernel", +# ":copy_dev_compiler_js_legacy", +# ":copy_dev_compiler_js_legacy_kernel", +# ] +# } # This rule copies tools to go along with ddc. -copy("copy_dev_compiler_tools") { - visibility = [ ":copy_dev_compiler_sdk" ] - deps = [ - ":copy_dev_compiler_js", - "../utils/dartdevc:dartdevc_web", - "../utils/dartdevc:stack_trace_mapper", - ] - dart_out = get_label_info("../utils/dartdevc:dartdevc_web", "root_out_dir") - sources = [ - "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js", - "$dart_out/dev_compiler/build/web/ddc_web_compiler.js", - ] - outputs = [ - "$root_out_dir/dart-sdk/lib/dev_compiler/web/{{source_file_part}}", - ] -} +#copy("copy_dev_compiler_tools") { +# visibility = [ ":copy_dev_compiler_sdk" ] +# deps = [ +# ":copy_dev_compiler_js", +# "../utils/dartdevc:dartdevc_web", +# "../utils/dartdevc:stack_trace_mapper", +# ] +# dart_out = get_label_info("../utils/dartdevc:dartdevc_web", "root_out_dir") +# sources = [ +# "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js", +# "$dart_out/dev_compiler/build/web/ddc_web_compiler.js", +# ] +# outputs = [ +# "$root_out_dir/dart-sdk/lib/dev_compiler/web/{{source_file_part}}", +# ] +#} # This is the main rule for copying ddc's dependencies to lib/ group("copy_dev_compiler_sdk") { visibility = [ ":create_full_sdk" ] public_deps = [ - ":copy_dev_compiler_js", + # ":copy_dev_compiler_js", ":copy_dev_compiler_summary", - ":copy_dev_compiler_tools", + # ":copy_dev_compiler_tools", ] } diff --git a/tools/observatory_tool.py b/tools/observatory_tool.py index 42028b75bf..4bd64645d0 100755 --- a/tools/observatory_tool.py +++ b/tools/observatory_tool.py @@ -179,7 +179,7 @@ def Build(dart_executable, if not silent: DisplayBootstrapWarning() command = [dart_executable, DART2JS_PATH] - command += ['--no-preview-dart-2'] + command += [] command += ['-DOBS_VER=' + utils.GetVersion(no_git_hash=True)] command += [script_path, '-o', output_path, '--packages=%s' % packages_path] # Add the defaults pub used diff --git a/utils/application_snapshot.gni b/utils/application_snapshot.gni index 5ed85b2d38..96cc2fc67b 100644 --- a/utils/application_snapshot.gni +++ b/utils/application_snapshot.gni @@ -87,7 +87,7 @@ template("application_snapshot") { deps = extra_deps if (dart_version == 1) { - snapshot_vm_args += [ "--no-preview-dart-2" ] + snapshot_vm_args += [ ] } else { # HACK: When creating app-jit snapshots for Dart 2 apps, the standalone # Dart VM binary requires the app-jit snapshot for the kernel service to @@ -112,6 +112,7 @@ template("application_snapshot") { vm_args = [ "--deterministic", + "--no_preview_dart_2", "--packages=$dot_packages", "--snapshot=$abs_output", "--snapshot-depfile=$abs_depfile", @@ -177,8 +178,9 @@ template("aot_assembly") { vm_args = [ # TODO(asiva): For not use --no-preview-dart-2, need to flip this to use # gen_kernel to generate a kernel file before creating an app snapshot. - "--no-preview-dart-2", + "--deterministic", + "--no_preview_dart_2", "--packages=$dot_packages", "--snapshot-kind=app-aot", "--snapshot=$abs_output", diff --git a/utils/dartdevc/BUILD.gn b/utils/dartdevc/BUILD.gn index ab80bccb5f..b5667bf98f 100644 --- a/utils/dartdevc/BUILD.gn +++ b/utils/dartdevc/BUILD.gn @@ -117,10 +117,10 @@ template("dart2js_compile") { } } -dart2js_compile("dartdevc_web") { - main = rebase_path("../../pkg/dev_compiler/web/main.dart") - out = "$root_out_dir/dev_compiler/build/web/ddc_web_compiler.js" -} +# dart2js_compile("dartdevc_web") { +# main = rebase_path("../../pkg/dev_compiler/web/main.dart") +# out = "$root_out_dir/dev_compiler/build/web/ddc_web_compiler.js" +# } dart2js_compile("stack_trace_mapper") { main = rebase_path("../../pkg/dev_compiler/web/stack_trace_mapper.dart") -- 2.29.2