C# Class Org.Mozilla.Classfile.ClassFileWriter

ClassFileWriter A ClassFileWriter is used to write a Java class file.
ClassFileWriter A ClassFileWriter is used to write a Java class file. Methods are provided to create fields and methods, and within methods to write Java bytecodes.
Afficher le fichier Open project: hazzik/Rhino.Net Class Usage Examples

Méthodes publiques

Méthode Description
AcquireLabel ( ) : int
Add ( int theOpCode ) : void

Add the single-byte opcode to the current method.

Add the single-byte opcode to the current method.

Add ( int theOpCode, int theOperand ) : void

Add a single-operand opcode to the current method.

Add a single-operand opcode to the current method.

Add ( int theOpCode, int theOperand1, int theOperand2 ) : void

Add the given two-operand bytecode to the current method.

Add the given two-operand bytecode to the current method.

Add ( int theOpCode, string className ) : void
Add ( int theOpCode, string className, string fieldName, string fieldType ) : void
AddALoad ( int local ) : void

Load object from the given local into stack.

Load object from the given local into stack.

AddAStore ( int local ) : void

Store object from stack top into the given local.

Store object from stack top into the given local.

AddDLoad ( int local ) : void

Load double from the given local into stack.

Load double from the given local into stack.

AddDStore ( int local ) : void

Store double from stack top into the given local.

Store double from stack top into the given local.

AddExceptionHandler ( int startLabel, int endLabel, int handlerLabel, string catchClassName ) : void
AddFLoad ( int local ) : void

Load float from the given local into stack.

Load float from the given local into stack.

AddFStore ( int local ) : void

Store float from stack top into the given local.

Store float from stack top into the given local.

AddField ( string fieldName, string type, short flags ) : void

Add a field to the class.

Add a field to the class.

AddField ( string fieldName, string type, short flags, double value ) : void

Add a field to the class.

Add a field to the class.

AddField ( string fieldName, string type, short flags, int value ) : void

Add a field to the class.

Add a field to the class.

AddField ( string fieldName, string type, short flags, long value ) : void

Add a field to the class.

Add a field to the class.

AddILoad ( int local ) : void

Load integer from the given local into stack.

Load integer from the given local into stack.

AddIStore ( int local ) : void

Store integer from stack top into the given local.

Store integer from stack top into the given local.

AddInterface ( string interfaceName ) : void

Add an interface implemented by this class.

Add an interface implemented by this class. This method may be called multiple times for classes that implement multiple interfaces.

AddInvoke ( int theOpCode, string className, string methodName, string methodType ) : void
AddLLoad ( int local ) : void

Load long from the given local into stack.

Load long from the given local into stack.

AddLStore ( int local ) : void

Store long from stack top into the given local.

Store long from stack top into the given local.

AddLineNumberEntry ( short lineNumber ) : void
AddLoadConstant ( double k ) : void

Generate the load constant bytecode for the given double.

Generate the load constant bytecode for the given double.

AddLoadConstant ( float k ) : void

Generate the load constant bytecode for the given float.

Generate the load constant bytecode for the given float.

AddLoadConstant ( int k ) : void

Generate the load constant bytecode for the given integer.

Generate the load constant bytecode for the given integer.

AddLoadConstant ( long k ) : void

Generate the load constant bytecode for the given long.

Generate the load constant bytecode for the given long.

AddLoadConstant ( string k ) : void

Generate the load constant bytecode for the given string.

Generate the load constant bytecode for the given string.

AddLoadThis ( ) : void

Load "this" into stack.

Load "this" into stack.

AddPush ( bool k ) : void
AddPush ( double k ) : void

Generate code to load the given double on stack.

Generate code to load the given double on stack.

AddPush ( int k ) : void

Generate code to load the given integer on stack.

Generate code to load the given integer on stack.

AddPush ( long k ) : void

Generate code to load the given long on stack.

Generate code to load the given long on stack.

AddPush ( string k ) : void

Generate the code to leave on stack the given string even if the string encoding exeeds the class file limit for single string constant

AddTableSwitch ( int low, int high ) : int
AddVariableDescriptor ( string name, string type, int startPC, int register ) : void

