Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

gox v1.12.0 #198

Merged
merged 5 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions cl/blockctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,27 +502,27 @@ func (p *bfType) String() string {
}

/*
func (p *blockCtx) initCTypes() {
pkg := p.pkg.Types
scope := pkg.Scope()
p.tyI128 = ctypes.NotImpl
p.tyU128 = ctypes.NotImpl
c := p.pkg.Import("github.com/goplus/c2go/clang")

aliasType(scope, pkg, "__int128", p.tyI128)
aliasType(scope, pkg, "void", ctypes.Void)

aliasCType(scope, pkg, "char", c, "Char")
aliasCType(scope, pkg, "float", c, "Float")
aliasCType(scope, pkg, "double", c, "Double")
aliasCType(scope, pkg, "_Bool", c, "Bool")

decl_builtin(p)
}
func (p *blockCtx) initCTypes() {
pkg := p.pkg.Types
scope := pkg.Scope()
p.tyI128 = ctypes.NotImpl
p.tyU128 = ctypes.NotImpl
c := p.pkg.Import("github.com/goplus/c2go/clang")

aliasType(scope, pkg, "__int128", p.tyI128)
aliasType(scope, pkg, "void", ctypes.Void)

aliasCType(scope, pkg, "char", c, "Char")
aliasCType(scope, pkg, "float", c, "Float")
aliasCType(scope, pkg, "double", c, "Double")
aliasCType(scope, pkg, "_Bool", c, "Bool")

decl_builtin(p)
}

func aliasCType(scope *types.Scope, pkg *types.Package, name string, c *gox.PkgRef, cname string) {
aliasType(scope, pkg, name, c.Ref(cname).Type())
}
func aliasCType(scope *types.Scope, pkg *types.Package, name string, c *gox.PkgRef, cname string) {
aliasType(scope, pkg, name, c.Ref(cname).Type())
}
*/
func (p *blockCtx) initCTypes() {
pkg := p.pkg.Types
Expand All @@ -531,6 +531,9 @@ func (p *blockCtx) initCTypes() {
p.tyU128 = ctypes.NotImpl

aliasType(scope, pkg, "__int128", p.tyI128)
aliasType(scope, pkg, "__int128_t", p.tyI128)
aliasType(scope, pkg, "__uint128_t", p.tyU128)

aliasType(scope, pkg, "void", ctypes.Void)

aliasType(scope, pkg, "char", types.Typ[types.Int8])
Expand Down
8 changes: 4 additions & 4 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func NewPackage(pkgPath, pkgName string, file *ast.Node, conf *Config) (pkg Pack
pkg.Package = gox.NewPackage(pkgPath, pkgName, confGox)
interp.fset = pkg.Fset
}
pkg.SetVarRedeclarable(true)
pkg.SetRedeclarable(true)
pkg.pi, err = loadFile(pkg.Package, conf, file)
return
}
Expand Down Expand Up @@ -402,7 +402,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) {
ast.AlwaysInlineAttr, ast.WarnUnusedResultAttr, ast.NoThrowAttr, ast.NoInlineAttr, ast.AllocSizeAttr,
ast.NonNullAttr, ast.ConstAttr, ast.PureAttr, ast.GNUInlineAttr, ast.ReturnsTwiceAttr, ast.NoSanitizeAttr,
ast.RestrictAttr, ast.MSAllocatorAttr, ast.VisibilityAttr, ast.C11NoReturnAttr, ast.StrictFPAttr,
ast.AllocAlignAttr, ast.DisableTailCallsAttr:
ast.AllocAlignAttr, ast.DisableTailCallsAttr, ast.FormatArgAttr:
default:
log.Panicln("compileFunc: unknown kind =", item.Kind)
}
Expand Down Expand Up @@ -436,7 +436,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) {
}
if rewritten { // for fnName is a recursive function
scope := pkg.Types.Scope()
substObj(pkg.Types, scope, origName, f.Func)
substObj(pkg.Types, scope, origName, f.Obj())
rewritten = false
}
cb := f.BodyStart(pkg)
Expand Down Expand Up @@ -468,7 +468,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) {
cb.Val(pkg.Import("os").Ref("Exit")).Typ(types.Typ[types.Int])
}
}
cb.Val(f.Func)
cb.Val(f.Obj())
if params != nil {
panic("TODO: main func with params")
}
Expand Down
1 change: 0 additions & 1 deletion cl/multifiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func (p *blockCtx) logFile(node *ast.Node) {
}
}
}
return
}

func (p *blockCtx) checkExists(name string) (exist bool) {
Expand Down
3 changes: 2 additions & 1 deletion cl/stmtchk.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ func (at *blockMarkCtx) markComplicated(ctx *markCtx, ref *blockMarkCtx) {
}
}

/*
func (at *blockMarkCtx) getName() string {
if at != nil {
return at.name
}
return "funcBody"
}
*/

func (at *blockMarkCtx) depth() (n int) {
for at != nil {
Expand Down Expand Up @@ -265,7 +267,6 @@ func (p *markCtx) markSwitch(ctx *blockCtx, switchStmt *ast.Node) {
p.mark(ctx, caseBody)
}
}
return
}

func (p *markCtx) markEnd() {
Expand Down
2 changes: 2 additions & 0 deletions cl/type_and_var.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,11 @@ func isNumber(typ types.Type) bool {
return isKind(typ, types.IsInteger|types.IsFloat)
}

/*
func isUnsigned(typ types.Type) bool {
return isKind(typ, types.IsUnsigned)
}
*/

func isInteger(typ types.Type) bool {
return isKind(typ, types.IsInteger)
Expand Down
1 change: 1 addition & 0 deletions clang/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
DeprecatedAttr Kind = "DeprecatedAttr"
BuiltinAttr Kind = "BuiltinAttr"
FormatAttr Kind = "FormatAttr"
FormatArgAttr Kind = "FormatArgAttr"
ColdAttr Kind = "ColdAttr"
ConstAttr Kind = "ConstAttr"
PureAttr Kind = "PureAttr"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/goplus/c2go
go 1.16

require (
github.com/goplus/gox v1.11.38
github.com/goplus/gox v1.12.0
github.com/goplus/mod v0.11.5
github.com/json-iterator/go v1.1.12
github.com/qiniu/x v1.13.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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.11.38 h1:znqKvaIOx/zpVBPpF5NNFO+DuQ/8UpvO0hIqFb45SlY=
github.com/goplus/gox v1.11.38/go.mod h1:QQfPGKVmtAzat6fDYE4V4PFo/v95zvrwB9M60tbqdMM=
github.com/goplus/gox v1.12.0 h1:VkQrIhVaKTYARQUUN+Q0+k8DtOXQqOvC6zaZP8wyG5E=
github.com/goplus/gox v1.12.0/go.mod h1:Ek4bXv4xzfBiFuHC6yfkzHXrhUHXfrM9QyXtMusdkGo=
github.com/goplus/mod v0.11.5 h1:3zcWlkLq/adU+y8GynZRMjSE50DfbnILdkRnToDaq24=
github.com/goplus/mod v0.11.5/go.mod h1:NDC5E+XOT8vcJCMjqKhLDJHTHX7lyVN4Vbfi2U7dBhs=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down
Loading