CodeQL学习——java程序抽象语法树

声明类

下述表格列出了所有Stmt的子类:

 

Statement syntaxCodeQL classSuperclassesRemarks
; EmptyStmt    
Expr ; ExprStmt    
{ Stmt ... } BlockStmt    
if ( Expr ) Stmt else Stmt IfStmt ConditionalStmt  
if ( Expr ) Stmt
while ( Expr ) Stmt WhileStmt ConditionalStmtLoopStmt  
do Stmt while ( Expr ) DoStmt ConditionalStmtLoopStmt  
for ( Expr ; Expr ; Expr ) Stmt ForStmt ConditionalStmtLoopStmt  
for ( VarAccess : Expr ) Stmt EnhancedForStmt LoopStmt  
switch ( Expr { SwitchCase ... } SwitchStmt    
try { Stmt ... finally { Stmt ... } TryStmt    
return Expr ; ReturnStmt    
return ;
throw Expr ; ThrowStmt    
break ; BreakStmt JumpStmt  
break label ;
continue ; ContinueStmt JumpStmt  
continue label ;
label : Stmt LabeledStmt    
synchronized ( Expr ) Stmt SynchronizedStmt    
assert Expr : Expr ; AssertStmt    
assert Expr ;
TypeAccess name ; LocalVariableDeclStmt    
class name { Member ... ; LocalClassDeclStmt    
this ( Expr ... ; ThisConstructorInvocationStmt    
super ( Expr ... ; SuperConstructorInvocationStmt    
catch ( TypeAccess name { Stmt ... } CatchClause   can only occur as child of a TryStmt
case Literal : Stmt ... ConstCase   can only occur as child of a SwitchStmt
default : Stmt ... DefaultCase   can only occur as child of a SwitchStmt

 

表达式类

表达式类分成很多种,本节的所有类都是Expr的子类。

Literal表达式

下面表格中列出的都是Literal的子类:

 

Expression syntax exampleCodeQL class
true BooleanLiteral
23 IntegerLiteral
23l LongLiteral
4.2f FloatingPointLiteral
4.2 DoubleLiteral
'a' CharacterLiteral
"Hello" StringLiteral
null NullLiteral

 

一元表达式

下面表格中列出的都是UnaryExpr的子类:

Expression syntaxCodeQL classSuperclassesRemarks
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 syntaxCodeQL classSuperclasses
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 syntaxCodeQL classSuperclasses
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 examplesCodeQL 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 examplesCodeQL classRemarks
(int) f CastExpr  
(23 42) ParExpr  
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  
posted @ 2021-05-08 21:07  bamb00  阅读(819)  评论(0编辑  收藏  举报