Add Information about java variable to use when generating the local variable table.

Add Information about java variable to use when generating the local variable table.

AdjustStackTop ( int delta ) : void
ClassFileWriter ( string className, string superClassName, string sourceFileName ) : System

Construct a ClassFileWriter for a class.

Construct a ClassFileWriter for a class.

ClassNameToSignature ( string name ) : string

Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form suitable for use as JVM type signatures.

Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form suitable for use as JVM type signatures.

GetClassName ( ) : string
GetCurrentCodeOffset ( ) : int

Get the current offset into the code of the current method.

Get the current offset into the code of the current method.

GetLabelPC ( int label ) : int
GetStackTop ( ) : short
IsUnderStringSizeLimit ( string k ) : bool

Check if k fits limit on string constant size imposed by class file format.

Check if k fits limit on string constant size imposed by class file format.

MarkHandler ( int theLabel ) : void
MarkLabel ( int label ) : void
MarkLabel ( int label, short stackTop ) : void
MarkTableSwitchCase ( int switchStart, int caseIndex ) : void
MarkTableSwitchCase ( int switchStart, int caseIndex, int stackTop ) : void
MarkTableSwitchDefault ( int switchStart ) : void
SetFlags ( short flags ) : void

Set the class's flags.

Set the class's flags. Flags must be a set of the following flags, bitwise or'd together: ACC_PUBLIC ACC_PRIVATE ACC_PROTECTED ACC_FINAL ACC_ABSTRACT TODO: check that this is the appropriate set

SetStackTop ( short n ) : void
SetTableSwitchJump ( int switchStart, int caseIndex, int jumpTarget ) : void

Set a jump case for a tableswitch instruction.

Set a jump case for a tableswitch instruction. The jump target should be marked as a super block start for stack map generation.

StartMethod ( string methodName, string type, short flags ) : void

Add a method and begin adding code.

Add a method and begin adding code. This method must be called before other methods for adding code, exception tables, etc. can be invoked.

StopMethod ( short maxLocals ) : void

Complete generation of the method.

Complete generation of the method. After this method is called, no more code can be added to the method begun with startMethod.

ToByteArray ( ) : byte[]

Get the class file as array of bytesto the OutputStream.

Get the class file as array of bytesto the OutputStream.

Write ( Stream oStream ) : void

Write the class file to the OutputStream.

Write the class file to the OutputStream.

Private Methods

Méthode Description
AddLabelFixup ( int label, int fixupSite ) : void
AddReservedCodeSpace ( int size ) : int
AddSuperBlockStart ( int pc ) : void

Add a pc as the start of super block.

Add a pc as the start of super block. A pc is the beginning of a super block if: - pc == 0 - it is the target of a branch instruction - it is the beginning of an exception handler - it is directly after an unconditional jump

AddToCodeBuffer ( int b ) : void
AddToCodeInt16 ( int value ) : void
ArrayTypeToName ( int type ) : char

Convert a newarray operand into an internal type.

Convert a newarray operand into an internal type.

BadStack ( int value ) : void
BytecodeStr ( int code ) : string
ClassDescriptorToInternalName ( string descriptor ) : string

Convert a class descriptor into an internal name.

Convert a class descriptor into an internal name. For example, descriptor Ljava/lang/Object; becomes java/lang/Object.

ClassFileWriter ( ) : System
CreateInitialLocals ( ) : int[]

Compute the initial local variable array for the current method.

Compute the initial local variable array for the current method. Creates an array of the size of the method's max locals, regardless of the number of parameters in the method.

DescriptorToInternalName ( string descriptor ) : string

Convert a non-method type descriptor into an internal type.

Convert a non-method type descriptor into an internal type.

FinalizeSuperBlockStarts ( ) : void

Sort the list of recorded super block starts and remove duplicates.

Sort the list of recorded super block starts and remove duplicates. Also adds exception handling blocks as block starts, since there is no explicit control flow to these. Used for stack map table generation.

FixLabelGotos ( ) : void
GetCharBuffer ( int minimalSize ) : char[]
GetSlashedForm ( string name ) : string
GetWriteSize ( ) : int
OpcodeCount ( int opcode ) : int

