Module io.github.sugarcubes.cloner
Interface CodeEmitter
public interface CodeEmitter
Instructions of a method body, the subset the copier template needs. Names of classes are internal names
(
java/lang/Object), types of fields and methods are descriptors.-
Method Summary
Modifier and TypeMethodDescriptionvoidBinds the label to the current position.voidChecks the type of the reference on the stack.voidReplaces the object on the stack with the value of its field.voidPushes the value of a static field.voidJumps to the label if the reference on the stack isnull.voidinvokeSpecial(String owner, String name, String descriptor) Invokes a constructor or a private or super method.voidinvokeStatic(String owner, String name, String descriptor) Invokes a static method of a class.voidinvokeVirtual(String owner, String name, String descriptor) Invokes a virtual method.voidPushes a class constant.voidloadInt(int slot) Pushes anintfrom a local variable.voidloadReference(int slot) Pushes a reference from a local variable.voidloadString(String value) Pushes a string constant.newLabel()Creates a label to be bound later.voidpushInt(int value) Pushes anintconstant.voidpushNull()Pushesnull.voidSets the field of the object below the value on the stack.voidSets a static field to the value on the stack.voidReturns from avoidmethod.voidstoreReference(int slot) Stores the reference on the stack into a local variable.voidtableSwitch(int low, CodeLabel defaultLabel, CodeLabel... labels) Jumps by theinton the stack: tolabels[value - low]or to the default label.
-
Method Details
-
loadReference
void loadReference(int slot) Pushes a reference from a local variable.- Parameters:
slot- slot of the variable
-
loadInt
void loadInt(int slot) Pushes anintfrom a local variable.- Parameters:
slot- slot of the variable
-
pushNull
void pushNull()Pushesnull. -
pushInt
void pushInt(int value) Pushes anintconstant.- Parameters:
value- value
-
checkCast
Checks the type of the reference on the stack.- Parameters:
type- internal name of a class or descriptor of an array
-
getField
Replaces the object on the stack with the value of its field.- Parameters:
owner- internal name of the class declaring the fieldname- field namedescriptor- field descriptor
-
putField
Sets the field of the object below the value on the stack.- Parameters:
owner- internal name of the class declaring the fieldname- field namedescriptor- field descriptor
-
loadString
Pushes a string constant.- Parameters:
value- value
-
loadClass
Pushes a class constant.- Parameters:
type- internal name of a class
-
getStatic
Pushes the value of a static field.- Parameters:
owner- internal name of the class declaring the fieldname- field namedescriptor- field descriptor
-
putStatic
Sets a static field to the value on the stack.- Parameters:
owner- internal name of the class declaring the fieldname- field namedescriptor- field descriptor
-
invokeStatic
Invokes a static method of a class.- Parameters:
owner- internal name of the class declaring the methodname- method namedescriptor- method descriptor
-
invokeSpecial
Invokes a constructor or a private or super method.- Parameters:
owner- internal name of the class declaring the methodname- method namedescriptor- method descriptor
-
invokeVirtual
Invokes a virtual method.- Parameters:
owner- internal name of the class declaring the methodname- method namedescriptor- method descriptor
-
storeReference
void storeReference(int slot) Stores the reference on the stack into a local variable.- Parameters:
slot- index of the local variable
-
ifNull
Jumps to the label if the reference on the stack isnull.- Parameters:
label- target
-
returnVoid
void returnVoid()Returns from avoidmethod. -
newLabel
CodeLabel newLabel()Creates a label to be bound later.- Returns:
- label
-
bind
Binds the label to the current position.- Parameters:
label- label
-
tableSwitch
Jumps by theinton the stack: tolabels[value - low]or to the default label.- Parameters:
low- value of the first labeldefaultLabel- target of the other valueslabels- targets of the values fromlow
-