|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dellroad.jc.cgen.CExpr
Class for assembling C language expressions and outputting them as C code.
The purpose of this class is to allow us to output arbitrarily complex expressions in C that contain sufficient, but not stupidly unnecessary, parentheses. Note that we do output unnecessary parentheses in those cases where it's deemed to make things clearer.
Field Summary | |
static int |
ADD
|
static int |
ADDRESS_OF
|
static int |
AND
|
static int |
ARRAYINDEX
|
static int |
ARROW
|
static int |
ATOMIC
|
static int |
CAST
|
static int |
COMPLEMENT
|
static int |
DEREFERENCE
|
static int |
DIVIDE
|
static int |
EQUAL
|
static int |
FUNCTION
|
static int |
GE
|
static int |
GT
|
static int |
LE
|
static int |
LOGICAL_AND
|
static int |
LOGICAL_NOT
|
static int |
LOGICAL_OR
|
static int |
LT
|
static int |
MODULO
|
static int |
MULTIPLY
|
static int |
NEGATE
|
static int |
NOT_EQUAL
|
static int |
NUM_TYPES
|
static int |
OR
|
static int |
SHIFT_LEFT
|
static int |
SHIFT_RIGHT
|
static int |
SUBTRACT
|
static int |
THREEWAY
|
static int |
XOR
|
Constructor Summary | |
CExpr(int type,
CExpr op1)
Create a function invocation or unary C expression. |
|
CExpr(int type,
CExpr op1,
CExpr op2)
Create a function invocation or binary C expression. |
|
CExpr(int type,
CExpr op1,
CExpr op2,
CExpr op3)
Create a function invocation or ternary C expression. |
|
CExpr(int type,
Collection ops)
|
|
CExpr(int type,
Object op1)
Create a function invocation or unary C expression. |
|
CExpr(int type,
Object[] ops)
|
|
CExpr(int type,
Object op1,
Object op2)
Create a function invocation or binary C expression. |
|
CExpr(int type,
Object op1,
Object op2,
Object op3)
Create a function invocation or ternary C expression. |
|
CExpr(int type,
Object op1,
Object op2,
Object op3,
Object op4)
Create a function invocation. |
|
CExpr(String s)
Create an "atomic" C expression containing the given string. |
Method Summary | |
void |
dumpOps(int depth)
|
static boolean |
isBinary(int type)
|
static boolean |
isTernary(int type)
|
static boolean |
isUnary(int type)
|
static void |
main(String[] args)
Test method. |
static CExpr |
random(Random r)
Generate a random C expression. |
String |
toString()
Return valid C code that expresses this C expression. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int ATOMIC
public static final int DEREFERENCE
public static final int ADDRESS_OF
public static final int LOGICAL_NOT
public static final int COMPLEMENT
public static final int NEGATE
public static final int ADD
public static final int SUBTRACT
public static final int LOGICAL_AND
public static final int LOGICAL_OR
public static final int AND
public static final int OR
public static final int XOR
public static final int DIVIDE
public static final int MULTIPLY
public static final int MODULO
public static final int SHIFT_LEFT
public static final int SHIFT_RIGHT
public static final int ARROW
public static final int ARRAYINDEX
public static final int LT
public static final int LE
public static final int GT
public static final int GE
public static final int EQUAL
public static final int NOT_EQUAL
public static final int CAST
public static final int FUNCTION
public static final int THREEWAY
public static final int NUM_TYPES
Constructor Detail |
public CExpr(String s)
public CExpr(int type, CExpr op1)
public CExpr(int type, CExpr op1, CExpr op2)
public CExpr(int type, CExpr op1, CExpr op2, CExpr op3)
public CExpr(int type, Object op1)
public CExpr(int type, Object op1, Object op2)
public CExpr(int type, Object op1, Object op2, Object op3)
public CExpr(int type, Object op1, Object op2, Object op3, Object op4)
public CExpr(int type, Collection ops)
public CExpr(int type, Object[] ops)
Method Detail |
public static boolean isUnary(int type)
public static boolean isBinary(int type)
public static boolean isTernary(int type)
public String toString()
public static CExpr random(Random r)
public void dumpOps(int depth)
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |