pike.git/
src/
operators.c
Branch:
Tag:
Non-build tags
All tags
No tags
2016-12-31
2016-12-31 22:27:45 by Martin Nilsson <nilsson@fastmail.com>
16c23f806b661c8f4a4c76daee6a9fb496dff323 (
24
lines) (+
7
/-
17
)
[
Show
|
Annotate
]
Branch:
8.1
Convert unary operations to use call_lhs_lfun and retire CALL_OPERATOR.
1265:
*/ 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].
4523:
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:
4643:
{ 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: