Improved type system

This commit is contained in:
2025-02-09 23:52:07 +01:00
parent 7634244c56
commit f19d9063a5
30 changed files with 132 additions and 85 deletions

View File

@ -10,25 +10,27 @@ func ByName(name string, pkg string, structs map[string]*Struct) Type {
to := strings.TrimPrefix(name, "*")
typ := ByName(to, pkg, structs)
if typ != nil {
return &Pointer{To: typ}
if typ == Any {
return AnyPointer
}
return nil
return &Pointer{To: typ}
}
if strings.HasPrefix(name, "[]") {
to := strings.TrimPrefix(name, "[]")
typ := ByName(to, pkg, structs)
if typ != nil {
return &Array{Of: typ}
if typ == Any {
return AnyArray
}
return nil
return &Array{Of: typ}
}
switch name {
case "Any":
return Any
case "Int":
return Int
case "Int64":
@ -45,8 +47,6 @@ func ByName(name string, pkg string, structs map[string]*Struct) Type {
return Float64
case "Float32":
return Float32
case "Pointer":
return AnyPointer
}
typ, exists := structs[pkg+"."+name]