Merge pull request #527 from xushiwei/q

ssa: BinOp (map equal) fix; time.ParseDuration; fmt.Errorf; pkg: flag, strings; flagdemo: to fix bug
This commit is contained in:
xushiwei
2024-07-17 07:45:06 +08:00
committed by GitHub
15 changed files with 326 additions and 223 deletions

View File

@@ -271,8 +271,10 @@ Here are the Go packages that can be imported correctly:
* [io](https://pkg.go.dev/io) * [io](https://pkg.go.dev/io)
* [io/fs](https://pkg.go.dev/io/fs) * [io/fs](https://pkg.go.dev/io/fs)
* [log](https://pkg.go.dev/log) * [log](https://pkg.go.dev/log)
* [flag](https://pkg.go.dev/flag)
* [sort](https://pkg.go.dev/sort) * [sort](https://pkg.go.dev/sort)
* [strconv](https://pkg.go.dev/strconv) * [strconv](https://pkg.go.dev/strconv)
* [strings](https://pkg.go.dev/strings)
* [sync/atomic](https://pkg.go.dev/sync/atomic) * [sync/atomic](https://pkg.go.dev/sync/atomic)
* [sync](https://pkg.go.dev/sync) (partially) * [sync](https://pkg.go.dev/sync) (partially)
* [syscall](https://pkg.go.dev/syscall) (partially) * [syscall](https://pkg.go.dev/syscall) (partially)

View File

@@ -1,7 +1,12 @@
package main package main
import "strconv" import (
"fmt"
"strconv"
"strings"
)
func main() { func main() {
println(strconv.Itoa(-123)) fmt.Println(strconv.Itoa(-123))
fmt.Println(strings.Split("abc,def,123", ","))
} }

View File

@@ -0,0 +1,21 @@
package main
import (
"flag"
"fmt"
"os"
)
func main() {
fmt.Println("os.Args:", os.Args)
if len(os.Args) == 1 {
os.Args = []string{"flagdemo", "-cpu", "100"}
}
verbose := flag.Bool("v", false, "verbose")
cpu := flag.Int("cpu", 1, "cpu number")
host := flag.String("host", ":8888", "host")
flag.Parse()
fmt.Println("host:", *host, "cpu:", *cpu, "verbose:", *verbose)
}

View File

@@ -537,7 +537,8 @@ define void @"main.init#7"() {
_llgo_0: _llgo_0:
%0 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8 %0 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %0, i64 0) %1 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %0, i64 0)
call void @main.assert(i1 true) %2 = icmp ne ptr %1, null
call void @main.assert(i1 %2)
call void @main.assert(i1 true) call void @main.assert(i1 true)
ret void ret void
} }

View File

@@ -394,13 +394,15 @@ _llgo_0:
%0 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8 %0 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %0, i64 0) %1 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %0, i64 0)
%2 = load i64, ptr %1, align 4 %2 = load i64, ptr %1, align 4
%3 = icmp eq ptr %1, null
%4 = icmp ne ptr %1, null
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %1) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %1)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %2) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %2)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 false) call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %3)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true) call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %4)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr null) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr null)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
@@ -410,161 +412,161 @@ _llgo_0:
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 false) call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 false)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
%3 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8 %5 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %3, i64 0) %6 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %5, i64 0)
%5 = alloca [1 x i64], align 8 %7 = alloca [1 x i64], align 8
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %5, i64 8) %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %7, i64 8)
%7 = getelementptr inbounds i64, ptr %6, i64 0 %9 = getelementptr inbounds i64, ptr %8, i64 0
store i64 1, ptr %7, align 4 store i64 1, ptr %9, align 4
%8 = load [1 x i64], ptr %6, align 4 %10 = load [1 x i64], ptr %8, align 4
%9 = load ptr, ptr @_llgo_main.N1, align 8 %11 = load ptr, ptr @_llgo_main.N1, align 8
%10 = extractvalue [1 x i64] %8, 0 %12 = extractvalue [1 x i64] %10, 0
%11 = inttoptr i64 %10 to ptr %13 = inttoptr i64 %12 to ptr
%12 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %14 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
%13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, i32 0, i32 0 %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %14, i32 0, i32 0
store ptr %9, ptr %13, align 8 store ptr %11, ptr %15, align 8
%14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, i32 0, i32 1 %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %14, i32 0, i32 1
store ptr %11, ptr %14, align 8 store ptr %13, ptr %16, align 8
%15 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, align 8 %17 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %14, align 8
%16 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8 %18 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) %19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
store %"github.com/goplus/llgo/internal/runtime.eface" %15, ptr %17, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %17, ptr %19, align 8
%18 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %16, ptr %4, ptr %17) %20 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %18, ptr %6, ptr %19)
store i64 100, ptr %18, align 4 store i64 100, ptr %20, align 4
%19 = alloca [1 x i64], align 8 %21 = alloca [1 x i64], align 8
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %19, i64 8) %22 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %21, i64 8)
%21 = getelementptr inbounds i64, ptr %20, i64 0 %23 = getelementptr inbounds i64, ptr %22, i64 0
store i64 2, ptr %21, align 4 store i64 2, ptr %23, align 4
%22 = load [1 x i64], ptr %20, align 4 %24 = load [1 x i64], ptr %22, align 4
%23 = load ptr, ptr @_llgo_main.N1, align 8 %25 = load ptr, ptr @_llgo_main.N1, align 8
%24 = extractvalue [1 x i64] %22, 0 %26 = extractvalue [1 x i64] %24, 0
%25 = inttoptr i64 %24 to ptr %27 = inttoptr i64 %26 to ptr
%26 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %28 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
%27 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %26, i32 0, i32 0 %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %28, i32 0, i32 0
store ptr %23, ptr %27, align 8 store ptr %25, ptr %29, align 8
%28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %26, i32 0, i32 1 %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %28, i32 0, i32 1
store ptr %25, ptr %28, align 8 store ptr %27, ptr %30, align 8
%29 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %26, align 8 %31 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %28, align 8
%30 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8 %32 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8
%31 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) %33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
store %"github.com/goplus/llgo/internal/runtime.eface" %29, ptr %31, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %31, ptr %33, align 8
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %30, ptr %4, ptr %31) %34 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %32, ptr %6, ptr %33)
store i64 200, ptr %32, align 4 store i64 200, ptr %34, align 4
%33 = alloca [1 x i64], align 8 %35 = alloca [1 x i64], align 8
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %33, i64 8) %36 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %35, i64 8)
%35 = getelementptr inbounds i64, ptr %34, i64 0 %37 = getelementptr inbounds i64, ptr %36, i64 0
store i64 3, ptr %35, align 4 store i64 3, ptr %37, align 4
%36 = load [1 x i64], ptr %34, align 4 %38 = load [1 x i64], ptr %36, align 4
%37 = load ptr, ptr @_llgo_main.N1, align 8 %39 = load ptr, ptr @_llgo_main.N1, align 8
%38 = extractvalue [1 x i64] %36, 0 %40 = extractvalue [1 x i64] %38, 0
%39 = inttoptr i64 %38 to ptr %41 = inttoptr i64 %40 to ptr
%40 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %42 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
%41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %40, i32 0, i32 0 %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %42, i32 0, i32 0
store ptr %37, ptr %41, align 8 store ptr %39, ptr %43, align 8
%42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %40, i32 0, i32 1 %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %42, i32 0, i32 1
store ptr %39, ptr %42, align 8 store ptr %41, ptr %44, align 8
%43 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %40, align 8 %45 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %42, align 8
%44 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8 %46 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8
%45 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) %47 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
store %"github.com/goplus/llgo/internal/runtime.eface" %43, ptr %45, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %45, ptr %47, align 8
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %44, ptr %4, ptr %45) %48 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %46, ptr %6, ptr %47)
store i64 300, ptr %46, align 4 store i64 300, ptr %48, align 4
%47 = alloca [1 x i64], align 8 %49 = alloca [1 x i64], align 8
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %47, i64 8) %50 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %49, i64 8)
%49 = getelementptr inbounds i64, ptr %48, i64 0 %51 = getelementptr inbounds i64, ptr %50, i64 0
store i64 2, ptr %49, align 4 store i64 2, ptr %51, align 4
%50 = load [1 x i64], ptr %48, align 4 %52 = load [1 x i64], ptr %50, align 4
%51 = load ptr, ptr @_llgo_main.N1, align 8 %53 = load ptr, ptr @_llgo_main.N1, align 8
%52 = extractvalue [1 x i64] %50, 0 %54 = extractvalue [1 x i64] %52, 0
%53 = inttoptr i64 %52 to ptr %55 = inttoptr i64 %54 to ptr
%54 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %56 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
%55 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %54, i32 0, i32 0 %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %56, i32 0, i32 0
store ptr %51, ptr %55, align 8 store ptr %53, ptr %57, align 8
%56 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %54, i32 0, i32 1 %58 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %56, i32 0, i32 1
store ptr %53, ptr %56, align 8 store ptr %55, ptr %58, align 8
%57 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %54, align 8 %59 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %56, align 8
%58 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8 %60 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8
%59 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) %61 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
store %"github.com/goplus/llgo/internal/runtime.eface" %57, ptr %59, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %59, ptr %61, align 8
%60 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %58, ptr %4, ptr %59) %62 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %60, ptr %6, ptr %61)
store i64 -200, ptr %60, align 4 store i64 -200, ptr %62, align 4
%61 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8 %63 = load ptr, ptr @"map[_llgo_any]_llgo_int", align 8
%62 = call ptr @"github.com/goplus/llgo/internal/runtime.NewMapIter"(ptr %61, ptr %4) %64 = call ptr @"github.com/goplus/llgo/internal/runtime.NewMapIter"(ptr %63, ptr %6)
br label %_llgo_1 br label %_llgo_1
_llgo_1: ; preds = %_llgo_7, %_llgo_0 _llgo_1: ; preds = %_llgo_7, %_llgo_0
%63 = call { i1, ptr, ptr } @"github.com/goplus/llgo/internal/runtime.MapIterNext"(ptr %62) %65 = call { i1, ptr, ptr } @"github.com/goplus/llgo/internal/runtime.MapIterNext"(ptr %64)
%64 = extractvalue { i1, ptr, ptr } %63, 0 %66 = extractvalue { i1, ptr, ptr } %65, 0
br i1 %64, label %_llgo_4, label %_llgo_5 br i1 %66, label %_llgo_4, label %_llgo_5
_llgo_2: ; preds = %_llgo_6 _llgo_2: ; preds = %_llgo_6
%65 = extractvalue { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } %84, 1 %67 = extractvalue { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } %86, 1
%66 = extractvalue { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } %84, 2 %68 = extractvalue { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } %86, 2
%67 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %65, 0 %69 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %67, 0
%68 = load ptr, ptr @_llgo_main.N1, align 8 %70 = load ptr, ptr @_llgo_main.N1, align 8
%69 = icmp eq ptr %67, %68 %71 = icmp eq ptr %69, %70
br i1 %69, label %_llgo_7, label %_llgo_8 br i1 %71, label %_llgo_7, label %_llgo_8
_llgo_3: ; preds = %_llgo_6 _llgo_3: ; preds = %_llgo_6
ret void ret void
_llgo_4: ; preds = %_llgo_1 _llgo_4: ; preds = %_llgo_1
%70 = extractvalue { i1, ptr, ptr } %63, 1 %72 = extractvalue { i1, ptr, ptr } %65, 1
%71 = extractvalue { i1, ptr, ptr } %63, 2 %73 = extractvalue { i1, ptr, ptr } %65, 2
%72 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %70, align 8 %74 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %72, align 8
%73 = load i64, ptr %71, align 4 %75 = load i64, ptr %73, align 4
%74 = alloca { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, align 8 %76 = alloca { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, align 8
%75 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %74, i32 0, i32 0 %77 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %76, i32 0, i32 0
store i1 true, ptr %75, align 1 store i1 true, ptr %77, align 1
%76 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %74, i32 0, i32 1 %78 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %76, i32 0, i32 1
store %"github.com/goplus/llgo/internal/runtime.eface" %72, ptr %76, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %74, ptr %78, align 8
%77 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %74, i32 0, i32 2 %79 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %76, i32 0, i32 2
store i64 %73, ptr %77, align 4 store i64 %75, ptr %79, align 4
%78 = load { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %74, align 8 %80 = load { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %76, align 8
br label %_llgo_6 br label %_llgo_6
_llgo_5: ; preds = %_llgo_1 _llgo_5: ; preds = %_llgo_1
%79 = alloca { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, align 8 %81 = alloca { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, align 8
%80 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %79, i32 0, i32 0 %82 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %81, i32 0, i32 0
store i1 false, ptr %80, align 1 store i1 false, ptr %82, align 1
%81 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %79, i32 0, i32 1 %83 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %81, i32 0, i32 1
store %"github.com/goplus/llgo/internal/runtime.eface" zeroinitializer, ptr %81, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" zeroinitializer, ptr %83, align 8
%82 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %79, i32 0, i32 2 %84 = getelementptr inbounds { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %81, i32 0, i32 2
store i64 0, ptr %82, align 4 store i64 0, ptr %84, align 4
%83 = load { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %79, align 8 %85 = load { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 }, ptr %81, align 8
br label %_llgo_6 br label %_llgo_6
_llgo_6: ; preds = %_llgo_5, %_llgo_4 _llgo_6: ; preds = %_llgo_5, %_llgo_4
%84 = phi { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } [ %78, %_llgo_4 ], [ %83, %_llgo_5 ] %86 = phi { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } [ %80, %_llgo_4 ], [ %85, %_llgo_5 ]
%85 = extractvalue { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } %84, 0 %87 = extractvalue { i1, %"github.com/goplus/llgo/internal/runtime.eface", i64 } %86, 0
br i1 %85, label %_llgo_2, label %_llgo_3 br i1 %87, label %_llgo_2, label %_llgo_3
_llgo_7: ; preds = %_llgo_2 _llgo_7: ; preds = %_llgo_2
%86 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %65, 1 %88 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %67, 1
%87 = ptrtoint ptr %86 to i64 %89 = ptrtoint ptr %88 to i64
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %87) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %89)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %66) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %68)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
br label %_llgo_1 br label %_llgo_1
_llgo_8: ; preds = %_llgo_2 _llgo_8: ; preds = %_llgo_2
%88 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %90 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
%89 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %88, i32 0, i32 0 %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 0
store ptr @13, ptr %89, align 8 store ptr @13, ptr %91, align 8
%90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %88, i32 0, i32 1 %92 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 1
store i64 21, ptr %90, align 4 store i64 21, ptr %92, align 4
%91 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %88, align 8 %93 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %90, align 8
%92 = load ptr, ptr @_llgo_string, align 8 %94 = load ptr, ptr @_llgo_string, align 8
%93 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) %95 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
store %"github.com/goplus/llgo/internal/runtime.String" %91, ptr %93, align 8 store %"github.com/goplus/llgo/internal/runtime.String" %93, ptr %95, align 8
%94 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %96 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
%95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %94, i32 0, i32 0 %97 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %96, i32 0, i32 0
store ptr %92, ptr %95, align 8 store ptr %94, ptr %97, align 8
%96 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %94, i32 0, i32 1 %98 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %96, i32 0, i32 1
store ptr %93, ptr %96, align 8 store ptr %95, ptr %98, align 8
%97 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %94, align 8 %99 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %96, align 8
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %97) call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %99)
unreachable unreachable
} }

