|
|
@@ -26,22 +26,17 @@ import com.jfinal.template.stat.Scope;
|
|
|
|
|
|
/**
|
|
|
* Arithmetic
|
|
|
- * 1:支持 int long float double BigDecimal 的 + - * / % 运算
|
|
|
+ * 1:支持 byte short int long float double BigDecimal 的 + - * / % 运算
|
|
|
* 2:支持字符串加法运算
|
|
|
*/
|
|
|
public class Arith extends Expr {
|
|
|
|
|
|
- public static final int INT = 0;
|
|
|
+ public static final int INT = 0; // byte、short 用 int 类型支持,java 表达式亦如此
|
|
|
public static final int LONG = 1;
|
|
|
public static final int FLOAT = 2;
|
|
|
public static final int DOUBLE = 3;
|
|
|
public static final int BIGDECIMAL = 4;
|
|
|
|
|
|
- // 后续版本考虑支持
|
|
|
- // public static final int BYTE = 5;
|
|
|
- // public static final int SHORT = 6;
|
|
|
- // public static final int BIGINTEGER = 7;
|
|
|
-
|
|
|
private Sym op;
|
|
|
private Expr left;
|
|
|
private Expr right;
|
|
|
@@ -136,6 +131,8 @@ public class Arith extends Expr {
|
|
|
return DOUBLE;
|
|
|
} else if (obj instanceof BigDecimal) {
|
|
|
return BIGDECIMAL;
|
|
|
+ } else if (obj instanceof Short || obj instanceof Byte) {
|
|
|
+ return INT; // short byte 用 int 支持,java 表达式亦如此
|
|
|
}
|
|
|
throw new TemplateException("Unsupported data type: " + obj.getClass().getName(), location);
|
|
|
}
|