mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-24 22:39:04 +00:00
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:
committed by
Ron Evans
parent
88bb61f287
commit
6b5b4a681d
@@ -26,7 +26,6 @@ type Program struct {
|
||||
Globals []*Global
|
||||
globalMap map[*ssa.Global]*Global
|
||||
comments map[string]*ast.CommentGroup
|
||||
NamedTypes []*NamedType
|
||||
}
|
||||
|
||||
// Function or method.
|
||||
@@ -50,19 +49,6 @@ type Global struct {
|
||||
extern bool // go:extern
|
||||
}
|
||||
|
||||
// Type with a name and possibly methods.
|
||||
type NamedType struct {
|
||||
*ssa.Type
|
||||
LLVMType llvm.Type
|
||||
}
|
||||
|
||||
// Type that is at some point put in an interface.
|
||||
type TypeWithMethods struct {
|
||||
t types.Type
|
||||
Num int
|
||||
Methods map[string]*types.Selection
|
||||
}
|
||||
|
||||
// Interface type that is at some point used in a type assert (to check whether
|
||||
// it implements another interface).
|
||||
type Interface struct {
|
||||
@@ -210,8 +196,6 @@ func (p *Program) AddPackage(pkg *ssa.Package) {
|
||||
case *ssa.Function:
|
||||
p.addFunction(member)
|
||||
case *ssa.Type:
|
||||
t := &NamedType{Type: member}
|
||||
p.NamedTypes = append(p.NamedTypes, t)
|
||||
methods := getAllMethods(pkg.Prog, member.Type())
|
||||
if !types.IsInterface(member.Type()) {
|
||||
// named type
|
||||
|
||||
Reference in New Issue
Block a user