use of com.github.anba.es6draft.runtime.objects.date.DateObject in project es6draft by anba.
the class SourceBuilder method source.
private String source(ExecutionContext cx, HashSet<ScriptObject> stack, Object value) {
switch(Type.of(value)) {
case Null:
return "null";
case Boolean:
return Type.booleanValue(value) ? "true" : "false";
case String:
return Strings.quote(Type.stringValue(value).toString());
case Symbol:
return Type.symbolValue(value).toString();
case Number:
return ToFlatString(cx, value);
case SIMD:
return Type.simdValue(value).toString();
case Object:
ScriptObject objValue = Type.objectValue(value);
if (IsCallable(objValue)) {
return ((Callable) objValue).toSource(cx);
}
if (stack.contains(objValue) || stack.size() > maxStackDepth) {
return "« ... »";
}
stack.add(objValue);
try {
if (objValue instanceof DateObject) {
return DatePrototype.Properties.toString(cx, value).toString();
} else if (objValue instanceof RegExpObject) {
return RegExpPrototype.Properties.toString(cx, value).toString();
} else if (objValue instanceof ArrayObject) {
return arrayToSource(cx, stack, objValue);
} else {
return objectToSource(cx, stack, objValue);
}
} finally {
stack.remove(objValue);
}
case Undefined:
default:
return "(void 0)";
}
}
Aggregations