Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Side by Side Diff: lib/src/compiler/module_builder.dart

Issue 2016483002: Enable strong mode in DDC, fix all warnings/errors (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/compiler/js_metalet.dart ('k') | lib/src/compiler/nullable_type_inference.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:path/path.dart' as path; 5 import 'package:path/path.dart' as path;
6 6
7 import '../js_ast/js_ast.dart'; 7 import '../js_ast/js_ast.dart';
8 import 'js_names.dart'; 8 import 'js_names.dart';
9 9
10 /// Base class for compiling ES6 modules into various ES5 module patterns. 10 /// Base class for compiling ES6 modules into various ES5 module patterns.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 "Imports", new ArrayInitializer(importNames, multiline: true)), 101 "Imports", new ArrayInitializer(importNames, multiline: true)),
102 resultModule 102 resultModule
103 ]); 103 ]);
104 return new Program(<ModuleItem>[moduleDef]); 104 return new Program(<ModuleItem>[moduleDef]);
105 } 105 }
106 } 106 }
107 107
108 /// Generates node modules. 108 /// Generates node modules.
109 class NodeModuleBuilder extends _ModuleBuilder { 109 class NodeModuleBuilder extends _ModuleBuilder {
110 Program build(Program module) { 110 Program build(Program module) {
111 var importStatements = []; 111 var importStatements = <Statement>[];
112 112
113 // Collect imports/exports/statements. 113 // Collect imports/exports/statements.
114 visitProgram(module); 114 visitProgram(module);
115 115
116 for (var import in imports) { 116 for (var import in imports) {
117 // TODO(jmesserly): we could use destructuring once Atom supports it. 117 // TODO(jmesserly): we could use destructuring once Atom supports it.
118 var moduleVar = 118 var moduleVar =
119 new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); 119 new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes));
120 importStatements 120 importStatements
121 .add(js.statement('const # = require(#);', [moduleVar, import.from])); 121 .add(js.statement('const # = require(#);', [moduleVar, import.from]));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Ensure the identifier first character is not numeric and that the whole 178 // Ensure the identifier first character is not numeric and that the whole
179 // identifier is not a keyword. 179 // identifier is not a keyword.
180 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) { 180 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) {
181 return '\$$result'; 181 return '\$$result';
182 } 182 }
183 return result; 183 return result;
184 } 184 }
185 185
186 // Invalid characters for identifiers, which would need to be escaped. 186 // Invalid characters for identifiers, which would need to be escaped.
187 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]'); 187 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]');
OLDNEW
« no previous file with comments | « lib/src/compiler/js_metalet.dart ('k') | lib/src/compiler/nullable_type_inference.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698