diff --git a/internal/lib/math/math.go b/internal/lib/math/math.go index 588cbae5..be6f1c8d 100644 --- a/internal/lib/math/math.go +++ b/internal/lib/math/math.go @@ -22,6 +22,10 @@ import ( "github.com/goplus/llgo/c" ) +const ( + LLGoPackage = true +) + //go:linkname Acos C.acos func Acos(x float64) float64 diff --git a/ssa/decl.go b/ssa/decl.go index caffa5fe..9e4a6ca6 100644 --- a/ssa/decl.go +++ b/ssa/decl.go @@ -26,13 +26,6 @@ import ( // ----------------------------------------------------------------------------- -const ( - ClosureCtx = "__llgo_ctx" - ClosureStub = "__llgo_stub." -) - -// ----------------------------------------------------------------------------- - const ( NameValist = "__llgo_va_list" ) diff --git a/ssa/package.go b/ssa/package.go index 9ef00f79..2a04994f 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -564,6 +564,11 @@ func (p Package) cFunc(fullName string, sig *types.Signature) Expr { return p.NewFunc(fullName, sig, InC).Expr } +const ( + closureCtx = "__llgo_ctx" + closureStub = "__llgo_stub." +) + func (p Package) closureStub(b Builder, t *types.Struct, v Expr) Expr { name := v.impl.Name() prog := b.Prog @@ -574,9 +579,9 @@ func (p Package) closureStub(b Builder, t *types.Struct, v Expr) Expr { sig := v.raw.Type.(*types.Signature) n := sig.Params().Len() nret := sig.Results().Len() - ctx := types.NewParam(token.NoPos, nil, ClosureCtx, types.Typ[types.UnsafePointer]) + ctx := types.NewParam(token.NoPos, nil, closureCtx, types.Typ[types.UnsafePointer]) sig = FuncAddCtx(ctx, sig) - fn := p.NewFunc(ClosureStub+name, sig, InC) + fn := p.NewFunc(closureStub+name, sig, InC) fn.impl.SetLinkage(llvm.LinkOnceAnyLinkage) args := make([]Expr, n) for i := 0; i < n; i++ { diff --git a/ssa/type_cvt.go b/ssa/type_cvt.go index a9314a68..299a0970 100644 --- a/ssa/type_cvt.go +++ b/ssa/type_cvt.go @@ -133,7 +133,7 @@ func (p goTypes) cvtNamed(t *types.Named) (raw *types.Named, cvt bool) { } func (p goTypes) cvtClosure(sig *types.Signature) *types.Struct { - ctx := types.NewParam(token.NoPos, nil, ClosureCtx, types.Typ[types.UnsafePointer]) + ctx := types.NewParam(token.NoPos, nil, closureCtx, types.Typ[types.UnsafePointer]) raw := p.cvtFunc(sig, ctx) flds := []*types.Var{ types.NewField(token.NoPos, nil, "f", raw, false),