View File

@@ -0,0 +1,78 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package fmt
import (
"errors"
"sort"
)
// Errorf formats according to a format specifier and returns the string as a
// value that satisfies error.
//
// If the format specifier includes a %w verb with an error operand,
// the returned error will implement an Unwrap method returning the operand.
// If there is more than one %w verb, the returned error will implement an
// Unwrap method returning a []error containing all the %w operands in the
// order they appear in the arguments.
// It is invalid to supply the %w verb with an operand that does not implement
// the error interface. The %w verb is otherwise a synonym for %v.
func Errorf(format string, a ...any) error {
p := newPrinter()
p.wrapErrs = true
p.doPrintf(format, a)
s := string(p.buf)
var err error
switch len(p.wrappedErrs) {
case 0:
err = errors.New(s)
case 1:
w := &wrapError{msg: s}
w.err, _ = a[p.wrappedErrs[0]].(error)
err = w
default:
if p.reordered {
sort.Ints(p.wrappedErrs)
}
var errs []error
for i, argNum := range p.wrappedErrs {
if i > 0 && p.wrappedErrs[i-1] == argNum {
continue
}
if e, ok := a[argNum].(error); ok {
errs = append(errs, e)
}
}
err = &wrapErrors{s, errs}
}
p.free()
return err
}
type wrapError struct {
msg string
err error
}
func (e *wrapError) Error() string {
return e.msg
}
func (e *wrapError) Unwrap() error {
return e.err
}
type wrapErrors struct {
msg string
errs []error
}
func (e *wrapErrors) Error() string {
return e.msg
}
func (e *wrapErrors) Unwrap() []error {
return e.errs
}

View File

@@ -777,13 +777,10 @@ func (p *pp) printArg(arg any, verb rune) {
func (p *pp) printValue(value reflect.Value, verb rune, depth int) { func (p *pp) printValue(value reflect.Value, verb rune, depth int) {
// Handle values with special methods if not already handled by printArg (depth == 0). // Handle values with special methods if not already handled by printArg (depth == 0).
if depth > 0 && value.IsValid() && value.CanInterface() { if depth > 0 && value.IsValid() && value.CanInterface() {
/* TODO(xsw):
p.arg = value.Interface() p.arg = value.Interface()
if p.handleMethods(verb) { if p.handleMethods(verb) {
return return
} }
*/
panic("todo: fmt.(*pp).printValue - handleMethods")
} }
p.arg = nil p.arg = nil
p.value = value p.value = value

View File

@@ -157,7 +157,7 @@ func (t rtype) NumMethod() int {
} }
return len(t.exportedMethods()) return len(t.exportedMethods())
*/ */
panic("todo") panic("todo: reflectlite.rtype.NumMethod")
} }
func (t rtype) PkgPath() string { func (t rtype) PkgPath() string {
@@ -171,7 +171,7 @@ func (t rtype) PkgPath() string {
} }
return t.nameOff(ut.PkgPath).Name() return t.nameOff(ut.PkgPath).Name()
*/ */
panic("todo") panic("todo: reflectlite.rtype.PkgPath")
} }
func (t rtype) Name() string { func (t rtype) Name() string {
@@ -193,7 +193,7 @@ func (t rtype) Name() string {
} }
return s[i+1:] return s[i+1:]
*/ */
panic("todo") panic("todo: reflectlite.rtype.Name")
} }
func toRType(t *abi.Type) rtype { func toRType(t *abi.Type) rtype {
@@ -220,7 +220,7 @@ func (t rtype) In(i int) Type {
} }
return toType(tt.InSlice()[i]) return toType(tt.InSlice()[i])
*/ */
panic("todo") panic("todo: reflectlite.rtype.In")
} }
func (t rtype) Key() Type { func (t rtype) Key() Type {
@@ -255,7 +255,7 @@ func (t rtype) NumIn() int {
} }
return int(tt.InCount) return int(tt.InCount)
*/ */
panic("todo") panic("todo: reflectlite.rtype.NumIn")
} }
func (t rtype) NumOut() int { func (t rtype) NumOut() int {
@@ -266,7 +266,7 @@ func (t rtype) NumOut() int {
} }
return tt.NumOut() return tt.NumOut()
*/ */
panic("todo") panic("todo: reflectlite.rtype.NumOut")
} }
func (t rtype) Out(i int) Type { func (t rtype) Out(i int) Type {
@@ -277,7 +277,7 @@ func (t rtype) Out(i int) Type {
} }
return toType(tt.OutSlice()[i]) return toType(tt.OutSlice()[i])
*/ */
panic("todo") panic("todo: reflectlite.rtype.Out")
} }
// add returns p+x. // add returns p+x.
@@ -408,7 +408,7 @@ func implements(T, V *abi.Type) bool {
} }
return false return false
*/ */
panic("todo") panic("todo: reflectlite.implements")
} }
// directlyAssignable reports whether a value x of type V can be directly // directlyAssignable reports whether a value x of type V can be directly
@@ -544,7 +544,7 @@ func haveIdenticalUnderlyingType(T, V *abi.Type, cmpTags bool) bool {
return false return false
*/ */
panic("todo") panic("todo: reflectlite.haveIdenticalUnderlyingType")
} }
// toType converts from a *rtype to a Type that can be returned // toType converts from a *rtype to a Type that can be returned

