Arith performs an arithmetic operation over the two values (or one, in case of negation) at the top of the stack, with the value at the top being the second operand, ops these values and pushes the result of the operation. The function follows the semantics of the corresponding Lua operator (that is
(op Operator)
| 713 | // |
| 714 | // http://www.lua.org/manual/5.2/manual.html#lua_arith |
| 715 | func (l *State) Arith(op Operator) { |
| 716 | if op != OpUnaryMinus { |
| 717 | l.checkElementCount(2) |
| 718 | } else { |
| 719 | l.checkElementCount(1) |
| 720 | l.push(l.stack[l.top-1]) |
| 721 | } |
| 722 | o1, o2 := l.stack[l.top-2], l.stack[l.top-1] |
| 723 | if n1, n2, ok := pairAsNumbers(o1, o2); ok { |
| 724 | l.stack[l.top-2] = arith(op, n1, n2) |
| 725 | } else { |
| 726 | l.stack[l.top-2] = l.arith(o1, o2, tm(op-OpAdd)+tmAdd) |
| 727 | } |
| 728 | l.top-- |
| 729 | } |
| 730 | |
| 731 | // RawEqual verifies that the values at index1 and index2 are primitively |
| 732 | // equal (that is, without calling their metamethods). |
nothing calls this directly
no test coverage detected