Added Value type
This commit is contained in:
@ -58,20 +58,24 @@ func (f *Function) CompileAssignDivision(expr *expression.Expression) error {
|
||||
defer f.UseVariable(remainderVariable)
|
||||
}
|
||||
|
||||
dividend := right.Children[0]
|
||||
_, dividendRegister, isTemporary, err := f.Evaluate(dividend)
|
||||
dividendExpr := right.Children[0]
|
||||
dividend, isTemporary, err := f.Evaluate(dividendExpr)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !types.Is(dividend.Type, types.AnyInt) {
|
||||
return errors.New(&errors.TypeMismatch{Encountered: dividend.Type.Name(), Expected: types.AnyInt.Name()}, f.File, dividendExpr.Token.Position)
|
||||
}
|
||||
|
||||
divisor := right.Children[1]
|
||||
err = f.Execute(right.Token, dividendRegister, divisor)
|
||||
err = f.Execute(right.Token, dividend.Register, divisor)
|
||||
f.RegisterRegister(asm.MOVE, quotientVariable.Register, x86.RAX)
|
||||
f.RegisterRegister(asm.MOVE, remainderVariable.Register, x86.RDX)
|
||||
|
||||
if isTemporary {
|
||||
f.FreeRegister(dividendRegister)
|
||||
f.FreeRegister(dividend.Register)
|
||||
}
|
||||
|
||||
return err
|
||||
|
Reference in New Issue
Block a user