pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/operators.c:1258:
*! otherwise. *! *! @note *! For total orders, e.g. integers, this is the inverse of @[`<()]. *! *! @seealso *! @[`<=()], @[`>()], @[`<()] */ COMPARISON(f_ge,"`>=",is_ge)
-
-
#define CALL_OPERATOR(OP, args) do { \
-
struct object *o_ = sp[-args].u.object; \
-
int i; \
-
if(!o_->prog) \
-
bad_arg_error(lfun_names[OP], sp-args, args, 1, "object", sp-args, \
-
"Called in destructed object.\n"); \
-
if((i = FIND_LFUN(o_->prog->inherits[SUBTYPEOF(sp[-args])].prog, \
-
OP)) == -1) \
-
bad_arg_error(lfun_names[OP], sp-args, args, 1, "object", sp-args, \
-
"Operator not in object.\n"); \
-
apply_low(o_, i, args-1); \
-
stack_pop_keep_top(); \
-
} while (0)
-
+
/* Helper function for calling ``-operators. * * Assumes o is at Pike_sp[e - args]. * * i is the resolved lfun to call. * * Returns the number of remaining elements on the stack. */ PMOD_EXPORT INT32 low_rop(struct object *o, int i, INT32 e, INT32 args) {
pike.git/src/operators.c:4516:
return 1; } return 0; } PMOD_EXPORT void o_compl(void) { switch(TYPEOF(sp[-1])) { case T_OBJECT:
-
CALL
_
OPERATOR
(LFUN_COMPL,1);
+
if(!call
_
lhs_lfun
(LFUN_COMPL,1)
)
+
PIKE_ERROR("`~", "Complement on object without `~ operator.\n", sp, 1)
;
+
stack_pop_keep_top();
break; case T_INT: SET_SVAL(sp[-1], T_INT, NUMBER_NUMBER, integer, ~sp[-1].u.integer); break; case T_FLOAT: sp[-1].u.float_number = (FLOAT_TYPE) -1.0 - sp[-1].u.float_number; break;
pike.git/src/operators.c:4636:
} return 0; } PMOD_EXPORT void o_negate(void) { switch(TYPEOF(sp[-1])) { case T_OBJECT: do_lfun_negate:
-
CALL
_
OPERATOR
(LFUN_SUBTRACT,1);
+
if(!call
_
lhs_lfun
(LFUN_SUBTRACT,1)
)
+
PIKE_ERROR("`-", "Negate on object without `- operator.\n", sp, 1)
;
+
stack_pop_keep_top();
break; case T_FLOAT: sp[-1].u.float_number=-sp[-1].u.float_number; return; case T_INT: if(INT_TYPE_NEG_OVERFLOW(sp[-1].u.integer)) { convert_stack_top_to_bignum();