kmy.jint.gen
Class JVMClassGenerator

java.lang.Object
  |
  +--kmy.jint.gen.CodeGenerator
        |
        +--kmy.jint.gen.JVMClassGenerator

public class JVMClassGenerator
extends CodeGenerator
implements JVMCodes


Inner Class Summary
(package private) static class JVMClassGenerator.FieldEntry
           
(package private) static class JVMClassGenerator.HandlerEntry
           
(package private) static class JVMClassGenerator.HandlerEntryTmp
           
(package private) static class JVMClassGenerator.Label
           
(package private) static class JVMClassGenerator.LineNumber
           
(package private) static class JVMClassGenerator.MethodEntry
           
(package private) static class JVMClassGenerator.TuneJump
           
 
Inner classes inherited from class kmy.jint.gen.CodeGenerator
CodeGenerator.MyMark
 
Field Summary
(package private)  short accessFlags
           
(package private)  java.io.DataOutputStream codeAcc
           
(package private)  java.io.ByteArrayOutputStream codeAccInt
           
(package private)  JVMConstantPool constantPool
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpCode
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpConstantValue
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpExceptions
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpJintType
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpLineNumberTable
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpSourceFile
           
(package private)  JVMConstantPool.CP_UTF8_Entry cpSourceFileName
           
(package private)  JVMClassGenerator.MethodEntry currentMethod
           
(package private)  int currStack
           
(package private) static java.lang.Double D_ONE
           
(package private) static java.lang.Double D_ZERO
           
(package private) static java.lang.Float F_ONE
           
(package private) static java.lang.Float F_ZERO
           
(package private)  java.util.Vector fields
           
(package private)  java.util.Vector handlers
           
(package private) static java.lang.Integer I_ONE
           
(package private) static java.lang.Integer I_ZERO
           
(package private)  JVMConstantPool.CP_Class_Entry[] interfaces
           
static boolean keepCaller
           
(package private) static java.lang.Long L_ONE
           
(package private) static java.lang.Long L_ZERO
           
(package private)  java.util.Vector lineNumberAcc
           
(package private) static byte[] magic
           
(package private)  int maxLocals
           
(package private)  int maxStack
           
(package private)  java.util.Vector methods
           
(package private)  JVMConstantPool.CP_Class_Entry superClass
           
(package private)  JVMConstantPool.CP_Class_Entry thisClass
           
(package private)  java.util.Stack toTune
           
 
Fields inherited from class kmy.jint.gen.CodeGenerator
markCounter, out, reachable
 
Fields inherited from interface kmy.jint.gen.JVMCodes
_goto, aaload, aastore, aconst_null, aload, aload_0, aload_1, aload_2, aload_3, anewarray, areturn, arraylength, astore, astore_0, astore_1, astore_2, astore_3, athrow, baload, bastore, bipush, caload, castore, checkcast, d2f, d2i, d2l, dadd, daload, dastore, dcmpg, dcmpl, dconst_0, dconst_1, ddiv, dload, dload_0, dload_1, dload_2, dload_3, dmul, dneg, drem, dreturn, dstore, dstore_0, dstore_1, dstore_2, dstore_3, dsub, dup, dup_x1, dup_x2, dup2, dup2_x1, dup2_x2, f2d, f2i, f2l, fadd, faload, fastore, fcmpg, fcmpl, fconst_0, fconst_1, fconst_2, fdiv, fload, fload_0, fload_1, fload_2, fload_3, fmul, fneg, frem, freturn, fstore, fstore_0, fstore_1, fstore_2, fstore_3, fsub, getfield, getstatic, goto_w, i2b, i2c, i2d, i2f, i2l, i2s, iadd, iaload, iand, iastore, iconst_0, iconst_1, iconst_2, iconst_3, iconst_4, iconst_5, iconst_m1, idiv, if_acmpeq, if_acmpne, if_icmpeq, if_icmpge, if_icmpgt, if_icmple, if_icmplt, if_icmpne, ifeq, ifge, ifgt, ifle, iflt, ifne, ifnonnull, ifnull, iinc, iload, iload_0, iload_1, iload_2, iload_3, imul, ineg, instnceof, invokeinterface, invokespecial, invokestatic, invokevirtual, ior, irem, ireturn, ishl, ishr, istore, istore_0, istore_1, istore_2, istore_3, isub, iushr, ixor, jsr, jsr_w, l2d, l2f, l2i, ladd, laload, land, lastore, lcmp, lconst_0, lconst_1, ldc, ldc_w, ldc2_w, ldiv, lload, lload_0, lload_1, lload_2, lload_3, lmul, lneg, lookupswitch, lor, lrem, lreturn, lshl, lshr, lstore, lstore_0, lstore_1, lstore_2, lstore_3, lsub, lushr, lxor, monitorenter, monitorexit, multianewarray, newarray, newobject, nop, pop, pop2, putfield, putstatic, ret, saload, sastore, sipush, swap, tableswitch, TAG_Class, TAG_Double, TAG_FieldRef, TAG_Float, TAG_Integer, TAG_InterfaceMethodRef, TAG_Long, TAG_MethodRef, TAG_NameAndType, TAG_String, TAG_UTF8, vreturn, wide
 
Constructor Summary
JVMClassGenerator(int flags, java.lang.String name, java.lang.String superName)
           
 
Method Summary
 void addExceptionHandler(AbstractMark from, AbstractMark to, AbstractMark jump, java.lang.String exceptionClass)
           
 void addField(int accessFlags, java.lang.String name, java.lang.String jintType, java.lang.Object value)
          Add a field to the class.
(package private)  void addTuneJump(int instrPC, int storePC, JVMClassGenerator.Label target)
           
 void arraylength()
           
 void athrow()
           
 void cast(java.lang.String fromType, java.lang.String toType)
           
 void compare(boolean cmpToZero, java.lang.String type, boolean gFlag)
           
 void dup(java.lang.String type)
           
 void endMethod()
           
(package private) static int getArgSize(java.lang.String type)
           
 void getelement(java.lang.String type)
           
 void getfield(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
(package private)  int getPC()
           
 int getStackDepth()
           
 void getstatic(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 void iinc(int var, int n)
           
 void insert(java.lang.String what, java.lang.String under)
           
 void instnceof(java.lang.String clazz)
           
 void invokeinterface(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 void invokespecial(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 void invokestatic(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 void invokevirtual(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 boolean isReachable()
           
 void jsr(AbstractMark mark, int stackChange)
           
 void jump(AbstractMark m)
           
 void jumpIf(boolean ifTrue, boolean cmpToZero, int op, java.lang.String type, AbstractMark target)
           
 void linenumber(int line)
           
 void load(int var, java.lang.String type)
           
 void loadConst(java.lang.Object v)
           
 void lookupswitch(int[] items, AbstractMark[] marks, AbstractMark defaultMark)
           
static void main(java.lang.String[] args)
           
(package private) static java.lang.String makeJVMDescriptorFromJintDescriptor(boolean field, java.lang.String type)
           
 void mark(AbstractMark m, boolean mayBeUnreachable)
           
 void mark(AbstractMark m, int stack)
           
 void monitorenter()
           
 void monitorexit()
           
 void newarray(java.lang.String elemType)
           
 AbstractMark newMark()
           
 void newmultiarray(java.lang.String arrType, int depth)
           
 void newobject(java.lang.String clazz)
           
 void op(int op, java.lang.String type)
           
 void pop(java.lang.String type, int nelem)
           
 void putelement(java.lang.String type)
           
 void putfield(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 void putstatic(java.lang.String clazz, java.lang.String name, java.lang.String type)
           
 void ret(int var)
           
 void retrn(java.lang.String type)
           
 void setInterfaces(java.lang.String[] interfaceNames)
           
 void setSourceFile(java.lang.String file)
           
(package private)  void stackPop(int n)
           
(package private)  int stackPopArgsPushResult(java.lang.String type)
           
(package private)  void stackPush(int n)
           
 void startMethod(int accessFlags, java.lang.String name, java.lang.String jintType, java.lang.String[] exceptions)
           
 void store(int var, java.lang.String type)
           
 void swap()
           
 void tableswitch(int low, AbstractMark[] marks, AbstractMark defaultMark)
           
(package private)  void tuneJumps(byte[] code)
           
 void writeAttributes(java.io.DataOutputStream out)
           
 void writeFields(java.io.DataOutputStream out)
           
 void writeInterfaces(java.io.DataOutputStream out)
           
(package private)  void writeLabel(int instrPC, AbstractMark m)
           
 void writeMethods(java.io.DataOutputStream out)
           
(package private) static void writeSimpleAttribute(java.io.DataOutputStream out, short name, short value)
           
 void writeTo(java.io.DataOutputStream out)
           
 
Methods inherited from class kmy.jint.gen.CodeGenerator
close, flush, jumpIf, jumpIfNot, mark
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

magic

static final byte[] magic

accessFlags

short accessFlags

constantPool

JVMConstantPool constantPool

thisClass

JVMConstantPool.CP_Class_Entry thisClass

superClass

JVMConstantPool.CP_Class_Entry superClass

keepCaller

public static boolean keepCaller

interfaces

JVMConstantPool.CP_Class_Entry[] interfaces

fields

java.util.Vector fields

cpJintType

JVMConstantPool.CP_UTF8_Entry cpJintType

cpConstantValue

JVMConstantPool.CP_UTF8_Entry cpConstantValue

cpExceptions

JVMConstantPool.CP_UTF8_Entry cpExceptions

cpCode

JVMConstantPool.CP_UTF8_Entry cpCode

cpLineNumberTable

JVMConstantPool.CP_UTF8_Entry cpLineNumberTable

methods

java.util.Vector methods

currentMethod

JVMClassGenerator.MethodEntry currentMethod

handlers

java.util.Vector handlers

lineNumberAcc

java.util.Vector lineNumberAcc

codeAcc

java.io.DataOutputStream codeAcc

codeAccInt

java.io.ByteArrayOutputStream codeAccInt

maxStack

int maxStack

maxLocals

int maxLocals

currStack

int currStack

cpSourceFile

JVMConstantPool.CP_UTF8_Entry cpSourceFile

cpSourceFileName

JVMConstantPool.CP_UTF8_Entry cpSourceFileName

I_ONE

static final java.lang.Integer I_ONE

I_ZERO

static final java.lang.Integer I_ZERO

L_ONE

static final java.lang.Long L_ONE

L_ZERO

static final java.lang.Long L_ZERO

F_ONE

static final java.lang.Float F_ONE

F_ZERO

static final java.lang.Float F_ZERO

D_ONE

static final java.lang.Double D_ONE

D_ZERO

static final java.lang.Double D_ZERO

toTune

java.util.Stack toTune
Constructor Detail

JVMClassGenerator

public JVMClassGenerator(int flags,
                         java.lang.String name,
                         java.lang.String superName)
Method Detail

setInterfaces

public void setInterfaces(java.lang.String[] interfaceNames)
Overrides:
setInterfaces in class CodeGenerator

writeInterfaces

public void writeInterfaces(java.io.DataOutputStream out)
                     throws java.io.IOException

addField

public void addField(int accessFlags,
                     java.lang.String name,
                     java.lang.String jintType,
                     java.lang.Object value)
Add a field to the class.
Overrides:
addField in class CodeGenerator
Parameters:
accessFlags - access flags (ACC_*) for this field, ored together
name - field name
type - type descriptor (not class name)
value - initial value, null for nothing, short numerical types represented by Integer
jintType - if not null gives JintType attribute value

writeFields

public void writeFields(java.io.DataOutputStream out)
                 throws java.io.IOException

writeSimpleAttribute

static void writeSimpleAttribute(java.io.DataOutputStream out,
                                 short name,
                                 short value)
                          throws java.io.IOException

startMethod

public void startMethod(int accessFlags,
                        java.lang.String name,
                        java.lang.String jintType,
                        java.lang.String[] exceptions)
Overrides:
startMethod in class CodeGenerator

endMethod

public void endMethod()
Overrides:
endMethod in class CodeGenerator

writeMethods

public void writeMethods(java.io.DataOutputStream out)
                  throws java.io.IOException

setSourceFile

public void setSourceFile(java.lang.String file)
Overrides:
setSourceFile in class CodeGenerator

writeAttributes

public void writeAttributes(java.io.DataOutputStream out)
                     throws java.io.IOException

writeTo

public void writeTo(java.io.DataOutputStream out)
             throws java.io.IOException

stackPush

void stackPush(int n)

stackPop

void stackPop(int n)

makeJVMDescriptorFromJintDescriptor

static java.lang.String makeJVMDescriptorFromJintDescriptor(boolean field,
                                                            java.lang.String type)

getArgSize

static int getArgSize(java.lang.String type)

stackPopArgsPushResult

int stackPopArgsPushResult(java.lang.String type)

getPC

int getPC()
    throws java.io.IOException

addTuneJump

void addTuneJump(int instrPC,
                 int storePC,
                 JVMClassGenerator.Label target)

tuneJumps

void tuneJumps(byte[] code)

writeLabel

void writeLabel(int instrPC,
                AbstractMark m)
          throws java.io.IOException

addExceptionHandler

public void addExceptionHandler(AbstractMark from,
                                AbstractMark to,
                                AbstractMark jump,
                                java.lang.String exceptionClass)
Overrides:
addExceptionHandler in class CodeGenerator

linenumber

public void linenumber(int line)
                throws java.io.IOException
Overrides:
linenumber in class CodeGenerator

loadConst

public void loadConst(java.lang.Object v)
               throws java.io.IOException
Overrides:
loadConst in class CodeGenerator

getfield

public void getfield(java.lang.String clazz,
                     java.lang.String name,
                     java.lang.String type)
              throws java.io.IOException
Overrides:
getfield in class CodeGenerator

getstatic

public void getstatic(java.lang.String clazz,
                      java.lang.String name,
                      java.lang.String type)
               throws java.io.IOException
Overrides:
getstatic in class CodeGenerator

putfield

public void putfield(java.lang.String clazz,
                     java.lang.String name,
                     java.lang.String type)
              throws java.io.IOException
Overrides:
putfield in class CodeGenerator

putstatic

public void putstatic(java.lang.String clazz,
                      java.lang.String name,
                      java.lang.String type)
               throws java.io.IOException
Overrides:
putstatic in class CodeGenerator

store

public void store(int var,
                  java.lang.String type)
           throws java.io.IOException
Overrides:
store in class CodeGenerator

load

public void load(int var,
                 java.lang.String type)
          throws java.io.IOException
Overrides:
load in class CodeGenerator

invokevirtual

public void invokevirtual(java.lang.String clazz,
                          java.lang.String name,
                          java.lang.String type)
                   throws java.io.IOException
Overrides:
invokevirtual in class CodeGenerator

invokespecial

public void invokespecial(java.lang.String clazz,
                          java.lang.String name,
                          java.lang.String type)
                   throws java.io.IOException
Overrides:
invokespecial in class CodeGenerator

invokeinterface

public void invokeinterface(java.lang.String clazz,
                            java.lang.String name,
                            java.lang.String type)
                     throws java.io.IOException
Overrides:
invokeinterface in class CodeGenerator

invokestatic

public void invokestatic(java.lang.String clazz,
                         java.lang.String name,
                         java.lang.String type)
                  throws java.io.IOException
Overrides:
invokestatic in class CodeGenerator

getelement

public void getelement(java.lang.String type)
                throws java.io.IOException
Overrides:
getelement in class CodeGenerator

putelement

public void putelement(java.lang.String type)
                throws java.io.IOException
Overrides:
putelement in class CodeGenerator

iinc

public void iinc(int var,
                 int n)
          throws java.io.IOException
Overrides:
iinc in class CodeGenerator

newobject

public void newobject(java.lang.String clazz)
               throws java.io.IOException
Overrides:
newobject in class CodeGenerator

newarray

public void newarray(java.lang.String elemType)
              throws java.io.IOException
Overrides:
newarray in class CodeGenerator

newmultiarray

public void newmultiarray(java.lang.String arrType,
                          int depth)
                   throws java.io.IOException
Overrides:
newmultiarray in class CodeGenerator

arraylength

public void arraylength()
                 throws java.io.IOException
Overrides:
arraylength in class CodeGenerator

monitorenter

public void monitorenter()
                  throws java.io.IOException
Overrides:
monitorenter in class CodeGenerator

monitorexit

public void monitorexit()
                 throws java.io.IOException
Overrides:
monitorexit in class CodeGenerator

newMark

public AbstractMark newMark()
                     throws java.io.IOException
Overrides:
newMark in class CodeGenerator

mark

public void mark(AbstractMark m,
                 int stack)
          throws java.io.IOException
Overrides:
mark in class CodeGenerator

mark

public void mark(AbstractMark m,
                 boolean mayBeUnreachable)
          throws java.io.IOException
Overrides:
mark in class CodeGenerator

jump

public void jump(AbstractMark m)
          throws java.io.IOException
Overrides:
jump in class CodeGenerator

jumpIf

public void jumpIf(boolean ifTrue,
                   boolean cmpToZero,
                   int op,
                   java.lang.String type,
                   AbstractMark target)
            throws java.io.IOException
Overrides:
jumpIf in class CodeGenerator

compare

public void compare(boolean cmpToZero,
                    java.lang.String type,
                    boolean gFlag)
             throws java.io.IOException
Overrides:
compare in class CodeGenerator

retrn

public void retrn(java.lang.String type)
           throws java.io.IOException
Overrides:
retrn in class CodeGenerator

jsr

public void jsr(AbstractMark mark,
                int stackChange)
         throws java.io.IOException
Overrides:
jsr in class CodeGenerator

ret

public void ret(int var)
         throws java.io.IOException
Overrides:
ret in class CodeGenerator

athrow

public void athrow()
            throws java.io.IOException
Overrides:
athrow in class CodeGenerator

lookupswitch

public void lookupswitch(int[] items,
                         AbstractMark[] marks,
                         AbstractMark defaultMark)
                  throws java.io.IOException
Overrides:
lookupswitch in class CodeGenerator

tableswitch

public void tableswitch(int low,
                        AbstractMark[] marks,
                        AbstractMark defaultMark)
                 throws java.io.IOException
Overrides:
tableswitch in class CodeGenerator

cast

public void cast(java.lang.String fromType,
                 java.lang.String toType)
          throws java.io.IOException
Overrides:
cast in class CodeGenerator

instnceof

public void instnceof(java.lang.String clazz)
               throws java.io.IOException
Overrides:
instnceof in class CodeGenerator

pop

public void pop(java.lang.String type,
                int nelem)
         throws java.io.IOException
Overrides:
pop in class CodeGenerator

swap

public void swap()
          throws java.io.IOException
Overrides:
swap in class CodeGenerator

dup

public void dup(java.lang.String type)
         throws java.io.IOException
Overrides:
dup in class CodeGenerator

insert

public void insert(java.lang.String what,
                   java.lang.String under)
            throws java.io.IOException
Overrides:
insert in class CodeGenerator

op

public void op(int op,
               java.lang.String type)
        throws java.io.IOException
Overrides:
op in class CodeGenerator

isReachable

public boolean isReachable()
Overrides:
isReachable in class CodeGenerator

getStackDepth

public int getStackDepth()
Overrides:
getStackDepth in class CodeGenerator

main

public static void main(java.lang.String[] args)