// neg static inline void _vm_neg(struct a2_vm* vm_p){ struct a2_obj* _d = callinfo_sfreg(curr_ci, ir_ga(curr_ir)); struct a2_obj* _v = _getvalue(vm_p, ir_gbx(curr_ir)); if(obj_t(_v)!=A2_TNUMBER) vm_error("the varable is not number type at set neg."); *_d = a2_number2obj(obj_vNum(_v)*(-1)); curr_pc++; }
A2_API inline void a2_len(struct a2_state* state, int idx){ struct a2_obj* obj = a2_getcstack(state->env_p, idx); size_t len =0; struct a2_obj len_obj; switch(obj_t(obj)){ case A2_TMAP: len = a2_map_len(a2_gcobj2map(obj_vX(obj, obj))); break; case A2_TARRAY: len = a2_array_len(a2_gcobj2array(obj_vX(obj, obj))); break; case A2_TSTRING: len = a2_string_len(a2_gcobj2string(obj_vX(obj, obj))); break; default: a2_error(state->env_p, e_run_error, "the type is not map or array at len function."); } len_obj = a2_number2obj((a2_number)len); a2_pushstack(state->env_p, &len_obj); }
A2_API inline void a2_pushnumber(struct a2_state* state, a2_number number){ struct a2_obj obj = a2_number2obj(number); a2_pushstack(state->env_p, &obj); }