PrintIface
This commit is contained in:
21
cl/_testgo/errors/in.go
Normal file
21
cl/_testgo/errors/in.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
// New returns an error that formats as the given text.
|
||||
// Each call to New returns a distinct error value even if the text is identical.
|
||||
func New(text string) error {
|
||||
return &errorString{text}
|
||||
}
|
||||
|
||||
// errorString is a trivial implementation of error.
|
||||
type errorString struct {
|
||||
s string
|
||||
}
|
||||
|
||||
func (e *errorString) Error() string {
|
||||
return e.s
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := New("an error")
|
||||
println(err, err.Error())
|
||||
}
|
||||
0
cl/_testgo/errors/out.ll
Normal file
0
cl/_testgo/errors/out.ll
Normal file
@@ -69,3 +69,7 @@ func PrintSlice(s Slice) {
|
||||
func PrintEface(e Eface) {
|
||||
print("(", e._type, ",", e.data, ")")
|
||||
}
|
||||
|
||||
func PrintIface(i Iface) {
|
||||
print("(", i.tab, ",", i.data, ")")
|
||||
}
|
||||
|
||||
@@ -1080,6 +1080,8 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) {
|
||||
fn = "PrintString"
|
||||
case vkEface:
|
||||
fn = "PrintEface"
|
||||
case vkIface:
|
||||
fn = "PrintIface"
|
||||
// case vkComplex:
|
||||
// fn = "PrintComplex"
|
||||
default:
|
||||
|
||||
@@ -127,7 +127,7 @@ func (b Builder) abiNamedOf(t *types.Named) Expr {
|
||||
|
||||
func (b Builder) abiPointerOf(t *types.Pointer) Expr {
|
||||
elem := b.abiTypeOf(t.Elem())
|
||||
return b.Call(b.Pkg.rtFunc("Pointer"), elem)
|
||||
return b.Call(b.Pkg.rtFunc("PointerTo"), elem)
|
||||
}
|
||||
|
||||
// func Struct(pkgPath string, size uintptr, fields []abi.StructField)
|
||||
|
||||
Reference in New Issue
Block a user