decompiler  1.0.0
Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
PrintJava Class Reference

The java-language token emitter. More...

#include <printjava.hh>

Inheritance diagram for PrintJava:
PrintC PrintLanguage

Public Member Functions

 PrintJava (Architecture *g, const string &nm="java-language")
 Constructor.
 
virtual void resetDefaults (void)
 Set printing options to their default value.
 
virtual void docFunction (const Funcdata *fd)
 Emit the declaration (and body) of a function. More...
 
virtual void pushTypeStart (const Datatype *ct, bool noident)
 
virtual void pushTypeEnd (const Datatype *ct)
 Push the tail ends of a data-type declaration onto the RPN stack. More...
 
virtual bool doEmitWideCharPrefix (void) const
 Return true if this language requires a prefix when expressing wide characters. More...
 
virtual void adjustTypeOperators (void)
 Set basic data-type information for p-code operators.
 
virtual void opLoad (const PcodeOp *op)
 Emit a LOAD operator.
 
virtual void opStore (const PcodeOp *op)
 Emit a STORE operator.
 
virtual void opCallind (const PcodeOp *op)
 Emit a CALLIND operator.
 
virtual void opCpoolRefOp (const PcodeOp *op)
 Emit a CPOOLREF operator.
 
- Public Member Functions inherited from PrintC
 PrintC (Architecture *g, const string &nm="c-language")
 Constructor. More...
 
void setNULLPrinting (bool val)
 Toggle the printing of a 'NULL' token.
 
void setInplaceOps (bool val)
 Toggle the printing of in-place operators.
 
void setConvention (bool val)
 Toggle whether calling conventions are printed.
 
void setNoCastPrinting (bool val)
 Toggle whether casts should not be printed.
 
void setCStyleComments (void)
 Set c-style "/* */" comment delimiters.
 
void setCPlusPlusStyleComments (void)
 Set c++-style "//" comment delimiters.
 
void setDisplayUnplaced (bool val)
 Toggle whether unplaced comments are displayed in the header.
 
void setHideImpliedExts (bool val)
 Toggle whether implied extensions are hidden.
 
virtual void setCommentStyle (const string &nm)
 Set the way comments are displayed in decompiler output. More...
 
virtual void docTypeDefinitions (const TypeFactory *typegrp)
 Emit definitions of data-types. More...
 
virtual void docAllGlobals (void)
 Emit declarations of global variables.
 
virtual void docSingleGlobal (const Symbol *sym)
 Emit the declaration for a single (global) Symbol. More...
 
virtual void emitBlockBasic (const BlockBasic *bb)
 Emit statements in a basic block.
 
virtual void emitBlockGraph (const BlockGraph *bl)
 Emit (an unspecified) list of blocks.
 
virtual void emitBlockCopy (const BlockCopy *bl)
 Emit a basic block (with any labels)
 
virtual void emitBlockGoto (const BlockGoto *bl)
 Emit a block ending with a goto statement.
 
virtual void emitBlockLs (const BlockList *bl)
 Emit a sequence of blocks.
 
virtual void emitBlockCondition (const BlockCondition *bl)
 Emit a conditional statement.
 
virtual void emitBlockIf (const BlockIf *bl)
 Emit an if/else style construct.
 
virtual void emitBlockWhileDo (const BlockWhileDo *bl)
 Emit a loop structure, check at top.
 
virtual void emitBlockFor (const BlockFor *bl)
 TODO.
 
virtual void emitBlockDoWhile (const BlockDoWhile *bl)
 Emit a loop structure, check at bottom.
 
virtual void emitBlockInfLoop (const BlockInfLoop *bl)
 Emit an infinite loop structure.
 
virtual void emitBlockSwitch (const BlockSwitch *bl)
 Emit a switch structure.
 
virtual void opCopy (const PcodeOp *op)
 Emit a COPY operator.
 
virtual void opBranch (const PcodeOp *op)
 Emit a BRANCH operator.
 
virtual void opCbranch (const PcodeOp *op)
 
virtual void opBranchind (const PcodeOp *op)
 Emit a BRANCHIND operator.
 
virtual void opCall (const PcodeOp *op)
 Emit a CALL operator.
 
virtual void opCallother (const PcodeOp *op)
 Emit a CALLOTHER operator.
 
