Beispiel #1
0
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 ) ;
    }
}
Beispiel #2
0
void
CfrTil_TrueFalseCombinator2 ( )
{
    int32 testCondition = Dsp [ - 2 ] ;
    block trueBlock = ( block ) Dsp [ - 1 ], falseBlock = ( block ) TOS ;
    _DataStack_DropN ( 2 ) ;
    if ( CompileMode )
    {
        CfrTil_BeginCombinator ( 2 ) ;

        Compile_GetLogicFromTOS ( 0 ) ;
        _Compile_UninitializedJumpEqualZero ( ) ;
        Stack_PointerToJmpOffset_Set ( ) ;

        _Compile_Block ( ( byte* ) trueBlock, 1, 0 ) ;
        CfrTil_Else ( ) ;
        _Compile_Block ( ( byte* ) falseBlock, 0, 0 ) ;
        CfrTil_EndIf ( ) ;

        CfrTil_EndCombinator ( 2, 1 ) ;
    }
    else
    {
        if ( testCondition )
        {
            _Block_Eval ( trueBlock ) ;
        }
        else
        {
            _Block_Eval ( falseBlock ) ;
        }
    }
}
Beispiel #3
0
void
CfrTil_TrueFalseCombinator3 ( )
{
    block testBlock = ( block ) Dsp [ - 2 ], trueBlock = ( block ) Dsp [ - 1 ],
        falseBlock = ( block ) TOS ;
    _DataStack_DropN ( 3 ) ;
    if ( CompileMode )
    {
        CfrTil_BeginCombinator ( 3 ) ;
        _Compile_Block ( ( byte* ) testBlock, 2, 1 ) ;
        _Compile_Block ( ( byte* ) trueBlock, 1, 0 ) ;
        CfrTil_Else ( ) ;
        _Compile_Block ( ( byte* ) falseBlock, 0, 0 ) ;
        CfrTil_EndIf ( ) ;
        CfrTil_EndCombinator ( 3, 1 ) ;
    }
    else
    {
        _Block_Eval ( testBlock ) ;
        if ( _DataStack_Pop ( ) )
        {
            _Block_Eval ( trueBlock ) ;
        }
        else
        {
            _Block_Eval ( falseBlock ) ;
        }
    }
}
Beispiel #4
0
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 ;
}
Beispiel #5
0
void
ilinrec ( block ifBlock, block thenBlock, block else1Block, block else2Block )
{
    _Block_Eval ( ifBlock ) ;
    if ( _DataStack_Pop ( ) )
    {
        _Block_Eval ( thenBlock ) ;
    }
    else
    {
        _Block_Eval ( else1Block ) ;
        D0 ( CfrTil_PrintDataStack ( ) ) ;
        ilinrec ( ifBlock, thenBlock, else1Block, else2Block ) ;
        _Block_Eval ( else2Block ) ;
    }
}
Beispiel #6
0
void
CfrTil_NLoopCombinator ( )
{
    int32 count = Dsp [ - 1 ] ;
    block loopBlock = ( block ) TOS ;
    _DataStack_DropN ( 2 ) ;
    while ( count -- ) _Block_Eval ( loopBlock ) ;
}
Beispiel #7
0
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 ) ;
    }
}
Beispiel #8
0
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 ) ;
    }
}
Beispiel #9
0
void
CfrTil_LoopCombinator ( )
{
    block loopBlock = ( block ) TOS ;
    _DataStack_DropN ( 1 ) ;
    if ( CompileMode )
    {
        CfrTil_BeginCombinator ( 1 ) ;
        byte * start = Here ;
        _Context_->Compiler0->ContinuePoint = start ;
        _Compile_Block ( ( byte* ) loopBlock, 0, 0 ) ;
        _Compile_JumpToAddress ( start ) ; // runtime
        _Context_->Compiler0->BreakPoint = Here ;
        CfrTil_EndCombinator ( 1, 1 ) ;
    }
    else while ( 1 ) _Block_Eval ( loopBlock ) ;
}
Beispiel #10
0
void
CfrTil_BlockRun ( )
{
    block doBlock = ( block ) TOS ;
    if ( CompileMode )
    {
        _DataStack_DropN ( 1 ) ;
        CfrTil_BeginCombinator ( 1 ) ;
        _Compile_Block ( ( byte* ) doBlock, 0, 0 ) ;
        CfrTil_EndCombinator ( 1, 1 ) ;
    }
    else
    {
        _Block_Eval ( doBlock ) ;
        //_DataStack_DropN ( 1 ) ; // needs to be here to correctly run lisp blocks from LO_EndBlock ( ) ?!?
    }
}
Beispiel #11
0
void
_CfrTil_BlockRun ( Boolean flag )
{
    block doBlock = ( block ) TOS ;
    _DataStack_DropN ( 1 ) ;
    if ( flag & FORCE_RUN )
    {
        _Block_Eval ( doBlock ) ;
    }
    else //if ( flag & FORCE_COMPILE )
    {
        CfrTil_BeginCombinator ( 1 ) ;
        _Compile_Block ( ( byte* ) doBlock, 0, 0 ) ;
        CfrTil_EndCombinator ( 1, 1 ) ;
        //return doBlock ;
    }
}
Beispiel #12
0
void
CfrTil_NLoopCombinator ( )
{
    int32 count = Dsp [ - 1 ] ;
    block loopBlock = ( block ) TOS ;
    _DataStack_DropN ( 2 ) ;
#if 0    
    if ( CompileMode )
    {
        CfrTil_BeginCombinator ( 1 ) ;
        byte * start = Here ;
        _Context_->Compiler0->ContinuePoint = start ;
        _Compile_Block ( ( byte* ) loopBlock ) ;
        _Compile_JumpToAddress ( start ) ; // runtime
        _Context_->Compiler0->BreakPoint = Here ;
        CfrTil_EndCombinator ( 1 ) ;
    }
#endif    
    while ( count -- )
        _Block_Eval ( loopBlock ) ;
}
Beispiel #13
0
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 ) ;
    }
}