Skip to content

Commit

Permalink
Merge pull request #431 from xushiwei/q
Browse files Browse the repository at this point in the history
remove c2go support
  • Loading branch information
xushiwei authored May 18, 2024
2 parents 7468f9e + 3a1f39a commit 250e767
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 729 deletions.
4 changes: 2 additions & 2 deletions ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,6 @@ retry:
case *tyTypeAsParams:
return matchFuncCall(pkg, chgObject(pkg, ft.obj, fn), args, flags|instrFlagGopxFunc)
}
} else if IsCSignature(t) {
sig = types.NewSignatureType(nil, nil, nil, t.Params(), t.Results(), t.Variadic())
} else {
sig = t
}
Expand Down Expand Up @@ -950,11 +948,13 @@ func restoreArgs(args []*internal.Elem, backup []backupElem) {
}
}

/*
func copyArgs(args []*internal.Elem) []*internal.Elem {
backup := make([]*internal.Elem, len(args))
copy(backup, args)
return backup
}
*/

func untypeBig(pkg *Package, cval constant.Value, tyRet types.Type) (*internal.Elem, bool) {
switch tyRet {
Expand Down
67 changes: 2 additions & 65 deletions builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,25 +302,6 @@ func TestGetSrcPos(t *testing.T) {
}
}

func TestExportFields(t *testing.T) {
pkg := NewPackage("", "foo", nil)
fields := []*types.Var{
types.NewField(token.NoPos, pkg.Types, "Y", types.Typ[types.Int], false),
types.NewField(token.NoPos, pkg.Types, "X__u", types.Typ[types.String], false),
}
tyT := pkg.NewType("T").InitType(pkg, types.NewStruct(fields, nil))
pkg.ExportFields(tyT)
if name := pkg.cb.getFieldName(tyT, "y"); name != "Y" {
t.Fatal("getFieldName y:", name)
}
if name := pkg.cb.getFieldName(tyT, "__u"); name != "X__u" {
t.Fatal("getFieldName __u:", name)
}
if CPubName("123") != "123" {
t.Fatal("CPubName(123) failed")
}
}

func TestIsTypeEx(t *testing.T) {
pkg := types.NewPackage("", "foo")
o := NewInstruction(0, pkg, "bar", lenInstr{})
Expand Down Expand Up @@ -699,13 +680,6 @@ func TestToVariadic(t *testing.T) {

func TestToType(t *testing.T) {
pkg := NewPackage("", "foo", gblConf)
cf := NewCSignature(nil, nil, false)
if !IsCSignature(cf) {
t.Fatal("IsCSignature failed: not c function?")
}
if v := typString(pkg, cf); v != "func()" {
t.Fatal("toType failed:", v)
}
toType(pkg, &unboundType{tBound: tyInt})
defer func() {
if e := recover(); e == nil {
Expand All @@ -715,6 +689,7 @@ func TestToType(t *testing.T) {
toType(pkg, &unboundType{})
}

/*
func typString(pkg *Package, t types.Type) string {
v := toType(pkg, t)
var b bytes.Buffer
Expand All @@ -724,6 +699,7 @@ func typString(pkg *Package, t types.Type) string {
}
return b.String()
}
*/

func TestMethodAutoProperty(t *testing.T) {
pkg := types.NewPackage("", "")
Expand Down Expand Up @@ -786,16 +762,11 @@ func TestHasAutoProperty(t *testing.T) {

func TestTypeEx(t *testing.T) {
subst := &TySubst{}
bfReft := &bfRefType{typ: tyInt}
if typ, ok := DerefType(bfReft); !ok || typ != tyInt {
t.Fatal("TestDerefType failed")
}
pkg := NewPackage("example.com/foo", "foo", gblConf)
tyInt := types.Typ[types.Int]
typs := []types.Type{
&refType{},
subst,
bfReft,
&unboundType{},
&unboundMapElemType{},
&TyOverloadFunc{},
Expand All @@ -811,9 +782,6 @@ func TestTypeEx(t *testing.T) {
&TemplateParamType{},
&TemplateSignature{},
}
if v := bfReft.String(); v != "bfRefType{typ: int:0 off: 0}" {
t.Fatal("bfRefType.String:", v)
}
if v := subst.String(); v != "substType{real: <nil>}" {
t.Fatal("substType.String:", v)
}
Expand Down Expand Up @@ -1307,37 +1275,6 @@ func TestCallIncDec(t *testing.T) {
callIncDec(pkg, args, token.INC)
}

func TestVFields(t *testing.T) {
pkg := NewPackage("", "foo", gblConf)
typ := types.NewNamed(types.NewTypeName(token.NoPos, pkg.Types, "bar", nil), tyInt, nil)
_, ok := pkg.VFields(typ)
if ok {
t.Fatal("VFields?")
}
{
flds := NewUnionFields([]*UnionField{
{Name: "foo"},
})
if flds.Len() != 1 {
t.Fatal("UnionFields.len != 1")
}
if flds.At(0).Name != "foo" {
t.Fatal("UnionField.name != foo")
}
}
{
flds := NewBitFields([]*BitField{
{Name: "foo"},
})
if flds.Len() != 1 {
t.Fatal("BitFields.len != 1")
}
if flds.At(0).Name != "foo" {
t.Fatal("BitField.name != foo")
}
}
}

func TestTypeAST(t *testing.T) {
pkg := NewPackage("", "foo", gblConf)
fset := token.NewFileSet()
Expand Down
Loading

0 comments on commit 250e767

Please sign in to comment.