| Index: frog/frogsh
|
| diff --git a/frog/frogsh b/frog/frogsh
|
| index 059d9ba818707f31214a132f8a51ecbbeede249c..c095573e891439f66f40c77a8f91011af68181bd 100755
|
| --- a/frog/frogsh
|
| +++ b/frog/frogsh
|
| @@ -102,10 +102,12 @@ function $toDartException(e) {
|
| res = new StackOverflowException();
|
| }
|
| }
|
| - // TODO(jmesserly): setting the stack property is not a long term solution.
|
| - // Also it causes the exception to print as if it were a TypeError or
|
| - // RangeError, instead of using the proper toString.
|
| - res.stack = e.stack;
|
| + if (res) {
|
| + // TODO(jmesserly): setting the stack property is not a long term solution.
|
| + // Also it causes the exception to print as if it were a JS TypeError or
|
| + // RangeError, instead of using the proper toString.
|
| + res.stack = e.stack;
|
| + }
|
| return res;
|
| }
|
| function $notnull_bool(test) {
|
| @@ -10560,10 +10562,10 @@ CoreJs.prototype.generate = function(w) {
|
| w.writeln("/**\n * Generates a dynamic call stub for a function.\n * Our goal is to create a stub method like this on-the-fly:\n * function($0, $1, capture) { this($0, $1, true, capture); }\n *\n * This stub then replaces the dynamic one on Function, with one that is\n * specialized for that particular function, taking into account its default\n * arguments.\n */\nFunction.prototype.$genStub = function(argsLength, names) {\n // TODO(jmesserly): only emit $genStub if actually needed\n\n // Fast path: if no named arguments and arg count matches\n if (this.length == argsLength && !names) {\n return this;\n }\n\n function $throwArgMismatch() {\n // TODO(jmesserly): better error message\n $throw(new ClosureArgumentMismatchException());\n }\n\n var paramsNamed = this.$optional ? (this.$optional.length / 2) : 0;\n var paramsBare = this.length - paramsNamed;\n var argsNamed = names ? names.length : 0;\n var argsBare = argsLength - argsNamed;\n\n // Check we got the right number of arguments\n if (argsBare < paramsBare || argsLength > this.length ||\n argsNamed > paramsNamed) {\n return $throwArgMismatch;\n }\n\n // First, fill in all of the default values\n var p = new Array(paramsBare);\n if (paramsNamed) {\n p = p.concat(this.$optional.slice(paramsNamed));\n }\n // Fill in positional args\n var a = new Array(argsLength);\n for (var i = 0; i < argsBare; i++) {\n p[i] = a[i] = '$' + i;\n }\n // Then overwrite with supplied values for optional args\n var lastParameterIndex;\n var namesInOrder = true;\n for (var i = 0; i < argsNamed; i++) {\n var name = names[i];\n a[i + argsBare] = name;\n var j = this.$optional.indexOf(name, 0);\n if (j < 0 || j >= paramsNamed) {\n return $throwArgMismatch;\n } else if (lastParameterIndex && lastParameterIndex > j) {\n namesInOrder = false;\n }\n p[j + paramsBare] = name;\n lastParameterIndex = j;\n }\n\n if (this.length == argsLength && namesInOrder) {\n // Fast path #2: named arguments, but they're in order.\n return this;\n }\n\n // Note: using Function instead of 'eval' to get a clean scope.\n // TODO(jmesserly): evaluate the performance of these stubs.\n var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}';\n return new Function('$f', 'return ' + f + '').call(null, this);\n}");
|
| }
|
| if ($notnull_bool(this.useStackTraceOf)) {
|
| - w.writeln("function $stackTraceOf(e) {\n // TODO(jmesserly): we shouldn't be relying on the e.stack property.\n // Need to mangle it.\n return e.stack ? e.stack : null;\n}");
|
| + w.writeln("function $stackTraceOf(e) {\n // TODO(jmesserly): we shouldn't be relying on the e.stack property.\n // Need to mangle it.\n return (e && e.stack) ? e.stack : null;\n}");
|
| }
|
| if ($notnull_bool(this.useToDartException)) {
|
| - w.writeln("// Translate a JavaScript exception to a Dart exception\n// TODO(jmesserly): cross browser support. This is Chrome specific.\nfunction $toDartException(e) {\n var res = e;\n if (e instanceof TypeError) {\n switch(e.type) {\n case 'property_not_function':\n case 'called_non_callable':\n if (e.arguments[0] == null) {\n res = new NullPointerException();\n } else {\n res = new ObjectNotClosureException();\n }\n break;\n case 'non_object_property_call':\n case 'non_object_property_load':\n res = new NullPointerException();\n break;\n case 'undefined_method':\n if (e.arguments[0] == 'call' || e.arguments[0] == 'apply') {\n res = new ObjectNotClosureException();\n } else {\n // TODO(jmesserly): can this ever happen?\n res = new NoSuchMethodException('', e.arguments[0], []);\n }\n break;\n }\n } else if (e instanceof RangeError) {\n if (e.message.indexOf('call stack') >= 0) {\n res = new StackOverflowException();\n }\n }\n // TODO(jmesserly): setting the stack property is not a long term solution.\n // Also it causes the exception to print as if it were a TypeError or\n // RangeError, instead of using the proper toString.\n res.stack = e.stack;\n return res;\n}");
|
| + w.writeln("// Translate a JavaScript exception to a Dart exception\n// TODO(jmesserly): cross browser support. This is Chrome specific.\nfunction $toDartException(e) {\n var res = e;\n if (e instanceof TypeError) {\n switch(e.type) {\n case 'property_not_function':\n case 'called_non_callable':\n if (e.arguments[0] == null) {\n res = new NullPointerException();\n } else {\n res = new ObjectNotClosureException();\n }\n break;\n case 'non_object_property_call':\n case 'non_object_property_load':\n res = new NullPointerException();\n break;\n case 'undefined_method':\n if (e.arguments[0] == 'call' || e.arguments[0] == 'apply') {\n res = new ObjectNotClosureException();\n } else {\n // TODO(jmesserly): can this ever happen?\n res = new NoSuchMethodException('', e.arguments[0], []);\n }\n break;\n }\n } else if (e instanceof RangeError) {\n if (e.message.indexOf('call stack') >= 0) {\n res = new StackOverflowException();\n }\n }\n if (res) {\n // TODO(jmesserly): setting the stack property is not a long term solution.\n // Also it causes the exception to print as if it were a JS TypeError or\n // RangeError, instead of using the proper toString.\n res.stack = e.stack;\n }\n return res;\n}");
|
| }
|
| if ($notnull_bool(this.useNotNullBool)) {
|
| this.useThrow = true;
|
|
|