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

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

Issue 1245013005: fixes #259, clone ast before mutation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: revert dependency_overrides in pubspec Created 5 years, 5 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) 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 /// Command line tool to run the checker on a Dart program. 5 /// Command line tool to run the checker on a Dart program.
6 library dev_compiler.src.compiler; 6 library dev_compiler.src.compiler;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:math' as math; 10 import 'dart:math' as math;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 if (failureInLib) { 123 if (failureInLib) {
124 _failure = true; 124 _failure = true;
125 if (!options.codegenOptions.forceCompile) return; 125 if (!options.codegenOptions.forceCompile) return;
126 } 126 }
127 127
128 if (_jsGen != null) { 128 if (_jsGen != null) {
129 var unit = units.first; 129 var unit = units.first;
130 var parts = units.skip(1).toList(); 130 var parts = units.skip(1).toList();
131
132 // TODO(jmesserly): this hack is to avoid compiling the same compilation
133 // unit to JS twice. We mutate the AST, so it's not safe to run more than
134 // once on the same unit.
135 if (unit.getProperty(_propertyName) == true) return;
136 unit.setProperty(_propertyName, true);
137
138 _jsGen.generateLibrary(new LibraryUnit(unit, parts)); 131 _jsGen.generateLibrary(new LibraryUnit(unit, parts));
139 } 132 }
140 } 133 }
141 134
142 static const String _propertyName = 'dev_compiler.BatchCompiler.isCompiled';
143
144 void compileHtml(Source source) { 135 void compileHtml(Source source) {
145 // TODO(jmesserly): reuse DartScriptsTask instead of copy/paste. 136 // TODO(jmesserly): reuse DartScriptsTask instead of copy/paste.
146 var contents = context.getContents(source); 137 var contents = context.getContents(source);
147 var document = html.parse(contents.data, generateSpans: true); 138 var document = html.parse(contents.data, generateSpans: true);
148 var scripts = document.querySelectorAll('script[type="application/dart"]'); 139 var scripts = document.querySelectorAll('script[type="application/dart"]');
149 140
150 var loadedLibs = new LinkedHashSet<Uri>(); 141 var loadedLibs = new LinkedHashSet<Uri>();
151 142
152 for (var script in scripts) { 143 for (var script in scripts) {
153 Source scriptSource = null; 144 Source scriptSource = null;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 '_rtti.js', 385 '_rtti.js',
395 '_classes.js', 386 '_classes.js',
396 '_operations.js', 387 '_operations.js',
397 'dart_runtime.js', 388 'dart_runtime.js',
398 ]; 389 ];
399 files.addAll(corelibOrder.map((l) => l.replaceAll('.', '/') + '.js')); 390 files.addAll(corelibOrder.map((l) => l.replaceAll('.', '/') + '.js'));
400 return files; 391 return files;
401 }(); 392 }();
402 393
403 final _log = new Logger('dev_compiler.src.compiler'); 394 final _log = new Logger('dev_compiler.src.compiler');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698