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

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

Issue 745533002: Support native extensions for analysis and docgen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 leg_apiimpl; 5 library leg_apiimpl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../compiler.dart' as api; 9 import '../compiler.dart' as api;
10 import 'dart2jslib.dart' as leg; 10 import 'dart2jslib.dart' as leg;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 buildId: extractStringOption( 71 buildId: extractStringOption(
72 options, '--build-id=', 72 options, '--build-id=',
73 "build number could not be determined"), 73 "build number could not be determined"),
74 showPackageWarnings: 74 showPackageWarnings:
75 hasOption(options, '--show-package-warnings'), 75 hasOption(options, '--show-package-warnings'),
76 useContentSecurityPolicy: hasOption(options, '--csp'), 76 useContentSecurityPolicy: hasOption(options, '--csp'),
77 hasIncrementalSupport: 77 hasIncrementalSupport:
78 forceIncrementalSupport || 78 forceIncrementalSupport ||
79 hasOption(options, '--incremental-support'), 79 hasOption(options, '--incremental-support'),
80 suppressWarnings: hasOption(options, '--suppress-warnings'), 80 suppressWarnings: hasOption(options, '--suppress-warnings'),
81 enableAsyncAwait: hasOption(options, '--enable-async')) { 81 enableAsyncAwait: hasOption(options, '--enable-async'),
82 allowNativeExtensions:
83 hasOption(options, '--allow-native-extensions')) {
82 tasks.addAll([ 84 tasks.addAll([
83 userHandlerTask = new leg.GenericTask('Diagnostic handler', this), 85 userHandlerTask = new leg.GenericTask('Diagnostic handler', this),
84 userProviderTask = new leg.GenericTask('Input provider', this), 86 userProviderTask = new leg.GenericTask('Input provider', this),
85 ]); 87 ]);
86 if (!libraryRoot.path.endsWith("/")) { 88 if (!libraryRoot.path.endsWith("/")) {
87 throw new ArgumentError("libraryRoot must end with a /"); 89 throw new ArgumentError("libraryRoot must end with a /");
88 } 90 }
89 if (packageRoot != null && !packageRoot.path.endsWith("/")) { 91 if (packageRoot != null && !packageRoot.path.endsWith("/")) {
90 throw new ArgumentError("packageRoot must end with a /"); 92 throw new ArgumentError("packageRoot must end with a /");
91 } 93 }
92 if (enableAsyncAwait && !analyzeOnly) { 94 if (!analyzeOnly) {
93 throw new ArgumentError( 95 if (enableAsyncAwait) {
94 "--enable-async is currently only supported with --analyze-only"); 96 throw new ArgumentError(
97 "--enable-async is currently only supported with --analyze-only");
98 }
99 if (allowNativeExtensions) {
100 throw new ArgumentError(
101 "--allow-native-extensions is only supported with in combination "
floitsch 2014/11/21 13:26:11 -with-
Johnni Winther 2014/11/21 13:51:15 Done.
102 "with --analyze-only");
103 }
95 } 104 }
96 } 105 }
97 106
98 static String extractStringOption(List<String> options, 107 static String extractStringOption(List<String> options,
99 String prefix, 108 String prefix,
100 String defaultValue) { 109 String defaultValue) {
101 for (String option in options) { 110 for (String option in options) {
102 if (option.startsWith(prefix)) { 111 if (option.startsWith(prefix)) {
103 return option.substring(prefix.length); 112 return option.substring(prefix.length);
104 } 113 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 elements.Element element = currentElement; 196 elements.Element element = currentElement;
188 void reportReadError(exception) { 197 void reportReadError(exception) {
189 withCurrentElement(element, () { 198 withCurrentElement(element, () {
190 reportError(node, 199 reportError(node,
191 leg.MessageKind.READ_SCRIPT_ERROR, 200 leg.MessageKind.READ_SCRIPT_ERROR,
192 {'uri': readableUri, 'exception': exception}); 201 {'uri': readableUri, 'exception': exception});
193 }); 202 });
194 } 203 }
195 204
196 Uri resourceUri = translateUri(node, readableUri); 205 Uri resourceUri = translateUri(node, readableUri);
206 String resourceUriString = resourceUri.toString();
207 if (resourceUri.scheme == 'dart-ext') {
208 if (!allowNativeExtensions) {
209 withCurrentElement(element, () {
210 reportError(node, leg.MessageKind.DART_EXT_NOT_SUPPORTED);
211 });
212 }
213 return new Future.value(new leg.Script(readableUri, resourceUri,
214 new StringSourceFile(resourceUriString,
215 "// Synthetic source file generated for '$readableUri'.")));
216 }
217
197 // TODO(johnniwinther): Wrap the result from [provider] in a specialized 218 // TODO(johnniwinther): Wrap the result from [provider] in a specialized
198 // [Future] to ensure that we never execute an asynchronous action without 219 // [Future] to ensure that we never execute an asynchronous action without
199 // setting up the current element of the compiler. 220 // setting up the current element of the compiler.
200 return new Future.sync(() => callUserProvider(resourceUri)).then((data) { 221 return new Future.sync(() => callUserProvider(resourceUri)).then((data) {
201 SourceFile sourceFile; 222 SourceFile sourceFile;
202 String resourceUriString = resourceUri.toString();
203 if (data is List<int>) { 223 if (data is List<int>) {
204 sourceFile = new Utf8BytesSourceFile(resourceUriString, data); 224 sourceFile = new Utf8BytesSourceFile(resourceUriString, data);
205 } else if (data is String) { 225 } else if (data is String) {
206 sourceFile = new StringSourceFile(resourceUriString, data); 226 sourceFile = new StringSourceFile(resourceUriString, data);
207 } else { 227 } else {
208 String message = "Expected a 'String' or a 'List<int>' from the input " 228 String message = "Expected a 'String' or a 'List<int>' from the input "
209 "provider, but got: ${Error.safeToString(data)}."; 229 "provider, but got: ${Error.safeToString(data)}.";
210 reportReadError(message); 230 reportReadError(message);
211 } 231 }
212 // We use [readableUri] as the URI for the script since need to preserve 232 // We use [readableUri] as the URI for the script since need to preserve
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 374 }
355 375
356 void diagnoseCrashInUserCode(String message, exception, stackTrace) { 376 void diagnoseCrashInUserCode(String message, exception, stackTrace) {
357 hasCrashed = true; 377 hasCrashed = true;
358 print('$message: ${tryToString(exception)}'); 378 print('$message: ${tryToString(exception)}');
359 print(tryToString(stackTrace)); 379 print(tryToString(stackTrace));
360 } 380 }
361 381
362 fromEnvironment(String name) => environment[name]; 382 fromEnvironment(String name) => environment[name];
363 } 383 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698