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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/lazy_emitter/model_emitter.dart

Issue 2944843002: All strong mode cleaning of dart2js. (Closed)
Patch Set: More issues discovered during testing. Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library dart2js.js_emitter.lazy_emitter.model_emitter; 5 library dart2js.js_emitter.lazy_emitter.model_emitter;
6 6
7 import 'package:js_runtime/shared/embedded_names.dart' 7 import 'package:js_runtime/shared/embedded_names.dart'
8 show 8 show
9 CREATE_NEW_ISOLATE, 9 CREATE_NEW_ISOLATE,
10 DEFERRED_LIBRARY_URIS, 10 DEFERRED_LIBRARY_URIS,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 int emitProgram(Program program) { 142 int emitProgram(Program program) {
143 List<Fragment> fragments = program.fragments; 143 List<Fragment> fragments = program.fragments;
144 MainFragment mainFragment = fragments.first; 144 MainFragment mainFragment = fragments.first;
145 Iterable<Fragment> deferredFragments = program.deferredFragments; 145 Iterable<Fragment> deferredFragments = program.deferredFragments;
146 146
147 int totalSize = 0; 147 int totalSize = 0;
148 148
149 // We have to emit the deferred fragments first, since we need their 149 // We have to emit the deferred fragments first, since we need their
150 // deferred hash (which depends on the output) when emitting the main 150 // deferred hash (which depends on the output) when emitting the main
151 // fragment. 151 // fragment.
152 List<js.Expression> fragmentsCode = 152 List<js.Expression> fragmentsCode = deferredFragments.map((deferredUnit) {
153 deferredFragments.map((DeferredFragment deferredUnit) {
154 js.Expression types = 153 js.Expression types =
155 program.metadataTypesForOutputUnit(deferredUnit.outputUnit); 154 program.metadataTypesForOutputUnit(deferredUnit.outputUnit);
156 return emitDeferredFragment(types, deferredUnit, program.holders); 155 return emitDeferredFragment(types, deferredUnit, program.holders);
157 }).toList(); 156 }).toList();
158 157
159 js.Statement mainAst = emitMainFragment(program); 158 js.Statement mainAst = emitMainFragment(program);
160 159
161 js.TokenCounter counter = new js.TokenCounter(); 160 js.TokenCounter counter = new js.TokenCounter();
162 fragmentsCode.forEach(counter.countTokens); 161 fragmentsCode.forEach(counter.countTokens);
163 counter.countTokens(mainAst); 162 counter.countTokens(mainAst);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 return js.js.statement(""" 392 return js.js.statement("""
394 if (typeof($deferredInitializersGlobal) === 'undefined') 393 if (typeof($deferredInitializersGlobal) === 'undefined')
395 var $deferredInitializersGlobal = Object.create(null);"""); 394 var $deferredInitializersGlobal = Object.create(null);""");
396 } 395 }
397 396
398 Iterable<js.Property> emitEmbeddedGlobalsForDeferredLoading( 397 Iterable<js.Property> emitEmbeddedGlobalsForDeferredLoading(
399 Map<String, List<Fragment>> loadMap) { 398 Map<String, List<Fragment>> loadMap) {
400 List<js.Property> globals = <js.Property>[]; 399 List<js.Property> globals = <js.Property>[];
401 400
402 js.ArrayInitializer fragmentUris(List<Fragment> fragments) { 401 js.ArrayInitializer fragmentUris(List<Fragment> fragments) {
403 return js.stringArray(fragments.map((DeferredFragment fragment) => 402 return js.stringArray(fragments
404 "${fragment.outputFileName}.$deferredExtension")); 403 .map((fragment) => "${fragment.outputFileName}.$deferredExtension"));
405 } 404 }
406 405
407 js.ArrayInitializer fragmentHashes(List<Fragment> fragments) { 406 js.ArrayInitializer fragmentHashes(List<Fragment> fragments) {
408 // TODO(floitsch): the hash must depend on the generated code. 407 // TODO(floitsch): the hash must depend on the generated code.
409 return js.numArray( 408 return js.numArray(fragments.map((fragment) => fragment.hashCode));
410 fragments.map((DeferredFragment fragment) => fragment.hashCode));
411 } 409 }
412 410
413 List<js.Property> uris = new List<js.Property>(loadMap.length); 411 List<js.Property> uris = new List<js.Property>(loadMap.length);
414 List<js.Property> hashes = new List<js.Property>(loadMap.length); 412 List<js.Property> hashes = new List<js.Property>(loadMap.length);
415 int count = 0; 413 int count = 0;
416 loadMap.forEach((String loadId, List<Fragment> fragmentList) { 414 loadMap.forEach((String loadId, List<Fragment> fragmentList) {
417 uris[count] = 415 uris[count] =
418 new js.Property(js.string(loadId), fragmentUris(fragmentList)); 416 new js.Property(js.string(loadId), fragmentUris(fragmentList));
419 hashes[count] = 417 hashes[count] =
420 new js.Property(js.string(loadId), fragmentHashes(fragmentList)); 418 new js.Property(js.string(loadId), fragmentHashes(fragmentList));
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 #eagerClasses; 1288 #eagerClasses;
1291 1289
1292 var end = Date.now(); 1290 var end = Date.now();
1293 // print('Setup: ' + (end - start) + ' ms.'); 1291 // print('Setup: ' + (end - start) + ' ms.');
1294 1292
1295 #invokeMain; // Start main. 1293 #invokeMain; // Start main.
1296 1294
1297 })(Date.now(), #code) 1295 })(Date.now(), #code)
1298 }"""; 1296 }""";
1299 } 1297 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/metadata_collector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698