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

Unified Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 248473004: Redo "JS templates" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Created 6 years, 8 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 | « sdk/lib/_internal/lib/isolate_helper.dart ('k') | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index e0540978ba967f409037774ea3eeeaa26c80fd10..73dd57ed8909f88a176d4dd459d3fffdae30a1af 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -658,16 +658,19 @@ class Primitives {
static String objectTypeName(Object object) {
String name = constructorNameFallback(getInterceptor(object));
if (name == 'Object') {
- // Try to decompile the constructor by turning it into a string
- // and get the name out of that. If the decompiled name is a
- // string, we use that instead of the very generic 'Object'.
- var decompiled = JS('var', r'#.match(/^\s*function\s*(\S*)\s*\(/)[1]',
- JS('var', r'String(#.constructor)', object));
- if (decompiled is String) name = decompiled;
+ // Try to decompile the constructor by turning it into a string and get
+ // the name out of that. If the decompiled name is a string containing an
+ // identifier, we use that instead of the very generic 'Object'.
+ var decompiled =
+ JS('var', r'#.match(/^\s*function\s*(\S*)\s*\(/)[1]',
+ JS('var', r'String(#.constructor)', object));
+ if (decompiled is String)
+ if (JS('bool', r'/^\w+$/.test(#)', decompiled))
+ name = decompiled;
}
// TODO(kasperl): If the namer gave us a fresh global name, we may
// want to remove the numeric suffix that makes it unique too.
- if (identical(name.codeUnitAt(0), DOLLAR_CHAR_VALUE)) {
+ if (name.length > 1 && identical(name.codeUnitAt(0), DOLLAR_CHAR_VALUE)) {
name = name.substring(1);
}
return formatType(name, getRuntimeTypeInfo(object));
@@ -1511,7 +1514,7 @@ class TypeErrorDecoder {
// "(.*)\\.(.*) is not a function"
var function = JS('', r"""function($expr$) {
- var $argumentsExpr$ = '$arguments$'
+ var $argumentsExpr$ = '$arguments$';
try {
$expr$.$method$($argumentsExpr$);
} catch (e) {
@@ -1526,7 +1529,7 @@ class TypeErrorDecoder {
static String provokeCallErrorOnNull() {
// See [provokeCallErrorOn] for a detailed explanation.
var function = JS('', r"""function() {
- var $argumentsExpr$ = '$arguments$'
+ var $argumentsExpr$ = '$arguments$';
try {
null.$method$($argumentsExpr$);
} catch (e) {
@@ -1541,7 +1544,7 @@ class TypeErrorDecoder {
static String provokeCallErrorOnUndefined() {
// See [provokeCallErrorOn] for a detailed explanation.
var function = JS('', r"""function() {
- var $argumentsExpr$ = '$arguments$'
+ var $argumentsExpr$ = '$arguments$';
try {
(void 0).$method$($argumentsExpr$);
} catch (e) {
« no previous file with comments | « sdk/lib/_internal/lib/isolate_helper.dart ('k') | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698