Improved type system

This commit is contained in:
2025-02-17 14:31:47 +01:00
parent 3550f9e24e
commit b8e37fafae
62 changed files with 189 additions and 172 deletions

View File

@ -144,10 +144,6 @@ func (f *Function) ExpressionToRegister(node *expression.Expression, register cp
return nil, err
}
if typ == types.AnyPointer && right.Token.Kind == token.Identifier && f.VariableByName(right.Token.Text(f.File.Bytes)).Type == types.AnyPointer {
typ = types.Int
}
err = f.Execute(node.Token, register, right)
if register != final {
@ -155,5 +151,17 @@ func (f *Function) ExpressionToRegister(node *expression.Expression, register cp
f.FreeRegister(register)
}
_, isArray := typ.(*types.Array)
if isArray {
typ = types.AnyPointer
} else if right.Token.Kind == token.Identifier {
rightVariable := f.VariableByName(right.Token.Text(f.File.Bytes))
if typ == types.AnyPointer && rightVariable.Type == types.AnyPointer {
typ = types.Int
}
}
return typ, err
}