Index: dart/sdk/lib/_internal/compiler/implementation/dart2js.dart |
diff --git a/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart b/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart |
index 8d3c7da267dd827a5c2765fd143b337892ddbe12..b77b0b3348dd5cd48449ed5630e70a524d14a477 100644 |
--- a/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart |
+++ b/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart |
@@ -165,7 +165,15 @@ void compile(List<String> argv) { |
} |
} |
} |
- return passThrough('--categories=${categories.join(",")}'); |
+ passThrough('--categories=${categories.join(",")}'); |
+ } |
+ |
+ checkGlobalName(String argument) { |
+ String globalName = extractParameter(argument); |
+ if (!new RegExp(r'^\$[a-z]*$').hasMatch(globalName)) { |
+ fail('Error: "$globalName" must match "\\\$[a-z]*"'); |
ngeoffray
2013/05/28 20:01:54
Why? We could reserve the name in the namer.
ahe
2013/05/30 09:13:31
That wouldn't handle calling it "init", for exampl
|
+ } |
+ passThrough(argument); |
} |
handleShortOptions(String argument) { |
@@ -224,6 +232,7 @@ void compile(List<String> argv) { |
new OptionHandler('--report-sdk-use-of-deprecated-language-features', |
passThrough), |
new OptionHandler('--categories=.*', setCategories), |
+ new OptionHandler('--global-js-name=.*', checkGlobalName), |
// The following two options must come last. |
new OptionHandler('-.*', (String argument) { |
@@ -395,7 +404,7 @@ Common options: |
} |
void verboseHelp() { |
- print(''' |
+ print(r''' |
Usage: dart2js [options] dartfile |
Compiles Dart to JavaScript. |
@@ -484,6 +493,11 @@ be removed in a future version: |
unsupported category, for example, --categories=help. To enable |
all categories, use --categories=all. |
+ --global-js-name=<name> |
+ By default, dart2js generates JavaScript output that uses a global |
+ variable named "$". The name of this global can be overridden |
+ with this option. The name must match the regular expression "\$[a-z]*". |
+ |
'''.trim()); |
} |