virtual void opConstructor (const PcodeOp *op, bool withNew)
 Emit an operator constructing an object.
 
virtual void opReturn (const PcodeOp *op)
 Emit a RETURN operator.
 
virtual void opIntEqual (const PcodeOp *op)
 Emit a INT_EQUAL operator.
 
virtual void opIntNotEqual (const PcodeOp *op)
 Emit a INT_NOTEQUAL operator.
 
virtual void opIntSless (const PcodeOp *op)
 Emit a INT_SLESS operator.
 
virtual void opIntSlessEqual (const PcodeOp *op)
 Emit a INT_SLESSEQUAL operator.
 
virtual void opIntLess (const PcodeOp *op)
 Emit a INT_LESS operator.
 
virtual void opIntLessEqual (const PcodeOp *op)
 Emit a INT_LESSEQUAL operator.
 
virtual void opIntZext (const PcodeOp *op, const PcodeOp *readOp)
 Emit a INT_ZEXT operator.
 
virtual void opIntSext (const PcodeOp *op, const PcodeOp *readOp)
 Emit a INT_SEXT operator.
 
virtual void opIntAdd (const PcodeOp *op)
 Emit a INT_ADD operator.
 
virtual void opIntSub (const PcodeOp *op)
 Emit a INT_SUB operator.
 
virtual void opIntCarry (const PcodeOp *op)
 Emit a INT_CARRY operator.
 
virtual void opIntScarry (const PcodeOp *op)
 Emit a INT_SCARRY operator.
 
virtual void opIntSborrow (const PcodeOp *op)
 Emit a INT_SBORROW operator.
 
virtual void opInt2Comp (const PcodeOp *op)
 Emit a INT_2COMP operator.
 
virtual void opIntNegate (const PcodeOp *op)
 Emit a INT_NEGATE operator.
 
virtual void opIntXor (const PcodeOp *op)
 Emit a INT_XOR operator.
 
virtual void opIntAnd (const PcodeOp *op)
 Emit a INT_AND operator.
 
virtual void opIntOr (const PcodeOp *op)
 Emit a INT_OR operator.
 
virtual void opIntLeft (const PcodeOp *op)
 Emit a INT_LEFT operator.
 
virtual void opIntRight (const PcodeOp *op)
 Emit a INT_RIGHT operator.
 
virtual void opIntSright (const PcodeOp *op)
 Emit a INT_SRIGHT operator.
 
virtual void opIntMult (const PcodeOp *op)
 Emit a INT_MULT operator.
 
virtual void opIntDiv (const PcodeOp *op)
 Emit a INT_DIV operator.
 
virtual void opIntSdiv (const PcodeOp *op)
 Emit a INT_SDIV operator.
 
virtual void opIntRem (const PcodeOp *op)
 Emit a INT_REM operator.
 
virtual void opIntSrem (const PcodeOp *op)
 Emit a INT_SREM operator.
 
virtual void opBoolNegate (const PcodeOp *op)
 
virtual void opBoolXor (const PcodeOp *op)
 Emit a BOOL_XOR operator.
 
virtual void opBoolAnd (const PcodeOp *op)
 Emit a BOOL_AND operator.
 
virtual void opBoolOr (const PcodeOp *op)
 Emit a BOOL_OR operator.
 
virtual void opFloatEqual (const PcodeOp *op)
 Emit a FLOAT_EQUAL operator.
 
virtual void opFloatNotEqual (const PcodeOp *op)
 Emit a FLOAT_NOTEQUAL operator.
 
virtual void opFloatLess (const PcodeOp *op)
 Emit a FLOAT_LESS operator.
 
virtual void opFloatLessEqual (const PcodeOp *op)
 Emit a FLOAT_LESSEQUAL operator.
 
virtual void opFloatNan (const PcodeOp *op)
 Emit a FLOAT_NAN operator.
 
virtual void opFloatAdd (const PcodeOp *op)
 Emit a FLOAT_ADD operator.
 
virtual void opFloatDiv (const PcodeOp *op)
 Emit a FLOAT_DIV operator.
 
virtual void opFloatMult (const PcodeOp *op)
 Emit a FLOAT_MULT operator.
 
virtual void opFloatSub (const PcodeOp *op)
 Emit a FLOAT_SUB operator.
 
