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

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

Issue 2183603003: Working compiler in browser. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Git merged master Created 4 years, 4 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/analyzer/context.dart ('k') | pubspec.lock » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'dart:collection' show HashSet; 5 import 'dart:collection' show HashSet;
6 import 'package:args/args.dart' show ArgParser, ArgResults; 6 import 'package:args/args.dart' show ArgParser, ArgResults;
7 import 'package:args/src/usage_exception.dart' show UsageException; 7 import 'package:args/src/usage_exception.dart' show UsageException;
8 import 'package:analyzer/analyzer.dart' 8 import 'package:analyzer/analyzer.dart'
9 show 9 show
10 AnalysisError, 10 AnalysisError,
11 CompilationUnit, 11 CompilationUnit,
12 CompileTimeErrorCode, 12 CompileTimeErrorCode,
13 ErrorSeverity, 13 ErrorSeverity,
14 StaticWarningCode; 14 StaticWarningCode;
15 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
15 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; 16 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
16 import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind; 17 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException;
18 import 'package:analyzer/src/generated/source.dart' show DartUriResolver;
19 import 'package:analyzer/src/generated/source_io.dart'
20 show Source, SourceKind, UriResolver;
17 import 'package:func/func.dart' show Func1; 21 import 'package:func/func.dart' show Func1;
18 import 'package:path/path.dart' as path; 22 import 'package:path/path.dart' as path;
19 23
20 import '../analyzer/context.dart' 24 import '../analyzer/context.dart'
21 show AnalyzerOptions, createAnalysisContextWithSources; 25 show AnalyzerOptions, createAnalysisContextWithSources;
22 import 'extension_types.dart' show ExtensionTypeSet; 26 import 'extension_types.dart' show ExtensionTypeSet;
23 import 'code_generator.dart' show CodeGenerator; 27 import 'code_generator.dart' show CodeGenerator;
24 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors; 28 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors;
25 29
26 /// Compiles a set of Dart files into a single JavaScript module. 30 /// Compiles a set of Dart files into a single JavaScript module.
(...skipping 21 matching lines...) Expand all
48 : context = context, 52 : context = context,
49 _extensionTypes = new ExtensionTypeSet(context) { 53 _extensionTypes = new ExtensionTypeSet(context) {
50 if (!context.analysisOptions.strongMode) { 54 if (!context.analysisOptions.strongMode) {
51 throw new ArgumentError('AnalysisContext must be strong mode'); 55 throw new ArgumentError('AnalysisContext must be strong mode');
52 } 56 }
53 if (!context.sourceFactory.dartSdk.context.analysisOptions.strongMode) { 57 if (!context.sourceFactory.dartSdk.context.analysisOptions.strongMode) {
54 throw new ArgumentError('AnalysisContext must have strong mode SDK'); 58 throw new ArgumentError('AnalysisContext must have strong mode SDK');
55 } 59 }
56 } 60 }
57 61
58 ModuleCompiler(AnalyzerOptions analyzerOptions) 62 ModuleCompiler(AnalyzerOptions analyzerOptions,
59 : this.withContext(createAnalysisContextWithSources(analyzerOptions)); 63 {DartUriResolver sdkResolver,
64 ResourceProvider resourceProvider,
65 List<UriResolver> fileResolvers})
66 : this.withContext(createAnalysisContextWithSources(analyzerOptions,
67 sdkResolver: sdkResolver,
68 fileResolvers: fileResolvers,
69 resourceProvider: resourceProvider));
60 70
61 /// Compiles a single Dart build unit into a JavaScript module. 71 /// Compiles a single Dart build unit into a JavaScript module.
62 /// 72 ///
63 /// *Warning* - this may require resolving the entire world. 73 /// *Warning* - this may require resolving the entire world.
64 /// If that is not desired, the analysis context must be pre-configured using 74 /// If that is not desired, the analysis context must be pre-configured using
65 /// summaries before calling this method. 75 /// summaries before calling this method.
66 JSModuleFile compile(BuildUnit unit, CompilerOptions options) { 76 JSModuleFile compile(BuildUnit unit, CompilerOptions options) {
67 var trees = <CompilationUnit>[]; 77 var trees = <CompilationUnit>[];
68 var errors = <AnalysisError>[]; 78 var errors = <AnalysisError>[];
69 79
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 367 }
358 } 368 }
359 369
360 /// (Public for tests) the error code used when a part is missing. 370 /// (Public for tests) the error code used when a part is missing.
361 final missingPartErrorCode = const CompileTimeErrorCode( 371 final missingPartErrorCode = const CompileTimeErrorCode(
362 'MISSING_PART', 'The part was not supplied as an input to the compiler.'); 372 'MISSING_PART', 'The part was not supplied as an input to the compiler.');
363 373
364 /// (Public for tests) the error code used when a part is unused. 374 /// (Public for tests) the error code used when a part is unused.
365 final unusedPartWarningCode = const StaticWarningCode('UNUSED_PART', 375 final unusedPartWarningCode = const StaticWarningCode('UNUSED_PART',
366 'The part was not used by any libraries being compiled.', null, false); 376 'The part was not used by any libraries being compiled.', null, false);
OLDNEW
« no previous file with comments | « lib/src/analyzer/context.dart ('k') | pubspec.lock » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698