TestVar done
This commit is contained in:
@@ -19,8 +19,6 @@ package ssa
|
|||||||
import (
|
import (
|
||||||
"go/constant"
|
"go/constant"
|
||||||
"go/types"
|
"go/types"
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/goplus/llvm"
|
"github.com/goplus/llvm"
|
||||||
"golang.org/x/tools/go/types/typeutil"
|
"golang.org/x/tools/go/types/typeutil"
|
||||||
@@ -33,7 +31,7 @@ type Program struct {
|
|||||||
|
|
||||||
target *Target
|
target *Target
|
||||||
td llvm.TargetData
|
td llvm.TargetData
|
||||||
tm llvm.TargetMachine
|
// tm llvm.TargetMachine
|
||||||
|
|
||||||
intType llvm.Type
|
intType llvm.Type
|
||||||
int8Type llvm.Type
|
int8Type llvm.Type
|
||||||
@@ -88,6 +86,11 @@ func (p *Package) NewFunc(name string, sig *types.Signature) *Function {
|
|||||||
return &Function{}
|
return &Function{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Package) String() string {
|
||||||
|
return p.mod.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
type CodeGenFileType = llvm.CodeGenFileType
|
type CodeGenFileType = llvm.CodeGenFileType
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -125,3 +128,4 @@ func (p *Package) WriteFile(file string) (err error) {
|
|||||||
defer f.Close()
|
defer f.Close()
|
||||||
return llvm.WriteBitcodeToFile(p.mod, f)
|
return llvm.WriteBitcodeToFile(p.mod, f)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func assertPkg(t *testing.T, p *Package) {
|
/*
|
||||||
|
func asmPkg(t *testing.T, p *Package) {
|
||||||
b, err := p.CodeGen(AssemblyFile)
|
b, err := p.CodeGen(AssemblyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("ctx.ParseIR:", err)
|
t.Fatal("ctx.ParseIR:", err)
|
||||||
@@ -30,10 +31,21 @@ func assertPkg(t *testing.T, p *Package) {
|
|||||||
t.Log(v)
|
t.Log(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func assertPkg(t *testing.T, p *Package, expected string) {
|
||||||
|
if v := p.String(); v != expected {
|
||||||
|
t.Fatalf("\n==> got:\n%s\n==> expected:\n%s\n", v, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestVar(t *testing.T) {
|
func TestVar(t *testing.T) {
|
||||||
prog := NewProgram(nil)
|
prog := NewProgram(nil)
|
||||||
pkg := prog.NewPackage("foo", "foo")
|
pkg := prog.NewPackage("bar", "foo/bar")
|
||||||
pkg.NewVar("a", types.Typ[types.Int])
|
pkg.NewVar("a", types.Typ[types.Int])
|
||||||
assertPkg(t, pkg)
|
assertPkg(t, pkg, `; ModuleID = 'foo/bar'
|
||||||
|
source_filename = "foo/bar"
|
||||||
|
|
||||||
|
@a = external global i64
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/goplus/llvm"
|
"github.com/goplus/llvm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,6 +34,7 @@ type Target struct {
|
|||||||
GOARM string // "5", "6", "7" (default)
|
GOARM string // "5", "6", "7" (default)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (p *Program) targetMachine() llvm.TargetMachine {
|
func (p *Program) targetMachine() llvm.TargetMachine {
|
||||||
if p.tm.C == nil {
|
if p.tm.C == nil {
|
||||||
spec := p.target.toSpec()
|
spec := p.target.toSpec()
|
||||||
@@ -150,3 +149,4 @@ func (p *Target) toSpec() (spec targetSpec) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user