Number of operands accompanying the opcode.

Number of operands accompanying the opcode.

OpcodeLength ( int opcode, bool wide ) : int

Size of a bytecode instruction, counting the opcode and its operands.

Size of a bytecode instruction, counting the opcode and its operands. This is different from opcodeCount, since opcodeCount counts logical operands.

PutInt16 ( int value, byte array, int offset ) : int
PutInt32 ( int value, byte array, int offset ) : int
PutInt64 ( long value, byte array, int offset ) : int
SizeOfParameters ( string pString ) : int
StackChange ( int opcode ) : int

The effect on the operand stack of a given opcode.

The effect on the operand stack of a given opcode.

Xop ( int shortOp, int op, int local ) : void

Method Details

AcquireLabel() public méthode

public AcquireLabel ( ) : int
Résultat int

Add() public méthode

Add the single-byte opcode to the current method.
Add the single-byte opcode to the current method.
public Add ( int theOpCode ) : void
theOpCode int the opcode of the bytecode
Résultat void

Add() public méthode

Add a single-operand opcode to the current method.
Add a single-operand opcode to the current method.
public Add ( int theOpCode, int theOperand ) : void
theOpCode int the opcode of the bytecode
theOperand int the operand of the bytecode
Résultat void

Add() public méthode

Add the given two-operand bytecode to the current method.
Add the given two-operand bytecode to the current method.
public Add ( int theOpCode, int theOperand1, int theOperand2 ) : void
theOpCode int the opcode of the bytecode
theOperand1 int the first operand of the bytecode
theOperand2 int the second operand of the bytecode
Résultat void

Add() public méthode

public Add ( int theOpCode, string className ) : void
theOpCode int
className string
Résultat void

Add() public méthode

public Add ( int theOpCode, string className, string fieldName, string fieldType ) : void
theOpCode int
className string
fieldName string
fieldType string
Résultat void

AddALoad() public méthode

Load object from the given local into stack.
Load object from the given local into stack.
public AddALoad ( int local ) : void
local int number of local register
Résultat void

AddAStore() public méthode

Store object from stack top into the given local.
Store object from stack top into the given local.
public AddAStore ( int local ) : void
local int number of local register
Résultat void

AddDLoad() public méthode

Load double from the given local into stack.
Load double from the given local into stack.
public AddDLoad ( int local ) : void
local int number of local register
Résultat void

AddDStore() public méthode

Store double from stack top into the given local.
Store double from stack top into the given local.
public AddDStore ( int local ) : void
local int number of local register
Résultat void

AddExceptionHandler() public méthode

public AddExceptionHandler ( int startLabel, int endLabel, int handlerLabel, string catchClassName ) : void
startLabel int
endLabel int
handlerLabel int
catchClassName string
Résultat void

AddFLoad() public méthode

Load float from the given local into stack.
Load float from the given local into stack.
public AddFLoad ( int local ) : void
local int number of local register
Résultat void

AddFStore() public méthode

Store float from stack top into the given local.
Store float from stack top into the given local.
public AddFStore ( int local ) : void
local int number of local register
Résultat void

AddField() public méthode

Add a field to the class.
Add a field to the class.
public AddField ( string fieldName, string type, short flags ) : void
fieldName string the name of the field
type string the type of the field using ...
flags short /// the attributes of the field, such as ACC_PUBLIC, etc. /// bitwise or'd together ///
Résultat void

AddField() public méthode

Add a field to the class.
Add a field to the class.
public AddField ( string fieldName, string type, short flags, double value ) : void
fieldName string the name of the field
type string the type of the field using ...
flags short /// the attributes of the field, such as ACC_PUBLIC, etc. /// bitwise or'd together ///
value double an initial double value
Résultat void

AddField() public méthode

Add a field to the class.
Add a field to the class.
public AddField ( string fieldName, string type, short flags, int value ) : void
fieldName string the name of the field
type string the type of the field using ...
flags short /// the attributes of the field, such as ACC_PUBLIC, etc. /// bitwise or'd together ///
value int an initial integral value
Résultat void

AddField() public méthode

