CodeQL学习——java程序抽象语法树
声明类
下述表格列出了所有Stmt的子类:
表达式类
表达式类分成很多种,本节的所有类都是Expr的子类。
Literal表达式
下面表格中列出的都是Literal的子类:
Expression syntax example | CodeQL class |
---|---|
true |
BooleanLiteral |
23 |
IntegerLiteral |
23l |
LongLiteral |
4.2f |
FloatingPointLiteral |
4.2 |
DoubleLiteral |
'a' |
CharacterLiteral |
"Hello" |
StringLiteral |
null |
NullLiteral |
一元表达式
下面表格中列出的都是UnaryExpr的子类:
Expression syntax | CodeQL class | Superclasses | Remarks |
---|---|---|---|
Expr++ |
PostIncExpr | UnaryAssignExpr | |
Expr-- |
PostDecExpr | UnaryAssignExpr | |
++ Expr |
PreIncExpr | UnaryAssignExpr | |
-- Expr |
PreDecExpr | UnaryAssignExpr | |
~ Expr |
BitNotExpr | BitwiseExpr | see below for other subclasses of BitwiseExpr |
- Expr |
MinusExpr | ||
+ Expr |
PlusExpr | ||
! Expr |
LogNotExpr | LogicExpr | see below for other subclasses of LogicExpr |
二进制表达式
下面表格中列出的都是BinaryExpr的子类:
Expression syntax | CodeQL class | Superclasses |
---|---|---|
Expr * Expr |
MulExpr | |
Expr / Expr |
DivExpr | |
Expr % Expr |
RemExpr | |
Expr + Expr |
AddExpr | |
Expr - Expr |
SubExpr | |
Expr << Expr |
LShiftExpr | |
Expr >> Expr |
RShiftExpr | |
Expr >>> Expr |
URShiftExpr | |
Expr && Expr |
AndLogicalExpr | LogicExpr |
Expr || Expr |
OrLogicalExpr | LogicExpr |
Expr < Expr |
LTExpr | ComparisonExpr |
Expr > Expr |
GTExpr | ComparisonExpr |
Expr <= Expr |
LEExpr | ComparisonExpr |
Expr >= Expr |
GEExpr | ComparisonExpr |
Expr == Expr |
EQExpr | EqualityTest |
Expr != Expr |
NEExpr | EqualityTest |
Expr & Expr |
AndBitwiseExpr | BitwiseExpr |
Expr | Expr |
OrBitwiseExpr | BitwiseExpr |
Expr ^ Expr |
XorBitwiseExpr | BitwiseExpr |
Assignment表达式
下面表格中列出的都是 Assignment的子类:
Expression syntax | CodeQL class | Superclasses |
---|---|---|
Expr = Expr |
AssignExpr | |
Expr += Expr |
AssignAddExpr | AssignOp |
Expr -= Expr |
AssignSubExpr | AssignOp |
Expr *= Expr |
AssignMulExpr | AssignOp |
Expr /= Expr |
AssignDivExpr | AssignOp |
Expr %= Expr |
AssignRemExpr | AssignOp |
Expr &= Expr |
AssignAndExpr | AssignOp |
Expr |= Expr |
AssignOrExpr | AssignOp |
Expr ^= Expr |
AssignXorExpr | AssignOp |
Expr <<= Expr |
AssignLShiftExpr | AssignOp |
Expr >>= Expr |
AssignRShiftExpr | AssignOp |
Expr >>>= Expr |
AssignURShiftExpr | AssignOp |
Accesse表达式
Expression syntax examples | CodeQL class |
---|---|
this |
ThisAccess |
Outer.this |
|
super |
SuperAccess |
Outer.super |
|
x |
VarAccess |
e.f |
|
a[i] |
ArrayAccess |
f(...) |
MethodAccess |
e.m(...) |
|
String |
TypeAccess |
java.lang.String |
|
? extends Number |
WildcardTypeAccess |
? super Double |
Miscellaneous
Expression syntax examples | CodeQL class | Remarks |
---|---|---|
(int) f |
CastExpr | |
(23 + 42) |
ParExpr | |
o instanceof String |
InstanceOfExpr | |
Expr ? Expr : Expr |
ConditionalExpr | |
String. class |
TypeLiteral | |
new A() |
ClassInstanceExpr | |
new String[3][2] |
ArrayCreationExpr | |
new int[] { 23, 42 } |
||
{ 23, 42 } |
ArrayInit | can only appear as an initializer or as a child of an ArrayCreationExpr |
@Annot(key=val) |
Annotation |