当前位置: 首页>>代码示例>>Java>>正文


Java ScriptRuntime.builtinObjectToString方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptRuntime.builtinObjectToString方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.builtinObjectToString方法的具体用法?Java ScriptRuntime.builtinObjectToString怎么用?Java ScriptRuntime.builtinObjectToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.runtime.ScriptRuntime的用法示例。


在下文中一共展示了ScriptRuntime.builtinObjectToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toString

import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
 * ECMA 15.4.4.2 Array.prototype.toString ( )
 *
 * @param self self reference
 * @return string representation of array
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toString(final Object self) {
    final Object obj = Global.toObject(self);
    if (obj instanceof ScriptObject) {
        final InvokeByName joinInvoker = getJOIN();
        final ScriptObject sobj = (ScriptObject)obj;
        try {
            final Object join = joinInvoker.getGetter().invokeExact(sobj);
            if (Bootstrap.isCallable(join)) {
                return joinInvoker.getInvoker().invokeExact(join, sobj);
            }
        } catch (final RuntimeException | Error e) {
            throw e;
        } catch (final Throwable t) {
            throw new RuntimeException(t);
        }
    }

    // FIXME: should lookup Object.prototype.toString and call that?
    return ScriptRuntime.builtinObjectToString(self);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:NativeArray.java

示例2: toLocaleString

import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
 * ECMA 15.2.4.3 Object.prototype.toLocaleString ( )
 *
 * @param self self reference
 * @return localized ToString
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toLocaleString(final Object self) {
    final Object obj = JSType.toScriptObject(self);
    if (obj instanceof ScriptObject) {
        final InvokeByName toStringInvoker = getTO_STRING();
        final ScriptObject sobj = (ScriptObject)self;
        try {
            final Object toString = toStringInvoker.getGetter().invokeExact(sobj);

            if (Bootstrap.isCallable(toString)) {
                return toStringInvoker.getInvoker().invokeExact(toString, sobj);
            }
        } catch (final RuntimeException | Error e) {
            throw e;
        } catch (final Throwable t) {
            throw new RuntimeException(t);
        }

        throw typeError("not.a.function", "toString");
    }

    return ScriptRuntime.builtinObjectToString(self);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:NativeObject.java

示例3: toLocaleString

import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
 * ECMA 15.2.4.3 Object.prototype.toLocaleString ( )
 *
 * @param self self reference
 * @return localized ToString
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toLocaleString(final Object self) {
    final Object obj = JSType.toScriptObject(self);
    if (obj instanceof ScriptObject) {
        final InvokeByName toStringInvoker = getTO_STRING();
        final ScriptObject sobj = (ScriptObject)obj;
        try {
            final Object toString = toStringInvoker.getGetter().invokeExact(sobj);

            if (Bootstrap.isCallable(toString)) {
                return toStringInvoker.getInvoker().invokeExact(toString, sobj);
            }
        } catch (final RuntimeException | Error e) {
            throw e;
        } catch (final Throwable t) {
            throw new RuntimeException(t);
        }

        throw typeError("not.a.function", "toString");
    }

    return ScriptRuntime.builtinObjectToString(self);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:NativeObject.java

示例4: toString

import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
 * ECMA 15.2.4.2 Object.prototype.toString ( )
 *
 * @param self self reference
 * @return ToString of object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static String toString(final Object self) {
    return ScriptRuntime.builtinObjectToString(self);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:NativeObject.java


注:本文中的jdk.nashorn.internal.runtime.ScriptRuntime.builtinObjectToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。