diff --git a/README.md b/README.md index fed235f6..5762e3dd 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,10 @@ Here are the Go packages that can be imported correctly: * [fmt](https://pkg.go.dev/fmt) (partially) * [reflect](https://pkg.go.dev/reflect) (partially) * [time](https://pkg.go.dev/time) (partially) +* [encoding/binary](https://pkg.go.dev/encoding/binary) +* [encoding/hex](https://pkg.go.dev/encoding/hex) +* [encoding/base32](https://pkg.go.dev/encoding/base32) +* [encoding/base64](https://pkg.go.dev/encoding/base64) * [regexp](https://pkg.go.dev/regexp) * [regexp/syntax](https://pkg.go.dev/regexp/syntax) diff --git a/_cmptest/base64demo/base64.go b/_cmptest/base64demo/base64.go new file mode 100644 index 00000000..0fbd1fa4 --- /dev/null +++ b/_cmptest/base64demo/base64.go @@ -0,0 +1,48 @@ +package main + +import ( + "encoding/base32" + "encoding/base64" + "encoding/hex" + "fmt" + "log" +) + +func base64Demo() { + msg := "Hello, 世界" + encoded := base64.StdEncoding.EncodeToString([]byte(msg)) + fmt.Println(encoded) + decoded, err := base64.StdEncoding.DecodeString(encoded) + if err != nil { + fmt.Println("decode error:", err) + return + } + fmt.Println(string(decoded)) +} + +func base32Demo() { + str := "JBSWY3DPFQQHO33SNRSCC===" + dst := make([]byte, base32.StdEncoding.DecodedLen(len(str))) + n, err := base32.StdEncoding.Decode(dst, []byte(str)) + if err != nil { + fmt.Println("decode error:", err) + return + } + dst = dst[:n] + fmt.Printf("%q\n", dst) +} + +func hexDemo() { + const s = "48656c6c6f20476f7068657221" + decoded, err := hex.DecodeString(s) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%s\n", decoded) + +} +func main() { + base64Demo() + base32Demo() + hexDemo() +} diff --git a/ssa/expr.go b/ssa/expr.go index 9400958a..263ebb7a 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -699,6 +699,7 @@ func (b Builder) ChangeType(t Type, x Expr) (ret Expr) { case vkFuncDecl: ret.impl = checkExpr(x, t.raw.Type, b).impl case vkClosure: + // TODO(xsw): change type should be a noop instruction convType := func() Expr { r := Expr{llvm.CreateAlloca(b.impl, t.ll), b.Prog.Pointer(t)} b.Store(r, x)