From aae7af21947a7b3bf3d726baeb9c56a9b93e363e Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 30 Jul 2024 18:26:33 +0800 Subject: [PATCH] library: hash, hash/crc64 --- README.md | 2 ++ _cmptest/crcdemo/crc.go | 11 +++++++++++ ssa/expr.go | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 _cmptest/crcdemo/crc.go diff --git a/README.md b/README.md index b52b82d6..9ea97453 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,8 @@ Here are the Go packages that can be imported correctly: * [encoding/base32](https://pkg.go.dev/encoding/base32) * [encoding/base64](https://pkg.go.dev/encoding/base64) * [encoding/csv](https://pkg.go.dev/encoding/csv) +* [hash](https://pkg.go.dev/hash) +* [hash/crc64](https://pkg.go.dev/hash/crc64) * [crypto/md5](https://pkg.go.dev/crypto/md5) * [regexp](https://pkg.go.dev/regexp) * [regexp/syntax](https://pkg.go.dev/regexp/syntax) diff --git a/_cmptest/crcdemo/crc.go b/_cmptest/crcdemo/crc.go new file mode 100644 index 00000000..872c4b23 --- /dev/null +++ b/_cmptest/crcdemo/crc.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + "hash/crc64" +) + +func main() { + crc := crc64.MakeTable(crc64.ECMA) + fmt.Printf("%016x\n", crc64.Checksum([]byte("Hello world"), crc)) +} diff --git a/ssa/expr.go b/ssa/expr.go index 263ebb7a..d1b158dd 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -562,7 +562,7 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr { return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret} } case vkArray: - typ := x.raw.Type.(*types.Array) + typ := x.raw.Type.Underlying().(*types.Array) elem := b.Prog.Elem(x.Type) ret := prog.BoolVal(true) for i, n := 0, int(typ.Len()); i < n; i++ {