llgo/internal/runtime
This commit is contained in:
@@ -90,10 +90,17 @@ func Initialize(flags InitFlags) {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type Runtime interface {
|
||||
Runtime() *types.Package
|
||||
}
|
||||
|
||||
type aProgram struct {
|
||||
ctx llvm.Context
|
||||
typs typeutil.Map
|
||||
|
||||
rt *types.Scope
|
||||
rtget Runtime
|
||||
|
||||
target *Target
|
||||
td llvm.TargetData
|
||||
// tm llvm.TargetMachine
|
||||
@@ -107,6 +114,7 @@ type aProgram struct {
|
||||
voidType llvm.Type
|
||||
voidPtrTy llvm.Type
|
||||
|
||||
anyTy Type
|
||||
voidTy Type
|
||||
boolTy Type
|
||||
intTy Type
|
||||
@@ -128,6 +136,18 @@ func NewProgram(target *Target) Program {
|
||||
return &aProgram{ctx: ctx, target: target, td: td}
|
||||
}
|
||||
|
||||
// SetRuntime sets the runtime package.
|
||||
func (p Program) SetRuntime(runtime Runtime) {
|
||||
p.rtget = runtime
|
||||
}
|
||||
|
||||
func (p Program) runtime() *types.Scope {
|
||||
if p.rt == nil {
|
||||
p.rt = p.rtget.Runtime().Scope()
|
||||
}
|
||||
return p.rt
|
||||
}
|
||||
|
||||
// NewPackage creates a new package.
|
||||
func (p Program) NewPackage(name, pkgPath string) Package {
|
||||
mod := p.ctx.NewModule(pkgPath)
|
||||
@@ -154,6 +174,13 @@ func (p Program) Bool() Type {
|
||||
return p.boolTy
|
||||
}
|
||||
|
||||
func (p Program) Any() Type {
|
||||
if p.anyTy == nil {
|
||||
p.anyTy = p.Type(tyAny)
|
||||
}
|
||||
return p.anyTy
|
||||
}
|
||||
|
||||
// Int returns int type.
|
||||
func (p Program) Int() Type {
|
||||
if p.intTy == nil {
|
||||
|
||||
Reference in New Issue
Block a user