emit_pre_pop_reg(emit,&vtype_fun,REG_ARG_1);// the function
assert(vtype_fun==VTYPE_PYOBJ);
emit_call(emit,rt_call_function_0);
}elseif(n_positional==1){
vtype_kind_tvtype_fun,vtype_arg1;
emit_pre_pop_reg_reg(emit,&vtype_arg1,REG_ARG_2,&vtype_fun,REG_ARG_1);// the single argument, the function
assert(vtype_fun==VTYPE_PYOBJ);
assert(vtype_arg1==VTYPE_PYOBJ);
emit_call(emit,rt_call_function_1);
}elseif(n_positional==2){
vtype_kind_tvtype_fun,vtype_arg1,vtype_arg2;
emit_pre_pop_reg_reg_reg(emit,&vtype_arg2,REG_ARG_3,&vtype_arg1,REG_ARG_2,&vtype_fun,REG_ARG_1);// the second argument, the first argument, the function
emit_pre_pop_reg_reg(emit,&vtype_self,REG_ARG_2,&vtype_meth,REG_ARG_1);// the self object (or NULL), the method
assert(vtype_meth==VTYPE_PYOBJ);
assert(vtype_self==VTYPE_PYOBJ);
emit_call(emit,rt_call_method_1);
}elseif(n_positional==1){
vtype_kind_tvtype_meth,vtype_self,vtype_arg1;
emit_pre_pop_reg_reg_reg(emit,&vtype_arg1,REG_ARG_3,&vtype_self,REG_ARG_2,&vtype_meth,REG_ARG_1);// the first argument, the self object (or NULL), the method
assert(vtype_meth==VTYPE_PYOBJ);
assert(vtype_self==VTYPE_PYOBJ);
assert(vtype_arg1==VTYPE_PYOBJ);
emit_call(emit,rt_call_method_2);
}else{
assert(0);
}
emit_post_push_reg(emit,VTYPE_PYOBJ,REG_RET);
}
staticvoidemit_x64_return_value(emit_t*emit){
// easy. since we don't know who we return to, just return the raw value.
// runtime needs then to know our type signature, but I think that's possible.
vtype_kind_tvtype;
emit_pre_pop_reg(emit,&vtype,REG_RAX);
if(emit->do_viper_types){
assert(vtype==VTYPE_PTR_NONE);
}else{
assert(vtype==VTYPE_PYOBJ);
}
emit->last_emit_was_return_value=true;
//asm_x64_call_ind(emit->as, 0, REG_RAX); to seg fault for debugging with gdb