Showing the changes to src (3 of 3 files). Show all
Unified · Split
| @@ -4565,15 +4565,20 @@ t_CKBOOL emit_engine_emit_func_def( Chuck_Emitter * emit, a_Func_Def func_def ) · 4564 unmodified lines | ||
| 4565 | 4565 | if( !emit_engine_emit_stmt( emit, func_def->code, FALSE ) ) |
| 4566 | 4566 | return FALSE; |
| 4567 | 4567 | |
| 4568 | − // added by spencer June 2014 (1.3.5.0) | |
| 4569 | − // ensure return | |
| 4568 | + // added by spencer June 2014 (1.3.5.0) | ensure return | |
| 4570 | 4569 | if( func_def->ret_type && func_def->ret_type != emit->env->t_void ) |
| 4571 | 4570 | { |
| 4572 | − emit->append( new Chuck_Instr_Reg_Push_Imm(0) ); | |
| 4573 | − | |
| 4574 | − Chuck_Instr_Goto * instr = new Chuck_Instr_Goto( 0 ); | |
| 4575 | − emit->append( instr ); | |
| 4576 | − emit->code->stack_return.push_back( instr ); | |
| 4571 | + // 1.4.2.1 (ge) | account for differences in return type size | |
| 4572 | + // push 0 for the width of the return type in question | |
| 4573 | + emit->append( new Chuck_Instr_Reg_Push_Zero( func_def->ret_type->size ) ); | |
| 4574 | + // previously this pushed 0 as int, regardless of return type size | |
| 4575 | + // emit->append( new Chuck_Instr_Reg_Push_Imm(0) ); | |
| 4576 | + | |
| 4577 | + // 1.4.2.1 (ge) | commented out this goto... | |
| 4578 | + // (okay as long as the next instruction is Chuck_Instr_Func_Return...) | |
| 4579 | + // Chuck_Instr_Goto * instr = new Chuck_Instr_Goto( 0 ); | |
| 4580 | + // emit->append( instr ); | |
| 4581 | + // emit->code->stack_return.push_back( instr ); | |
| 4577 | 4582 | } |
| 4578 | 4583 | |
| 4579 | 4584 | // ge: pop scope (2012 april | added 1.3.0.0) |
| @@ -2041,6 +2041,23 @@ void Chuck_Instr_Reg_Push_Imm4::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) · 2040 unmodified lines | ||
| 2041 | 2041 | |
| 2042 | 2042 | |
| 2043 | 2043 | |
| 2044 | +//----------------------------------------------------------------------------- | |
| 2045 | +// name: execute() | |
| 2046 | +// desc: ... | |
| 2047 | +//----------------------------------------------------------------------------- | |
| 2048 | +void Chuck_Instr_Reg_Push_Zero::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) | |
| 2049 | +{ | |
| 2050 | + t_CKBYTE *& reg_sp = (t_CKBYTE *&)shred->reg->sp; | |
| 2051 | + | |
| 2052 | + // push val into reg stack | |
| 2053 | + memset( reg_sp, 0, m_val ); | |
| 2054 | + // move stack pointer | |
| 2055 | + reg_sp += m_val; | |
| 2056 | +} | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2044 | 2061 | //----------------------------------------------------------------------------- |
| 2045 | 2062 | // name: execute() |
| 2046 | 2063 | // desc: ... |
| @@ -2017,6 +2017,23 @@ protected: · 2016 unmodified lines | ||
| 2017 | 2017 | |
| 2018 | 2018 | |
| 2019 | 2019 | |
| 2020 | +//----------------------------------------------------------------------------- | |
| 2021 | +// name: struct Chuck_Instr_Reg_Push_Zero | |
| 2022 | +// desc: push immediate value 0 to reg stack with specific width | |
| 2023 | +//----------------------------------------------------------------------------- | |
| 2024 | +struct Chuck_Instr_Reg_Push_Zero : public Chuck_Instr_Unary_Op | |
| 2025 | +{ | |
| 2026 | +public: | |
| 2027 | + Chuck_Instr_Reg_Push_Zero( t_CKUINT sizeInBytes ) | |
| 2028 | + { this->set( sizeInBytes ); } | |
| 2029 | + | |
| 2030 | +public: | |
| 2031 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 2032 | +}; | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2020 | 2037 | //----------------------------------------------------------------------------- |
| 2021 | 2038 | // name: struct Chuck_Instr_Reg_Dup_Last |
| 2022 | 2039 | // desc: duplicate last value on reg stack |