Add a field to the class.
Add a field to the class.
public AddField ( string fieldName, string type, short flags, long value ) : void
fieldName string the name of the field
type string the type of the field using ...
flags short /// the attributes of the field, such as ACC_PUBLIC, etc. /// bitwise or'd together ///
value long an initial long value
Résultat void

AddILoad() public méthode

Load integer from the given local into stack.
Load integer from the given local into stack.
public AddILoad ( int local ) : void
local int number of local register
Résultat void

AddIStore() public méthode

Store integer from stack top into the given local.
Store integer from stack top into the given local.
public AddIStore ( int local ) : void
local int number of local register
Résultat void

AddInterface() public méthode

Add an interface implemented by this class.
Add an interface implemented by this class. This method may be called multiple times for classes that implement multiple interfaces.
public AddInterface ( string interfaceName ) : void
interfaceName string /// a name of an interface implemented /// by the class being written, including full package /// qualification. ///
Résultat void

AddInvoke() public méthode

public AddInvoke ( int theOpCode, string className, string methodName, string methodType ) : void
theOpCode int
className string
methodName string
methodType string
Résultat void

AddLLoad() public méthode

Load long from the given local into stack.
Load long from the given local into stack.
public AddLLoad ( int local ) : void
local int number of local register
Résultat void

AddLStore() public méthode

Store long from stack top into the given local.
Store long from stack top into the given local.
public AddLStore ( int local ) : void
local int number of local register
Résultat void

AddLineNumberEntry() public méthode

public AddLineNumberEntry ( short lineNumber ) : void
lineNumber short
Résultat void

AddLoadConstant() public méthode

Generate the load constant bytecode for the given double.
Generate the load constant bytecode for the given double.
public AddLoadConstant ( double k ) : void
k double the constant
Résultat void

AddLoadConstant() public méthode

Generate the load constant bytecode for the given float.
Generate the load constant bytecode for the given float.
public AddLoadConstant ( float k ) : void
k float the constant
Résultat void

AddLoadConstant() public méthode

Generate the load constant bytecode for the given integer.
Generate the load constant bytecode for the given integer.
public AddLoadConstant ( int k ) : void
k int the constant
Résultat void

AddLoadConstant() public méthode

Generate the load constant bytecode for the given long.
Generate the load constant bytecode for the given long.
public AddLoadConstant ( long k ) : void
k long the constant
Résultat void

AddLoadConstant() public méthode

Generate the load constant bytecode for the given string.
Generate the load constant bytecode for the given string.
public AddLoadConstant ( string k ) : void
k string the constant
Résultat void

AddLoadThis() public méthode

Load "this" into stack.
Load "this" into stack.
public AddLoadThis ( ) : void
Résultat void

AddPush() public méthode

public AddPush ( bool k ) : void
k bool
Résultat void

AddPush() public méthode

Generate code to load the given double on stack.
Generate code to load the given double on stack.
public AddPush ( double k ) : void
k double the constant
Résultat void

AddPush() public méthode

Generate code to load the given integer on stack.
Generate code to load the given integer on stack.
public AddPush ( int k ) : void
k int the constant
Résultat void

AddPush() public méthode

Generate code to load the given long on stack.
Generate code to load the given long on stack.
public AddPush ( long k ) : void
k long the constant
Résultat void

AddPush() public méthode

Generate the code to leave on stack the given string even if the string encoding exeeds the class file limit for single string constant
public AddPush ( string k ) : void
k string the constant
Résultat void

AddTableSwitch() public méthode

public AddTableSwitch ( int low, int high ) : int
low int
high int
Résultat int

AddVariableDescriptor() public méthode

Add Information about java variable to use when generating the local variable table.
Add Information about java variable to use when generating the local variable table.
public AddVariableDescriptor ( string name, string type, int startPC, int register ) : void
name string variable name.
type string variable type as bytecode descriptor string.
startPC int /// the starting bytecode PC where this variable is live, /// or -1 if it does not have a Java register. ///
register int /// the Java register number of variable /// or -1 if it does not have a Java register. ///
Résultat void

AdjustStackTop() public méthode

public AdjustStackTop ( int delta ) : void
delta int
Résultat void

