Change the location at which defined IR types are wrapped
Defined IR types are wrapped in a TypeDefined by generateTypeNamed. This causes them to be sent through GEP, which is necessary for testing.
This commit is contained in:
parent
4878c62531
commit
ea697c19dd
|
@ -65,17 +65,14 @@ func (this *generator) generate () (*llvm.Module, error) {
|
|||
func (this *generator) typedef (typeName string) (llvm.Type, error) {
|
||||
for _, ty := range this.module.Types {
|
||||
if ty.Name() == typeName {
|
||||
return &llvm.TypeDefined { Source: ty }, nil
|
||||
return ty, nil
|
||||
}
|
||||
}
|
||||
def, exists := this.tree.Types[typeName]
|
||||
if !exists {
|
||||
return nil, errNotFound
|
||||
}
|
||||
|
||||
ty, err := this.generateTypedef(def)
|
||||
if err != nil { return nil, err }
|
||||
return &llvm.TypeDefined { Source: ty }, nil
|
||||
return this.generateTypedef(def)
|
||||
}
|
||||
|
||||
func (this *generator) method (typeName string, name string) (*llvm.Function, error) {
|
||||
|
|
|
@ -7,7 +7,9 @@ import "git.tebibyte.media/sashakoshka/fspl/llvm"
|
|||
import "git.tebibyte.media/sashakoshka/fspl/entity"
|
||||
|
||||
func (this *generator) generateTypeNamed (ty *entity.TypeNamed) (llvm.Type, error) {
|
||||
return this.typedef(ty.Name)
|
||||
underlying, err := this.typedef(ty.Name)
|
||||
if err != nil { return nil, err }
|
||||
return &llvm.TypeDefined { Source: underlying }, nil
|
||||
}
|
||||
|
||||
func (this *generator) generateTypePointer (ty *entity.TypePointer) (llvm.Type, error) {
|
||||
|
|
|
@ -173,6 +173,8 @@ func resultType (elemType, src Type, indices []gepIndex) Type {
|
|||
panic(fmt.Errorf("unable to index into struct type `%v` using gep with non-constant index", e))
|
||||
}
|
||||
e = elm.Fields[index.Val]
|
||||
case *TypeDefined:
|
||||
continue
|
||||
default:
|
||||
panic(fmt.Errorf("cannot index into type %T using gep", e))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue