library: encoding/{binary, base64}

This commit is contained in:
xushiwei
2024-07-30 00:28:04 +08:00
parent 37956e2f05
commit afdf31a66c
3 changed files with 21 additions and 0 deletions

View File

@@ -291,6 +291,8 @@ Here are the Go packages that can be imported correctly:
* [fmt](https://pkg.go.dev/fmt) (partially) * [fmt](https://pkg.go.dev/fmt) (partially)
* [reflect](https://pkg.go.dev/reflect) (partially) * [reflect](https://pkg.go.dev/reflect) (partially)
* [time](https://pkg.go.dev/time) (partially) * [time](https://pkg.go.dev/time) (partially)
* [encoding/binary](https://pkg.go.dev/encoding/binary)
* [encoding/base64](https://pkg.go.dev/encoding/base64)
* [regexp](https://pkg.go.dev/regexp) * [regexp](https://pkg.go.dev/regexp)
* [regexp/syntax](https://pkg.go.dev/regexp/syntax) * [regexp/syntax](https://pkg.go.dev/regexp/syntax)

View File

@@ -0,0 +1,18 @@
package main
import (
"encoding/base64"
"fmt"
)
func main() {
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))
}

View File

@@ -699,6 +699,7 @@ func (b Builder) ChangeType(t Type, x Expr) (ret Expr) {
case vkFuncDecl: case vkFuncDecl:
ret.impl = checkExpr(x, t.raw.Type, b).impl ret.impl = checkExpr(x, t.raw.Type, b).impl
case vkClosure: case vkClosure:
// TODO(xsw): change type should be a noop instruction
convType := func() Expr { convType := func() Expr {
r := Expr{llvm.CreateAlloca(b.impl, t.ll), b.Prog.Pointer(t)} r := Expr{llvm.CreateAlloca(b.impl, t.ll), b.Prog.Pointer(t)}
b.Store(r, x) b.Store(r, x)