Implement the gzip checksum

Also fix a bug in ast.Raw.SetPackage, discovered because type checking
failed to show that "[] u8" and "[] u8" are equivalent types.
This commit is contained in:
Nigel Tao committed 2018-03-28 12:30:00 +11:00
1 parent 153d1276a1
commit a8e40fedc9
7 files changed
+184 -28

No files matched your search

+22 -6
View File
@@ -256,12 +256,24 @@ func (n *Raw) SetFilenameLine(f string, l uint32) { n.filename, n.line = f, l }
func (n *Raw) SetPackage(tm *t.Map, pkg t.ID) error {
return n.Node().Walk(func(o *Node) error {
switch o.Kind() {
case KConst, KExpr, KFunc, KStatus, KStruct, KTypeExpr:
if o.id1 != 0 {
return fmt.Errorf(`invalid SetPackage(%q) call: old package: got %q, want ""`,
pkg.Str(tm), o.id1.Str(tm))
default:
return nil
case KConst, KFunc, KStatus, KStruct:
// No-op.
case KExpr:
switch o.id0.Key() {
default:
return nil
case t.KeyError, t.KeyStatus, t.KeySuspension:
// No-op.
}
case KTypeExpr:
if o.id0.Key() != 0 {
return nil
}
// TODO: Add signed integer types, as per the builtin.Types var?
//
// Or, don't hard code these, and instead require built-in types to
@@ -270,9 +282,13 @@ func (n *Raw) SetPackage(tm *t.Map, pkg t.ID) error {
case t.KeyU8, t.KeyU16, t.KeyU32, t.KeyU64, t.KeyBool, t.KeyStatus, t.KeyReader1, t.KeyWriter1:
return nil
}
o.id1 = pkg
}
if o.id1 != 0 {
return fmt.Errorf(`invalid SetPackage(%q) call: old package: got %q, want ""`,
pkg.Str(tm), o.id1.Str(tm))
}
o.id1 = pkg
return nil
})
}