Skip to content

Commit

Permalink
Get Joker vetting and building against go1.16beta1
Browse files Browse the repository at this point in the history
Doesn't pass tests because of the type-alias issue, which can be fixed at the test level (if not by actually supporting them in Joker).

But this addresses the failure to vet as a result of:

golang/go#40701
  • Loading branch information
jcburley committed Dec 17, 2020
1 parent 07dd358 commit 7ce4d84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 52 deletions.
49 changes: 1 addition & 48 deletions tools/gostd/_tests/gold/amd64-linux/gosrc.gold
Original file line number Diff line number Diff line change
Expand Up @@ -152416,8 +152416,6 @@ func ExtractGoObjectSliceHeader(args []Object, index int) *reflect.SliceHeader {
switch o := a.(type) {
case GoObject:
switch r := o.O.(type) {
case reflect.SliceHeader:
return &r
case *reflect.SliceHeader:
return r
}
Expand All @@ -152435,34 +152433,12 @@ func ExtractGo_go_std_reflect__SliceHeader(rcvr, arg string, args *ArraySeq, n i
return
}

func _mapToSliceHeader(o Map) *reflect.SliceHeader {
return &reflect.SliceHeader{
Data: FieldAsUintPtr(o, "Data"),
Len: FieldAsInt(o, "Len"),
Cap: FieldAsInt(o, "Cap"),
}
}

func _Ctor_SliceHeader(_v Object) *reflect.SliceHeader {
switch _o := _v.(type) {
case *ArrayMap, *HashMap:
return _mapToSliceHeader(_o.(Map))
}
panic(RT.NewArgTypeError(0, _v, "GoObject[reflect.SliceHeader] or: Map"))
}

func _Wrapped_Ctor_SliceHeader(_o Object) Object {
return MakeGoObject(_Ctor_SliceHeader(_o))
}

GO TYPE reflect.StringHeader from reflect/value.go:
func ExtractGoObjectStringHeader(args []Object, index int) *reflect.StringHeader {
a := args[index]
switch o := a.(type) {
case GoObject:
switch r := o.O.(type) {
case reflect.StringHeader:
return &r
case *reflect.StringHeader:
return r
}
Expand All @@ -152480,25 +152456,6 @@ func ExtractGo_go_std_reflect__StringHeader(rcvr, arg string, args *ArraySeq, n
return
}

func _mapToStringHeader(o Map) *reflect.StringHeader {
return &reflect.StringHeader{
Data: FieldAsUintPtr(o, "Data"),
Len: FieldAsInt(o, "Len"),
}
}

func _Ctor_StringHeader(_v Object) *reflect.StringHeader {
switch _o := _v.(type) {
case *ArrayMap, *HashMap:
return _mapToStringHeader(_o.(Map))
}
panic(RT.NewArgTypeError(0, _v, "GoObject[reflect.StringHeader] or: Map"))
}

func _Wrapped_Ctor_StringHeader(_o Object) Object {
return MakeGoObject(_Ctor_StringHeader(_o))
}

GO TYPE reflect.StructField from reflect/type.go:
func ExtractGoObjectStructField(args []Object, index int) *reflect.StructField {
a := args[index]
Expand Down Expand Up @@ -153705,7 +153662,6 @@ GO INFO FOR TYPE go.std.reflect/refToSelectDir from /usr/local/go/src/reflect/va
GO INFO FOR TYPE go.std.reflect/SliceHeader from /usr/local/go/src/reflect/value.go:1994:6:
info_SliceHeader = GoTypeInfo{Name: "go.std.reflect/SliceHeader",
GoType: &GoType{T: &info_SliceHeader},
Ctor: _Wrapped_Ctor_SliceHeader,
Members: GoMembers{
},
}
Expand All @@ -153714,7 +153670,6 @@ GO INFO FOR TYPE go.std.reflect/SliceHeader from /usr/local/go/src/reflect/value
GO INFO FOR TYPE go.std.reflect/refToSliceHeader from /usr/local/go/src/reflect/value.go:1994:6:
info_PtrTo_SliceHeader = GoTypeInfo{Name: "go.std.reflect/refToSliceHeader",
GoType: &GoType{T: &info_PtrTo_SliceHeader},
Ctor: _Wrapped_Ctor_SliceHeader,
Members: GoMembers{
},
}
Expand All @@ -153723,7 +153678,6 @@ GO INFO FOR TYPE go.std.reflect/refToSliceHeader from /usr/local/go/src/reflect/
GO INFO FOR TYPE go.std.reflect/StringHeader from /usr/local/go/src/reflect/value.go:1983:6:
info_StringHeader = GoTypeInfo{Name: "go.std.reflect/StringHeader",
GoType: &GoType{T: &info_StringHeader},
Ctor: _Wrapped_Ctor_StringHeader,
Members: GoMembers{
},
}
Expand All @@ -153732,7 +153686,6 @@ GO INFO FOR TYPE go.std.reflect/StringHeader from /usr/local/go/src/reflect/valu
GO INFO FOR TYPE go.std.reflect/refToStringHeader from /usr/local/go/src/reflect/value.go:1983:6:
info_PtrTo_StringHeader = GoTypeInfo{Name: "go.std.reflect/refToStringHeader",
GoType: &GoType{T: &info_PtrTo_StringHeader},
Ctor: _Wrapped_Ctor_StringHeader,
Members: GoMembers{
},
}
Expand Down Expand Up @@ -176520,6 +176473,6 @@ Totals: functions=4055 generated=2987 (73.66%)
receivers=2063 (50.88%) generated=1459 (70.72%)
methods=397 (9.79%) generated=247 (62.22%)
types=1841
constructable=1674 ctors=887 (52.99%)
constructable=1674 ctors=883 (52.75%)
constants=4394 generated=4356 (99.14%)
variables=439 generated=439 (100.00%)
17 changes: 13 additions & 4 deletions tools/gostd/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,27 @@ func ExtractGoObject%s(args []Object, index int) *%s {
switch o := a.(type) {
case GoObject:
switch r := o.O.(type) {
case %s:
return &r
case *%s:
%s case *%s:
return r
}
%s}
panic(RT.NewArgTypeError(index, a, "GoObject[%s]"))
}
`
const goExtractRefToTemplate = `
case %s:
return &r
`

baseTypeName := ts.Name.Name
typeName := myGoImport + "." + baseTypeName

others := maybeImplicitConvert(godb.GoFileForTypeSpec(ts), typeName, ts)
goc := fmt.Sprintf(goExtractTemplate, baseTypeName, typeName, typeName, typeName, others, t)
goExtractRefTo := ""
if !(ti.GoPackage() == "reflect" && (ti.GoBaseName() == "StringHeader" || ti.GoBaseName() == "SliceHeader")) {
goExtractRefTo = fmt.Sprintf(goExtractRefToTemplate[1:], typeName)
}
goc := fmt.Sprintf(goExtractTemplate, baseTypeName, typeName, goExtractRefTo, typeName, others, t)

goc += goTypeExtractor(t, ti)

Expand All @@ -474,6 +480,9 @@ func genCtor(tyi TypeInfo) {
if !tyi.Custom() {
return
}
if tyi.GoPackage() == "reflect" && (tyi.GoBaseName() == "StringHeader" || tyi.GoBaseName() == "SliceHeader") {
return
}

ts := tyi.TypeSpec()
if ts == nil {
Expand Down

0 comments on commit 7ce4d84

Please sign in to comment.