Java Code Examples for jdk.nashorn.internal.runtime.ScriptRuntime#safeToString()

The following examples show how to use jdk.nashorn.internal.runtime.ScriptRuntime#safeToString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 2
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 3
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 4
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 5
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 6
private static String getArgument(final LinkRequest linkRequest) {
    final Operation op = linkRequest.getCallSiteDescriptor().getOperation();
    if (op instanceof NamedOperation) {
        return ((NamedOperation)op).getName().toString();
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 7
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 8
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 9
private static String getArgument(final LinkRequest linkRequest) {
    final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
    if (desc.getNameTokenCount() > 2) {
        return desc.getNameToken(2);
    }
    return ScriptRuntime.safeToString(linkRequest.getArguments()[1]);
}
 
Example 10
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public String getFunctionErrorMessage(final Object obj) {
    final String funcDesc = getFunctionDescription();
    return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
 
Example 11
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param desc call site descriptor
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public static String getFunctionErrorMessage(final CallSiteDescriptor desc, final Object obj) {
    return desc instanceof NashornCallSiteDescriptor ?
            ((NashornCallSiteDescriptor)desc).getFunctionErrorMessage(obj) :
            ScriptRuntime.safeToString(obj);
}
 
Example 12
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public String getFunctionErrorMessage(final Object obj) {
    final String funcDesc = getFunctionDescription();
    return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
 
Example 13
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public String getFunctionErrorMessage(final Object obj) {
    final String funcDesc = getFunctionDescription();
    return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
 
Example 14
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param desc call site descriptor
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public static String getFunctionErrorMessage(final CallSiteDescriptor desc, final Object obj) {
    return desc instanceof NashornCallSiteDescriptor ?
            ((NashornCallSiteDescriptor)desc).getFunctionErrorMessage(obj) :
            ScriptRuntime.safeToString(obj);
}
 
Example 15
/**
 * Returns the error message to be used when CALL or NEW is used on a non-function.
 *
 * @param obj object on which CALL or NEW is used
 * @return error message
 */
private String getFunctionErrorMessage(final Object obj) {
    final String funcDesc = getOperand(this);
    return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
 
Example 16
/**
 * Returns the error message to be used when CALL or NEW is used on a non-function.
 *
 * @param desc call site descriptor
 * @param obj object on which CALL or NEW is used
 * @return error message
 */
public static String getFunctionErrorMessage(final CallSiteDescriptor desc, final Object obj) {
    return desc instanceof NashornCallSiteDescriptor ?
            ((NashornCallSiteDescriptor)desc).getFunctionErrorMessage(obj) :
            ScriptRuntime.safeToString(obj);
}
 
Example 17
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public String getFunctionErrorMessage(final Object obj) {
    final String funcDesc = getFunctionDescription();
    return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
 
Example 18
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param desc call site descriptor
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public static String getFunctionErrorMessage(final CallSiteDescriptor desc, final Object obj) {
    return desc instanceof NashornCallSiteDescriptor ?
            ((NashornCallSiteDescriptor)desc).getFunctionErrorMessage(obj) :
            ScriptRuntime.safeToString(obj);
}
 
Example 19
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public String getFunctionErrorMessage(final Object obj) {
    final String funcDesc = getFunctionDescription();
    return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
 
Example 20
/**
 * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
 *
 * @param desc call site descriptor
 * @param obj object on which dyn:call or dyn:new is used
 * @return error message
 */
public static String getFunctionErrorMessage(final CallSiteDescriptor desc, final Object obj) {
    return desc instanceof NashornCallSiteDescriptor ?
            ((NashornCallSiteDescriptor)desc).getFunctionErrorMessage(obj) :
            ScriptRuntime.safeToString(obj);
}