Skip to content

Commit

Permalink
repair bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Nov 13, 2023
1 parent a35dec2 commit edf5d83
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
22 changes: 0 additions & 22 deletions ast/buffer.go
Expand Up @@ -204,28 +204,6 @@ func (self *linkedPairs) Get(key string) (*Pair, int) {
return nil, -1
}

func (self *linkedPairs) ToSlice(con []Pair) {
if len(con) < self.size {
return
}
i := self.size-1
a, b := i/_DEFAULT_NODE_CAP-1, i%_DEFAULT_NODE_CAP

if a < 0 {
copy(con, self.head[:b+1])
return
} else {
copy(con, self.head[:])
con = con[_DEFAULT_NODE_CAP:]
}

for i:=0; i<a; i++ {
copy(con, self.tail[i][:])
con = con[_DEFAULT_NODE_CAP:]
}
copy(con, self.tail[a][:b+1])
}

func (self *linkedPairs) ToMap(con map[string]Node) {
for i:=0; i<self.size; i++ {
n := self.At(i)
Expand Down
22 changes: 20 additions & 2 deletions ast/node.go
Expand Up @@ -1396,9 +1396,11 @@ func (self *Node) toGenericArrayUseNode() ([]Node, error) {
return []Node{}, nil
}

var s = (*linkedNodes)(self.p)
var out = make([]Node, nb)
s.ToSlice(out)
it := self.values()
for v := it.next(); v != nil; v = it.next() {
out = append(out, *v)
}

return out, nil
}
Expand Down Expand Up @@ -1460,6 +1462,22 @@ func (self *Node) toGenericObjectUseNode() (map[string]Node, error) {
return out, nil
}

func (self *Node) toGenericObjectUsePair() ([]Pair, error) {
var nb = self.len()
if nb == 0 {
return []Pair{}, nil
}

var out = make([]Pair, 0, nb)
it := self.properties()
for v := it.next(); v != nil; v = it.next() {
out = append(out, *v)
}

/* all done */
return out, nil
}

/**------------------------------------ Factory Methods ------------------------------------**/

var (
Expand Down
1 change: 1 addition & 0 deletions tools/simde
Submodule simde added at 4d55fc

0 comments on commit edf5d83

Please sign in to comment.