Support recursive types
Этот коммит содержится в:
родитель
cad3e03f94
коммит
a475233f36
2 изменённых файлов: 13 добавлений и 4 удалений
14
compiler.go
14
compiler.go
|
@ -216,7 +216,16 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
|
||||||
|
|
||||||
var frames []*Frame
|
var frames []*Frame
|
||||||
|
|
||||||
// Declare all named (struct) types.
|
// Declare all named struct types.
|
||||||
|
for _, t := range c.ir.NamedTypes {
|
||||||
|
if named, ok := t.t.Type().(*types.Named); ok {
|
||||||
|
if _, ok := named.Underlying().(*types.Struct); ok {
|
||||||
|
t.llvmType = c.ctx.StructCreateNamed(named.Obj().Pkg().Path() + "." + named.Obj().Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define all named struct types.
|
||||||
for _, t := range c.ir.NamedTypes {
|
for _, t := range c.ir.NamedTypes {
|
||||||
if named, ok := t.t.Type().(*types.Named); ok {
|
if named, ok := t.t.Type().(*types.Named); ok {
|
||||||
if st, ok := named.Underlying().(*types.Struct); ok {
|
if st, ok := named.Underlying().(*types.Struct); ok {
|
||||||
|
@ -224,8 +233,7 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
llvmNamedType := c.ctx.StructCreateNamed(named.Obj().Pkg().Path() + "." + named.Obj().Name())
|
t.llvmType.StructSetBody(llvmType.StructElementTypes(), false)
|
||||||
llvmNamedType.StructSetBody(llvmType.StructElementTypes(), false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
ir.go
3
ir.go
|
@ -41,7 +41,8 @@ type Global struct {
|
||||||
|
|
||||||
// Type with a name and possibly methods.
|
// Type with a name and possibly methods.
|
||||||
type NamedType struct {
|
type NamedType struct {
|
||||||
t *ssa.Type
|
t *ssa.Type
|
||||||
|
llvmType llvm.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type that is at some point put in an interface.
|
// Type that is at some point put in an interface.
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче