term.go: New function Clone()
This commit is contained in:
parent
837b887490
commit
5f8ca47ef0
19
term.go
19
term.go
@ -53,6 +53,25 @@ type term struct {
|
|||||||
evalFunc evalFuncType
|
evalFunc evalFuncType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *term) Clone() (d *term) {
|
||||||
|
var children []*term
|
||||||
|
if s.children != nil {
|
||||||
|
children = make([]*term, len(s.children))
|
||||||
|
for i, c := range s.children {
|
||||||
|
children[i] = c.Clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d = &term{
|
||||||
|
tk: *s.tk.Clone(),
|
||||||
|
parent: s.parent,
|
||||||
|
children: children,
|
||||||
|
position: s.position,
|
||||||
|
priority: s.priority,
|
||||||
|
evalFunc: s.evalFunc,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (term *term) String() string {
|
func (term *term) String() string {
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
term.toString(&sb)
|
term.toString(&sb)
|
||||||
|
Loading…
Reference in New Issue
Block a user