mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 00:47:28 +01:00
Decode flate's clcode symbols.
This commit is contained in:
1 parent
74400247f2
commit
fd07fa1f27
5 files changed
+299
-30
No files matched your search
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user