-
Notifications
You must be signed in to change notification settings - Fork 1
/
expressionState.go
56 lines (44 loc) · 1.33 KB
/
expressionState.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package spel
/**
* golang-sample源代码,版权归锦翰科技(深圳)有限公司所有。
* <p>
* 文件名称 : expressionState.go
* 文件路径 :
* 作者 : DavidLiu
× Email: david.liu@ginghan.com
*
* 创建日期 : 2022/4/7 18:15
* 修改历史 : 1. [2022/4/7 18:15] 创建文件 by NST
*/
import "container/list"
//根据KEY获取MAP的value
type ExpressionState struct {
RelatedContext EvaluationContext
RootObject TypedValue
ContextObjects list.List
VariableScopes list.List
}
func (this *ExpressionState) LookupVariable(name string) TypedValue {
variable := this.RelatedContext.LookupVariable(name)
return TypedValue{Value: variable}
}
func (this *ExpressionState) PopActiveContextObjectNull() {
front := this.ContextObjects.Front()
this.ContextObjects.Remove(front)
}
func (this *ExpressionState) PushActiveContextObject(obj TypedValue) {
this.ContextObjects.PushFront(obj)
}
func (this *ExpressionState) PopActiveContextObject() {
front := this.ContextObjects.Front()
this.ContextObjects.Remove(front)
}
func (this *ExpressionState) GetActiveContextObject() TypedValue {
return this.ContextObjects.Front().Value.(TypedValue)
}
func (this *ExpressionState) GetEvaluationContext() EvaluationContext {
return this.RelatedContext
}
func (this *ExpressionState) GetRootContextObject() TypedValue {
return this.RootObject
}