virtual void opFloatNeg (const PcodeOp *op)
 Emit a FLOAT_NEG operator.
 
virtual void opFloatAbs (const PcodeOp *op)
 Emit a FLOAT_ABS operator.
 
virtual void opFloatSqrt (const PcodeOp *op)
 Emit a FLOAT_SQRT operator.
 
virtual void opFloatInt2Float (const PcodeOp *op)
 Emit a FLOAT_INT2FLOAT operator.
 
virtual void opFloatFloat2Float (const PcodeOp *op)
 Emit a FLOAT_FLOAT2FLOAT operator.
 
virtual void opFloatTrunc (const PcodeOp *op)
 Emit a FLOAT_TRUNC operator.
 
virtual void opFloatCeil (const PcodeOp *op)
 Emit a FLOAT_CEIL operator.
 
virtual void opFloatFloor (const PcodeOp *op)
 Emit a FLOAT_FLOOR operator.
 
virtual void opFloatRound (const PcodeOp *op)
 Emit a FLOAT_ROUND operator.
 
virtual void opMultiequal (const PcodeOp *op)
 Emit a MULTIEQUAL operator.
 
virtual void opIndirect (const PcodeOp *op)
 Emit a INDIRECT operator.
 
virtual void opPiece (const PcodeOp *op)
 Emit a PIECE operator.
 
virtual void opSubpiece (const PcodeOp *op)
 Emit a SUBPIECE operator.
 
virtual void opCast (const PcodeOp *op)
 Emit a CAST operator.
 
virtual void opPtradd (const PcodeOp *op)
 Emit a PTRADD operator.
 
virtual void opPtrsub (const PcodeOp *op)
 
virtual void opSegmentOp (const PcodeOp *op)
 
virtual void opNewOp (const PcodeOp *op)
 Emit a NEW operator.
 
virtual void opInsertOp (const PcodeOp *op)
 Emit an INSERT operator.
 
virtual void opExtractOp (const PcodeOp *op)
 Emit an EXTRACT operator.
 
virtual void opPopcountOp (const PcodeOp *op)
 Emit a POPCOUNT operator.
 
- Public Member Functions inherited from PrintLanguage
 PrintLanguage (Architecture *g, const string &nm)
 Constructor. More...
 
virtual ~PrintLanguage (void)
 Destructor.
 
const string & getName (void) const
 Get the language name.
 
CastStrategygetCastStrategy (void) const
 Get the casting strategy for the language.
 
ostream * getOutputStream (void) const
 Get the output stream being emitted to.
 
void setOutputStream (ostream *t)
 Set the output stream to emit to.
 
void setMaxLineSize (int4 mls)
 Set the maximum number of characters per line.
 
void setIndentIncrement (int4 inc)
 Set the number of characters to indent per level of code nesting.
 
void setLineCommentIndent (int4 val)
 Set the number of characters to indent comment lines. More...
 
void setCommentDelimeter (const string &start, const string &stop, bool usecommentfill)
 Establish comment delimiters for the language. More...
 
uint4 getInstructionComment (void) const
 Get the type of comments suitable within the body of a function.
 
void setInstructionComment (uint4 val)
 Set the type of comments suitable within the body of a function.
 
void setNamespaceStrategy (namespace_strategy strat)
 Set how namespace tokens are displayed.
 
uint4 getHeaderComment (void) const
 Get the type of comments suitable for a function header.
 
void setHeaderComment (uint4 val)
 Set the type of comments suitable for a function header.
 
bool emitsXml (void) const
 Does the low-level emitter, emit XML markup.
 
void setXML (bool val)
 Set whether the low-level emitter, emits XML markup. More...
 
void setFlat (bool val)
 Set whether nesting code structure should be emitted. More...
 
virtual void clear (void)
 Clear the RPN stack and the low-level emitter.
 
virtual void setIntegerFormat (const string &nm)
 Set the default integer format. More...
 

Private Member Functions

void resetDefaultsPrintJava (void)
 Set options that are specific to Java.
 
virtual void printUnicode (ostream &s, int4 onechar) const
 Print a single unicode character as a character constant for the high-level language. More...
 

Static Private Member Functions

static bool isArrayType (const Datatype *ct)
 Does the given data-type reference a java array. More...
 
static bool needZeroArray (const Varnode *vn)
 Do we need '[0]' syntax. More...
 

