Index: src/string.js |
diff --git a/src/string.js b/src/string.js |
index 4ac6089f3b0c3bfebcaf5209c40aaf8f48c5805d..91858293b350b2ed0c9ed0bba7fb499f70d5a4c1 100644 |
--- a/src/string.js |
+++ b/src/string.js |
@@ -46,16 +46,18 @@ |
// ECMA-262 section 15.5.4.2 |
function StringToString() { |
- if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) |
+ if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { |
throw new $TypeError('String.prototype.toString is not generic'); |
+ } |
return %_ValueOf(this); |
} |
// ECMA-262 section 15.5.4.3 |
function StringValueOf() { |
- if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) |
+ if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { |
throw new $TypeError('String.prototype.valueOf is not generic'); |
+ } |
return %_ValueOf(this); |
} |
@@ -531,30 +533,36 @@ function StringSlice(start, end) { |
var s_len = s.length; |
var start_i = TO_INTEGER(start); |
var end_i = s_len; |
- if (end !== void 0) |
+ if (end !== void 0) { |
end_i = TO_INTEGER(end); |
+ } |
if (start_i < 0) { |
start_i += s_len; |
- if (start_i < 0) |
+ if (start_i < 0) { |
start_i = 0; |
+ } |
} else { |
- if (start_i > s_len) |
+ if (start_i > s_len) { |
start_i = s_len; |
+ } |
} |
if (end_i < 0) { |
end_i += s_len; |
- if (end_i < 0) |
+ if (end_i < 0) { |
end_i = 0; |
+ } |
} else { |
- if (end_i > s_len) |
+ if (end_i > s_len) { |
end_i = s_len; |
+ } |
} |
var num_c = end_i - start_i; |
- if (num_c < 0) |
+ if (num_c < 0) { |
num_c = 0; |
+ } |
return SubString(s, start_i, start_i + num_c); |
} |
@@ -692,7 +700,7 @@ function StringSubstring(start, end) { |
} |
} |
- return (start_i + 1 == end_i |
+ return ((start_i + 1 == end_i) |
? %_StringCharAt(s, start_i) |
: %_SubString(s, start_i, end_i)); |
} |
@@ -736,7 +744,7 @@ function StringSubstr(start, n) { |
var end = start + len; |
if (end > s.length) end = s.length; |
- return (start + 1 == end |
+ return ((start + 1 == end) |
? %_StringCharAt(s, start) |
: %_SubString(s, start, end)); |
} |