diff --git a/cl/blockctx.go b/cl/blockctx.go index 2b3fc0e..6e35b9f 100644 --- a/cl/blockctx.go +++ b/cl/blockctx.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/goplus/c2go/clang/ast" - "github.com/goplus/gox" + "github.com/goplus/gogen" "github.com/qiniu/x/ctype" ctypes "github.com/goplus/c2go/clang/types" @@ -24,16 +24,16 @@ const ( // ----------------------------------------------------------------------------- type funcCtx struct { - labels map[string]*gox.Label - vdefs *gox.VarDefs + labels map[string]*gogen.Label + vdefs *gogen.VarDefs basel int basev int orgName string } -func newFuncCtx(pkg *gox.Package, complicated bool, orgName string) *funcCtx { +func newFuncCtx(pkg *gogen.Package, complicated bool, orgName string) *funcCtx { ctx := &funcCtx{ - labels: make(map[string]*gox.Label), + labels: make(map[string]*gogen.Label), orgName: orgName, } if complicated { @@ -42,19 +42,19 @@ func newFuncCtx(pkg *gox.Package, complicated bool, orgName string) *funcCtx { return ctx } -func (p *funcCtx) newLabel(cb *gox.CodeBuilder) *gox.Label { +func (p *funcCtx) newLabel(cb *gogen.CodeBuilder) *gogen.Label { p.basel++ name := "_cgol_" + strconv.Itoa(p.basel) return cb.NewLabel(token.NoPos, name) } -func (p *funcCtx) label(cb *gox.CodeBuilder) *gox.Label { +func (p *funcCtx) label(cb *gogen.CodeBuilder) *gogen.Label { l := p.newLabel(cb) cb.Label(l) return l } -func (p *funcCtx) newAutoVar(pos token.Pos, typ types.Type, name string) (*gox.VarDecl, types.Object) { +func (p *funcCtx) newAutoVar(pos token.Pos, typ types.Type, name string) (*gogen.VarDecl, types.Object) { p.basev++ realName := name + "_cgo" + strconv.Itoa(p.basev) ret := p.vdefs.New(pos, typ, realName) @@ -65,8 +65,8 @@ func (p *funcCtx) newAutoVar(pos token.Pos, typ types.Type, name string) (*gox.V type flowCtx interface { // switch, for Parent() flowCtx - EndLabel(ctx *blockCtx) *gox.Label - ContinueLabel(ctx *blockCtx) *gox.Label + EndLabel(ctx *blockCtx) *gogen.Label + ContinueLabel(ctx *blockCtx) *gogen.Label } // ----------------------------------------------------------------------------- @@ -86,14 +86,14 @@ func (p *baseFlowCtx) Parent() flowCtx { return p.parent } -func (p *baseFlowCtx) EndLabel(ctx *blockCtx) *gox.Label { +func (p *baseFlowCtx) EndLabel(ctx *blockCtx) *gogen.Label { if (p.kind & (flowKindLoop | flowKindSwitch)) != 0 { return nil } return p.parent.EndLabel(ctx) } -func (p *baseFlowCtx) ContinueLabel(ctx *blockCtx) *gox.Label { +func (p *baseFlowCtx) ContinueLabel(ctx *blockCtx) *gogen.Label { if (p.kind & flowKindLoop) != 0 { return nil } @@ -103,10 +103,10 @@ func (p *baseFlowCtx) ContinueLabel(ctx *blockCtx) *gox.Label { // ----------------------------------------------------------------------------- type endLabelCtx struct { - done *gox.Label + done *gogen.Label } -func (p *endLabelCtx) EndLabel(ctx *blockCtx) *gox.Label { +func (p *endLabelCtx) EndLabel(ctx *blockCtx) *gogen.Label { done := p.done if done == nil { done = ctx.curfn.newLabel(ctx.cb) @@ -120,8 +120,8 @@ func (p *endLabelCtx) EndLabel(ctx *blockCtx) *gox.Label { type switchCtx struct { endLabelCtx parent flowCtx - next *gox.Label - defau *gox.Label + next *gogen.Label + defau *gogen.Label tag types.Object notmat types.Object // notMatched } @@ -130,11 +130,11 @@ func (p *switchCtx) Parent() flowCtx { return p.parent } -func (p *switchCtx) ContinueLabel(ctx *blockCtx) *gox.Label { +func (p *switchCtx) ContinueLabel(ctx *blockCtx) *gogen.Label { return p.parent.ContinueLabel(ctx) } -func (p *switchCtx) nextCaseLabel(ctx *blockCtx) *gox.Label { +func (p *switchCtx) nextCaseLabel(ctx *blockCtx) *gogen.Label { l := ctx.curfn.newLabel(ctx.cb) p.next = l return l @@ -155,11 +155,11 @@ func (p *ifCtx) Parent() flowCtx { return p.parent } -func (p *ifCtx) ContinueLabel(ctx *blockCtx) *gox.Label { +func (p *ifCtx) ContinueLabel(ctx *blockCtx) *gogen.Label { return p.parent.ContinueLabel(ctx) } -func (p *ifCtx) elseLabel(ctx *blockCtx) *gox.Label { +func (p *ifCtx) elseLabel(ctx *blockCtx) *gogen.Label { return ctx.curfn.newLabel(ctx.cb) } @@ -168,14 +168,14 @@ func (p *ifCtx) elseLabel(ctx *blockCtx) *gox.Label { type loopCtx struct { endLabelCtx parent flowCtx - start *gox.Label + start *gogen.Label } func (p *loopCtx) Parent() flowCtx { return p.parent } -func (p *loopCtx) ContinueLabel(ctx *blockCtx) *gox.Label { +func (p *loopCtx) ContinueLabel(ctx *blockCtx) *gogen.Label { return p.start } @@ -193,13 +193,13 @@ type unnamedType struct { } type blockCtx struct { - pkg *gox.Package - cb *gox.CodeBuilder + pkg *gogen.Package + cb *gogen.CodeBuilder fset *token.FileSet tyI128 types.Type tyU128 types.Type unnameds map[ast.ID]unnamedType - gblvars map[string]*gox.VarDefs + gblvars map[string]*gogen.VarDefs public map[string]string ignored []string srcdir string @@ -250,11 +250,11 @@ func (p *blockCtx) addExternFunc(name string) { } func (p *blockCtx) lookupParent(name string) types.Object { - _, o := gox.LookupParent(p.cb.Scope(), name, token.NoPos) + _, o := gogen.LookupParent(p.cb.Scope(), name, token.NoPos) return o } -func (p *blockCtx) newVar(scope *types.Scope, pos token.Pos, typ types.Type, name string) (ret *gox.VarDecl, inVBlock bool) { +func (p *blockCtx) newVar(scope *types.Scope, pos token.Pos, typ types.Type, name string) (ret *gogen.VarDecl, inVBlock bool) { cb, pkg := p.cb, p.pkg inGlobal := scope == pkg.Types.Scope() if !inGlobal { @@ -263,7 +263,7 @@ func (p *blockCtx) newVar(scope *types.Scope, pos token.Pos, typ types.Type, nam if inVBlock { var obj types.Object ret, obj = p.curfn.newAutoVar(pos, typ, name) - if scope.Insert(gox.NewSubst(pos, pkg.Types, name, obj)) != nil { + if scope.Insert(gogen.NewSubst(pos, pkg.Types, name, obj)) != nil { log.Panicf("newVar: variable %v exists already\n", name) } } else { @@ -343,7 +343,7 @@ func (p *blockCtx) initSource() []byte { return b } -func (p *blockCtx) getLabel(pos token.Pos, name string) *gox.Label { +func (p *blockCtx) getLabel(pos token.Pos, name string) *gogen.Label { if fn := p.curfn; fn != nil { l, ok := fn.labels[name] if !ok { @@ -444,11 +444,11 @@ func getFld(t *types.Struct, name string, from int) (flds []*types.Var, i int) { return nil, -1 } -func (p *blockCtx) buildVStruct(struc *types.Struct, vfs gox.VFields) *types.Struct { +func (p *blockCtx) buildVStruct(struc *types.Struct, vfs gogen.VFields) *types.Struct { var pkg = p.pkg.Types var vFlds []*types.Var switch v := vfs.(type) { - case *gox.BitFields: + case *gogen.BitFields: from, n := 0, v.Len() for i := 0; i < n; i++ { f := v.At(i) @@ -493,7 +493,7 @@ func (p *blockCtx) getVStruct(typ *types.Named) *types.Struct { type bfType struct { types.Type - *gox.BitField + *gogen.BitField first bool } @@ -520,7 +520,7 @@ func (p *bfType) String() string { decl_builtin(p) } - func aliasCType(scope *types.Scope, pkg *types.Package, name string, c *gox.PkgRef, cname string) { + func aliasCType(scope *types.Scope, pkg *types.Package, name string, c *gogen.PkgRef, cname string) { aliasType(scope, pkg, name, c.Ref(cname).Type()) } */ diff --git a/cl/codebuild.go b/cl/codebuild.go index 6647c43..37ab717 100644 --- a/cl/codebuild.go +++ b/cl/codebuild.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/goplus/gox" + "github.com/goplus/gogen" cast "github.com/goplus/c2go/clang/ast" ctypes "github.com/goplus/c2go/clang/types" @@ -105,21 +105,21 @@ func decl_builtin(ctx *blockCtx) { } fns[i] = pkg.Scope().Lookup(item) } - scope.Insert(gox.NewOverloadFunc(token.NoPos, pkg, o.name, fns...)) + scope.Insert(gogen.NewOverloadFunc(token.NoPos, pkg, o.name, fns...)) } } // ----------------------------------------------------------------------------- type unionBuilder struct { - fields []*gox.UnionField + fields []*gogen.UnionField } func newUnionBuilder() *unionBuilder { return &unionBuilder{} } -func unionEmbeddedField(ctx *blockCtx, fields []*gox.UnionField, t *types.Named, off int) []*gox.UnionField { +func unionEmbeddedField(ctx *blockCtx, fields []*gogen.UnionField, t *types.Named, off int) []*gogen.UnionField { o := t.Underlying().(*types.Struct) for i, n := 0, o.NumFields(); i < n; i++ { fld := o.Field(i) @@ -127,7 +127,7 @@ func unionEmbeddedField(ctx *blockCtx, fields []*gox.UnionField, t *types.Named, if fld.Embedded() { fields = unionEmbeddedField(ctx, fields, fldType.(*types.Named), off) } else { - fields = append(fields, &gox.UnionField{ + fields = append(fields, &gogen.UnionField{ Name: fld.Name(), Off: off, Type: fldType, @@ -139,7 +139,7 @@ func unionEmbeddedField(ctx *blockCtx, fields []*gox.UnionField, t *types.Named, } func (p *unionBuilder) Type(ctx *blockCtx, t *types.Named) *types.Struct { - var fldLargest *gox.UnionField + var fldLargest *gogen.UnionField var fields = p.fields var lenLargest, n = 0, len(fields) for i := 0; i < n; i++ { @@ -154,7 +154,7 @@ func (p *unionBuilder) Type(ctx *blockCtx, t *types.Named) *types.Struct { flds := make([]*types.Var, 0, 1) if fldLargest != nil { pkg := ctx.pkg - pkg.SetVFields(t, gox.NewUnionFields(fields)) + pkg.SetVFields(t, gogen.NewUnionFields(fields)) fld := types.NewField(fldLargest.Pos, pkg.Types, fldLargest.Name, fldLargest.Type, false) flds = append(flds, fld) } @@ -165,7 +165,7 @@ func (p *unionBuilder) Field(ctx *blockCtx, pos token.Pos, typ types.Type, name if embedded { name = "" } - fld := &gox.UnionField{ + fld := &gogen.UnionField{ Name: name, Type: typ, Pos: pos, @@ -177,7 +177,7 @@ func (p *unionBuilder) Field(ctx *blockCtx, pos token.Pos, typ types.Type, name type structBuilder struct { fields []*types.Var - bitFields []*gox.BitField + bitFields []*gogen.BitField lastFldName string lastTy types.Type totalBits int @@ -192,7 +192,7 @@ func newStructBuilder() *structBuilder { func (p *structBuilder) Type(ctx *blockCtx, t *types.Named) *types.Struct { struc := types.NewStruct(p.fields, nil) if len(p.bitFields) > 0 { - ctx.pkg.SetVFields(t, gox.NewBitFields(p.bitFields)) + ctx.pkg.SetVFields(t, gogen.NewBitFields(p.bitFields)) } return struc } @@ -200,7 +200,7 @@ func (p *structBuilder) Type(ctx *blockCtx, t *types.Named) *types.Struct { func (p *structBuilder) BitField(ctx *blockCtx, typ types.Type, name string, bits int) { if p.leftBits >= bits && ctypes.Identical(typ, p.lastTy) { if name != "" { - p.bitFields = append(p.bitFields, &gox.BitField{ + p.bitFields = append(p.bitFields, &gogen.BitField{ Name: name, FldName: p.lastFldName, Off: p.totalBits - p.leftBits, @@ -216,7 +216,7 @@ func (p *structBuilder) BitField(ctx *blockCtx, typ types.Type, name string, bit p.lastTy = typ p.leftBits = p.totalBits - bits if name != "" { - p.bitFields = append(p.bitFields, &gox.BitField{ + p.bitFields = append(p.bitFields, &gogen.BitField{ Name: name, FldName: p.lastFldName, Bits: bits, @@ -255,7 +255,7 @@ func toInt64(ctx *blockCtx, v *cast.Node, emsg string) int64 { // ----------------------------------------------------------------------------- -func typeCast(ctx *blockCtx, typ types.Type, arg *gox.Element) { +func typeCast(ctx *blockCtx, typ types.Type, arg *gogen.Element) { if !ctypes.Identical(typ, arg.Type) { adjustIntConst(ctx, arg, typ) *arg = *ctx.cb.Typ(typ).Val(arg).Call(1).InternalStack().Pop() @@ -266,7 +266,7 @@ func assign(ctx *blockCtx, src ast.Node) { cb := ctx.cb arg1 := cb.Get(-2) arg2 := cb.Get(-1) - arg1Type, _ := gox.DerefType(arg1.Type) + arg1Type, _ := gogen.DerefType(arg1.Type) typeCast(ctx, arg1Type, arg2) cb.AssignWith(1, 1, src) } @@ -275,7 +275,7 @@ func assignOp(ctx *blockCtx, op token.Token, src ast.Node) { cb := ctx.cb stk := cb.InternalStack() arg1 := stk.Get(-2) - arg1Type, _ := gox.DerefType(arg1.Type) + arg1Type, _ := gogen.DerefType(arg1.Type) switch op { case token.ADD_ASSIGN, token.SUB_ASSIGN: // ptr+=n, ptr-=n if t1, ok := arg1Type.(*types.Pointer); ok { @@ -308,7 +308,7 @@ done: cb.AssignOp(op, src) } -func isNegConst(v *gox.Element) bool { +func isNegConst(v *gogen.Element) bool { if cval := v.CVal; cval != nil && cval.Kind() == constant.Int { if v, ok := constant.Int64Val(cval); ok { return v < 0 @@ -317,7 +317,7 @@ func isNegConst(v *gox.Element) bool { return false } -func isNilConst(v *gox.Element) bool { +func isNilConst(v *gogen.Element) bool { if cval := v.CVal; cval != nil && cval.Kind() == constant.Int { if v, ok := constant.Int64Val(cval); ok { return v == 0 @@ -326,7 +326,7 @@ func isNilConst(v *gox.Element) bool { return false } -func isZeroNumber(v *gox.Element) bool { +func isZeroNumber(v *gogen.Element) bool { if cval := v.CVal; cval != nil { return constant.Sign(cval) == 0 } @@ -347,7 +347,7 @@ func unaryOp(ctx *blockCtx, op token.Token, v *cast.Node) { t := toType(ctx, v.Type, 0) args := ctx.cb.InternalStack().GetArgs(1) if isInteger(t) && isBool(args[0].Type) { - if v, ok := gox.CastFromBool(ctx.cb, t, args[0]); ok { + if v, ok := gogen.CastFromBool(ctx.cb, t, args[0]); ok { args[0] = v } } @@ -448,10 +448,10 @@ func binaryOp(ctx *blockCtx, op token.Token, v *cast.Node) { t := toType(ctx, v.Type, 0) if isInteger(t) { // bool => int args := stk.GetArgs(2) - if v, ok := gox.CastFromBool(cb, t, args[0]); ok { + if v, ok := gogen.CastFromBool(cb, t, args[0]); ok { args[0] = v } - if v, ok := gox.CastFromBool(cb, t, args[1]); ok { + if v, ok := gogen.CastFromBool(cb, t, args[1]); ok { args[1] = v } } @@ -464,13 +464,13 @@ func compareOp(ctx *blockCtx, op token.Token, src ast.Node) { ctx.cb.BinaryOp(op, src) } -func untypedZeroToNil(v *gox.Element) { +func untypedZeroToNil(v *gogen.Element) { v.Type = types.Typ[types.UntypedNil] v.Val = &ast.Ident{Name: "nil"} v.CVal = nil } -func castPtrOrFnPtrType(cb *gox.CodeBuilder, kind int, from, to types.Type, v *gox.Element) { +func castPtrOrFnPtrType(cb *gogen.CodeBuilder, kind int, from, to types.Type, v *gogen.Element) { switch kind { case ncKindSignature: castFnPtrType(cb, from, to, v) @@ -479,7 +479,7 @@ func castPtrOrFnPtrType(cb *gox.CodeBuilder, kind int, from, to types.Type, v *g } } -func stringLit(cb *gox.CodeBuilder, s string, typ types.Type) { +func stringLit(cb *gogen.CodeBuilder, s string, typ types.Type) { n := len(s) eos := true if typ == nil { @@ -501,7 +501,7 @@ func stringLit(cb *gox.CodeBuilder, s string, typ types.Type) { } } -func wstringLit(cb *gox.CodeBuilder, s string, typ types.Type) { +func wstringLit(cb *gogen.CodeBuilder, s string, typ types.Type) { var n int for _, c := range s { n++ @@ -520,17 +520,17 @@ func wstringLit(cb *gox.CodeBuilder, s string, typ types.Type) { } } -func arrayToElemPtr(cb *gox.CodeBuilder) { +func arrayToElemPtr(cb *gogen.CodeBuilder) { arr := cb.InternalStack().Pop() - t, _ := gox.DerefType(arr.Type) + t, _ := gogen.DerefType(arr.Type) elem := t.(*types.Array).Elem() cb.Typ(ctypes.NewPointer(elem)).Typ(ctypes.UnsafePointer). Val(arr).UnaryOp(token.AND).Call(1).Call(1) } -func arrayToElemPtrClosure(cb *gox.CodeBuilder) { +func arrayToElemPtrClosure(cb *gogen.CodeBuilder) { arr := cb.InternalStack().Pop() - t, _ := gox.DerefType(arr.Type) + t, _ := gogen.DerefType(arr.Type) elem := t.(*types.Array).Elem() pkg := cb.Pkg() ret := types.NewParam(token.NoPos, pkg.Types, "", ctypes.NewPointer(elem)) @@ -541,7 +541,7 @@ func arrayToElemPtrClosure(cb *gox.CodeBuilder) { End().Call(0) } -func castToBoolExpr(cb *gox.CodeBuilder) { +func castToBoolExpr(cb *gogen.CodeBuilder) { elem := cb.InternalStack().Get(-1) if t := elem.Type; isNumber(t) { cb.Val(0).BinaryOp(token.NEQ) @@ -550,7 +550,7 @@ func castToBoolExpr(cb *gox.CodeBuilder) { } } -func valOfAddr(cb *gox.CodeBuilder, addr types.Object, ctx *blockCtx) (elemSize int) { +func valOfAddr(cb *gogen.CodeBuilder, addr types.Object, ctx *blockCtx) (elemSize int) { typ := addr.Type() if t, ok := typ.(*types.Pointer); ok { typ = t.Elem() @@ -563,12 +563,12 @@ func valOfAddr(cb *gox.CodeBuilder, addr types.Object, ctx *blockCtx) (elemSize return 1 } -func isBasicLit(v *gox.Element) (ok bool) { +func isBasicLit(v *gogen.Element) (ok bool) { _, ok = v.Val.(*ast.BasicLit) return } -func adjustBigIntConst(ctx *blockCtx, v *gox.Element, t *types.Basic) { +func adjustBigIntConst(ctx *blockCtx, v *gogen.Element, t *types.Basic) { var bits = 8 * ctx.sizeof(t) var mask = (uint64(1) << bits) - 1 var val = constant.BinaryOp(v.CVal, token.AND, constant.MakeUint64(mask)) @@ -588,7 +588,7 @@ func adjustBigIntConst(ctx *blockCtx, v *gox.Element, t *types.Basic) { } } -func adjustIntConst(ctx *blockCtx, v *gox.Element, typ types.Type) { +func adjustIntConst(ctx *blockCtx, v *gogen.Element, typ types.Type) { if e := v.CVal; e == nil || e.Kind() != constant.Int { return } @@ -691,7 +691,7 @@ func typeCastIndex(ctx *blockCtx, lhs bool) { } } -func castFnPtrType(cb *gox.CodeBuilder, from, to types.Type, v *gox.Element) { +func castFnPtrType(cb *gogen.CodeBuilder, from, to types.Type, v *gogen.Element) { pkg := cb.Pkg() fn := types.NewParam(token.NoPos, pkg.Types, "_cgo_fn", from) ret := types.NewParam(token.NoPos, pkg.Types, "", to) @@ -702,7 +702,7 @@ func castFnPtrType(cb *gox.CodeBuilder, from, to types.Type, v *gox.Element) { End().Val(v).Call(1) } -func castPtrType(cb *gox.CodeBuilder, typ types.Type, v interface{}) { +func castPtrType(cb *gogen.CodeBuilder, typ types.Type, v interface{}) { cb.Typ(typ).Typ(ctypes.UnsafePointer).Val(v).Call(1).Call(1) } diff --git a/cl/compile.go b/cl/compile.go index 55f3511..42da27a 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -12,7 +12,7 @@ import ( "github.com/goplus/c2go/clang/ast" "github.com/goplus/c2go/clang/cmod" "github.com/goplus/c2go/clang/types/parser" - "github.com/goplus/gox" + "github.com/goplus/gogen" ctypes "github.com/goplus/c2go/clang/types" ) @@ -107,7 +107,7 @@ const ( // ----------------------------------------------------------------------------- type typeDecl struct { - *gox.TypeDecl + *gogen.TypeDecl defineHere func() } @@ -117,7 +117,7 @@ type PkgInfo struct { } type Package struct { - *gox.Package + *gogen.Package pi *PkgInfo } @@ -204,7 +204,7 @@ func NewPackage(pkgPath, pkgName string, file *ast.Node, conf *Config) (pkg Pack pkg = reused.pkg } else { interp := &nodeInterp{} - confGox := &gox.Config{ + confGox := &gogen.Config{ Fset: conf.Fset, Importer: conf.Importer, LoadNamed: nil, @@ -214,7 +214,7 @@ func NewPackage(pkgPath, pkgName string, file *ast.Node, conf *Config) (pkg Pack CanImplicitCast: implicitCast, DefaultGoFile: headerGoFile, } - pkg.Package = gox.NewPackage(pkgPath, pkgName, confGox) + pkg.Package = gogen.NewPackage(pkgPath, pkgName, confGox) interp.fset = pkg.Fset } pkg.SetRedeclarable(true) @@ -222,7 +222,7 @@ func NewPackage(pkgPath, pkgName string, file *ast.Node, conf *Config) (pkg Pack return } -func implicitCast(pkg *gox.Package, V, T types.Type, pv *gox.Element) bool { +func implicitCast(pkg *gogen.Package, V, T types.Type, pv *gogen.Element) bool { switch t := T.(type) { case *types.Basic: /* TODO: @@ -237,7 +237,7 @@ func implicitCast(pkg *gox.Package, V, T types.Type, pv *gox.Element) bool { return false } if (t.Info() & types.IsInteger) != 0 { // int type - if e, ok := gox.CastFromBool(pkg.CB(), T, pv); ok { + if e, ok := gogen.CastFromBool(pkg.CB(), T, pv); ok { pv.Type, pv.Val = T, e.Val return true } @@ -256,7 +256,7 @@ func implicitCast(pkg *gox.Package, V, T types.Type, pv *gox.Element) bool { // ----------------------------------------------------------------------------- -func loadFile(p *gox.Package, conf *Config, file *ast.Node) (pi *PkgInfo, err error) { +func loadFile(p *gogen.Package, conf *Config, file *ast.Node) (pi *PkgInfo, err error) { if file.Kind != ast.TranslationUnitDecl { return nil, syscall.EINVAL } @@ -267,7 +267,7 @@ func loadFile(p *gox.Package, conf *Config, file *ast.Node) (pi *PkgInfo, err er ctx := &blockCtx{ pkg: p, cb: p.CB(), fset: p.Fset, unnameds: make(map[ast.ID]unnamedType), - gblvars: make(map[string]*gox.VarDefs), + gblvars: make(map[string]*gogen.VarDefs), ignored: conf.Ignored, public: conf.Public, srcdir: filepath.Dir(srcFile), @@ -415,7 +415,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) { if tyRet := toType(ctx, fnType, parser.FlagGetRetType); ctypes.NotVoid(tyRet) { results = types.NewTuple(pkg.NewParam(token.NoPos, "", tyRet)) } - sig := gox.NewCSignature(types.NewTuple(params...), results, variadic) + sig := gogen.NewCSignature(types.NewTuple(params...), results, variadic) origName, rewritten := fnName, false if !ctx.inHeader && fn.StorageClass == ast.Static { fnName, rewritten = ctx.autoStaticName(origName), true @@ -505,11 +505,11 @@ func (p *blockCtx) getPubName(pfnName *string) (ok bool) { goName, ok := p.public[name] if ok { if goName == "" { - goName = gox.CPubName(name) + goName = gogen.CPubName(name) } } else if _, ok = p.autopub[name]; ok { p.public[name] = "" - goName = gox.CPubName(name) + goName = gogen.CPubName(name) } else { return } diff --git a/cl/compile_test.go b/cl/compile_test.go index 600cb32..318fdd5 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -16,7 +16,7 @@ import ( "github.com/goplus/c2go/clang/ast" "github.com/goplus/c2go/clang/parser" "github.com/goplus/c2go/clang/preprocessor" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -28,7 +28,7 @@ var ( func init() { SetDebug(DbgFlagAll) - gox.SetDebug(gox.DbgFlagAll) + gogen.SetDebug(gogen.DbgFlagAll) preprocessor.SetDebug(preprocessor.DbgFlagAll) home, err := os.UserHomeDir() @@ -81,7 +81,7 @@ func check(err error) { type testEnv struct { doc *ast.Node - pkg *gox.Package + pkg *gogen.Package ctx *blockCtx json []byte } @@ -89,7 +89,7 @@ type testEnv struct { func newTestEnv(code string) *testEnv { var json []byte doc, src := parse(code, &json) - p := gox.NewPackage("", "main", nil) + p := gogen.NewPackage("", "main", nil) ctx := &blockCtx{ pkg: p, cb: p.CB(), fset: p.Fset, src: src, unnameds: make(map[ast.ID]unnamedType), @@ -131,7 +131,7 @@ func testWith(t *testing.T, name string, fn string, code string, outFunc string, } pkg, err := NewPackage("", "main", doc, conf) check(err) - file := gox.ASTFile(pkg.Package) + file := gogen.ASTFile(pkg.Package) ret := goast.Node(file) if fn != "" { ret = findFunc(file, fn) diff --git a/cl/expr.go b/cl/expr.go index 3956b60..243ffb9 100644 --- a/cl/expr.go +++ b/cl/expr.go @@ -13,7 +13,7 @@ import ( ctypes "github.com/goplus/c2go/clang/types" "github.com/goplus/c2go/clang/ast" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -329,13 +329,13 @@ func compileCallExpr(ctx *blockCtx, v *ast.Node) { for i := 0; i < n; i++ { compileExpr(ctx, v.Inner[i]) } - var flags gox.InstrFlags + var flags gogen.InstrFlags var ellipsis = n > 2 && isVariadic(cb.Get(-n).Type) && isValist(cb.Get(-1).Type) if ellipsis { _, o := cb.Scope().LookupParent(valistName, token.NoPos) cb.InternalStack().Pop() cb.Val(o) - flags = gox.InstrFlagEllipsis + flags = gogen.InstrFlagEllipsis } cb.CallWith(n-1, flags, ctx.goNode(v)) } @@ -383,16 +383,16 @@ func compileMemberExpr(ctx *blockCtx, v *ast.Node, lhs bool) { if lhs { cb.MemberRef(name, src) } else { - _, err := cb.Member(name, gox.MemberFlagVal, src) + _, err := cb.Member(name, gogen.MemberFlagVal, src) if err != nil { // see aslong @ testdata/compoundlit.c if t, ok := checkAnonyUnion(cb.InternalStack().Get(-1).Type); ok { if stru, ok := t.Underlying().(*types.Struct); ok && stru.NumFields() == 1 { fld := stru.Field(0) - fields := []*gox.UnionField{ + fields := []*gogen.UnionField{ {Name: fld.Name(), Type: fld.Type()}, {Name: name, Type: toType(ctx, v.Type, 0)}, } - ctx.pkg.SetVFields(t, gox.NewUnionFields(fields)) + ctx.pkg.SetVFields(t, gogen.NewUnionFields(fields)) cb.MemberVal(name, src) return } @@ -567,7 +567,7 @@ func compileSimpleIncDec(ctx *blockCtx, op token.Token, v *ast.Node) { cb := ctx.cb stk := cb.InternalStack() compileExprLHS(ctx, v.Inner[0]) - typ, _ := gox.DerefType(stk.Get(-1).Type) + typ, _ := gogen.DerefType(stk.Get(-1).Type) if t, ok := typ.(*types.Pointer); ok { // *type cb.UnaryOp(token.AND) castPtrType(cb, tyUintptrPtr, stk.Pop()) @@ -601,7 +601,7 @@ func compileIncDec(ctx *blockCtx, op token.Token, v *ast.Node) { cb.Return(n).End().Call(0) } -func closureStartInitAddr(ctx *blockCtx, v *ast.Node) (*gox.CodeBuilder, *types.Var) { +func closureStartInitAddr(ctx *blockCtx, v *ast.Node) (*gogen.CodeBuilder, *types.Var) { pos := ctx.goNodePos(v) cb, ret := closureStart(ctx, pos, "_cgo_ret") cb.DefineVarStart(pos, addrVarName) @@ -610,13 +610,13 @@ func closureStartInitAddr(ctx *blockCtx, v *ast.Node) (*gox.CodeBuilder, *types. return cb, ret } -func closureStart(ctx *blockCtx, pos token.Pos, retName string) (*gox.CodeBuilder, *types.Var) { +func closureStart(ctx *blockCtx, pos token.Pos, retName string) (*gogen.CodeBuilder, *types.Var) { pkg := ctx.pkg ret := pkg.NewAutoParamEx(pos, retName) return ctx.cb.NewClosure(nil, types.NewTuple(ret), false).BodyStart(pkg), ret } -func closureStartT(ctx *blockCtx, pos token.Pos, t types.Type) (*gox.CodeBuilder, *types.Var) { +func closureStartT(ctx *blockCtx, pos token.Pos, t types.Type) (*gogen.CodeBuilder, *types.Var) { pkg := ctx.pkg ret := pkg.NewParam(pos, "", t) return ctx.cb.NewClosure(nil, types.NewTuple(ret), false).BodyStart(pkg), ret @@ -647,7 +647,7 @@ func compileConditionalOperator(ctx *blockCtx, v *ast.Node) { } } -func returnIf(notVoid bool, cb *gox.CodeBuilder, src goast.Node) { +func returnIf(notVoid bool, cb *gogen.CodeBuilder, src goast.Node) { if notVoid { cb.Return(1, src) } else { @@ -730,7 +730,7 @@ func compileAtomicExpr(ctx *blockCtx, v *ast.Node) { } } -func getCaller(cb *gox.CodeBuilder) (string, bool) { +func getCaller(cb *gogen.CodeBuilder) (string, bool) { v := cb.Get(-1) if e, ok := v.Val.(*goast.CallExpr); ok { if fn, ok := e.Fun.(*goast.Ident); ok { diff --git a/cl/multifiles.go b/cl/multifiles.go index c6870d0..8936062 100644 --- a/cl/multifiles.go +++ b/cl/multifiles.go @@ -12,7 +12,7 @@ import ( ctypes "github.com/goplus/c2go/clang/types" "github.com/goplus/c2go/clang/ast" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -31,7 +31,7 @@ type multiFileCtl struct { } // baseDir should be absolute path -func (p *multiFileCtl) initMultiFileCtl(pkg *gox.Package, baseDir string, conf *Config) { +func (p *multiFileCtl) initMultiFileCtl(pkg *gogen.Package, baseDir string, conf *Config) { reused := conf.Reused if reused != nil { pi := reused.pkg.pi @@ -184,13 +184,13 @@ type depPkgs struct { skipLibcH bool // skip libc header } -func initDepPkgs(pkg *gox.Package, deps *depPkgs) { +func initDepPkgs(pkg *gogen.Package, deps *depPkgs) { scope := pkg.Types.Scope() for _, dep := range deps.pkgs { depPkg := pkg.Import(dep.path) for _, pub := range dep.pubs { if obj := depPkg.TryRef(pub.goName); obj != nil { - if old := scope.Insert(gox.NewSubst(token.NoPos, pkg.Types, pub.name, obj)); old != nil { + if old := scope.Insert(gogen.NewSubst(token.NoPos, pkg.Types, pub.name, obj)); old != nil { log.Panicf("conflicted name `%v` in %v, previous definition is %v\n", pub.name, dep.path, old) } if t, ok := obj.Type().(*types.Named); ok { diff --git a/cl/multifiles_test.go b/cl/multifiles_test.go index 10991b0..6bc8875 100644 --- a/cl/multifiles_test.go +++ b/cl/multifiles_test.go @@ -3,12 +3,12 @@ package cl import ( "testing" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) func TestInitDepPkgs(t *testing.T) { testPanic(t, "conflicted name `printf` in github.com/goplus/c2go/cl/internal/libc, previous definition is var printf substType{real: func github.com/goplus/c2go/cl/internal/libc.Printf(fmt *int8, args ...interface{})}\n", func() { - pkg := gox.NewPackage("", "foo", nil) + pkg := gogen.NewPackage("", "foo", nil) dep := depPkg{ path: "github.com/goplus/c2go/cl/internal/libc", pubs: []pubName{{name: "printf", goName: "Printf"}}, diff --git a/cl/pkginfo.go b/cl/pkginfo.go index 4a2602c..8bebe1c 100644 --- a/cl/pkginfo.go +++ b/cl/pkginfo.go @@ -14,7 +14,7 @@ import ( ctypes "github.com/goplus/c2go/clang/types" "github.com/goplus/c2go/clang/ast" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -38,7 +38,7 @@ func (p Package) InitDependencies() { var uds []undefStruct for name, tdecl := range p.pi.typdecls { - if tdecl.State() == gox.TyStateUninited { + if tdecl.State() == gogen.TyStateUninited { uds = append(uds, undefStruct{name, tdecl}) } } @@ -67,7 +67,7 @@ func (p Package) InitDependencies() { switch t := scope.Lookup(uf).Type().(type) { case *types.Signature: sig = t - case *gox.SubstType: + case *gogen.SubstType: real := t.Real uf, sig = real.Name(), real.Type().(*types.Signature) } @@ -135,7 +135,7 @@ func loadPubFile(pubfile string) (pubs []pubName) { goName := "" switch len(flds) { case 1: - goName = gox.CPubName(flds[0]) + goName = gogen.CPubName(flds[0]) case 2: goName = flds[1] case 0: diff --git a/cl/stmt.go b/cl/stmt.go index 417f021..ca864bd 100644 --- a/cl/stmt.go +++ b/cl/stmt.go @@ -6,7 +6,7 @@ import ( "log" "github.com/goplus/c2go/clang/ast" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -156,7 +156,7 @@ func compileComplicatedIfStmt(ctx *blockCtx, stmt *ast.Node) { defer ctx.leave(flow) var done = flow.EndLabel(ctx) - var label *gox.Label + var label *gogen.Label if stmt.HasElse { label = flow.elseLabel(ctx) } else { @@ -320,8 +320,8 @@ func compileComplicatedSwitchStmt(ctx *blockCtx, switchStmt *ast.Node) { ctx.newVar(scope, token.NoPos, tag.Type, tagNamePrefix) ctx.newVar(scope, token.NoPos, types.Typ[types.Bool], notMatchedNamePrefix) - sw.tag = gox.Lookup(scope, tagNamePrefix) - sw.notmat = gox.Lookup(scope, notMatchedNamePrefix) + sw.tag = gogen.Lookup(scope, tagNamePrefix) + sw.notmat = gogen.Lookup(scope, notMatchedNamePrefix) cb := ctx.cb.VarRef(sw.tag).VarRef(sw.notmat).Val(tag).Val(true).Assign(2) @@ -469,11 +469,11 @@ func compileReturnStmt(ctx *blockCtx, stmt *ast.Node) { ctx.cb.Return(n, ctx.goNode(stmt)) } -func getRetType(cb *gox.CodeBuilder) types.Type { +func getRetType(cb *gogen.CodeBuilder) types.Type { return cb.Func().Type().(*types.Signature).Results().At(0).Type() } -func getRetTypeEx(cb *gox.CodeBuilder) (ret types.Type, ok bool) { +func getRetTypeEx(cb *gogen.CodeBuilder) (ret types.Type, ok bool) { results := cb.Func().Type().(*types.Signature).Results() if results.Len() == 1 { return results.At(0).Type(), true diff --git a/cl/type_and_var.go b/cl/type_and_var.go index 1fadb71..4340b32 100644 --- a/cl/type_and_var.go +++ b/cl/type_and_var.go @@ -12,7 +12,7 @@ import ( "github.com/goplus/c2go/clang/ast" "github.com/goplus/c2go/clang/types/parser" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -40,7 +40,7 @@ retry: if e, ok := err.(*parser.TypeNotFound); ok && e.StructOrUnion { name := e.Literal if pub { - name = gox.CPubName(name) + name = gogen.CPubName(name) } newStructOrUnionType(ctx, nil, name) if pub { @@ -69,7 +69,7 @@ func toAnonymType(ctx *blockCtx, src goast.Node, decl *ast.Node) (ret *types.Nam func checkFieldName(pname *string, pub bool) { if pub { - *pname = gox.CPubName(*pname) + *pname = gogen.CPubName(*pname) } else { avoidKeyword(pname) } @@ -254,7 +254,7 @@ func compileStructOrUnion(ctx *blockCtx, name string, decl *ast.Node, pub bool) if debugCompileDecl { log.Println(decl.TagUsed, name, "-", decl.Loc.PresumedLine) } - var t *gox.TypeDecl + var t *gogen.TypeDecl src := ctx.goNode(decl) pkg := ctx.pkg if ctx.inSrcFile() && decl.Name != "" { @@ -300,8 +300,8 @@ func compileEnum(ctx *blockCtx, decl *ast.Node, global bool) { } } -func compileEnumConst(ctx *blockCtx, cdecl *gox.ConstDefs, v *ast.Node, iotav int) int { - fn := func(cb *gox.CodeBuilder) int { +func compileEnumConst(ctx *blockCtx, cdecl *gogen.ConstDefs, v *ast.Node, iotav int) int { + fn := func(cb *gogen.CodeBuilder) int { if len(v.Inner) > 0 { compileExpr(ctx, v.Inner[0]) cval := cb.Get(-1).CVal @@ -366,16 +366,16 @@ func compileVarDecl(ctx *blockCtx, decl *ast.Node, global bool) { if rewritten { substObj(ctx.pkg.Types, ctx.cb.Scope(), origName, scope.Lookup(decl.Name)) } else if kind == parser.KindFVolatile && !global { - addr := gox.Lookup(scope, decl.Name) + addr := gogen.Lookup(scope, decl.Name) ctx.cb.VarRef(nil).Val(addr).Assign(1) // musl: use volatile to mark unused } } } func substObj(pkg *types.Package, scope *types.Scope, origName string, real types.Object) { - old := scope.Insert(gox.NewSubst(token.NoPos, pkg, origName, real)) + old := scope.Insert(gogen.NewSubst(token.NoPos, pkg, origName, real)) if old != nil { - if t, ok := old.Type().(*gox.SubstType); ok { + if t, ok := old.Type().(*gogen.SubstType); ok { t.Real = real } else { log.Panicln(origName, "redefined") @@ -443,7 +443,7 @@ func newVarAndInit(ctx *blockCtx, scope *types.Scope, typ types.Type, decl *ast. cb.EndInit(1) } } else if inVBlock { - addr := gox.Lookup(scope, decl.Name) + addr := gogen.Lookup(scope, decl.Name) ctx.cb.VarRef(addr).ZeroLit(typ).Assign(1) } } @@ -465,7 +465,7 @@ retry: } func varAssign(ctx *blockCtx, scope *types.Scope, typ types.Type, name string, initExpr *ast.Node) { - addr := gox.Lookup(scope, name) + addr := gogen.Lookup(scope, name) cb := ctx.cb.VarRef(addr) varInit(ctx, typ, initExpr) cb.Assign(1) @@ -528,17 +528,17 @@ func structLit(ctx *blockCtx, typ *types.Named, decl *ast.Node) { ctx.cb.StructLit(typ, n, false) } -func checkUnion(ctx *blockCtx, typ types.Type) (ufs *gox.UnionFields, is bool) { +func checkUnion(ctx *blockCtx, typ types.Type) (ufs *gogen.UnionFields, is bool) { if t, ok := typ.(*types.Named); ok { if vft, ok := ctx.pkg.VFields(t); ok { - ufs, is = vft.(*gox.UnionFields) + ufs, is = vft.(*gogen.UnionFields) return } } return nil, false } -func initUnionVar(ctx *blockCtx, name string, ufs *gox.UnionFields, decl *ast.Node) { +func initUnionVar(ctx *blockCtx, name string, ufs *gogen.UnionFields, decl *ast.Node) { initExpr := decl.Inner[0] t := toType(ctx, initExpr.Type, 0) for i, n := 0, ufs.Len(); i < n; i++ { @@ -546,7 +546,7 @@ func initUnionVar(ctx *blockCtx, name string, ufs *gox.UnionFields, decl *ast.No if ctypes.Identical(fld.Type, t) { pkg, cb := ctx.pkg, ctx.cb scope := cb.Scope() - obj := gox.Lookup(scope, name) + obj := gogen.Lookup(scope, name) global := scope == pkg.Types.Scope() if global { pkg.NewFunc(nil, "init", nil, nil, false).BodyStart(pkg) @@ -570,7 +570,7 @@ const ( ncKindSignature ) -func checkNilComparable(v *gox.Element) int { +func checkNilComparable(v *gogen.Element) int { switch t := v.Type.(type) { case *types.Pointer: return ncKindPointer diff --git a/cl/type_and_var_test.go b/cl/type_and_var_test.go index 20467be..08425db 100644 --- a/cl/type_and_var_test.go +++ b/cl/type_and_var_test.go @@ -6,7 +6,7 @@ import ( "testing" ctypes "github.com/goplus/c2go/clang/types" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -78,7 +78,7 @@ func newStrucT(pkg *types.Package, flds []structFld) *types.Struct { func newBftype(typ types.Type, fldName, name string, off, bits int, first bool) *bfType { return &bfType{ Type: typ, - BitField: &gox.BitField{ + BitField: &gogen.BitField{ Name: name, FldName: fldName, Off: off, diff --git a/clang/types/parser/parser.go b/clang/types/parser/parser.go index 775706c..bb9b99a 100644 --- a/clang/types/parser/parser.go +++ b/clang/types/parser/parser.go @@ -11,7 +11,7 @@ import ( ctypes "github.com/goplus/c2go/clang/types" "github.com/goplus/c2go/clang/types/scanner" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) const ( @@ -192,7 +192,7 @@ const ( func (p *parser) lookupType(tylit string, flags int) (t types.Type, err error) { structOrUnion := (flags & flagStructOrUnion) != 0 - _, o := gox.LookupParent(p.scope, tylit, token.NoPos) + _, o := gogen.LookupParent(p.scope, tylit, token.NoPos) if o == nil { return nil, &TypeNotFound{Literal: tylit, StructOrUnion: structOrUnion} } diff --git a/clang/types/scanner/scanner.go b/clang/types/scanner/scanner.go index a0082e7..2610f66 100644 --- a/clang/types/scanner/scanner.go +++ b/clang/types/scanner/scanner.go @@ -11,13 +11,11 @@ import ( // encountered and a handler was installed, the handler is called with a // position and an error message. The position points to the beginning of // the offending token. -// type ErrorHandler func(pos token.Position, msg string) // A Scanner holds the scanner's internal state while processing // a given text. It can be allocated as part of another data // structure but must be initialized via Init before use. -// type Scanner struct { // immutable state src string diff --git a/clang/types/types.go b/clang/types/types.go index 0846ef9..5912cf5 100644 --- a/clang/types/types.go +++ b/clang/types/types.go @@ -5,7 +5,7 @@ import ( "go/types" "unsafe" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) // ----------------------------------------------------------------------------- @@ -35,7 +35,7 @@ func MangledName(tag, name string) string { var ( ValistTag types.Type - Valist types.Type = types.NewSlice(gox.TyEmptyInterface) + Valist types.Type = types.NewSlice(gogen.TyEmptyInterface) ) func init() { @@ -47,7 +47,7 @@ func init() { // ----------------------------------------------------------------------------- func NewFunc(params, results *types.Tuple, variadic bool) *types.Signature { - return gox.NewCSignature(params, results, variadic) + return gogen.NewCSignature(params, results, variadic) } func NewPointer(typ types.Type) types.Type { @@ -57,7 +57,7 @@ func NewPointer(typ types.Type) types.Type { return types.Typ[types.UnsafePointer] } case *types.Signature: - if gox.IsCSignature(t) { + if gogen.IsCSignature(t) { return types.NewSignature(nil, t.Params(), t.Results(), t.Variadic()) } case *types.Named: @@ -71,7 +71,7 @@ func NewPointer(typ types.Type) types.Type { func IsFunc(typ types.Type) bool { sig, ok := typ.(*types.Signature) if ok { - ok = gox.IsCSignature(sig) + ok = gogen.IsCSignature(sig) } return ok } diff --git a/cmd/c2go/impl/c2go.go b/cmd/c2go/impl/c2go.go index d06a76d..e029443 100644 --- a/cmd/c2go/impl/c2go.go +++ b/cmd/c2go/impl/c2go.go @@ -7,7 +7,7 @@ import ( "github.com/goplus/c2go" "github.com/goplus/c2go/cl" "github.com/goplus/c2go/clang/preprocessor" - "github.com/goplus/gox" + "github.com/goplus/gogen" ) const ( @@ -49,7 +49,7 @@ func Main(flag *flag.FlagSet, args []string) { if *verbose { cl.SetDebug(cl.DbgFlagAll) preprocessor.SetDebug(preprocessor.DbgFlagAll) - gox.SetDebug(gox.DbgFlagInstruction) // | gox.DbgFlagMatch) + gogen.SetDebug(gogen.DbgFlagInstruction) // | gogen.DbgFlagMatch) } if *test || *runcmd != "" { flags |= c2go.FlagRunTest diff --git a/go.mod b/go.mod index af22386..1557feb 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/goplus/c2go go 1.18 require ( - github.com/goplus/gox v1.14.13-0.20240221041432-a29adc8f26fd - github.com/goplus/mod v0.13.8 + github.com/goplus/gogen v1.15.0 + github.com/goplus/mod v0.13.9 github.com/json-iterator/go v1.1.12 github.com/qiniu/x v1.13.9 ) @@ -12,8 +12,8 @@ require ( require ( github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - golang.org/x/mod v0.15.0 // indirect - golang.org/x/tools v0.18.0 // indirect + golang.org/x/mod v0.16.0 // indirect + golang.org/x/tools v0.19.0 // indirect ) retract v0.7.15 diff --git a/go.sum b/go.sum index 440cc75..8ca9b5c 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/goplus/gox v1.14.13-0.20240221041432-a29adc8f26fd h1:DZsCu/zgtGKDwp6MBjRRrmSvZRktI/Fs6TYS8O8pKVs= -github.com/goplus/gox v1.14.13-0.20240221041432-a29adc8f26fd/go.mod h1:6b6XYHmyiCevhwuEHcV/jzm7Z2FXLDBhuxgvkjceA+o= -github.com/goplus/mod v0.13.8 h1:5PbALN7GjvpQidAx2qiE3x/Bgf+ZHPrVZ3C63dfjGrA= -github.com/goplus/mod v0.13.8/go.mod h1:7/8zsNzGWyB4Qojg+D7SxSgMzpcsDbZsbKo2SHy4Lwk= +github.com/goplus/gogen v1.15.0 h1:mQphpjiw/Fka46lEVnDSWwql3s6VF9VGjKc0EohlEYI= +github.com/goplus/gogen v1.15.0/go.mod h1:92qEzVgv7y8JEFICWG9GvYI5IzfEkxYdsA1DbmnTkqk= +github.com/goplus/mod v0.13.9 h1:B9zZoHi2AzMltTSOFqZNVjqGlSMlhhNTWwEzVqhTQzg= +github.com/goplus/mod v0.13.9/go.mod h1:MibsLSftGmxaQq78YzUzNviyFwB9RtpMaoscufvEKH4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= @@ -26,8 +26,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -63,6 +63,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proj.go b/proj.go index 085b201..4528b69 100644 --- a/proj.go +++ b/proj.go @@ -28,8 +28,8 @@ import ( "github.com/goplus/c2go/clang/parser" "github.com/goplus/c2go/clang/pathutil" "github.com/goplus/c2go/clang/preprocessor" - "github.com/goplus/gox" - "github.com/goplus/gox/cpackages" + "github.com/goplus/gogen" + "github.com/goplus/gogen/cpackages" jsoniter "github.com/json-iterator/go" ) @@ -243,7 +243,7 @@ func execProjDone(base string, flags int, conf *c2goConf) { if pkg := conf.Reused.Pkg(); pkg.IsValid() { dir := pathutil.Canonical(base, conf.Target.Dir) os.MkdirAll(dir, 0777) - pkg.ForEachFile(func(fname string, file *gox.File) { + pkg.ForEachFile(func(fname string, file *gogen.File) { gofile := fname if strings.HasPrefix(fname, "_") { gofile = "x2g" + fname