+added two uprootable stubs: _ONCALC, _ONNEG.

This commit is contained in:
Wang Renxin 2017-12-15 20:09:57 +08:00
parent 1e521698a8
commit 2007ff93d0

View File

@ -1096,38 +1096,41 @@ static _object_t* _exp_assign = 0;
val->data.integer = strcmp(_str1, _str2) __optr 0; \ val->data.integer = strcmp(_str1, _str2) __optr 0; \
} while(0) } while(0)
#ifdef MB_ENABLE_USERTYPE_REF #ifdef MB_ENABLE_USERTYPE_REF
# define _instruct_obj_meta_obj(__optr, __tuple, __result, __exit) \ # if !defined _instruct_obj_meta_obj
do { \ # define _instruct_obj_meta_obj(__optr, __tuple, __result, __exit) \
_tuple3_t* tpptr = (_tuple3_t*)(*__tuple); \ do { \
_object_t* opnd1 = (_object_t*)(tpptr->e1); \ _tuple3_t* tpptr = (_tuple3_t*)(*__tuple); \
_object_t* opnd2 = (_object_t*)(tpptr->e2); \ _object_t* opnd1 = (_object_t*)(tpptr->e1); \
_object_t* retval = (_object_t*)(tpptr->e3); \ _object_t* opnd2 = (_object_t*)(tpptr->e2); \
if(opnd1->type == _DT_VAR) opnd1 = opnd1->data.variable->data; \ _object_t* retval = (_object_t*)(tpptr->e3); \
if(opnd2->type == _DT_VAR) opnd2 = opnd2->data.variable->data; \ if(opnd1->type == _DT_VAR) opnd1 = opnd1->data.variable->data; \
{ \ if(opnd2->type == _DT_VAR) opnd2 = opnd2->data.variable->data; \
mb_value_t vfst, vscd; \ { \
mb_value_t ret; \ mb_value_t vfst, vscd; \
mb_make_nil(vfst); \ mb_value_t ret; \
mb_make_nil(vscd); \ mb_make_nil(vfst); \
mb_make_nil(ret); \ mb_make_nil(vscd); \
if(opnd1->type == _DT_USERTYPE_REF && opnd1->data.usertype_ref->calc_operators && opnd1->data.usertype_ref->calc_operators->__optr) { \ mb_make_nil(ret); \
_internal_object_to_public_value(opnd1, &vfst); \ if(opnd1->type == _DT_USERTYPE_REF && opnd1->data.usertype_ref->calc_operators && opnd1->data.usertype_ref->calc_operators->__optr) { \
_internal_object_to_public_value(opnd2, &vscd); \ _internal_object_to_public_value(opnd1, &vfst); \
__result = opnd1->data.usertype_ref->calc_operators->__optr(s, (__tuple), &vfst, &vscd, &ret); \ _internal_object_to_public_value(opnd2, &vscd); \
_public_value_to_internal_object(&ret, retval); \ __result = opnd1->data.usertype_ref->calc_operators->__optr(s, (__tuple), &vfst, &vscd, &ret); \
goto __exit; \ _public_value_to_internal_object(&ret, retval); \
} else if(opnd2->type == _DT_USERTYPE_REF && opnd2->data.usertype_ref->calc_operators && opnd2->data.usertype_ref->calc_operators->__optr) { \ goto __exit; \
_internal_object_to_public_value(opnd1, &vfst); \ } else if(opnd2->type == _DT_USERTYPE_REF && opnd2->data.usertype_ref->calc_operators && opnd2->data.usertype_ref->calc_operators->__optr) { \
_internal_object_to_public_value(opnd2, &vscd); \ _internal_object_to_public_value(opnd1, &vfst); \
__result = opnd2->data.usertype_ref->calc_operators->__optr(s, (__tuple), &vfst, &vscd, &ret); \ _internal_object_to_public_value(opnd2, &vscd); \
_public_value_to_internal_object(&ret, retval); \ __result = opnd2->data.usertype_ref->calc_operators->__optr(s, (__tuple), &vfst, &vscd, &ret); \
goto __exit; \ _public_value_to_internal_object(&ret, retval); \
goto __exit; \
} \
} \ } \
} \ } while(0)
} while(0) # endif /* _instruct_obj_meta_obj */
#else /* MB_ENABLE_USERTYPE_REF */
# define _instruct_obj_meta_obj(__optr, __tuple, __result, __exit) do { ((void)(__tuple)); ((void)(__result)); } while(0)
#endif /* MB_ENABLE_USERTYPE_REF */ #endif /* MB_ENABLE_USERTYPE_REF */
#ifndef _instruct_obj_meta_obj
# define _instruct_obj_meta_obj(__optr, __tuple, __result, __exit) do { ((void)(__tuple)); ((void)(__result)); } while(0)
#endif /* _instruct_obj_meta_obj */
#define _proc_div_by_zero(__s, __tuple, __exit, __result, __kind) \ #define _proc_div_by_zero(__s, __tuple, __exit, __result, __kind) \
do { \ do { \
_instruct_common(__tuple) \ _instruct_common(__tuple) \
@ -1343,7 +1346,14 @@ static int mb_uu_substr(const char* ch, int begin, int count, char** o);
/** Expression processing */ /** Expression processing */
#ifndef _ONCOND #ifndef _ONCALC /* Uprootable stub */
# define _ONCALC(__optr, __tuple, __result, __exit) do { ((void)(__tuple)); ((void)(__result)); } while(0)
#endif /* _ONCALC */
#ifndef _ONNEG /* Uprootable stub */
# define _ONNEG(__arg, __result, __exit) do { ((void)(__arg)); ((void)(__result)); } while(0)
#endif /* _ONNEG */
#ifndef _ONCOND /* Uprootable stub */
# define _ONCOND(__s, __o, __v) do { ((void)(__s)); ((void)(__o)); ((void)(__v)); } while(0) # define _ONCOND(__s, __o, __v) do { ((void)(__s)); ((void)(__o)); ((void)(__v)); } while(0)
#endif /* _ONCOND */ #endif /* _ONCOND */
@ -1359,10 +1369,10 @@ static bool_t _is_unexpected_calc_type(mb_interpreter_t* s, _object_t* obj);
static bool_t _is_referenced_calc_type(mb_interpreter_t* s, _object_t* obj); static bool_t _is_referenced_calc_type(mb_interpreter_t* s, _object_t* obj);
static int _calc_expression(mb_interpreter_t* s, _ls_node_t** l, _object_t** val); static int _calc_expression(mb_interpreter_t* s, _ls_node_t** l, _object_t** val);
#ifndef _PREVCALL #ifndef _PREVCALL /* Uprootable stub */
# define _PREVCALL(__s, __l, __r) do { ((void)(__s)); ((void)(__l)); ((void)(__r)); } while(0) # define _PREVCALL(__s, __l, __r) do { ((void)(__s)); ((void)(__l)); ((void)(__r)); } while(0)
#endif /* _PREVCALL */ #endif /* _PREVCALL */
#ifndef _POSTCALL #ifndef _POSTCALL /* Uprootable stub */
# define _POSTCALL(__s, __l, __r) do { ((void)(__s)); ((void)(__l)); ((void)(__r)); } while(0) # define _POSTCALL(__s, __l, __r) do { ((void)(__s)); ((void)(__l)); ((void)(__r)); } while(0)
#endif /* _POSTCALL */ #endif /* _POSTCALL */
@ -1697,16 +1707,16 @@ static void _real_to_str(real_t r, char* str, size_t size, size_t afterpoint);
default: break; \ default: break; \
} \ } \
} }
#ifndef _GCNOW #ifndef _GCNOW /* Uprootable stub */
# define _GCNOW(__s) (!!(__s)) # define _GCNOW(__s) (!!(__s))
#endif /* _GCNOW */ #endif /* _GCNOW */
#ifndef _PREPAREGC #ifndef _PREPAREGC /* Uprootable stub */
# define _PREPAREGC(__s, __g) do { ((void)(__s)); ((void)(__g)); } while(0) # define _PREPAREGC(__s, __g) do { ((void)(__s)); ((void)(__g)); } while(0)
#endif /* _PREPAREGC */ #endif /* _PREPAREGC */
#ifndef _PREVGC #ifndef _PREVGC /* Uprootable stub */
# define _PREVGC(__s, __g) do { ((void)(__s)); ((void)(__g)); } while(0) # define _PREVGC(__s, __g) do { ((void)(__s)); ((void)(__g)); } while(0)
#endif /* _PREVGC */ #endif /* _PREVGC */
#ifndef _POSTGC #ifndef _POSTGC /* Uprootable stub */
# define _POSTGC(__s, __g) do { ((void)(__s)); ((void)(__g)); } while(0) # define _POSTGC(__s, __g) do { ((void)(__s)); ((void)(__g)); } while(0)
#endif /* _POSTGC */ #endif /* _POSTGC */
@ -14673,6 +14683,7 @@ static int _core_add(mb_interpreter_t* s, void** l) {
mb_assert(s && l); mb_assert(s && l);
_ONCALC(add, l, result, _exit);
_instruct_obj_meta_obj(add, l, result, _exit); _instruct_obj_meta_obj(add, l, result, _exit);
if(_is_string(((_tuple3_t*)*l)->e1) || _is_string(((_tuple3_t*)*l)->e2)) { if(_is_string(((_tuple3_t*)*l)->e1) || _is_string(((_tuple3_t*)*l)->e2)) {
if(_is_string(((_tuple3_t*)*l)->e1) && _is_string(((_tuple3_t*)*l)->e2)) { if(_is_string(((_tuple3_t*)*l)->e1) && _is_string(((_tuple3_t*)*l)->e2)) {
@ -14694,6 +14705,7 @@ static int _core_min(mb_interpreter_t* s, void** l) {
mb_assert(s && l); mb_assert(s && l);
_ONCALC(sub, l, result, _exit);
_instruct_obj_meta_obj(sub, l, result, _exit); _instruct_obj_meta_obj(sub, l, result, _exit);
_instruct_num_op_num(-, l); _instruct_num_op_num(-, l);
@ -14709,6 +14721,7 @@ static int _core_mul(mb_interpreter_t* s, void** l) {
mb_assert(s && l); mb_assert(s && l);
_ONCALC(mul, l, result, _exit);
_instruct_obj_meta_obj(mul, l, result, _exit); _instruct_obj_meta_obj(mul, l, result, _exit);
_instruct_num_op_num(*, l); _instruct_num_op_num(*, l);
@ -14724,6 +14737,7 @@ static int _core_div(mb_interpreter_t* s, void** l) {
mb_assert(s && l); mb_assert(s && l);
_ONCALC(div, l, result, _exit);
_instruct_obj_meta_obj(div, l, result, _exit); _instruct_obj_meta_obj(div, l, result, _exit);
_proc_div_by_zero(s, l, _exit, result, SE_RN_DIVIDE_BY_ZERO); _proc_div_by_zero(s, l, _exit, result, SE_RN_DIVIDE_BY_ZERO);
_instruct_num_op_num(/, l); _instruct_num_op_num(/, l);
@ -14830,6 +14844,7 @@ static int _core_neg(mb_interpreter_t* s, void** l) {
if(inep) if(inep)
(*inep)--; (*inep)--;
_ONNEG(arg, result, _exit);
switch(arg.type) { switch(arg.type) {
case MB_DT_INT: case MB_DT_INT:
arg.value.integer = -(arg.value.integer); arg.value.integer = -(arg.value.integer);