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


Java InvokeByName类代码示例

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


InvokeByName类属于jdk.nashorn.internal.runtime.linker包,在下文中一共展示了InvokeByName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toString

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的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.linker.InvokeByName; //导入依赖的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: add

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
@Override
public final void add(final int index, final Object e) {
    try {
        if(index < 0) {
            throw invalidIndex(index);
        } else if(index == 0) {
            addFirst(e);
        } else {
            final int size = size();
            if(index < size) {
                final InvokeByName spliceAddInvoker = getSPLICE_ADD();
                final Object fn = spliceAddInvoker.getGetter().invokeExact(obj);
                checkFunction(fn, spliceAddInvoker);
                spliceAddInvoker.getInvoker().invokeExact(fn, obj, index, 0, e);
            } else if(index == size) {
                addLast(e);
            } else {
                throw invalidIndex(index);
            }
        }
    } catch(final RuntimeException | Error ex) {
        throw ex;
    } catch(final Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:ListAdapter.java

示例4: initBuiltinObjects

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
/**
 * Initialize standard builtin objects like "Object", "Array", "Function" etc.
 * as well as our extension builtin objects like "Java", "JSAdapter" as properties
 * of the global scope object.
 *
 * @param eng ScriptEngine to initialize
 */
public void initBuiltinObjects(final ScriptEngine eng) {
    if (this.builtinObject != null) {
        // already initialized, just return
        return;
    }

    TO_STRING = new InvokeByName("toString", ScriptObject.class);
    VALUE_OF  = new InvokeByName("valueOf",  ScriptObject.class);

    this.engine = eng;
    if (this.engine != null) {
        this.scontext = new ThreadLocal<>();
    }
    init(eng);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Global.java

示例5: toLocaleString

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的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

示例6: add

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
@Override
public final void add(int index, Object e) {
    try {
        if(index < 0) {
            throw invalidIndex(index);
        } else if(index == 0) {
            addFirst(e);
        } else {
            final int size = size();
            if(index < size) {
                final InvokeByName spliceAddInvoker = getSPLICE_ADD();
                final Object fn = spliceAddInvoker.getGetter().invokeExact(obj);
                checkFunction(fn, spliceAddInvoker);
                spliceAddInvoker.getInvoker().invokeExact(fn, obj, index, 0, e);
            } else if(index == size) {
                addLast(e);
            } else {
                throw invalidIndex(index);
            }
        }
    } catch(RuntimeException | Error ex) {
        throw ex;
    } catch(Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:27,代码来源:ListAdapter.java

示例7: getTO_JSON

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getTO_JSON() {
    return Global.instance().getInvokeByName(TO_JSON,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("toJSON", ScriptObject.class, Object.class, Object.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:NativeJSON.java

示例8: getJOIN

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getJOIN() {
    return Global.instance().getInvokeByName(JOIN,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("join", ScriptObject.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:NativeArray.java

示例9: getTO_LOCALE_STRING

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getTO_LOCALE_STRING() {
    return Global.instance().getInvokeByName(TO_LOCALE_STRING,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("toLocaleString", ScriptObject.class, String.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:NativeArray.java

示例10: getTO_ISO_STRING

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getTO_ISO_STRING() {
    return Global.instance().getInvokeByName(TO_ISO_STRING,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("toISOString", ScriptObject.class, Object.class, Object.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:NativeDate.java

示例11: toJSON

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
/**
 * ECMA 15.9.5.44 Date.prototype.toJSON ( key )
 *
 * Provides a string representation of this Date for use by {@link NativeJSON#stringify(Object, Object, Object, Object)}
 *
 * @param self self reference
 * @param key ignored
 * @return JSON representation of this date
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toJSON(final Object self, final Object key) {
    // NOTE: Date.prototype.toJSON is generic. Accepts other objects as well.
    final Object selfObj = Global.toObject(self);
    if (!(selfObj instanceof ScriptObject)) {
        return null;
    }
    final ScriptObject sobj  = (ScriptObject)selfObj;
    final Object       value = sobj.getDefaultValue(Number.class);
    if (value instanceof Number) {
        final double num = ((Number)value).doubleValue();
        if (isInfinite(num) || isNaN(num)) {
            return null;
        }
    }

    try {
        final InvokeByName toIsoString = getTO_ISO_STRING();
        final Object func = toIsoString.getGetter().invokeExact(sobj);
        if (Bootstrap.isCallable(func)) {
            return toIsoString.getInvoker().invokeExact(func, sobj, key);
        }
        throw typeError("not.a.function", ScriptRuntime.safeToString(func));
    } catch (final RuntimeException | Error e) {
        throw e;
    } catch (final Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:NativeDate.java

示例12: getTO_STRING

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getTO_STRING() {
    return Global.instance().getInvokeByName(TO_STRING,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("toString", ScriptObject.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:NativeObject.java

示例13: getPUSH

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getPUSH() {
    return Context.getGlobal().getInvokeByName(PUSH,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("push", Object.class, void.class, Object.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ListAdapter.java

示例14: getUNSHIFT

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getUNSHIFT() {
    return Context.getGlobal().getInvokeByName(UNSHIFT,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("unshift", Object.class, void.class, Object.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ListAdapter.java

示例15: getPOP

import jdk.nashorn.internal.runtime.linker.InvokeByName; //导入依赖的package包/类
private static InvokeByName getPOP() {
    return Context.getGlobal().getInvokeByName(POP,
            new Callable<InvokeByName>() {
                @Override
                public InvokeByName call() {
                    return new InvokeByName("pop", Object.class, Object.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ListAdapter.java


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