add composite simplifaction
This commit is contained in:
parent
aeb305210c
commit
72b2ec224b
1 changed files with 21 additions and 0 deletions
|
|
@ -487,6 +487,27 @@ func quickComposite(a ...TypeSignature) TypeSignature {
|
|||
return s
|
||||
}
|
||||
|
||||
func simplifyComposite(a TypeSignature) TypeSignature {
|
||||
var atoms []TypeSignature
|
||||
|
||||
s := NewStack[TypeSignature](16)
|
||||
s.Push(a)
|
||||
|
||||
for s.Current > 0 {
|
||||
i := s.Pop()
|
||||
|
||||
c, ok := i.(*CompositeSignature)
|
||||
if !ok {
|
||||
|
||||
atoms = append(atoms, i)
|
||||
} else {
|
||||
s.Push(c.A, c.B)
|
||||
}
|
||||
}
|
||||
|
||||
return quickComposite(atoms...)
|
||||
}
|
||||
|
||||
type InnerSignature struct{}
|
||||
|
||||
func (*InnerSignature) Type() Type {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue