Implemented package specific structs

This commit is contained in:
2025-02-08 16:06:39 +01:00
parent 91bafc0867
commit 97cdcbd1cb
15 changed files with 121 additions and 78 deletions

36
src/types/ByName.go Normal file
View File

@ -0,0 +1,36 @@
package types
import (
"strings"
)
// ByName returns the type with the given name or `nil` if it doesn't exist.
func ByName(name string, pkg string, structs map[string]*Struct) Type {
if strings.HasPrefix(name, "*") {
to := strings.TrimPrefix(name, "*")
return &Pointer{To: ByName(to, pkg, structs)}
}
switch name {
case "Int":
return Int
case "Int64":
return Int64
case "Int32":
return Int32
case "Int16":
return Int16
case "Int8":
return Int8
case "Float":
return Float
case "Float64":
return Float64
case "Float32":
return Float32
case "Pointer":
return PointerAny
}
return structs[pkg+"."+name]
}