operand-map.go: to be removed
This commit is contained in:
parent
c39970fa7e
commit
263e419d9a
34
operand-map.go
Normal file
34
operand-map.go
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
|
||||
// operand-map.go
|
||||
package expr
|
||||
|
||||
// -------- map term
|
||||
func newMapTerm(args map[any]*term) *term {
|
||||
return &term{
|
||||
tk: *NewValueToken(0, 0, SymDict, "{}", args),
|
||||
parent: nil,
|
||||
children: nil,
|
||||
position: posLeaf,
|
||||
priority: priValue,
|
||||
evalFunc: evalMap,
|
||||
}
|
||||
}
|
||||
|
||||
// -------- map func
|
||||
func evalMap(ctx ExprContext, self *term) (v any, err error) {
|
||||
dict, _ := self.value().(map[any]*term)
|
||||
items := make(map[any]any, len(dict))
|
||||
for key, tree := range dict {
|
||||
var param any
|
||||
if param, err = tree.compute(ctx); err != nil {
|
||||
break
|
||||
}
|
||||
items[key] = param
|
||||
}
|
||||
if err == nil {
|
||||
v = items
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user