compiler: refactor named types to create them lazily

This commit refactors named types to be created lazily. Instead of
defining all types in advance, do it only when necessary.
This commit is contained in:
Ayke van Laethem
2019-06-07 21:04:56 +02:00
committed by Ron Evans
parent 88bb61f287
commit 6b5b4a681d
9 changed files with 51 additions and 63 deletions
+2 -2
View File
@@ -163,8 +163,8 @@ func (c *Compiler) LowerInterfaces() {
// run runs the pass itself.
func (p *lowerInterfacesPass) run() {
// Collect all type codes.
typecodeIDPtr := llvm.PointerType(p.mod.GetTypeByName("runtime.typecodeID"), 0)
typeInInterfacePtr := llvm.PointerType(p.mod.GetTypeByName("runtime.typeInInterface"), 0)
typecodeIDPtr := llvm.PointerType(p.getLLVMRuntimeType("typecodeID"), 0)
typeInInterfacePtr := llvm.PointerType(p.getLLVMRuntimeType("typeInInterface"), 0)
var typesInInterfaces []llvm.Value
for global := p.mod.FirstGlobal(); !global.IsNil(); global = llvm.NextGlobal(global) {
switch global.Type() {