Static Private Attributes

static OpToken instanceof = { "instanceof", 2, 60, true, OpToken::binary, 1, 0, (OpToken *)0 }
 The instanceof keyword.
 

Additional Inherited Members

- Public Types inherited from PrintLanguage
enum  modifiers {
  force_hex = 1, force_dec = 2, bestfit = 4, force_scinote = 8,
  force_pointer = 0x10, print_load_value = 0x20, print_store_value = 0x40, no_branch = 0x80,
  only_branch = 0x100, comma_separate = 0x200, flat = 0x400, falsebranch = 0x800,
  nofallthru = 0x1000, negatetoken = 0x2000, hide_thisparam = 0x4000
}
 Possible context sensitive modifiers to how tokens get emitted. More...
 
enum  tagtype {
  syntax, vartoken, functoken, optoken,
  typetoken, fieldtoken, blanktoken
}
 Possible types of Atom. More...
 
enum  namespace_strategy { MINIMAL_NAMESPACES = 0, NO_NAMESPACES = 1, ALL_NAMESPACES = 2 }
 Strategies for displaying namespace tokens. More...
 
- Static Public Member Functions inherited from PrintLanguage
static int4 mostNaturalBase (uintb val)
 Determine the most natural base for an integer. More...
 
static void formatBinary (ostream &s, uintb val)
 Print a number in binary form. More...
 
- Protected Member Functions inherited from PrintC
void buildTypeStack (const Datatype *ct, vector< const Datatype * > &typestack)
 Prepare to push components of a data-type declaration. More...
 
void pushPrototypeInputs (const FuncProto *proto)
 Push input parameters. More...
 
void pushSymbolScope (const Symbol *symbol)
 Push tokens resolving a symbol's scope. More...
 
void emitSymbolScope (const Symbol *symbol)
 Emit tokens resolving a symbol's scope. More...
 
void pushBoolConstant (uintb val, const TypeBase *ct, const Varnode *vn, const PcodeOp *op)
 Push a true or false token to the RPN stack. More...
 
void pushCharConstant (uintb val, const TypeChar *ct, const Varnode *vn, const PcodeOp *op)
 Push a single character constant to the RPN stack. More...
 
void pushEnumConstant (uintb val, const TypeEnum *ct, const Varnode *vn, const PcodeOp *op)
 Push an enumerated value to the RPN stack. More...
 
virtual bool pushPtrCharConstant (uintb val, const TypePointer *ct, const Varnode *vn, const PcodeOp *op)
 Attempt to push a quoted string representing a given constant pointer onto the RPN stack. More...
 
bool pushPtrCodeConstant (uintb val, const TypePointer *ct, const Varnode *vn, const PcodeOp *op)
 Attempt to push a function name representing a constant pointer onto the RPN stack. More...
 
bool checkArrayDeref (const Varnode *vn) const
 Determine whether a LOAD/STORE expression requires pointer '*' syntax. More...
 
void emitStructDefinition (const TypeStruct *ct)
 Emit the definition of a structure data-type. More...
 
void emitEnumDefinition (const TypeEnum *ct)
 Emit the definition of an enumeration data-type. More...
 
void emitPrototypeOutput (const FuncProto *proto, const Funcdata *fd)
 Emit the output data-type of a function prototype. More...
 
void emitPrototypeInputs (const FuncProto *proto)
 Emit the input data-types of a function prototype. More...
 
void emitGlobalVarDeclsRecursive (Scope *scope)
 Emit variable declarations for all global symbols under given scope. More...
 
void emitLocalVarDecls (const Funcdata *fd)
 Emit variable declarations for a function. More...
 
void emitStatement (const PcodeOp *inst)
 Emit a statement in the body of a function. More...
 
bool emitInplaceOp (const PcodeOp *op)
 Attempt to emit an expression rooted at an in-place operator. More...
 
void emitGotoStatement (const FlowBlock *bl, const FlowBlock *exp_bl, uint4 type)
 Emit a statement representing an unstructured branch. More...
 
void emitSwitchCase (int4 casenum, const BlockSwitch *switchbl)
 Emit labels for a case block. More...
 
void emitLabel (const FlowBlock *bl)
 Emit a formal label for a given control-flow block. More...
 
void emitLabelStatement (const FlowBlock *bl)
 Emit any required label statement for a given basic block. More...
 