View File

@@ -98,7 +98,7 @@ func (v Value) pointer() unsafe.Pointer {
} }
return v.ptr return v.ptr
*/ */
panic("todo") panic("todo: reflectlite.Value.pointer")
} }
// packEface converts v to the empty interface. // packEface converts v to the empty interface.
@@ -263,7 +263,7 @@ func (v Value) Elem() Value {
} }
panic(&ValueError{"reflectlite.Value.Elem", v.kind()}) panic(&ValueError{"reflectlite.Value.Elem", v.kind()})
*/ */
panic("todo") panic("todo: reflectlite.Value.Elem")
} }
func valueInterface(v Value) any { func valueInterface(v Value) any {
@@ -367,7 +367,7 @@ func (v Value) numMethod() int {
} }
return v.typ.NumMethod() return v.typ.NumMethod()
*/ */
panic("todo") panic("todo: reflectlite.Value.numMethod")
} }
// Set assigns x to the value v. // Set assigns x to the value v.
@@ -455,7 +455,7 @@ func (v Value) assignTo(context string, dst *abi.Type, target unsafe.Pointer) Va
// Failed. // Failed.
// TODO(xsw): // TODO(xsw):
// panic(context + ": value of type " + toRType(v.typ).String() + " is not assignable to type " + toRType(dst).String()) // panic(context + ": value of type " + toRType(v.typ).String() + " is not assignable to type " + toRType(dst).String())
panic("todo") panic("todo: reflectlite.Value.assignTo")
} }
// arrayAt returns the i-th element of p, // arrayAt returns the i-th element of p,

