mirror of
https://github.com/louisrubet/rpn
synced 2025-01-01 18:20:06 +01:00
Operators + - * / now show an error if arguments are not from proper type
This commit is contained in:
parent
10b3622408
commit
0addd217b3
1 changed files with 10 additions and 0 deletions
|
@ -24,6 +24,8 @@ void plus()
|
|||
_stack->pop_back();
|
||||
*((ostring*)_stack->back())->_value += second;
|
||||
}
|
||||
else
|
||||
ERR_CONTEXT(ret_bad_operand_type);
|
||||
}
|
||||
|
||||
void minus()
|
||||
|
@ -46,6 +48,8 @@ void minus()
|
|||
integer_t first = getb();
|
||||
putb(getb() - first);
|
||||
}
|
||||
else
|
||||
ERR_CONTEXT(ret_bad_operand_type);
|
||||
}
|
||||
|
||||
void mul()
|
||||
|
@ -64,6 +68,8 @@ void mul()
|
|||
//TODO really too slow
|
||||
putb(getb() * getb());
|
||||
}
|
||||
else
|
||||
ERR_CONTEXT(ret_bad_operand_type);
|
||||
}
|
||||
|
||||
void div()
|
||||
|
@ -95,6 +101,8 @@ void div()
|
|||
putb(getb() / first);
|
||||
}
|
||||
}
|
||||
else
|
||||
ERR_CONTEXT(ret_bad_operand_type);
|
||||
}
|
||||
|
||||
void neg()
|
||||
|
@ -107,6 +115,8 @@ void neg()
|
|||
// binary
|
||||
else if (IS_ARG_TYPE(0, cmd_binary))
|
||||
putb(-getb());
|
||||
else
|
||||
ERR_CONTEXT(ret_bad_operand_type);
|
||||
}
|
||||
|
||||
void inv()
|
||||
|
|
Loading…
Reference in a new issue