void emitAnyLabelStatement (const FlowBlock *bl)
 Emit any required label statement for a given control-flow block. More...
 
void emitCommentGroup (const PcodeOp *inst)
 Emit comments associated with a given statement. More...
 
void emitCommentFuncHeader (const Funcdata *fd)
 Emit comments in the given function's header. More...
 
void opFunc (const PcodeOp *op)
 Push a functional expression based on the given p-code op to the RPN stack. More...
 
void opTypeCast (const PcodeOp *op)
 Push the given p-code op using type-cast syntax to the RPN stack. More...
 
void opHiddenFunc (const PcodeOp *op)
 Push the given p-code op as a hidden token. More...
 
bool printCharacterConstant (ostream &s, const Address &addr, Datatype *charType) const
 Print a quoted (unicode) string at the given address. More...
 
int4 getHiddenThisSlot (const PcodeOp *op, FuncProto *fc)
 Get position of "this" pointer needing to be hidden. More...
 
void resetDefaultsPrintC (void)
 Set default values for options specific to PrintC.
 
virtual void pushConstant (uintb val, const Datatype *ct, const Varnode *vn, const PcodeOp *op)
 Push a constant onto the RPN stack. More...
 
virtual bool pushEquate (uintb val, int4 sz, const EquateSymbol *sym, const Varnode *vn, const PcodeOp *op)
 Push a constant marked up by and EquateSymbol onto the RPN stack. More...
 
virtual void pushAnnotation (const Varnode *vn, const PcodeOp *op)
 Push an address which is not in the normal data-flow. More...
 
virtual void pushSymbol (const Symbol *sym, const Varnode *vn, const PcodeOp *op)
 Push a specific Symbol onto the RPN stack. More...
 
virtual void pushUnnamedLocation (const Address &addr, const Varnode *vn, const PcodeOp *op)
 Push an address as a substitute for a Symbol onto the RPN stack. More...
 
virtual void pushPartialSymbol (const Symbol *sym, int4 off, int4 sz, const Varnode *vn, const PcodeOp *op, Datatype *outtype)
 Push a variable that represents only part of a symbol onto the RPN stack. More...
 
virtual void pushMismatchSymbol (const Symbol *sym, int4 off, int4 sz, const Varnode *vn, const PcodeOp *op)
 Push an identifier for a variable that mismatches with its Symbol. More...
 
virtual void push_integer (uintb val, int4 sz, bool sign, const Varnode *vn, const PcodeOp *op)
 Push a constant with an integer data-type to the RPN stack. More...
 
virtual void push_float (uintb val, int4 sz, const Varnode *vn, const PcodeOp *op)
 Push a constant with a floating-point data-type to the RPN stack. More...
 
virtual void pushType (const Datatype *ct)
 Push a data-type name onto the RPN expression stack. More...
 
virtual string genericFunctionName (const Address &addr)
 Create a generic function name base on the entry point address. More...
 
virtual string genericTypeName (const Datatype *ct)
 Generate a generic name for an unnamed data-type. More...
 
virtual void emitExpression (const PcodeOp *op)
 Emit a full expression. More...
 
virtual void emitVarDecl (const Symbol *sym)
 Emit a variable declaration. More...
 
virtual void emitVarDeclStatement (const Symbol *sym)
 Emit a variable declaration statement. More...
 
virtual bool emitScopeVarDecls (const Scope *scope, int4 cat)
 Emit all the variable declarations for a given scope. More...
 
virtual void emitFunctionDeclaration (const Funcdata *fd)
 Emit a function declaration. More...
 
virtual void emitTypeDefinition (const Datatype *ct)
 Emit the definition of the given data-type. More...
 
virtual bool checkPrintNegation (const Varnode *vn)
 Check whether a given boolean Varnode can be printed in negated form. More...
 
- Protected Member Functions inherited from PrintLanguage
bool isSet (uint4 m) const
 Is the given printing modification active.
 
void pushScope (const Scope *sc)
 Push a new symbol scope.
 
void popScope (void)
 Pop to the previous symbol scope.
 
void pushMod (void)
 Push current printing modifications to the stack.
 
void popMod (void)
 Pop to the previous printing modifications.
 
void setMod (uint4 m)
 Activate the given printing modification.
 
