Java Doc for CodeAssembler.java in  » Byte-Code » Cojen » org » cojen » classfile » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Byte Code » Cojen » org.cojen.classfile 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.cojen.classfile.CodeAssembler

All known Subclasses:   org.cojen.classfile.AbstractCodeAssembler,  org.cojen.classfile.DelegatedCodeAssembler,  org.cojen.classfile.CodeBuilder,  org.cojen.classfile.CodeAssemblerPrinter,
CodeAssembler
public interface CodeAssembler (Code)
CodeAssembler is a high-level interface for assembling Java Virtual Machine byte code. It can also be used as a visitor to a disassembler.
author:
   Brian S O'Neill


Field Summary
final public static  intCONVERT_FP_BITS
    
final public static  intCONVERT_FP_NORMAL
    
final public static  intCONVERT_FP_RAW_BITS
    


Method Summary
 voidarrayLength()
     Generates code for an arraylength instruction.
 voidbranch(Location location)
     Generates code that performs an unconditional branch to the specified location.
 voidbreakpoint()
     Generates a breakpoint instruction for use in a debugging environment.
 voidcheckCast(TypeDesc type)
     Generates code that performs an object cast operation.
 voidconvert(TypeDesc fromType, TypeDesc toType)
     Generates code that converts the value of a primitive type already on the stack.
 voidconvert(TypeDesc fromType, TypeDesc toType, int fpConvertMode)
     Generates code that converts the value of a primitive type already on the stack.
 LabelcreateLabel()
     Creates a label, whose location must be set.
 LocalVariablecreateLocalVariable(String name, TypeDesc type)
     Creates a LocalVariable reference from a name and type.
 voiddup()
     Generates code for the dup instruction.
 voiddup2()
     Generates code for the dup2 instruction.
 voiddup2X1()
     Generates code for the dup2_x1 instruction.
 voiddup2X2()
     Generates code for the dup2_x2 instruction.
 voiddupX1()
     Generates code for the dup_x1 instruction.
 voiddupX2()
     Generates code for the dup_x2 instruction.
 voidexceptionHandler(Location startLocation, Location endLocation, String catchClassName)
     Sets up an exception handler located here, the location of the next code to be generated.
 LocalVariablegetParameter(int index)
     Returns a specific parameter, whose index lies within 0 to getParameterCount() - 1.
 intgetParameterCount()
     Returns the amount of parameters that are accepted by the method being built, not including any "this" reference.
 voidifComparisonBranch(Location location, String choice)
     Generates code the performs a conditional branch based on a comparison between two int values on the stack.
 voidifComparisonBranch(Location location, String choice, TypeDesc type)
     Generates code the performs a conditional branch based on a comparison between two values of the given type on the stack.
 voidifEqualBranch(Location location, boolean choice)
     Generates code that performs a conditional branch based on the value of two object references on the stack.
 voidifNullBranch(Location location, boolean choice)
     Generates code that performs a conditional branch based on the value of an object on the stack.
 voidifZeroComparisonBranch(Location location, String choice)
     Generates code the performs a conditional branch based on a comparison between an int value on the stack and zero.
 voidinline(Object code)
     Allows code to disassembled and copied straight in.
 voidinstanceOf(TypeDesc type)
     Generates code that performs an instanceof operation.
 voidintegerIncrement(LocalVariable local, int amount)
     Generates code that increments a local integer variable by a signed constant amount.
 voidinvoke(Method method)
     Generates code to invoke a method.
 voidinvoke(Constructor constructor)
     Generates code to invoke a class constructor in any class.
 voidinvokeConstructor(TypeDesc[] params)
     Generates code to invoke a class constructor in this class.
 voidinvokeConstructor(String className, TypeDesc[] params)
     Generates code to invoke a class constructor in any class.
 voidinvokeConstructor(TypeDesc classDesc, TypeDesc[] params)
     Generates code to invoke a class constructor in any class.
 voidinvokeInterface(String className, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke an interface method in any class.
 voidinvokeInterface(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke an interface method in any class.
 voidinvokePrivate(String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a private method in this class.
 voidinvokeStatic(String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a static method in this class.
 voidinvokeStatic(String className, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a static method in any class.
 voidinvokeStatic(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a static method in any class.
 voidinvokeSuper(Method method)
     Generates code to invoke a method in the super class.
 voidinvokeSuper(String superClassName, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a method in the super class.
 voidinvokeSuper(TypeDesc superClassDesc, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a method in the super class.
 voidinvokeSuperConstructor(TypeDesc[] params)
     Generates code to invoke a super class constructor.
 voidinvokeVirtual(String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a virtual method in this class.
 voidinvokeVirtual(String className, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a virtual method in any class.
 voidinvokeVirtual(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params)
     Generates code to invoke a virtual method in any class.
 voidjsr(Location location)
     Generates code that performs a subroutine branch to the specified location.
 voidloadConstant(String value)
     Generates code that loads a constant string value onto the stack.
 voidloadConstant(TypeDesc type)
     Generates code that loads a constant class value onto the stack.
 voidloadConstant(boolean value)
     Generates code that loads a constant boolean value onto the stack.
 voidloadConstant(int value)
     Generates code that loads a constant int, char, short or byte value onto the stack.
 voidloadConstant(long value)
     Generates code that loads a constant long value onto the stack.
 voidloadConstant(float value)
     Generates code that loads a constant float value onto the stack.
 voidloadConstant(double value)
     Generates code that loads a constant double value onto the stack.
 voidloadField(String fieldName, TypeDesc type)
     Generates code that loads a value from a field from this class.
 voidloadField(String className, String fieldName, TypeDesc type)
     Generates code that loads a value from a field from any class.
 voidloadField(TypeDesc classDesc, String fieldName, TypeDesc type)
     Generates code that loads a value from a field from any class.
 voidloadFromArray(TypeDesc type)
     Generates code that loads a value from an array.
 voidloadLocal(LocalVariable local)
     Generates code that loads a local variable onto the stack.
 voidloadNull()
     Generates code that loads a null reference onto the stack.
 voidloadStaticField(String fieldName, TypeDesc type)
     Generates code that loads a value from a static field from this class.
 voidloadStaticField(String className, String fieldName, TypeDesc type)
     Generates code that loads a value from a static field from any class.
 voidloadStaticField(TypeDesc classDesc, String fieldName, TypeDesc type)
     Generates code that loads a value from a static field from any class.
 voidloadThis()
     Loads a reference to "this" onto the stack.
 voidmapLineNumber(int lineNumber)
     Map the location of the next code to be generated to a line number in source code.
 voidmath(byte opcode)
     Generates code for either a unary or binary math operation on one or two values pushed on the stack.

Pass in an opcode from the the Opcode class.

 voidmonitorEnter()
     Generates code to enter the monitor on an object loaded on the stack.
 voidmonitorExit()
     Generates code to exit the monitor on an object loaded on the stack.
 voidnewObject(TypeDesc type)
     Generates code to create a new object.
 voidnewObject(TypeDesc type, int dimensions)
     Generates code to create a new array.
 voidnop()
     Generates an instruction that does nothing.
 voidpop()
     Generates code for the pop instruction.
 voidpop2()
     Generates code for the pop2 instruction.
 voidret(LocalVariable local)
     Generates code that returns from a subroutine invoked by jsr.
Parameters:
  local - The local variable reference that contains the returnaddress.
 voidreturnValue(TypeDesc type)
     Generates code that returns an object or primitive type.
 voidreturnVoid()
     Generates code that returns void.
 voidstoreField(String fieldName, TypeDesc type)
     Generates code that stores a value into a field from this class.
 voidstoreField(String className, String fieldName, TypeDesc type)
     Generates code that stores a value into a field from any class.
 voidstoreField(TypeDesc classDesc, String fieldName, TypeDesc type)
     Generates code that stores a value into a field from any class.
 voidstoreLocal(LocalVariable local)
     Generates code that pops a value off of the stack into a local variable.
 voidstoreStaticField(String fieldName, TypeDesc type)
     Generates code that stores a value into a field from this class.
 voidstoreStaticField(String className, String fieldName, TypeDesc type)
     Generates code that stores a value into a field from any class.
 voidstoreStaticField(TypeDesc classDesc, String fieldName, TypeDesc type)
     Generates code that stores a value into a field from any class.
 voidstoreToArray(TypeDesc type)
     Generates code that stores a value to an array.
 voidswap()
     Generates code for the swap instruction.
 voidswap2()
     Generates code for a swap2 instruction.
 voidswitchBranch(int[] cases, Location[] locations, Location defaultLocation)
     Generates code for a switch statement.
 voidthrowObject()
     Generates code that throws an exception.

Field Detail
CONVERT_FP_BITS
final public static int CONVERT_FP_BITS(Code)
Convert floating point values as bits (NaN is canonicalized)



CONVERT_FP_NORMAL
final public static int CONVERT_FP_NORMAL(Code)
Convert floating point values as normal



CONVERT_FP_RAW_BITS
final public static int CONVERT_FP_RAW_BITS(Code)
Convert floating point values as raw bits





Method Detail
arrayLength
void arrayLength()(Code)
Generates code for an arraylength instruction. The object to get the length from must already be on the stack.



branch
void branch(Location location)(Code)
Generates code that performs an unconditional branch to the specified location.
Parameters:
  location - The location to branch to



breakpoint
void breakpoint()(Code)
Generates a breakpoint instruction for use in a debugging environment.



checkCast
void checkCast(TypeDesc type)(Code)
Generates code that performs an object cast operation. The object to check must already be on the stack.



convert
void convert(TypeDesc fromType, TypeDesc toType)(Code)
Generates code that converts the value of a primitive type already on the stack. Conversions between all primitive types are supported as well as boxing and unboxing conversions. Some example conversions:
 int to char
 byte to double
 Double to double
 Float to boolean
 long to Long
 Double to Short
 
In all, 240 conversions are supported.
throws:
  IllegalArgumentException - if conversion not supported



convert
void convert(TypeDesc fromType, TypeDesc toType, int fpConvertMode)(Code)
Generates code that converts the value of a primitive type already on the stack. Conversions between all primitive types are supported as well as boxing and unboxing conversions. Some example conversions:
 int to char
 byte to double
 Double to double
 Float to boolean
 long to Long
 Double to Short
 
In all, 240 conversions are supported.
Parameters:
  fpConvertMode - controls floating point conversion if convertingfloat <--> int or double <--> long
throws:
  IllegalArgumentException - if conversion not supported



createLabel
Label createLabel()(Code)
Creates a label, whose location must be set. To create a label and locate it here, the following example demonstrates how the call to setLocation can be chained:
 CodeBuilder builder;
 ...
 Label label = builder.createLabel().setLocation();
 

See Also:   Label.setLocation



createLocalVariable
LocalVariable createLocalVariable(String name, TypeDesc type)(Code)
Creates a LocalVariable reference from a name and type. Although name is optional, it is encouraged that a name be provided. Names do not need to be unique.
Parameters:
  name - Optional name for the LocalVariable.
Parameters:
  type - The type of data that the requested LocalVariable can store.



dup
void dup()(Code)
Generates code for the dup instruction.



dup2
void dup2()(Code)
Generates code for the dup2 instruction.



dup2X1
void dup2X1()(Code)
Generates code for the dup2_x1 instruction.



dup2X2
void dup2X2()(Code)
Generates code for the dup2_x2 instruction.



dupX1
void dupX1()(Code)
Generates code for the dup_x1 instruction.



dupX2
void dupX2()(Code)
Generates code for the dup_x2 instruction.



exceptionHandler
void exceptionHandler(Location startLocation, Location endLocation, String catchClassName)(Code)
Sets up an exception handler located here, the location of the next code to be generated.
Parameters:
  startLocation - Location at the start of the section ofcode to be wrapped by an exception handler.
Parameters:
  endLocation - Location directly after the end of thesection of code.
Parameters:
  catchClassName - The class name of exception to be caught; if null, then catch every object.



getParameter
LocalVariable getParameter(int index) throws IndexOutOfBoundsException(Code)
Returns a specific parameter, whose index lies within 0 to getParameterCount() - 1. The names of the LocalVariables returned by this method are initially set to null. It is encouraged that a name be provided.



getParameterCount
int getParameterCount()(Code)
Returns the amount of parameters that are accepted by the method being built, not including any "this" reference.



ifComparisonBranch
void ifComparisonBranch(Location location, String choice) throws IllegalArgumentException(Code)
Generates code the performs a conditional branch based on a comparison between two int values on the stack. The first int value on the stack is on the left side of the comparison expression.

The generated instruction consumes the two values on the stack.
Parameters:
  location - The location to branch to
Parameters:
  choice - One of "==", "!=", "<", ">=", ">" or "<="
throws:
  IllegalArgumentException - When the choice is not valid




ifComparisonBranch
void ifComparisonBranch(Location location, String choice, TypeDesc type) throws IllegalArgumentException(Code)
Generates code the performs a conditional branch based on a comparison between two values of the given type on the stack. The first int value on the stack is on the left side of the comparison expression. When comparing objects, only an identity comparison is performed.

When comparing floating point values, treatment of NaN requires special attention. Ordinarily, it is assumed that the branch location represents the target of a comparison failure, and that the code to handle the "true" condition immediately follows the comparison. If this is not the case, append a 't' suffix to the choice to indicate that the target location is reached for a "true" condition. This suffix is ignored if the type is not a float or double.

The generated instruction(s) consumes the two values on the stack.
Parameters:
  location - The location to branch to
Parameters:
  choice - One of "==", "!=", "<", ">=", ">", "<=", "==t", "!=t","=t", ">t", or "<=t". Object types can only be compared forequality.
Parameters:
  type - Type to expect on the stack
throws:
  IllegalArgumentException - When the choice is not valid




ifEqualBranch
void ifEqualBranch(Location location, boolean choice)(Code)
Generates code that performs a conditional branch based on the value of two object references on the stack. A branch is performed based on whether the two objects are exactly the same.

The generated instruction consumes the two values on the stack.
Parameters:
  location - The location to branch to
Parameters:
  choice - If true, branch when equal, else branch when not equal




ifNullBranch
void ifNullBranch(Location location, boolean choice)(Code)
Generates code that performs a conditional branch based on the value of an object on the stack. A branch is performed based on whether the object reference on the stack is null or not.

The generated instruction consumes the value on the stack.
Parameters:
  location - The location to branch to
Parameters:
  choice - If true, do branch when null, else branch when not null




ifZeroComparisonBranch
void ifZeroComparisonBranch(Location location, String choice) throws IllegalArgumentException(Code)
Generates code the performs a conditional branch based on a comparison between an int value on the stack and zero. The int value on the stack is on the left side of the comparison expression.

The generated instruction consumes the value on the stack.
Parameters:
  location - The location to branch to
Parameters:
  choice - One of "==", "!=", "<", ">=", ">" or "<="
throws:
  IllegalArgumentException - When the choice is not valid




inline
void inline(Object code) throws IllegalArgumentException, MissingResourceException(Code)
Allows code to disassembled and copied straight in. The code object passed in must have a single method named "define" whose arguments match the type and order of values expected on the operand stack. If a return value is provided, it will pushed onto the stack. The define method can have any access modifier.
throws:
  IllegalArgumentException - if define method not found, or ifmultiple are found
throws:
  MissingResourceException - if define code not found



instanceOf
void instanceOf(TypeDesc type)(Code)
Generates code that performs an instanceof operation. The object to check must already be on the stack.



integerIncrement
void integerIncrement(LocalVariable local, int amount)(Code)
Generates code that increments a local integer variable by a signed constant amount.



invoke
void invoke(Method method)(Code)
Generates code to invoke a method. If the method is static, the method's argument(s) must be on the stack. If the method is non-static, then the object reference must also be on the stack, prior to the arguments.



invoke
void invoke(Constructor constructor)(Code)
Generates code to invoke a class constructor in any class. The object reference and the constructor's argument(s) must be on the stack.



invokeConstructor
void invokeConstructor(TypeDesc[] params)(Code)
Generates code to invoke a class constructor in this class. The object reference and the constructor's argument(s) must be on the stack.
Parameters:
  params - May be null if constructor takes no parameters.



invokeConstructor
void invokeConstructor(String className, TypeDesc[] params)(Code)
Generates code to invoke a class constructor in any class. The object reference and the constructor's argument(s) must be on the stack.
Parameters:
  params - May be null if constructor takes no parameters.



invokeConstructor
void invokeConstructor(TypeDesc classDesc, TypeDesc[] params)(Code)
Generates code to invoke a class constructor in any class. The object reference and the constructor's argument(s) must be on the stack.
Parameters:
  params - May be null if constructor takes no parameters.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



invokeInterface
void invokeInterface(String className, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke an interface method in any class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeInterface
void invokeInterface(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke an interface method in any class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



invokePrivate
void invokePrivate(String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a private method in this class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeStatic
void invokeStatic(String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a static method in this class. The method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeStatic
void invokeStatic(String className, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a static method in any class. The method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeStatic
void invokeStatic(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a static method in any class. The method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



invokeSuper
void invokeSuper(Method method)(Code)
Generates code to invoke a method in the super class. The object reference and the method's argument(s) must be on the stack.



invokeSuper
void invokeSuper(String superClassName, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a method in the super class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeSuper
void invokeSuper(TypeDesc superClassDesc, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a method in the super class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.
throws:
  IllegalArgumentException - if superClassDesc refers to an array orprimitive type



invokeSuperConstructor
void invokeSuperConstructor(TypeDesc[] params)(Code)
Generates code to invoke a super class constructor. The object reference and the constructor's argument(s) must be on the stack.
Parameters:
  params - May be null if constructor takes no parameters.



invokeVirtual
void invokeVirtual(String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a virtual method in this class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeVirtual
void invokeVirtual(String className, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a virtual method in any class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.



invokeVirtual
void invokeVirtual(TypeDesc classDesc, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Generates code to invoke a virtual method in any class. The object reference and the method's argument(s) must be on the stack.
Parameters:
  ret - May be null if method returns void.
Parameters:
  params - May be null if method takes no parameters.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



jsr
void jsr(Location location)(Code)
Generates code that performs a subroutine branch to the specified location. The instruction generated is either jsr or jsr_w. It is most often used for implementing a finally block.
Parameters:
  location - The location to branch to



loadConstant
void loadConstant(String value)(Code)
Generates code that loads a constant string value onto the stack. If value is null, the generated code loads a null onto the stack. Strings that exceed 65535 UTF encoded bytes in length are loaded by creating a StringBuffer (or a StringBuilder), appending substrings, and then converting it to a String.



loadConstant
void loadConstant(TypeDesc type) throws IllegalStateException(Code)
Generates code that loads a constant class value onto the stack. If value is null, the generated code loads a null onto the stack.
Parameters:
  type - any object or primitive type
throws:
  IllegalStateException - if class file target version does notsupport this feature



loadConstant
void loadConstant(boolean value)(Code)
Generates code that loads a constant boolean value onto the stack.



loadConstant
void loadConstant(int value)(Code)
Generates code that loads a constant int, char, short or byte value onto the stack.



loadConstant
void loadConstant(long value)(Code)
Generates code that loads a constant long value onto the stack.



loadConstant
void loadConstant(float value)(Code)
Generates code that loads a constant float value onto the stack.



loadConstant
void loadConstant(double value)(Code)
Generates code that loads a constant double value onto the stack.



loadField
void loadField(String fieldName, TypeDesc type)(Code)
Generates code that loads a value from a field from this class. An object reference must be on the stack. After the generated code has executed, the object reference is replaced by the value retrieved from the field.



loadField
void loadField(String className, String fieldName, TypeDesc type)(Code)
Generates code that loads a value from a field from any class. An object reference must be on the stack. After the generated code has executed, the object reference is replaced by the value retrieved from the field.



loadField
void loadField(TypeDesc classDesc, String fieldName, TypeDesc type)(Code)
Generates code that loads a value from a field from any class. An object reference must be on the stack. After the generated code has executed, the object reference is replaced by the value retrieved from the field.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



loadFromArray
void loadFromArray(TypeDesc type)(Code)
Generates code that loads a value from an array. An array reference followed by an index must be on the stack. The array reference and index are replaced by the value retrieved from the array after the generated instruction has executed.

The type doesn't need to be an exact match for objects. TypeDesc.OBJECT works fine for all objects. For primitive types, use the appropriate TypeDesc. For an int, the type is TypeDesc.INT.
Parameters:
  type - The type of data stored in the array.




loadLocal
void loadLocal(LocalVariable local)(Code)
Generates code that loads a local variable onto the stack. Parameters passed to a method and the "this" reference are all considered local variables, as well as any that were created.
Parameters:
  local - The local variable reference



loadNull
void loadNull()(Code)
Generates code that loads a null reference onto the stack.



loadStaticField
void loadStaticField(String fieldName, TypeDesc type)(Code)
Generates code that loads a value from a static field from this class. After the generated code has executed, the value retrieved is placed on the stack.



loadStaticField
void loadStaticField(String className, String fieldName, TypeDesc type)(Code)
Generates code that loads a value from a static field from any class. After the generated code has executed, the value retrieved is placed on the stack.



loadStaticField
void loadStaticField(TypeDesc classDesc, String fieldName, TypeDesc type)(Code)
Generates code that loads a value from a static field from any class. After the generated code has executed, the value retrieved is placed on the stack.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



loadThis
void loadThis()(Code)
Loads a reference to "this" onto the stack. Static methods have no "this" reference, and an exception is thrown when attempting to generate "this" in a static method.



mapLineNumber
void mapLineNumber(int lineNumber)(Code)
Map the location of the next code to be generated to a line number in source code. This enables line numbers in a stack trace from the generated code.



math
void math(byte opcode)(Code)
Generates code for either a unary or binary math operation on one or two values pushed on the stack.

Pass in an opcode from the the Opcode class. The only valid math opcodes are:

 IADD, ISUB, IMUL, IDIV, IREM, INEG, IAND, IOR, IXOR, ISHL, ISHR, IUSHR
 LADD, LSUB, LMUL, LDIV, LREM, LNEG, LAND, LOR, LXOR, LSHL, LSHR, LUSHR
 FADD, FSUB, FMUL, FDIV, FREM, FNEG
 DADD, DSUB, DMUL, DDIV, DREM, DNEG
 LCMP
 FCMPG, FCMPL
 DCMPG, DCMPL
 
A not operation (~) is performed by doing a loadConstant with either -1 or -1L followed by math(Opcode.IXOR) or math(Opcode.LXOR).
Parameters:
  opcode - An opcode from the Opcode class.
throws:
  IllegalArgumentException - When the opcode selected is nota math operation.
See Also:   Opcode



monitorEnter
void monitorEnter()(Code)
Generates code to enter the monitor on an object loaded on the stack.



monitorExit
void monitorExit()(Code)
Generates code to exit the monitor on an object loaded on the stack.



newObject
void newObject(TypeDesc type)(Code)
Generates code to create a new object. Unless the new object is an array, it is invalid until a constructor method is invoked on it.

If the specified type is an array, this call is equivalent to newObject(type, 1). The size of the dimension must be on the operand stack. To create multi-dimensional arrays, call newObject(type, dimensions).
See Also:   CodeAssembler.invokeConstructor




newObject
void newObject(TypeDesc type, int dimensions)(Code)
Generates code to create a new array. The type descriptor specifies the type of array to create. The dimensions parameter specifies the amount of dimensions that will initialized, which may not be larger than the amount of dimensions specified in the type.

For each dimension, its size must be on the operand stack. If the specified dimensions is 0 and the type is not an array, then this call is equivalent to newObject(type).




nop
void nop()(Code)
Generates an instruction that does nothing. (No-OPeration)



pop
void pop()(Code)
Generates code for the pop instruction.



pop2
void pop2()(Code)
Generates code for the pop2 instruction.



ret
void ret(LocalVariable local)(Code)
Generates code that returns from a subroutine invoked by jsr.
Parameters:
  local - The local variable reference that contains the returnaddress. The local variable must be of an object type.



returnValue
void returnValue(TypeDesc type)(Code)
Generates code that returns an object or primitive type. The value to return must be on the stack.

The type doesn't need to be an exact match for objects. TypeDesc.OBJECT works fine for all objects. For primitive types, use the appropriate TypeDesc. For an int, the type is TypeDesc.INT.




returnVoid
void returnVoid()(Code)
Generates code that returns void.



storeField
void storeField(String fieldName, TypeDesc type)(Code)
Generates code that stores a value into a field from this class. An object reference and value must be on the stack. After the generated code has executed, the object reference and value are gone from the stack.



storeField
void storeField(String className, String fieldName, TypeDesc type)(Code)
Generates code that stores a value into a field from any class. An object reference and value must be on the stack. After the generated code has executed, the object reference and value are gone from the stack.



storeField
void storeField(TypeDesc classDesc, String fieldName, TypeDesc type)(Code)
Generates code that stores a value into a field from any class. An object reference and value must be on the stack. After the generated code has executed, the object reference and value are gone from the stack.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



storeLocal
void storeLocal(LocalVariable local)(Code)
Generates code that pops a value off of the stack into a local variable. Parameters passed to a method and the "this" reference are all considered local variables, as well as any that were created.
Parameters:
  local - The local variable reference
See Also:   CodeAssembler.getParameter
See Also:   CodeAssembler.createLocalVariable



storeStaticField
void storeStaticField(String fieldName, TypeDesc type)(Code)
Generates code that stores a value into a field from this class. A value must be on the stack. After the generated code has executed, the value is gone from the stack.



storeStaticField
void storeStaticField(String className, String fieldName, TypeDesc type)(Code)
Generates code that stores a value into a field from any class. A value must be on the stack. After the generated code has executed, the value is gone from the stack.



storeStaticField
void storeStaticField(TypeDesc classDesc, String fieldName, TypeDesc type)(Code)
Generates code that stores a value into a field from any class. A value must be on the stack. After the generated code has executed, the value is gone from the stack.
throws:
  IllegalArgumentException - if classDesc refers to an array orprimitive type



storeToArray
void storeToArray(TypeDesc type)(Code)
Generates code that stores a value to an array. An array reference followed by an index, followed by a value (or two if a long or double) must be on the stack. All items on the stack are gone after the generated instruction has executed.

The type doesn't need to be an exact match for objects. TypeDesc.OBJECT works fine for all objects. For primitive types, use the appropriate TypeDesc. For an int, the type is TypeDesc.INT.
Parameters:
  type - The type of data stored in the array.




swap
void swap()(Code)
Generates code for the swap instruction.



swap2
void swap2()(Code)
Generates code for a swap2 instruction.



switchBranch
void switchBranch(int[] cases, Location[] locations, Location defaultLocation)(Code)
Generates code for a switch statement. The generated code is either a lookupswitch or tableswitch. The choice of which switch type to generate is made based on the amount of bytes to be generated. A tableswitch is usually smaller, unless the cases are sparse.

The key value to switch on must already be on the stack when this instruction executes. It is consumed by the instruction.
Parameters:
  cases - The values to match on. The array length must be the sameas for locations.
Parameters:
  locations - The locations to branch to for each case.The array length must be the same as for cases.
Parameters:
  defaultLocation - The location to branch to if the key onthe stack was not matched.




throwObject
void throwObject()(Code)
Generates code that throws an exception. The object to throw must already be on the stack.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.