View File

@@ -87,7 +87,7 @@ func (f *File) ReadAt(b []byte, off int64) (n int, err error) {
} }
return return
*/ */
panic("todo") panic("todo: os.File.ReadAt")
} }
// ReadFrom implements io.ReaderFrom. // ReadFrom implements io.ReaderFrom.
@@ -102,7 +102,7 @@ func (f *File) ReadFrom(r io.Reader) (n int64, err error) {
} }
return n, f.wrapErr("write", e) return n, f.wrapErr("write", e)
*/ */
panic("todo") panic("todo: os.File.ReadFrom")
} }
func genericReadFrom(f *File, r io.Reader) (int64, error) { func genericReadFrom(f *File, r io.Reader) (int64, error) {

View File

@@ -146,7 +146,7 @@ func makeMethodValue(op string, v Value) Value {
return Value{ftyp.Common(), unsafe.Pointer(fv), v.flag&flagRO | flag(Func)} return Value{ftyp.Common(), unsafe.Pointer(fv), v.flag&flagRO | flag(Func)}
*/ */
panic("todo") panic("todo: reflect.makeMethodValue")
} }
/* /*

View File

@@ -461,7 +461,7 @@ func (t *rtype) NumMethod() int {
} }
return len(t.exportedMethods()) return len(t.exportedMethods())
*/ */
panic("todo") panic("todo: reflect.rtype.NumMethod")
} }
func (t *rtype) Method(i int) (m Method) { func (t *rtype) Method(i int) (m Method) {
@@ -498,7 +498,7 @@ func (t *rtype) Method(i int) (m Method) {
m.Index = i m.Index = i
return m return m
*/ */
panic("todo") panic("todo: reflect.rtype.Method")
} }
func (t *rtype) MethodByName(name string) (m Method, ok bool) { func (t *rtype) MethodByName(name string) (m Method, ok bool) {
@@ -533,7 +533,7 @@ func (t *rtype) MethodByName(name string) (m Method, ok bool) {
return Method{}, false return Method{}, false
*/ */
panic("todo") panic("todo: reflect.rtype.MethodByName")
} }
func (t *rtype) PkgPath() string { func (t *rtype) PkgPath() string {
@@ -570,7 +570,7 @@ func (t *rtype) Name() string {
} }
return s[i+1:] return s[i+1:]
*/ */
panic("todo") panic("todo: reflect.rtype.Name")
} }
func nameFor(t *abi.Type) string { func nameFor(t *abi.Type) string {
@@ -596,7 +596,7 @@ func elem(t *abi.Type) *abi.Type {
} }
// TODO(xsw): // TODO(xsw):
// panic("reflect: Elem of invalid type " + stringFor(t)) // panic("reflect: Elem of invalid type " + stringFor(t))
panic("todo") panic("todo: reflect.elem")
} }
func (t *rtype) Elem() Type { func (t *rtype) Elem() Type {
@@ -611,7 +611,7 @@ func (t *rtype) Field(i int) StructField {
tt := (*structType)(unsafe.Pointer(t)) tt := (*structType)(unsafe.Pointer(t))
return tt.Field(i) return tt.Field(i)
*/ */
panic("todo") panic("todo: reflect.rtype.Field")
} }
func (t *rtype) FieldByIndex(index []int) StructField { func (t *rtype) FieldByIndex(index []int) StructField {
@@ -622,7 +622,7 @@ func (t *rtype) FieldByIndex(index []int) StructField {
tt := (*structType)(unsafe.Pointer(t)) tt := (*structType)(unsafe.Pointer(t))
return tt.FieldByIndex(index) return tt.FieldByIndex(index)
*/ */
panic("todo") panic("todo: reflect.rtype.FieldByIndex")
} }
func (t *rtype) FieldByName(name string) (StructField, bool) { func (t *rtype) FieldByName(name string) (StructField, bool) {
@@ -633,7 +633,7 @@ func (t *rtype) FieldByName(name string) (StructField, bool) {
tt := (*structType)(unsafe.Pointer(t)) tt := (*structType)(unsafe.Pointer(t))
return tt.FieldByName(name) return tt.FieldByName(name)
*/ */
panic("todo") panic("todo: reflect.rtype.FieldByName")
} }
func (t *rtype) FieldByNameFunc(match func(string) bool) (StructField, bool) { func (t *rtype) FieldByNameFunc(match func(string) bool) (StructField, bool) {
@@ -644,7 +644,7 @@ func (t *rtype) FieldByNameFunc(match func(string) bool) (StructField, bool) {
tt := (*structType)(unsafe.Pointer(t)) tt := (*structType)(unsafe.Pointer(t))
return tt.FieldByNameFunc(match) return tt.FieldByNameFunc(match)
*/ */
panic("todo") panic("todo: reflect.rtype.FieldByNameFunc")
} }
func (t *rtype) Key() Type { func (t *rtype) Key() Type {
@@ -679,7 +679,7 @@ func (t *rtype) In(i int) Type {
tt := (*abi.FuncType)(unsafe.Pointer(t)) tt := (*abi.FuncType)(unsafe.Pointer(t))
return toType(tt.InSlice()[i]) return toType(tt.InSlice()[i])
*/ */
panic("todo") panic("todo: reflect.rtype.In")
} }
func (t *rtype) NumIn() int { func (t *rtype) NumIn() int {
@@ -690,7 +690,7 @@ func (t *rtype) NumIn() int {
tt := (*abi.FuncType)(unsafe.Pointer(t)) tt := (*abi.FuncType)(unsafe.Pointer(t))
return tt.NumIn() return tt.NumIn()
*/ */
panic("todo") panic("todo: reflect.rtype.NumIn")
} }
func (t *rtype) NumOut() int { func (t *rtype) NumOut() int {
@@ -701,7 +701,7 @@ func (t *rtype) NumOut() int {
tt := (*abi.FuncType)(unsafe.Pointer(t)) tt := (*abi.FuncType)(unsafe.Pointer(t))
return tt.NumOut() return tt.NumOut()
*/ */
panic("todo") panic("todo: reflect.rtype.NumOut")
} }
func (t *rtype) Out(i int) Type { func (t *rtype) Out(i int) Type {
@@ -712,7 +712,7 @@ func (t *rtype) Out(i int) Type {
tt := (*abi.FuncType)(unsafe.Pointer(t)) tt := (*abi.FuncType)(unsafe.Pointer(t))
return toType(tt.OutSlice()[i]) return toType(tt.OutSlice()[i])
*/ */
panic("todo") panic("todo: reflect.rtype.Out")
} }
func (t *rtype) IsVariadic() bool { func (t *rtype) IsVariadic() bool {
@@ -723,7 +723,7 @@ func (t *rtype) IsVariadic() bool {
tt := (*abi.FuncType)(unsafe.Pointer(t)) tt := (*abi.FuncType)(unsafe.Pointer(t))
return tt.IsVariadic() return tt.IsVariadic()
*/ */
panic("todo") panic("todo: reflect.rtype.IsVariadic")
} }
// add returns p+x. // add returns p+x.
@@ -916,7 +916,7 @@ func (t *rtype) ptrTo() *abi.Type {
pi, _ := ptrMap.LoadOrStore(t, &pp) pi, _ := ptrMap.LoadOrStore(t, &pp)
return &pi.(*ptrType).Type return &pi.(*ptrType).Type
*/ */
panic("todo") panic("todo: reflect.rtype.ptrTo")
} }
func ptrTo(t *abi.Type) *abi.Type { func ptrTo(t *abi.Type) *abi.Type {
@@ -942,7 +942,7 @@ func (t *rtype) Implements(u Type) bool {
} }
return implements(u.common(), t.common()) return implements(u.common(), t.common())
*/ */
panic("todo") panic("todo: reflect.rtype.Implements")
} }
func (t *rtype) AssignableTo(u Type) bool { func (t *rtype) AssignableTo(u Type) bool {
@@ -953,7 +953,7 @@ func (t *rtype) AssignableTo(u Type) bool {
uu := u.common() uu := u.common()
return directlyAssignable(uu, t.common()) || implements(uu, t.common()) return directlyAssignable(uu, t.common()) || implements(uu, t.common())
*/ */
panic("todo") panic("todo: reflect.rtype.AssignableTo")
} }
func (t *rtype) ConvertibleTo(u Type) bool { func (t *rtype) ConvertibleTo(u Type) bool {
@@ -963,7 +963,7 @@ func (t *rtype) ConvertibleTo(u Type) bool {
} }
return convertOp(u.common(), t.common()) != nil return convertOp(u.common(), t.common()) != nil
*/ */
panic("todo") panic("todo: reflect.rtype.ConvertibleTo")
} }
func (t *rtype) Comparable() bool { func (t *rtype) Comparable() bool {
@@ -1055,7 +1055,7 @@ func implements(T, V *abi.Type) bool {
} }
return false return false
*/ */
panic("todo") panic("todo: reflect.implements")
} }
// specialChannelAssignability reports whether a value x of channel type V // specialChannelAssignability reports whether a value x of channel type V
@@ -1070,7 +1070,7 @@ func specialChannelAssignability(T, V *abi.Type) bool {
// and at least one of V or T is not a defined type. // and at least one of V or T is not a defined type.
return V.ChanDir() == abi.BothDir && (nameFor(T) == "" || nameFor(V) == "") && haveIdenticalType(T.Elem(), V.Elem(), true) return V.ChanDir() == abi.BothDir && (nameFor(T) == "" || nameFor(V) == "") && haveIdenticalType(T.Elem(), V.Elem(), true)
*/ */
panic("todo") panic("todo: reflect.specialChannelAssignability")
} }
// directlyAssignable reports whether a value x of type V can be directly // directlyAssignable reports whether a value x of type V can be directly
@@ -1202,7 +1202,7 @@ func haveIdenticalUnderlyingType(T, V *abi.Type, cmpTags bool) bool {
return false return false
*/ */
panic("todo") panic("todo: reflect.haveIdenticalUnderlyingType")
} }
// SliceOf returns the slice type with element type t. // SliceOf returns the slice type with element type t.

View File

@@ -128,7 +128,7 @@ func (v Value) pointer() unsafe.Pointer {
} }
return v.ptr return v.ptr
*/ */
panic("todo") panic("todo: reflect.Value.pointer")
} }
// packEface converts v to the empty interface. // packEface converts v to the empty interface.
@@ -355,7 +355,7 @@ func (v Value) bytesSlow() []byte {
} }
panic(&ValueError{"reflect.Value.Bytes", v.kind()}) panic(&ValueError{"reflect.Value.Bytes", v.kind()})
*/ */
panic("todo") panic("todo: reflect.Value.byteSlow")
} }
// runes returns v's underlying value. // runes returns v's underlying value.
@@ -747,7 +747,6 @@ func (v Value) Interface() (i any) {
} }
func valueInterface(v Value, safe bool) any { func valueInterface(v Value, safe bool) any {
/*
if v.flag == 0 { if v.flag == 0 {
panic(&ValueError{"reflect.Value.Interface", Invalid}) panic(&ValueError{"reflect.Value.Interface", Invalid})
} }
@@ -762,6 +761,7 @@ func valueInterface(v Value, safe bool) any {
} }
if v.kind() == Interface { if v.kind() == Interface {
/* TODO(xsw):
// Special case: return the element inside the interface. // Special case: return the element inside the interface.
// Empty interface has one layout, all interfaces with // Empty interface has one layout, all interfaces with
// methods have a second layout. // methods have a second layout.
@@ -771,12 +771,12 @@ func valueInterface(v Value, safe bool) any {
return *(*interface { return *(*interface {
M() M()
})(v.ptr) })(v.ptr)
*/
panic("todo: reflect.valueInterface")
} }
// TODO: pass safe to packEface so we don't need to copy if safe==true? // TODO: pass safe to packEface so we don't need to copy if safe==true?
return packEface(v) return packEface(v)
*/
panic("todo")
} }
// InterfaceData returns a pair of unspecified uintptr values. // InterfaceData returns a pair of unspecified uintptr values.
@@ -800,7 +800,7 @@ func (v Value) InterfaceData() [2]uintptr {
// Interface value is always bigger than a word; assume flagIndir. // Interface value is always bigger than a word; assume flagIndir.
return *(*[2]uintptr)(v.ptr) return *(*[2]uintptr)(v.ptr)
*/ */
panic("todo") panic("todo: reflect.Value.InterfaceData")
} }
// IsNil reports whether its argument v is nil. The argument must be // IsNil reports whether its argument v is nil. The argument must be
@@ -901,7 +901,7 @@ func (v Value) IsZero() bool {
panic(&ValueError{"reflect.Value.IsZero", v.Kind()}) panic(&ValueError{"reflect.Value.IsZero", v.Kind()})
} }
*/ */
panic("todo") panic("todo: reflect.Value.IsZero")
} }
// SetZero sets v to be the zero value of v's type. // SetZero sets v to be the zero value of v's type.
@@ -958,7 +958,7 @@ func (v Value) SetZero() {
panic(&ValueError{"reflect.Value.SetZero", v.Kind()}) panic(&ValueError{"reflect.Value.SetZero", v.Kind()})
} }
*/ */
panic("todo") panic("todo: reflect.Value.SetZero")
} }
// Kind returns v's Kind. // Kind returns v's Kind.
@@ -998,7 +998,7 @@ func (v Value) lenNonSlice() int {
} }
panic(&ValueError{"reflect.Value.Len", v.kind()}) panic(&ValueError{"reflect.Value.Len", v.kind()})
*/ */
panic("todo") panic("todo: reflect.Value.lenNonSlice")
} }
// Pointer returns v's value as a uintptr. // Pointer returns v's value as a uintptr.
@@ -1772,7 +1772,7 @@ func AppendSlice(s, t Value) Value {
Copy(s.Slice(ns, ns+nt), t) Copy(s.Slice(ns, ns+nt), t)
return s return s
*/ */
panic("todo") panic("todo: reflect.AppendSlice")
} }
// Zero returns a Value representing the zero value for the specified type. // Zero returns a Value representing the zero value for the specified type.
@@ -1819,7 +1819,7 @@ func New(typ Type) Value {
fl := flag(Pointer) fl := flag(Pointer)
return Value{pt, ptr, fl} return Value{pt, ptr, fl}
*/ */
panic("todo") panic("todo: reflect.New")
} }
// NewAt returns a Value representing a pointer to a value of the // NewAt returns a Value representing a pointer to a value of the
@@ -1872,7 +1872,7 @@ func (v Value) assignTo(context string, dst *abi.Type, target unsafe.Pointer) Va
// Failed. // Failed.
// TODO(xsw): // TODO(xsw):
// panic(context + ": value of type " + stringFor(v.typ()) + " is not assignable to type " + stringFor(dst)) // panic(context + ": value of type " + stringFor(v.typ()) + " is not assignable to type " + stringFor(dst))
panic("todo") panic("todo: reflect.Value.assignTo")
} }
// memmove copies size bytes to dst from src. No write barriers are used. // memmove copies size bytes to dst from src. No write barriers are used.

View File

@@ -1582,7 +1582,6 @@ func leadingFraction(s string) (x uint64, scale float64, rem string) {
return x, scale, s[i:] return x, scale, s[i:]
} }
/* TODO(xsw):
var unitMap = map[string]uint64{ var unitMap = map[string]uint64{
"ns": uint64(Nanosecond), "ns": uint64(Nanosecond),
"us": uint64(Microsecond), "us": uint64(Microsecond),
@@ -1697,4 +1696,3 @@ func ParseDuration(s string) (Duration, error) {
} }
return Duration(d), nil return Duration(d), nil
} }
*/

View File

@@ -501,6 +501,12 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
case vkUnsigned, vkPtr: case vkUnsigned, vkPtr:
pred := uintPredOpToLLVM[op-predOpBase] pred := uintPredOpToLLVM[op-predOpBase]
return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret} return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret}
case vkMap:
switch op {
case token.EQL, token.NEQ:
pred := uintPredOpToLLVM[op-predOpBase]
return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret}
}
case vkFloat: case vkFloat:
pred := floatPredOpToLLVM[op-predOpBase] pred := floatPredOpToLLVM[op-predOpBase]
return Expr{llvm.CreateFCmp(b.impl, pred, x.impl, y.impl), tret} return Expr{llvm.CreateFCmp(b.impl, pred, x.impl, y.impl), tret}
@@ -552,7 +558,7 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
fallthrough fallthrough
case vkFuncPtr, vkFuncDecl: case vkFuncPtr, vkFuncDecl:
switch op { switch op {
case token.EQL: case token.EQL: // TODO(xsw): check this code
return b.Prog.BoolVal(x.impl.IsNull() == y.impl.IsNull()) return b.Prog.BoolVal(x.impl.IsNull() == y.impl.IsNull())
case token.NEQ: case token.NEQ:
return b.Prog.BoolVal(x.impl.IsNull() != y.impl.IsNull()) return b.Prog.BoolVal(x.impl.IsNull() != y.impl.IsNull())
@@ -605,13 +611,6 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
case token.NEQ: case token.NEQ:
return Expr{b.impl.CreateICmp(llvm.IntNE, dx, dy, ""), tret} return Expr{b.impl.CreateICmp(llvm.IntNE, dx, dy, ""), tret}
} }
case vkMap:
switch op {
case token.EQL:
return b.Prog.BoolVal(x.impl.IsNull() == y.impl.IsNull())
case token.NEQ:
return b.Prog.BoolVal(x.impl.IsNull() != y.impl.IsNull())
}
case vkIface, vkEface: case vkIface, vkEface:
toEface := func(x Expr, emtpy bool) Expr { toEface := func(x Expr, emtpy bool) Expr {
if emtpy { if emtpy {