add composite simplifaction
This commit is contained in:
parent
7a5203cc26
commit
86760689f1
1 changed files with 21 additions and 0 deletions
|
|
@ -487,6 +487,27 @@ func quickComposite(a ...TypeSignature) TypeSignature {
|
||||||
return s
|
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{}
|
type InnerSignature struct{}
|
||||||
|
|
||||||
func (*InnerSignature) Type() Type {
|
func (*InnerSignature) Type() Type {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue