Decode flate's clcode symbols.

This commit is contained in:
Nigel Tao committed 2017-07-21 17:47:58 +10:00
1 parent 74400247f2
commit fd07fa1f27
5 files changed
+299 -30

No files matched your search

+4 -1
View File
@@ -67,7 +67,10 @@ func (z *facts) appendFact(fact *a.Expr) {
z.appendFact(fact.RHS().Expr())
return
case t.KeyXAssociativeAnd:
// TODO.
for _, a := range fact.Args() {
z.appendFact(a.Expr())
}
return
}
*z = append(*z, fact)
+16 -2
View File
@@ -101,7 +101,7 @@ func invert(tm *t.Map, n *a.Expr) (*a.Expr, error) {
if cv := n.ConstValue(); cv != nil {
return nil, fmt.Errorf("check: invert(%q) called on constant expression", n.String(tm))
}
id0, lhs, rhs := n.ID0(), n.LHS().Expr(), n.RHS().Expr()
id0, lhs, rhs, args := n.ID0(), n.LHS().Expr(), n.RHS().Expr(), []*a.Node(nil)
switch id0.Key() {
case t.KeyXUnaryNot:
return rhs, nil
@@ -132,10 +132,24 @@ func invert(tm *t.Map, n *a.Expr) (*a.Expr, error) {
} else {
id0 = t.IDXBinaryAnd
}
case t.KeyXAssociativeAnd, t.KeyXAssociativeOr:
args = make([]*a.Node, 0, len(n.Args()))
for _, a := range n.Args() {
v, err := invert(tm, a.Expr())
if err != nil {
return nil, err
}
args = append(args, v.Node())
}
if id0.Key() == t.KeyXAssociativeAnd {
id0 = t.IDXAssociativeOr
} else {
id0 = t.IDXAssociativeAnd
}
default:
id0, lhs, rhs = t.IDXUnaryNot, nil, n
}
o := a.NewExpr(n.Node().Raw().Flags(), id0, 0, lhs.Node(), nil, rhs.Node(), nil)
o := a.NewExpr(n.Node().Raw().Flags(), id0, 0, lhs.Node(), nil, rhs.Node(), args)
o.SetMType(n.MType())
return o, nil
}