void CfrTil_DoWhileDoCombinator ( ) { block testBlock = ( block ) Dsp [ - 1 ], doBlock2 = ( block ) TOS, doBlock1 = ( block ) Dsp [ - 2 ] ; byte * start ; _DataStack_DropN ( 3 ) ; if ( CompileMode ) { CfrTil_BeginCombinator ( 3 ) ; _Context_->Compiler0->ContinuePoint = Here ; start = Here ; _Compile_Block ( ( byte* ) doBlock1, 2, 0 ) ; _Compile_Block ( ( byte* ) testBlock, 1, 1 ) ; _Compile_Block ( ( byte* ) doBlock2, 0, 0 ) ; _Compile_JumpToAddress ( start ) ; // runtime _Context_->Compiler0->BreakPoint = Here ; CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; CfrTil_EndCombinator ( 3, 1 ) ; } else { do { _Block_Eval ( doBlock1 ) ; _Block_Eval ( testBlock ) ; if ( ! _DataStack_Pop ( ) ) break ; _Block_Eval ( doBlock2 ) ; } while ( 1 ) ; } }
int32 CfrTil_DoWhileCombinator ( ) { block testBlock = ( block ) TOS, doBlock = ( block ) Dsp [ - 1 ] ; _DataStack_DropN ( 2 ) ; if ( CompileMode ) { CfrTil_BeginCombinator ( 2 ) ; byte * start = Here ; _Context_->Compiler0->ContinuePoint = Here ; _Compile_Block ( ( byte* ) doBlock, 1, 0 ) ; //_Compile_Block ( ( byte* ) testBlock, 0, 1 ) ; if ( ! _Compile_Block ( ( byte* ) testBlock, 0, 1 ) ) { SetHere ( start ) ; return 0 ; } _Compile_JumpToAddress ( start ) ; _Context_->Compiler0->BreakPoint = Here ; CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; CfrTil_EndCombinator ( 2, 1 ) ; } else { do { _Block_Eval ( doBlock ) ; _Block_Eval ( testBlock ) ; if ( ! _DataStack_Pop ( ) ) break ; } while ( 1 ) ; } return 1 ; }
void CfrTil_EndIf ( ) { if ( CompileMode ) { CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; } else { Error_Abort ( ( byte* ) "\n\"endif\" can only be used in compile mode." ) ; } }
void CfrTil_Else ( ) { if ( CompileMode ) { _Compile_UninitializedJump ( ) ; // at the end of the 'if block' we need to jmp over the 'else block' CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; _Stack_PointerToJmpOffset_Set ( ) ; } else { Error_Abort ( ( byte* ) "\n\"else\" can only be used in compile mode." ) ; } }
void CfrTil_ForCombinator ( ) { block doBlock = ( block ) TOS, doPostBlock = ( block ) Dsp [ - 1 ], testBlock = ( block ) Dsp [ - 2 ], doPreBlock = ( block ) Dsp [ - 3 ] ; _DataStack_DropN ( 4 ) ; if ( CompileMode ) { CfrTil_BeginCombinator ( 4 ) ; _Compile_Block ( ( byte* ) doPreBlock, 3, 0 ) ; byte * start = Here ; _Compile_Block ( ( byte* ) testBlock, 2, 1 ) ; _Context_->Compiler0->ContinuePoint = Here ; _Compile_Block ( ( byte* ) doBlock, 0, 0 ) ; _Compile_Block ( ( byte* ) doPostBlock, 1, 0 ) ; _Compile_JumpToAddress ( start ) ; // runtime _Context_->Compiler0->BreakPoint = Here ; CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; CfrTil_EndCombinator ( 4, 1 ) ; } else { _Block_Eval ( doPreBlock ) ; do { _Block_Eval ( testBlock ) ; if ( ! _DataStack_Pop ( ) ) break ; _Context_->Compiler0->ContinuePoint = Here ; _Block_Eval ( doBlock ) ; _Block_Eval ( doPostBlock ) ; _Context_->Compiler0->BreakPoint = Here ; } while ( 1 ) ; } }
void CfrTil_If2Combinator ( ) { block testBlock = ( block ) Dsp [ - 1 ], doBlock = ( block ) TOS ; _DataStack_DropN ( 2 ) ; if ( CompileMode ) { CfrTil_BeginCombinator ( 2 ) ; _Compile_Block ( ( byte* ) testBlock, 1, 1 ) ; _Compile_Block ( ( byte* ) doBlock, 0, 0 ) ; CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; CfrTil_EndCombinator ( 2, 1 ) ; } else { _Block_Eval ( testBlock ) ; if ( _DataStack_Pop ( ) ) _Block_Eval ( doBlock ) ; } }
void CfrTil_If1Combinator ( ) { block doBlock = ( block ) TOS ; _DataStack_DropN ( 1 ) ; if ( CompileMode ) { CfrTil_BeginCombinator ( 1 ) ; Compile_GetLogicFromTOS ( 0 ) ; _Compile_UninitializedJumpEqualZero ( ) ; Stack_PointerToJmpOffset_Set ( ) ; _Compile_Block ( ( byte* ) doBlock, 0, 0 ) ; CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; CfrTil_EndCombinator ( 1, 1 ) ; } else { if ( _DataStack_Pop ( ) ) _Block_Eval ( doBlock ) ; } }
void CfrTil_JmpToHere ( ) { CfrTil_CalculateAndSetPreviousJmpOffset_ToHere ( ) ; }