Side effect characterization of String.fromCharCode

This allows dart2js to determine 'Primitive_stringFromCharCode' is effect free.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org/1420273011 .
This commit is contained in:
Stephen Adams 2015-11-05 10:36:06 -08:00
parent c861e4d28a
commit f7a39a6241

View file

@ -1017,13 +1017,15 @@ class Primitives {
static String stringFromCharCode(charCode) {
if (0 <= charCode) {
if (charCode <= 0xffff) {
return JS('String', 'String.fromCharCode(#)', charCode);
return JS('returns:String;effects:none;depends:none',
'String.fromCharCode(#)', charCode);
}
if (charCode <= 0x10ffff) {
var bits = charCode - 0x10000;
var low = 0xDC00 | (bits & 0x3ff);
var high = 0xD800 | (bits >> 10);
return JS('String', 'String.fromCharCode(#, #)', high, low);
return JS('returns:String;effects:none;depends:none',
'String.fromCharCode(#, #)', high, low);
}
}
throw new RangeError.range(charCode, 0, 0x10ffff);