ClassFileWriter() public méthode

Construct a ClassFileWriter for a class.
Construct a ClassFileWriter for a class.
public ClassFileWriter ( string className, string superClassName, string sourceFileName ) : System
className string /// the name of the class to write, including /// full package qualification. ///
superClassName string /// the name of the superclass of the class /// to write, including full package qualification. ///
sourceFileName string /// the name of the source file to use for /// producing debug information, or null if debug information /// is not desired ///
Résultat System

ClassNameToSignature() public static méthode

Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form suitable for use as JVM type signatures.
Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form suitable for use as JVM type signatures.
public static ClassNameToSignature ( string name ) : string
name string
Résultat string

GetClassName() public méthode

public GetClassName ( ) : string
Résultat string

GetCurrentCodeOffset() public méthode

Get the current offset into the code of the current method.
Get the current offset into the code of the current method.
public GetCurrentCodeOffset ( ) : int
Résultat int

GetLabelPC() public méthode

public GetLabelPC ( int label ) : int
label int
Résultat int

GetStackTop() public méthode

public GetStackTop ( ) : short
Résultat short

IsUnderStringSizeLimit() public méthode

Check if k fits limit on string constant size imposed by class file format.
Check if k fits limit on string constant size imposed by class file format.
public IsUnderStringSizeLimit ( string k ) : bool
k string the string constant
Résultat bool

MarkHandler() public méthode

public MarkHandler ( int theLabel ) : void
theLabel int
Résultat void

MarkLabel() public méthode

public MarkLabel ( int label ) : void
label int
Résultat void

MarkLabel() public méthode

public MarkLabel ( int label, short stackTop ) : void
label int
stackTop short
Résultat void

MarkTableSwitchCase() public méthode

public MarkTableSwitchCase ( int switchStart, int caseIndex ) : void
switchStart int
caseIndex int
Résultat void

MarkTableSwitchCase() public méthode

public MarkTableSwitchCase ( int switchStart, int caseIndex, int stackTop ) : void
switchStart int
caseIndex int
stackTop int
Résultat void

MarkTableSwitchDefault() public méthode

public MarkTableSwitchDefault ( int switchStart ) : void
switchStart int
Résultat void

SetFlags() public méthode

Set the class's flags.
Set the class's flags. Flags must be a set of the following flags, bitwise or'd together: ACC_PUBLIC ACC_PRIVATE ACC_PROTECTED ACC_FINAL ACC_ABSTRACT TODO: check that this is the appropriate set
public SetFlags ( short flags ) : void
flags short the set of class flags to set
Résultat void

SetStackTop() public méthode

public SetStackTop ( short n ) : void
n short
Résultat void

SetTableSwitchJump() public méthode

Set a jump case for a tableswitch instruction.
Set a jump case for a tableswitch instruction. The jump target should be marked as a super block start for stack map generation.
public SetTableSwitchJump ( int switchStart, int caseIndex, int jumpTarget ) : void
switchStart int
caseIndex int
jumpTarget int
Résultat void

StartMethod() public méthode

Add a method and begin adding code.
Add a method and begin adding code. This method must be called before other methods for adding code, exception tables, etc. can be invoked.
public StartMethod ( string methodName, string type, short flags ) : void
methodName string the name of the method
type string a string representing the type
flags short /// the attributes of the field, such as ACC_PUBLIC, etc. /// bitwise or'd together ///
Résultat void

StopMethod() public méthode

Complete generation of the method.
Complete generation of the method. After this method is called, no more code can be added to the method begun with startMethod.
public StopMethod ( short maxLocals ) : void
maxLocals short /// the maximum number of local variable slots /// (a.k.a. Java registers) used by the method ///
Résultat void

ToByteArray() public méthode

Get the class file as array of bytesto the OutputStream.
Get the class file as array of bytesto the OutputStream.
public ToByteArray ( ) : byte[]
Résultat byte[]

Write() public méthode

Write the class file to the OutputStream.
Write the class file to the OutputStream.
if writing to the stream produces an exception
public Write ( Stream oStream ) : void
oStream Stream the stream to write to
Résultat void