void unsetMod (uint4 m)
 Deactivate the given printing modification.
 
void pushOp (const OpToken *tok, const PcodeOp *op)
 Push an operator token onto the RPN stack. More...
 
void pushAtom (const Atom &atom)
 Push a variable token onto the RPN stack. More...
 
void pushVnImplied (const Varnode *vn, const PcodeOp *op, uint4 m)
 Push an implied variable onto the RPN stack. More...
 
void pushVnExplicit (const Varnode *vn, const PcodeOp *op)
 Push an explicit variable onto the RPN stack. More...
 
void pushVnLHS (const Varnode *vn, const PcodeOp *op)
 Push a variable as the left-hand side of an expression. More...
 
bool parentheses (const OpToken *op2)
 Determine if the given token should be emitted in its own parenthetic expression. More...
 
void emitOp (const ReversePolish &entry)
 Send an operator token from the RPN to the emitter. More...
 
void emitAtom (const Atom &atom)
 Send an variable token from the RPN to the emitter. More...
 
bool escapeCharacterData (ostream &s, const uint1 *buf, int4 count, int4 charsize, bool bigend) const
 Emit a byte buffer to the stream as unicode characters. More...
 
void recurse (void)
 Emit from the RPN stack as much as possible. More...
 
void opBinary (const OpToken *tok, const PcodeOp *op)
 Push a binary operator onto the RPN stack. More...
 
void opUnary (const OpToken *tok, const PcodeOp *op)
 Push a unary operator onto the RPN stack. More...
 
int4 getPending (void) const
 Get the number of pending nodes yet to be put on the RPN stack.
 
void resetDefaultsInternal (void)
 Reset options to default for PrintLanguage.
 
virtual void emitLineComment (int4 indent, const Comment *comm)
 Emit a comment line. More...
 
- Static Protected Member Functions inherited from PrintLanguage
static bool unicodeNeedsEscape (int4 codepoint)
 Determine if the given codepoint needs to be escaped. More...
 
- Protected Attributes inherited from PrintC
bool option_NULL
 Set to true if we should emit NULL keyword.
 
bool option_inplace_ops
 Set to true if we should use '+=' '&=' etc.
 
bool option_convention
 Set to true if we should print calling convention.
 
bool option_nocasts
 Don't print a cast if true.
 
bool option_unplaced
 Set to true if we should display unplaced comments.
 
bool option_hide_exts
 Set to true if we should hide implied extension operations.
 
string nullToken
 Token to use for 'null'.
 
CommentSorter commsorter
 Container/organizer for comments in the current function.
 
- Protected Attributes inherited from PrintLanguage
Architectureglb
 The Architecture owning the language emitter.
 
const Scopecurscope
 The current symbol scope.
 
CastStrategycastStrategy
 The strategy for emitting explicit case operations.
 
EmitXmlemit
 The low-level token emitter.
 
uint4 mods
 Currently active printing modifications.
 
uint4 instr_comment_type
 Type of instruction comments to display.
 
uint4 head_comment_type
 Type of header comments to display.
 
namespace_strategy namespc_strategy
 How should namespace tokens be displayed.
 
- Static Protected Attributes inherited from PrintC
static OpToken hidden = { "", 1, 70, false, OpToken::hiddenfunction, 0, 0, (OpToken *)0 }
 Hidden functional (that may force parentheses)
 
static OpToken scope = { "::", 2, 70, true, OpToken::binary, 0, 0, (OpToken *)0 }
 The sub-scope/namespace operator.
 
static OpToken object_member = { ".", 2, 66, true, OpToken::binary, 0, 0, (OpToken *)0 }
 The member operator.
 
static OpToken pointer_member = { "->", 2, 66, true, OpToken::binary, 0, 0, (OpToken *)0 }
 The points to member operator.
 
static OpToken subscript = { "[]", 2, 66, false, OpToken::postsurround, 0, 0, (OpToken *)0 }
 The array subscript operator.
 
static OpToken function_call = { "()", 2, 66, false, OpToken::postsurround, 0, 10, (OpToken *)0 }
 The function call operator.
 
