1 #include "rvmoperatorcast.h"
5 void rvm_op_cast_static_static(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
11 void rvm_op_cast_double_unsigned(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
13 rword r = (rword)RVM_REG_GETD(arg1);
16 RVM_REG_SETTYPE(res, RVM_DTYPE_UNSIGNED);
20 void rvm_op_cast_double_long(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
22 rlong r = (rlong)RVM_REG_GETD(arg1);
25 RVM_REG_SETTYPE(res, RVM_DTYPE_LONG);
30 void rvm_op_cast_long_unsigned(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
32 rword r = (rword)RVM_REG_GETL(arg1);
35 RVM_REG_SETTYPE(res, RVM_DTYPE_UNSIGNED);
40 void rvm_op_cast_long_double(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
42 rdouble r = (rdouble)RVM_REG_GETL(arg1);
45 RVM_REG_SETTYPE(res, RVM_DTYPE_DOUBLE);
50 void rvm_op_cast_unsigned_long(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
52 rlong r = (rlong)RVM_REG_GETU(arg1);
55 RVM_REG_SETTYPE(res, RVM_DTYPE_LONG);
60 void rvm_op_cast_unsigned_double(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
62 rdouble r = (rdouble)RVM_REG_GETU(arg1);
65 RVM_REG_SETTYPE(res, RVM_DTYPE_DOUBLE);
70 void rvm_op_cast_string_string(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
73 RVM_ABORT(cpu, RVM_E_ILLEGALDST);
74 rvm_reg_setstring(res, r_string_copy(RVM_REG_GETP(arg1)));
78 void rvm_op_cast_refreg_string(rvmcpu_t *cpu, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
81 RVM_ABORT(cpu, RVM_E_ILLEGALDST);
82 rvm_reg_refer(res, arg1);
86 void rvm_op_cast_init(rvm_opmap_t *opmap)
88 rvm_opmap_add_binary_operator(opmap, RVM_OPID_CAST);
89 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_static_static, RVM_DTYPE_DOUBLE, RVM_DTYPE_DOUBLE);
90 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_static_static, RVM_DTYPE_LONG, RVM_DTYPE_LONG);
91 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_long_double, RVM_DTYPE_LONG, RVM_DTYPE_DOUBLE);
92 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_long_unsigned, RVM_DTYPE_LONG, RVM_DTYPE_UNSIGNED);
93 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_double_long, RVM_DTYPE_DOUBLE, RVM_DTYPE_LONG);
94 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_double_unsigned, RVM_DTYPE_DOUBLE, RVM_DTYPE_UNSIGNED);
95 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_unsigned_long, RVM_DTYPE_UNSIGNED, RVM_DTYPE_LONG);
96 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_unsigned_double, RVM_DTYPE_UNSIGNED, RVM_DTYPE_DOUBLE);
97 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_refreg_string, RVM_DTYPE_REFREG, RVM_DTYPE_STRING);
98 rvm_opmap_set_binary_handler(opmap, RVM_OPID_CAST, rvm_op_cast_string_string, RVM_DTYPE_STRING, RVM_DTYPE_STRING);