Implemented package specific structs

This commit is contained in:
Eduard Urbach 2025-02-08 16:06:39 +01:00
parent d71bbd51cf
commit 8357aefc01
Signed by: eduard
GPG key ID: 49226B848C78F6C8
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]
}