| 程序包 | 说明 |
|---|---|
| com.jfinal.template.expr.ast | |
| com.jfinal.template.ext.directive | |
| com.jfinal.template.stat.ast |
| 限定符和类型 | 类和说明 |
|---|---|
class |
Arith
Arithmetic
1:支持 byte short int long float double BigInteger BigDecimal 的 + - * / % 运算
2:支持字符串加法运算
|
class |
Array
Array
用法:
1:[1, 2, 3]
2:["a", 1, "b", 2, false, 3.14]
|
class |
Assign
Assign
支持三种赋值,其中第二种如果括号中是 ID 或 STR 则演变为第三种是对 map 赋值:
1:ID = expr
2:ID [ expr ] = expr
如果 expr 为 int 或 long 型,则是对 array 赋值
如果 expr 为 ID、STR 型,则是对 map 进行赋值
否则抛异常出来
3:ID [ ID ] = expr 或者 ID [ STR ] = expr
4:支持无限连:id = array[ i = 0 ] = array[1] = 123
|
class |
Compare
Compare
1:支持 byte short int long float double BigInteger BigDecimal 的 == !
|
class |
Const
STR INT LONG FLOAT DOUBLE TRUE FALSE NULL
|
class |
ExprList
ExprList
|
class |
Field
Field
field 表达式取值优先次序,以 user.name 为例
1:假如 user.getName() 存在,则优先调用
2:假如 user 具有 public name 属性,则取 user.name 属性值
3:假如 user 为 Model 子类,则调用 user.get("name")
4:假如 user 为 Record,则调用 user.get("name")
5:假如 user 为 Map,则调用 user.get("name")
|
class |
ForCtrl
forCtrl : ID : expression
| exprList?
|
class |
Id
Id
|
class |
IncDec
自增与自减
|
class |
Index
index : expr '[' expr ']'
支持 a[i]、 a[b[i]]、a[i][j]、a[i][j]...
|
class |
Logic
Logic
支持逻辑运算: !
|
class |
Map
Map
1:定义 map 常量
{k1:123, k2:"abc", 'k3':true, "k4":[1,2,3], k5:1+2, 1:12, true:"Y", null:"abc"}
如上所示,map定义的 key 可以为 id 标识符或者 String、Integer、Long、Boolean、null
等常量值 (详见 ExprParser.buildMapEntry(...)
|
class |
Method
Method : expr '.'
|
class |
NullExpr
NullExpr
|
class |
NullSafe
NullSafe
在原则上只支持具有动态特征的用法,例如:方法调用、字段取值、Map 与 List 取值
而不支持具有静态特征的用法,例如:static method 调用、shared method 调用
用法:
#( seoTitle ??
|
class |
RangeArray
RangeArray : [expr .. expr]
用法:
1:[1..3]
2:[3..1]
|
class |
SharedMethod
SharedMethod
用法:
engine.addSharedMethod(new StrKit());
engine.addSharedStaticMethod(MyKit.class);
#if (notBlank(para))
....
|
class |
StaticField
StaticField : ID_list '::' ID
动态获取静态变量值,变量值改变时仍可正确获取
用法:com.jfinal.core.Const::JFINAL_VERSION
|
class |
StaticMethod
StaticMethod : ID_list : '::' ID '(' exprList?
|
class |
Ternary
Ternary
|
class |
Unary
unary : ('!'
|
| 限定符和类型 | 字段和说明 |
|---|---|
static Expr |
ExprList.NULL_EXPR |
static Expr[] |
ExprList.NULL_EXPR_ARRAY |
| 限定符和类型 | 方法和说明 |
|---|---|
Expr |
ExprList.getActualExpr()
持有 ExprList 的指令可以通过此方法提升 AST 执行性能
1:当 exprArray.length == 1 时返回 exprArray[0]
2:当 exprArray.length == 0 时返回 NullExpr
3:其它情况返回 ExprList 自身
意义在于,当满足前面两个条件时,避免掉了 ExprList.eval(...)
|
Expr |
ForCtrl.getCond() |
Expr |
ForCtrl.getExpr() |
Expr |
ExprList.getExpr(int index) |
Expr[] |
ExprList.getExprArray() |
Expr |
ExprList.getFirstExpr() |
Expr |
Assign.getIndex() |
Expr |
ForCtrl.getInit() |
Expr |
ExprList.getLastExpr() |
Expr |
Assign.getRight() |
Expr |
ForCtrl.getUpdate() |
Expr |
Unary.toConstIfPossible()
如果可能的话,将 Unary 表达式转化成 Const 表达式,类似于 ExprParser.buildMapEntry() 需要这种转化来简化实现
除了可简化程序外,还起到一定的性能优化作用
Number : +123 -456 +3.14 -0.12
Boolean : !
|
| 构造器和说明 |
|---|
Arith(Sym op,
Expr left,
Expr right,
Location location) |
Array(Expr[] exprList,
Location location) |
Assign(String id,
Expr index,
Expr right,
Location location)
数组赋值表达式
|
Assign(String id,
Expr right,
Location location)
普通赋值表达式
|
Compare(Sym op,
Expr left,
Expr right,
Location location) |
Field(Expr expr,
String fieldName,
boolean optionalChain,
Location location) |
ForCtrl(ExprList init,
Expr cond,
ExprList update,
Location location)
exprList?
|
ForCtrl(Id id,
Expr expr,
Location location)
ID : expr
|
IncDec(Sym op,
boolean isPost,
Expr id,
Location location) |
Index(Expr expr,
Expr index,
Location location) |
Logic(Sym op,
Expr left,
Expr right,
Location location)
构造 || && 结点
|
Logic(Sym op,
Expr right,
Location location)
构造 !
|
Method(Expr expr,
String methodName,
boolean optionalChain,
Location location) |
Method(Expr expr,
String methodName,
ExprList exprList,
boolean optionalChain,
Location location) |
NullSafe(Expr left,
Expr right,
Location location) |
RangeArray(Expr start,
Expr end,
Location location)
array : '[' exprList ?
|
Ternary(Expr cond,
Expr exprOne,
Expr exprTwo,
Location location)
cond ?
|
Unary(Sym op,
Expr expr,
Location location) |
| 构造器和说明 |
|---|
ExprList(List<Expr> exprList) |
Map(LinkedHashMap<Object,Expr> map) |
| 限定符和类型 | 字段和说明 |
|---|---|
protected Expr |
CallDirective.funcNameExpr |
| 限定符和类型 | 字段和说明 |
|---|---|
protected Expr |
Output.expr |
Copyright © 2024. All rights reserved.