static OpToken bitwise_not = { "~", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 The bitwise negate operator.
 
static OpToken boolean_not = { "!", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 The boolean not operator.
 
static OpToken unary_minus = { "-", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 The unary minus operator.
 
static OpToken unary_plus = { "+", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 The unary plus operator.
 
static OpToken addressof = { "&", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 The address of operator.
 
static OpToken dereference = { "*", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 The pointer dereference operator.
 
static OpToken typecast = { "()", 2, 62, false, OpToken::presurround, 0, 0, (OpToken *)0 }
 The type cast operator.
 
static OpToken multiply = { "*", 2, 54, true, OpToken::binary, 1, 0, (OpToken *)0 }
 The multiplication operator.
 
static OpToken divide = { "/", 2, 54, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The division operator.
 
static OpToken modulo = { "%", 2, 54, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The modulo operator.
 
static OpToken binary_plus = { "+", 2, 50, true, OpToken::binary, 1, 0, (OpToken *)0 }
 The binary addition operator.
 
static OpToken binary_minus = { "-", 2, 50, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The binary subtraction operator.
 
static OpToken shift_left = { "<<", 2, 46, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The left shift operator.
 
static OpToken shift_right = { ">>", 2, 46, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The right shift operator.
 
static OpToken shift_sright = { ">>", 2, 46, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The signed right shift operator.
 
static OpToken less_than = { "<", 2, 42, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The less than operator.
 
static OpToken less_equal = { "<=", 2, 42, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The less than or equal operator.
 
static OpToken greater_than = { ">", 2, 42, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The greater than operator.
 
static OpToken greater_equal = { ">=", 2, 42, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The greater than or equal operator.
 
static OpToken equal = { "==", 2, 38, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The equal operator.
 
static OpToken not_equal = { "!=", 2, 38, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The not equal operator.
 
static OpToken bitwise_and = { "&", 2, 34, true, OpToken::binary, 1, 0, (OpToken *)0 }
 The logical and operator.
 
static OpToken bitwise_xor = { "^", 2, 30, true, OpToken::binary, 1, 0, (OpToken *)0 }
 The logical xor operator.
 
static OpToken bitwise_or = { "|", 2, 26, true, OpToken::binary, 1, 0, (OpToken *)0 }
 The logical or operator.
 
static OpToken boolean_and = { "&&", 2, 22, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The boolean and operator.
 
static OpToken boolean_or = { "||", 2, 18, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The boolean or operator.
 
static OpToken boolean_xor = { "^^", 2, 20, false, OpToken::binary, 1, 0, (OpToken *)0 }
 The boolean xor operator.
 
static OpToken assignment = { "=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The assignment operator.
 
static OpToken comma = { ",", 2, 2, true, OpToken::binary, 0, 0, (OpToken *)0 }
 The comma operator (for parameter lists)
 
static OpToken new_op = { "", 2, 62, false, OpToken::space, 1, 0, (OpToken *)0 }
 The new operator.
 
static OpToken multequal = { "*=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place multiplication operator.
 
static OpToken divequal = { "/=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place division operator.
 
static OpToken remequal = { "%=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place modulo operator.
 
static OpToken plusequal = { "+=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place addition operator.
 
static OpToken minusequal = { "-=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place subtraction operator.
 
static OpToken leftequal = { "<<=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place left shift operator.
 
static OpToken rightequal = { ">>=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place right shift operator.
 
static OpToken andequal = { "&=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place logical and operator.
 
static OpToken orequal = { "|=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place logical or operator.
 
static OpToken xorequal = { "^=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 }
 The in-place logical xor operator.
 
static OpToken type_expr_space = { "", 2, 10, false, OpToken::space, 1, 0, (OpToken *)0 }
 Type declaration involving a space (identifier or adornment)
 
static OpToken type_expr_nospace = { "", 2, 10, false, OpToken::space, 0, 0, (OpToken *)0 }
 Type declaration with no space.
 
static OpToken ptr_expr = { "*", 1, 62, false, OpToken::unary_prefix, 0, 0, (OpToken *)0 }
 Pointer adornment for a type declaration.
 
static OpToken array_expr = { "[]", 2, 66, false, OpToken::postsurround, 1, 0, (OpToken *)0 }
 Array adornment for a type declaration.
 
static OpToken enum_cat = { "|", 2, 26, true, OpToken::binary, 0, 0, (OpToken *)0 }
 The concatenation operator for enumerated values.
 

Detailed Description

The java-language token emitter.

This builds heavily on the c-language PrintC emitter. Most operator tokens, the format of function prototypes, and code structuring are shared. Specifics of the java constant pool are handled through the overloaded opCpoolRefOp().

Java data-types are mapped into the decompiler's data-type system in a specific way. The primitives int, long, short, byte, boolean, float, and double all map directly. The char primitive is treated as a 2 byte unsigned integer. A TypeStruct object holds the field layout for a java class, then java objects get mapped as follows:

There are some adjustments to the printing of data-types and LOAD/STORE expressions to account for this mapping.

Member Function Documentation

void PrintJava::docFunction ( const Funcdata fd)
virtual

Emit the declaration (and body) of a function.

Parameters
fdis the function to emit

Reimplemented from PrintC.

References PrintLanguage::curscope, PrintC::docFunction(), Scope::getParent(), Funcdata::getScopeLocal(), PrintLanguage::popScope(), and PrintLanguage::pushScope().

virtual bool PrintJava::doEmitWideCharPrefix ( void  ) const
inlinevirtual

Return true if this language requires a prefix when expressing wide characters.

The c-language standard requires that strings (and character constants) made up of wide character elements have an 'L' prefix added before the quote characters. Other related languages may not do this. Having this as a virtual method lets derived languages to tailor their strings while still using the basic PrintC functionality

Returns
true if a prefix should be printed

Reimplemented from PrintC.

bool PrintJava::isArrayType ( const Datatype ct)
staticprivate

Does the given data-type reference a java array.

References to java array objects where the underlying element is a java primitive look like:

  • Pointer to int
  • Pointer to bool
  • Pointer to float

An array of java class objects is represented as a pointer to pointer data-type.

Parameters
ctis the given data-type
Returns
true if the data-type references a java array object

References Datatype::getMetatype(), Datatype::isCharPrint(), TYPE_BOOL, TYPE_FLOAT, TYPE_INT, TYPE_PTR, and TYPE_UINT.

Referenced by needZeroArray(), and pushTypeStart().

bool PrintJava::needZeroArray ( const Varnode vn)
staticprivate

Do we need '[0]' syntax.

Assuming the given Varnode is a dereferenced pointer, determine whether it needs to be represented using '[0]' syntax.

Parameters
vnis the given Varnode
Returns
true if '[0]' syntax is required

References PcodeOp::code(), CPUI_CPOOLREF, CPUI_PTRADD, CPUI_PTRSUB, Varnode::getDef(), Varnode::getType(), isArrayType(), Varnode::isExplicit(), and Varnode::isWritten().

Referenced by opLoad(), and opStore().

void PrintJava::printUnicode ( ostream &  s,
int4  onechar 
) const
privatevirtual

Print a single unicode character as a character constant for the high-level language.

For most languages, this prints the character surrounded by single quotes.

Parameters
sis the output stream
onecharis the unicode code point of the character to print

Reimplemented from PrintC.

References PrintLanguage::unicodeNeedsEscape(), and StringManager::writeUtf8().

void PrintJava::pushTypeEnd ( const Datatype ct)
virtual

Push the tail ends of a data-type declaration onto the RPN stack.

Because the front-ends were pushed on base-type -> final-modifier, the tail-ends are pushed on final-modifier -> base-type. The tail-ends amount to

  • array subscripts . [ # ] and
  • function parameters . ( paramlist )
Parameters
ctis the data-type being pushed

Reimplemented from PrintC.

void PrintJava::pushTypeStart ( const Datatype ct,
bool  noident 
)
virtual

Print a data-type up to the identifier, store off array sizes for printing after the identifier. Find the root type (the one with an identifier) and the count number of wrapping arrays.

Parameters
ctis the given data-type
noidentis true if no identifier will be pushed with this declaration

Reimplemented from PrintC.

References PrintLanguage::blanktoken, PrintC::genericTypeName(), Datatype::getMetatype(), Datatype::getName(), TypeFactory::getTypeVoid(), PrintLanguage::glb, isArrayType(), PrintLanguage::name, EmitXml::no_color, PrintLanguage::pushAtom(), PrintLanguage::pushOp(), PrintC::subscript, EmitXml::type_color, PrintC::type_expr_nospace, PrintC::type_expr_space, TYPE_PTR, Architecture::types, and PrintLanguage::typetoken.


The documentation for this class was generated from the following files: