Added array type
This commit is contained in:
@ -26,6 +26,10 @@ func (f *Function) CompileReturn(node *ast.Return) error {
|
||||
}
|
||||
|
||||
if !types.Is(typ, f.Output[i].Type) {
|
||||
if f.Package == "mem" && f.Name == "alloc" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New(&errors.TypeMismatch{
|
||||
Encountered: typ.Name(),
|
||||
Expected: f.Output[i].Type.Name(),
|
||||
|
@ -18,12 +18,12 @@ func (f *Function) ExpressionToMemory(node *expression.Expression, memory asm.Me
|
||||
if variable != nil {
|
||||
f.MemoryRegister(asm.STORE, memory, variable.Register)
|
||||
f.UseVariable(variable)
|
||||
return types.PointerAny, nil
|
||||
return types.AnyPointer, nil
|
||||
}
|
||||
|
||||
if function != nil {
|
||||
f.MemoryLabel(asm.STORE, memory, function.UniqueName)
|
||||
return types.PointerAny, nil
|
||||
return types.AnyPointer, nil
|
||||
}
|
||||
|
||||
return nil, errors.New(&errors.UnknownIdentifier{Name: name}, f.File, node.Token.Position)
|
||||
|
@ -83,7 +83,7 @@ func (f *Function) ExpressionToRegister(node *expression.Expression, register cp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if typ == types.PointerAny && right.Token.Kind == token.Identifier && f.VariableByName(right.Token.Text(f.File.Bytes)).Type == types.PointerAny {
|
||||
if typ == types.AnyPointer && right.Token.Kind == token.Identifier && f.VariableByName(right.Token.Text(f.File.Bytes)).Type == types.AnyPointer {
|
||||
typ = types.Int
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) (types.
|
||||
if function != nil {
|
||||
f.SaveRegister(register)
|
||||
f.RegisterLabel(asm.MOVE, register, function.UniqueName)
|
||||
return types.PointerAny, nil
|
||||
return types.AnyPointer, nil
|
||||
}
|
||||
|
||||
return nil, errors.New(&errors.UnknownIdentifier{Name: name}, f.File, t.Position)
|
||||
@ -55,7 +55,7 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) (types.
|
||||
label := f.AddBytes(slice)
|
||||
f.SaveRegister(register)
|
||||
f.RegisterLabel(asm.MOVE, register, label)
|
||||
return types.PointerAny, nil
|
||||
return types.String, nil
|
||||
|
||||
default:
|
||||
return nil, errors.New(errors.InvalidExpression, f.File, t.Position)
|
||||
|
Reference in New Issue
Block a user