compiler: refactor typeinfo functions

This commit is contained in:
Evgenii Stratonikov 2020-05-13 18:09:55 +03:00
parent b9b1066435
commit 70d0ff869d
4 changed files with 93 additions and 114 deletions

View file

@ -191,7 +191,11 @@ func (c *codegen) scReturnTypeFromScope(scope *funcScope) string {
}
func (c *codegen) scTypeFromExpr(typ ast.Expr) string {
switch t := c.typeInfo.Types[typ].Type.(type) {
t := c.typeOf(typ)
if c.typeOf(typ) == nil {
return "Any"
}
switch t := t.Underlying().(type) {
case *types.Basic:
info := t.Info()
switch {
@ -209,7 +213,7 @@ func (c *codegen) scTypeFromExpr(typ ast.Expr) string {
case *types.Struct:
return "Struct"
case *types.Slice:
if isByteArrayType(t) {
if isByte(t.Elem()) {
return "ByteArray"
}
return "Array"