af-mobile-client-vue3 1.2.30 → 1.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/data/XForm/index.vue +13 -17
- package/src/expression/ExpressionRunner.ts +28 -0
- package/src/expression/TestExpression.ts +510 -0
- package/src/expression/core/Delegate.ts +116 -0
- package/src/expression/core/Expression.ts +1359 -0
- package/src/expression/core/Program.ts +985 -0
- package/src/expression/core/Token.ts +29 -0
- package/src/expression/enums/ExpressionType.ts +81 -0
- package/src/expression/enums/TokenType.ts +11 -0
- package/src/expression/exception/BreakWayException.ts +2 -0
- package/src/expression/exception/ContinueWayException.ts +2 -0
- package/src/expression/exception/ExpressionException.ts +29 -0
- package/src/expression/exception/ReturnWayException.ts +14 -0
- package/src/expression/exception/ServiceException.ts +22 -0
- package/src/expression/instances/JSONArray.ts +52 -0
- package/src/expression/instances/JSONObject.ts +118 -0
- package/src/expression/instances/LogicConsole.ts +31 -0
- package/src/logic/LogicRunner.ts +67 -0
- package/src/logic/TestLogic.ts +13 -0
- package/src/logic/plugins/common/DateTools.ts +35 -0
- package/src/logic/plugins/common/VueTools.ts +30 -0
- package/src/logic/plugins/index.ts +7 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type Expression from './Expression'
|
|
2
|
+
import ExpressionType from '../enums/ExpressionType'
|
|
3
|
+
import ReturnWayException from '../exception/ReturnWayException'
|
|
4
|
+
import JSONObject from '../instances/JSONObject'
|
|
5
|
+
|
|
6
|
+
export default class Delegate {
|
|
7
|
+
private exp: Expression
|
|
8
|
+
private source: string
|
|
9
|
+
private lambdaOutProps: string[] = []
|
|
10
|
+
private objectNames: JSONObject
|
|
11
|
+
|
|
12
|
+
constructor(exp: Expression, source: string, objectNames?: JSONObject) {
|
|
13
|
+
this.exp = exp
|
|
14
|
+
this.source = source
|
|
15
|
+
if (objectNames) {
|
|
16
|
+
this.objectNames = objectNames
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.objectNames = new JSONObject()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 执行程序,执行前,参数必须实例化
|
|
24
|
+
invoke(params?: JSONObject): any {
|
|
25
|
+
if (params == null) {
|
|
26
|
+
params = new JSONObject()
|
|
27
|
+
}
|
|
28
|
+
// 把初始参数给参数表
|
|
29
|
+
this.objectNames = params
|
|
30
|
+
// 沿根Expression节点遍历,把delegate传递下去
|
|
31
|
+
this.putDelegate(this.exp)
|
|
32
|
+
// 调用exp的执行过程
|
|
33
|
+
try {
|
|
34
|
+
return this.exp.invoke()
|
|
35
|
+
}
|
|
36
|
+
catch (returnWay) {
|
|
37
|
+
if (returnWay instanceof ReturnWayException) {
|
|
38
|
+
return returnWay.getReturnObject()
|
|
39
|
+
}
|
|
40
|
+
throw returnWay
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 沿根节点递归,传递delegate的过程
|
|
45
|
+
private putDelegate(parent: Expression): void {
|
|
46
|
+
for (const child of parent.children) {
|
|
47
|
+
// 有些节点会放空的子节点
|
|
48
|
+
if (child == null) {
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
// try特殊处理
|
|
52
|
+
if (child.type === ExpressionType.Try) {
|
|
53
|
+
const exps: Expression[] = child.value as Expression[]
|
|
54
|
+
if (exps[0] != null) {
|
|
55
|
+
exps[0].setDelegate(this)
|
|
56
|
+
this.putDelegate(exps[0])
|
|
57
|
+
}
|
|
58
|
+
if (exps[1] != null) {
|
|
59
|
+
exps[1].setDelegate(this)
|
|
60
|
+
this.putDelegate(exps[1])
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
child.setDelegate(this)
|
|
64
|
+
this.putDelegate(child)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 获取表达式
|
|
69
|
+
getExp(): Expression {
|
|
70
|
+
return this.exp
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 获取对象值存储
|
|
74
|
+
getObjectNames(): JSONObject {
|
|
75
|
+
return this.objectNames
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 获取lambda外层参数名
|
|
79
|
+
getLambdaOutProps(): string[] {
|
|
80
|
+
return this.lambdaOutProps
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 存储对象值
|
|
84
|
+
put(key: string, value: any): void {
|
|
85
|
+
this.objectNames.put(key, value)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 获取对象值
|
|
89
|
+
get(key: string): any {
|
|
90
|
+
return this.objectNames.get(key)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 检查是否包含某个键
|
|
94
|
+
containsKey(key: string): boolean {
|
|
95
|
+
return this.objectNames.has(key)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 获取源代码
|
|
99
|
+
getSource(): string {
|
|
100
|
+
return this.source
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 使用参数调用
|
|
104
|
+
apply(params?: JSONObject): any {
|
|
105
|
+
if (params === null) {
|
|
106
|
+
params = new JSONObject()
|
|
107
|
+
}
|
|
108
|
+
const map = this.objectNames
|
|
109
|
+
if (this.lambdaOutProps.length === 0) {
|
|
110
|
+
this.lambdaOutProps.push(...map.keySet())
|
|
111
|
+
}
|
|
112
|
+
const lambdaMap = new JSONObject(map)
|
|
113
|
+
lambdaMap.put('data', params)
|
|
114
|
+
return this.invoke(lambdaMap)
|
|
115
|
+
}
|
|
116
|
+
}
|