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

Unified Diff: frog/minfrog

Issue 9616002: Update typeNameOf to treat Window as DOMWindow on Chrome. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update minfrog and make string raw. Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/leg/native_emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/minfrog
diff --git a/frog/minfrog b/frog/minfrog
index 1dd869c082d8edde50889ee1369d3159cc11a078..4948e0da77d82a396e9b1ba67152fa8e42140b02 100755
--- a/frog/minfrog
+++ b/frog/minfrog
@@ -485,7 +485,10 @@ Function.prototype.call$2 = function($0, $1) {
function to$call$2(f) { return f && f.to$call$2(); }
// ********** Code for Math **************
Math.parseInt = function(str) {
- var ret = parseInt(str);
+ var match = /^\s*[+-]?(?:(0[xX][abcdefABCDEF0-9]+)|\d+)\s*$/.exec(str);
+ if (!match) $throw(new BadNumberFormatException(str));
+ var isHex = !!match[1];
+ var ret = parseInt(str, isHex ? 16 : 10);
if (isNaN(ret)) $throw(new BadNumberFormatException(str));
return ret;
}
@@ -1893,7 +1896,9 @@ $defProp(Object.prototype, '$typeNameOf', (function() {
}
function chrome$typeNameOf() {
- return this.constructor.name;
+ var name = this.constructor.name;
+ if (name == 'Window') return 'DOMWindow';
+ return name;
}
function firefox$typeNameOf() {
@@ -3107,7 +3112,7 @@ CoreJs.prototype.ensureTypeNameOf = function() {
if (this._generatedTypeNameOf) return;
this._generatedTypeNameOf = true;
this.ensureDefProp();
- this.writer.writeln("$defProp(Object.prototype, '$typeNameOf', (function() {\n function constructorNameWithFallback(obj) {\n var constructor = obj.constructor;\n if (typeof(constructor) == 'function') {\n // The constructor isn't null or undefined at this point. Try\n // to grab hold of its name.\n var name = constructor.name;\n // If the name is a non-empty string, we use that as the type\n // name of this object. On Firefox, we often get 'Object' as\n // the constructor name even for more specialized objects so\n // we have to fall through to the toString() based implementation\n // below in that case.\n if (typeof(name) == 'string' && name && name != 'Object') return name;\n }\n var string = Object.prototype.toString.call(obj);\n return string.substring(8, string.length - 1);\n }\n\n function chrome$typeNameOf() {\n return this.constructor.name;\n }\n\n function firefox$typeNameOf() {\n var name = constructorNameWithFallback(this);\n if (name == 'Window') return 'DOMWindow';\n if (name == 'Document') return 'HTMLDocument';\n if (name == 'XMLDocument') return 'Document';\n return name;\n }\n\n function ie$typeNameOf() {\n var name = constructorNameWithFallback(this);\n if (name == 'Window') return 'DOMWindow';\n // IE calls both HTML and XML documents 'Document', so we check for the\n // xmlVersion property, which is the empty string on HTML documents.\n if (name == 'Document' && this.xmlVersion) return 'Document';\n if (name == 'Document') return 'HTMLDocument';\n return name;\n }\n\n // If we're not in the browser, we're almost certainly running on v8.\n if (typeof(navigator) != 'object') return chrome$typeNameOf;\n\n var userAgent = navigator.userAgent;\n if (/Chrome/.test(userAgent)) return chrome$typeNameOf;\n if (/Firefox/.test(userAgent)) return firefox$typeNameOf;\n if (/MSIE/.test(userAgent)) return ie$typeNameOf;\n return function() { return constructorNameWithFallback(this); };\n})());");
+ this.writer.writeln("$defProp(Object.prototype, '$typeNameOf', (function() {\n function constructorNameWithFallback(obj) {\n var constructor = obj.constructor;\n if (typeof(constructor) == 'function') {\n // The constructor isn't null or undefined at this point. Try\n // to grab hold of its name.\n var name = constructor.name;\n // If the name is a non-empty string, we use that as the type\n // name of this object. On Firefox, we often get 'Object' as\n // the constructor name even for more specialized objects so\n // we have to fall through to the toString() based implementation\n // below in that case.\n if (typeof(name) == 'string' && name && name != 'Object') return name;\n }\n var string = Object.prototype.toString.call(obj);\n return string.substring(8, string.length - 1);\n }\n\n function chrome$typeNameOf() {\n var name = this.constructor.name;\n if (name == 'Window') return 'DOMWindow';\n return name;\n }\n\n function firefox$typeNameOf() {\n var name = constructorNameWithFallback(this);\n if (name == 'Window') return 'DOMWindow';\n if (name == 'Document') return 'HTMLDocument';\n if (name == 'XMLDocument') return 'Document';\n return name;\n }\n\n function ie$typeNameOf() {\n var name = constructorNameWithFallback(this);\n if (name == 'Window') return 'DOMWindow';\n // IE calls both HTML and XML documents 'Document', so we check for the\n // xmlVersion property, which is the empty string on HTML documents.\n if (name == 'Document' && this.xmlVersion) return 'Document';\n if (name == 'Document') return 'HTMLDocument';\n return name;\n }\n\n // If we're not in the browser, we're almost certainly running on v8.\n if (typeof(navigator) != 'object') return chrome$typeNameOf;\n\n var userAgent = navigator.userAgent;\n if (/Chrome/.test(userAgent)) return chrome$typeNameOf;\n if (/Firefox/.test(userAgent)) return firefox$typeNameOf;\n if (/MSIE/.test(userAgent)) return ie$typeNameOf;\n return function() { return constructorNameWithFallback(this); };\n})());");
}
CoreJs.prototype.ensureInheritsHelper = function() {
if (this._generatedInherits) return;
@@ -14362,6 +14367,7 @@ World.prototype.withTiming = function(name, f) {
// ********** Code for FrogOptions **************
function FrogOptions(homedir, args, files) {
this.legOnly = false;
+ this.ignoreUnrecognizedFlags = false;
this.checkOnly = false;
this.disableBoundsChecks = false;
this.maxInferenceIterations = (4);
@@ -14391,144 +14397,144 @@ function FrogOptions(homedir, args, files) {
$globals.world.error(("Invalid configuration " + this.config));
$throw("Invalid configuration");
}
- var ignoreUnrecognizedFlags = false;
var passedLibDir = false;
this.childArgs = [];
loop:
for (var i = (2);
i < args.get$length(); i++) {
var arg = args.$index(i);
- switch (arg) {
- case "--leg":
- case "--enable_leg":
- case "--leg_only":
-
- this.legOnly = true;
- break;
-
- case "--enable_asserts":
+ if (this.tryParseSimpleOption(arg)) continue;
+ if (arg.endsWith(".dart")) {
+ this.dartScript = arg;
+ this.childArgs = args.getRange(i + (1), args.get$length() - i - (1));
+ break loop;
+ }
+ else if (arg.startsWith("--out=")) {
+ this.outfile = arg.substring$1("--out=".length);
+ }
+ else if (arg.startsWith("--libdir=")) {
+ this.libDir = arg.substring$1("--libdir=".length);
+ passedLibDir = true;
+ }
+ else if (!this.ignoreUnrecognizedFlags) {
+ print$(("unrecognized flag: \"" + arg + "\""));
+ }
+ }
+ if (!passedLibDir && $eq$(this.config, "dev") && !files.fileExists(this.libDir)) {
+ var temp = "frog/lib";
+ if (files.fileExists(temp)) {
+ this.libDir = temp;
+ }
+ else {
+ this.libDir = "lib";
+ }
+ }
+}
+FrogOptions.prototype.tryParseSimpleOption = function(option) {
+ if (!option.startsWith("--")) return false;
+ switch (option.replaceAll("_", "-")) {
+ case "--leg":
+ case "--enable-leg":
+ case "--leg-only":
- this.enableAsserts = true;
- break;
+ this.legOnly = true;
+ return true;
- case "--enable_type_checks":
+ case "--enable-asserts":
- this.enableTypeChecks = true;
- this.enableAsserts = true;
- break;
+ this.enableAsserts = true;
+ return true;
- case "--verify_implements":
+ case "--enable-type-checks":
- this.verifyImplements = true;
- break;
+ this.enableTypeChecks = true;
+ this.enableAsserts = true;
+ return true;
- case "--compile_all":
+ case "--verify-implements":
- this.compileAll = true;
- break;
+ this.verifyImplements = true;
+ return true;
- case "--check-only":
+ case "--compile-all":
- this.checkOnly = true;
- break;
+ this.compileAll = true;
+ return true;
- case "--diet-parse":
+ case "--check-only":
- this.dietParse = true;
- break;
+ this.checkOnly = true;
+ return true;
- case "--ignore-unrecognized-flags":
+ case "--diet-parse":
- ignoreUnrecognizedFlags = true;
- break;
+ this.dietParse = true;
+ return true;
- case "--verbose":
+ case "--ignore-unrecognized-flags":
- this.showInfo = true;
- break;
+ this.ignoreUnrecognizedFlags = true;
+ return true;
- case "--suppress_warnings":
+ case "--verbose":
- this.showWarnings = false;
- break;
+ this.showInfo = true;
+ return true;
- case "--warnings_as_errors":
+ case "--suppress-warnings":
- this.warningsAsErrors = true;
- break;
+ this.showWarnings = false;
+ return true;
- case "--throw_on_errors":
+ case "--warnings-as-errors":
- this.throwOnErrors = true;
- break;
+ this.warningsAsErrors = true;
+ return true;
- case "--throw_on_warnings":
+ case "--throw-on-errors":
- this.throwOnWarnings = true;
- break;
+ this.throwOnErrors = true;
+ return true;
- case "--compile-only":
+ case "--throw-on-warnings":
- this.compileOnly = true;
- break;
+ this.throwOnWarnings = true;
+ return true;
- case "--Xforce_dynamic":
+ case "--compile-only":
- this.forceDynamic = true;
- break;
+ this.compileOnly = true;
+ return true;
- case "--no_colors":
+ case "--Xforce-dynamic":
- this.useColors = false;
- break;
+ this.forceDynamic = true;
+ return true;
- case "--Xinfer_types":
+ case "--no-colors":
- this.inferTypes = true;
- break;
+ this.useColors = false;
+ return true;
- case "--checked":
+ case "--Xinfer-types":
- this.enableTypeChecks = true;
- this.enableAsserts = true;
- break;
+ this.inferTypes = true;
+ return true;
- case "--unchecked":
+ case "--enable-checked-mode":
+ case "--checked":
- this.disableBoundsChecks = true;
- break;
+ this.enableTypeChecks = true;
+ this.enableAsserts = true;
+ return true;
- default:
+ case "--unchecked":
- if (arg.endsWith(".dart")) {
- this.dartScript = arg;
- this.childArgs = args.getRange(i + (1), args.get$length() - i - (1));
- break loop;
- }
- else if (arg.startsWith("--out=")) {
- this.outfile = arg.substring$1("--out=".length);
- }
- else if (arg.startsWith("--libdir=")) {
- this.libDir = arg.substring$1("--libdir=".length);
- passedLibDir = true;
- }
- else {
- if (!ignoreUnrecognizedFlags) {
- print$(("unrecognized flag: \"" + arg + "\""));
- }
- }
+ this.disableBoundsChecks = true;
+ return true;
- }
- }
- if (!passedLibDir && $eq$(this.config, "dev") && !files.fileExists(this.libDir)) {
- var temp = "frog/lib";
- if (files.fileExists(temp)) {
- this.libDir = temp;
- }
- else {
- this.libDir = "lib";
- }
}
+ return false;
}
// ********** Code for LibraryReader **************
function LibraryReader() {
@@ -14536,7 +14542,7 @@ function LibraryReader() {
this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "corelib.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "corelib_impl.dart"), "dart:html", joinPaths($globals.options.libDir, "../../client/html/frog/html_frog.dart"), "dart:dom", joinPaths($globals.options.libDir, "../../client/dom/frog/dom_frog.dart"), "dart:json", joinPaths($globals.options.libDir, "../../lib/json/json_frog.dart"), "dart:isolate", joinPaths($globals.options.libDir, "../../lib/isolate/isolate_frog.dart")]);
}
else if ($eq$($globals.options.config, "sdk")) {
- this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "core/core_frog.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "coreimpl/coreimpl_frog.dart"), "dart:html", joinPaths($globals.options.libDir, "html/frog/html_frog.dart"), "dart:dom", joinPaths($globals.options.libDir, "dom/dom_frog.dart"), "dart:json", joinPaths($globals.options.libDir, "json/json_frog.dart"), "dart:isolate", joinPaths($globals.options.libDir, "isolate/isolate_frog.dart")]);
+ this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "core/core_frog.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "coreimpl/coreimpl_frog.dart"), "dart:html", joinPaths($globals.options.libDir, "html/html_frog.dart"), "dart:dom", joinPaths($globals.options.libDir, "dom/dom_frog.dart"), "dart:json", joinPaths($globals.options.libDir, "json/json_frog.dart"), "dart:isolate", joinPaths($globals.options.libDir, "isolate/isolate_frog.dart")]);
}
else {
$globals.world.error(("Invalid configuration " + $globals.options.config));
« no previous file with comments | « frog/leg/native_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698