ecma script: number to string

This commit is contained in:
honfika@gmail.com
2015-09-21 19:36:14 +02:00
parent 9b1e5e941c
commit a3fef3d306
2 changed files with 1691 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -71,7 +71,9 @@ public class EcmaScript {
if (o.getClass() == Long.class) {
return EcmaType.NUMBER;
}
if (o.getClass() == Boolean.class) {
return EcmaType.BOOLEAN;
}
if (o.getClass() == Null.class) {
return EcmaType.NULL;
}
@@ -289,4 +291,18 @@ public class EcmaScript {
posInt %= (1 << 32);
return posInt;
}
public static String toString(Object o) {
if (o == null) {
return "null";
}
if (o instanceof Number) {
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.8.1
Number n = (Number) o;
return new EcmaFloatingDecimal(n.doubleValue()).toJavaFormatString();
}
return o.toString();
}
}