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

Side by Side Diff: lib/devc.dart

Issue 1011153002: js: fix core.Object, output order, static const fields (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | lib/runtime/dart_runtime.js » ('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 /// 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.devc; 6 library dev_compiler.devc;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
11 11
12 import 'package:analyzer/src/generated/engine.dart' show ChangeSet; 12 import 'package:analyzer/src/generated/engine.dart' show ChangeSet;
13 import 'package:logging/logging.dart' show Level, Logger, LogRecord; 13 import 'package:logging/logging.dart' show Level, Logger, LogRecord;
14 import 'package:path/path.dart' as path; 14 import 'package:path/path.dart' as path;
15 import 'package:shelf/shelf.dart' as shelf; 15 import 'package:shelf/shelf.dart' as shelf;
16 import 'package:shelf/shelf_io.dart' as shelf; 16 import 'package:shelf/shelf_io.dart' as shelf;
17 import 'package:shelf_static/shelf_static.dart' as shelf_static; 17 import 'package:shelf_static/shelf_static.dart' as shelf_static;
18 18
19 import 'src/checker/checker.dart'; 19 import 'src/checker/checker.dart';
20 import 'src/checker/dart_sdk.dart' show mockSdkSources; 20 import 'src/checker/dart_sdk.dart' show mockSdkSources;
21 import 'src/checker/resolver.dart'; 21 import 'src/checker/resolver.dart';
22 import 'src/checker/rules.dart'; 22 import 'src/checker/rules.dart';
23 import 'src/codegen/code_generator.dart' show CodeGenerator; 23 import 'src/codegen/code_generator.dart' show CodeGenerator;
24 import 'src/codegen/dart_codegen.dart'; 24 import 'src/codegen/dart_codegen.dart';
25 import 'src/codegen/html_codegen.dart'; 25 import 'src/codegen/html_codegen.dart';
26 import 'src/codegen/js_codegen.dart'; 26 import 'src/codegen/js_codegen.dart';
27 import 'src/dependency_graph.dart'; 27 import 'src/dependency_graph.dart';
28 import 'src/info.dart' show LibraryInfo, CheckerResults; 28 import 'src/info.dart' show LibraryInfo, CheckerResults, LibraryUnit;
29 import 'src/options.dart'; 29 import 'src/options.dart';
30 import 'src/report.dart'; 30 import 'src/report.dart';
31 import 'src/utils.dart'; 31 import 'src/utils.dart';
32 32
33 /// Sets up the type checker logger to print a span that highlights error 33 /// Sets up the type checker logger to print a span that highlights error
34 /// messages. 34 /// messages.
35 StreamSubscription setupLogger(Level level, printFn) { 35 StreamSubscription setupLogger(Level level, printFn) {
36 Logger.root.level = level; 36 Logger.root.level = level;
37 return Logger.root.onRecord.listen((LogRecord rec) { 37 return Logger.root.onRecord.listen((LogRecord rec) {
38 printFn('${rec.level.name.toLowerCase()}: ${rec.message}'); 38 printFn('${rec.level.name.toLowerCase()}: ${rec.message}');
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 var current = node.info; 160 var current = node.info;
161 if (current != null) { 161 if (current != null) {
162 assert(current.library == lib); 162 assert(current.library == lib);
163 } else { 163 } else {
164 node.info = current = new LibraryInfo(lib, _isEntry(node)); 164 node.info = current = new LibraryInfo(lib, _isEntry(node));
165 } 165 }
166 _reporter.enterLibrary(source.uri); 166 _reporter.enterLibrary(source.uri);
167 _libraries.add(current); 167 _libraries.add(current);
168 _rules.currentLibraryInfo = current; 168 _rules.currentLibraryInfo = current;
169 169
170 var units = [entryUnit] 170 var resolvedParts = node.parts
171 ..addAll(node.parts.map( 171 .map((p) => _resolver.context.resolveCompilationUnit2(p.source, source))
172 (p) => _resolver.context.resolveCompilationUnit2(p.source, source))); 172 .toList(growable: false);
173 var libraryUnit = new LibraryUnit(entryUnit, resolvedParts);
173 bool failureInLib = false; 174 bool failureInLib = false;
174 for (var unit in units) { 175 for (var unit in libraryUnit.libraryThenParts) {
175 var unitSource = unit.element.source; 176 var unitSource = unit.element.source;
176 _reporter.enterSource(unitSource); 177 _reporter.enterSource(unitSource);
177 // TODO(sigmund): integrate analyzer errors with static-info (issue #6). 178 // TODO(sigmund): integrate analyzer errors with static-info (issue #6).
178 failureInLib = _resolver.logErrors(unitSource, _reporter) || failureInLib; 179 failureInLib = _resolver.logErrors(unitSource, _reporter) || failureInLib;
179 unit.visitChildren(_checker); 180 unit.visitChildren(_checker);
180 if (_checker.failure) failureInLib = true; 181 if (_checker.failure) failureInLib = true;
181 _reporter.leaveSource(); 182 _reporter.leaveSource();
182 } 183 }
183 if (failureInLib) { 184 if (failureInLib) {
184 _failure = true; 185 _failure = true;
185 if (!_options.forceCompile) return; 186 if (!_options.forceCompile) return;
186 } 187 }
187 188
188 for (var cg in _generators) { 189 for (var cg in _generators) {
189 var hash = cg.generateLibrary(units, current, _reporter); 190 var hash = cg.generateLibrary(libraryUnit, current, _reporter);
190 if (_hashing) node.cachingHash = hash; 191 if (_hashing) node.cachingHash = hash;
191 } 192 }
192 _reporter.leaveLibrary(); 193 _reporter.leaveLibrary();
193 } 194 }
194 195
195 CheckerResults run() { 196 CheckerResults run() {
196 var clock = new Stopwatch()..start(); 197 var clock = new Stopwatch()..start();
197 198
198 // TODO(sigmund): we are missing a couple failures here. The 199 // TODO(sigmund): we are missing a couple failures here. The
199 // dependendency_graph now detects broken imports or unsupported features 200 // dependendency_graph now detects broken imports or unsupported features
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // Note: the cache-control header should be enough, but this doesn't hurt 303 // Note: the cache-control header should be enough, but this doesn't hurt
303 // and can help renew the policy after it expires. 304 // and can help renew the policy after it expires.
304 headers['ETag'] = segments[1]; 305 headers['ETag'] = segments[1];
305 } 306 }
306 return response.change(headers: headers); 307 return response.change(headers: headers);
307 }; 308 };
308 } 309 }
309 310
310 final _log = new Logger('dev_compiler'); 311 final _log = new Logger('dev_compiler');
311 final _earlyErrorResult = new CheckerResults(const [], null, true); 312 final _earlyErrorResult = new CheckerResults(const [], null, true);
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/dart_runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698