jdk.nashorn.internal.codegen.ClassEmitter.Flag Java Examples

The following examples show how to use jdk.nashorn.internal.codegen.ClassEmitter.Flag. 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
Source File: ObjectClassGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #2
Source File: ObjectClassGenerator.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final ClassEmitter classEmitter, final String className) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className);
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #3
Source File: Compiler.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
private CompileUnit initCompileUnit(final String unitClassName, final long initialWeight) {
    final ClassEmitter classEmitter = new ClassEmitter(env, source.getName(), unitClassName, strict);
    final CompileUnit  compileUnit  = new CompileUnit(unitClassName, classEmitter, initialWeight);

    classEmitter.begin();

    final MethodEmitter initMethod = classEmitter.init(EnumSet.of(Flag.PRIVATE));
    initMethod.begin();
    initMethod.load(Type.OBJECT, 0);
    initMethod.newInstance(jdk.nashorn.internal.scripts.JS.class);
    initMethod.returnVoid();
    initMethod.end();

    return compileUnit;
}
 
Example #4
Source File: ObjectClassGenerator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #5
Source File: ObjectClassGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final ClassEmitter classEmitter, final String className) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className);
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #6
Source File: Compiler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private CompileUnit initCompileUnit(final String unitClassName, final long initialWeight) {
    final ClassEmitter classEmitter = new ClassEmitter(env, source.getName(), unitClassName, strict);
    final CompileUnit  compileUnit  = new CompileUnit(unitClassName, classEmitter, initialWeight);

    classEmitter.begin();

    final MethodEmitter initMethod = classEmitter.init(EnumSet.of(Flag.PRIVATE));
    initMethod.begin();
    initMethod.load(Type.OBJECT, 0);
    initMethod.newInstance(jdk.nashorn.internal.scripts.JS.class);
    initMethod.returnVoid();
    initMethod.end();

    return compileUnit;
}
 
Example #7
Source File: ObjectClassGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final ClassEmitter classEmitter, final String className) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className);
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #8
Source File: Compiler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private CompileUnit initCompileUnit(final String unitClassName, final long initialWeight) {
    final ClassEmitter classEmitter = new ClassEmitter(env, source.getName(), unitClassName, strict);
    final CompileUnit  compileUnit  = new CompileUnit(unitClassName, classEmitter, initialWeight);

    classEmitter.begin();

    final MethodEmitter initMethod = classEmitter.init(EnumSet.of(Flag.PRIVATE));
    initMethod.begin();
    initMethod.load(Type.OBJECT, 0);
    initMethod.newInstance(jdk.nashorn.internal.scripts.JS.class);
    initMethod.returnVoid();
    initMethod.end();

    return compileUnit;
}
 
Example #9
Source File: ObjectClassGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #10
Source File: ObjectClassGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #11
Source File: ObjectClassGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #12
Source File: ObjectClassGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #13
Source File: ObjectClassGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className, final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.symbolName(), ScriptObject.class, PropertyMap.class);
    allocate.begin();
    allocate._new(className, Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class), 0);
    allocate.invoke(constructorNoLookup(className, PropertyMap.class));
    allocate._return();
    allocate.end();
}
 
Example #14
Source File: MethodEmitter.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    final int flag = Flag.getValue(flags);
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(flag, className, methodName, descName, flag == H_INVOKEINTERFACE)));
    return this;
}
 
Example #15
Source File: MethodEmitter.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #16
Source File: MethodEmitter.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #17
Source File: MethodEmitter.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #18
Source File: MethodEmitter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #19
Source File: MethodEmitter.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #20
Source File: MethodEmitter.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #21
Source File: MethodEmitter.java    From jdk8u_nashorn with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #22
Source File: MethodEmitter.java    From nashorn with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}
 
Example #23
Source File: MethodEmitter.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Push a method handle to the stack
 *
 * @param className  class name
 * @param methodName method name
 * @param descName   descriptor
 * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
 *
 * @return the method emitter
 */
MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
    debug("load handle ");
    pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
    return this;
}