Beispiel #1
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 #2
0
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." ) ;
    }
}
Beispiel #3
0
int32
_Compile_Block_WithLogicFlag ( byte * srcAddress, int32 bindex, int32 jccFlag, int n )
{
    Compiler * compiler = _Context_->Compiler0 ;
    int32 jccFlag2 ;
    BlockInfo *bi = ( BlockInfo * ) _Stack_Pick ( compiler->CombinatorBlockInfoStack, bindex ) ; // -1 : remember - stack is zero based ; stack[0] is top
    if ( jccFlag )
    {
        if ( ! ( _Q_->OVT_LC && GetState ( _Q_->OVT_LC, ( LC_COMPILE_MODE ) ) ) )
        {
            if ( bi->LiteralWord )//&& bi->LiteralWord->StackPushRegisterCode ) // leave value in EAX, don't push it
            {
                if ( bi->LiteralWord->W_Value != 0 )
                {
                    return 1 ; // nothing need to be compiled
                }
                // else somehow don't use this block at all ie. eliminate the dead code and don't just ...
                return 0 ; // TODO : don't use the block/combinator
            }
        }
        jccFlag2 = Compile_ReConfigureLogicInBlock ( bi, 1 ) ;
    }
    if ( ! GetState ( _Q_->OVT_CfrTil, INLINE_ON ) ) Compile_Call ( srcAddress ) ;
    else
    {
        _Block_Copy ( srcAddress, bi->bp_Last - bi->bp_First ) ;
    }
    if ( jccFlag )
    {
        if ( jccFlag2 )
        {
            Compile_JCC ( n ? bi->NegFlag : ! bi->NegFlag, bi->Ttt, 0 ) ;
        }
        else
        {
            Compile_GetLogicFromTOS ( bi ) ;
            Compile_JCC ( n, ZERO_CC, 0 ) ;
        }
        _Stack_PointerToJmpOffset_Set ( Here - CELL ) ;
    }
    return 1 ;
}
Beispiel #4
0
void
CfrTil_If ( )
{
    if ( CompileMode )
    {
        _Compile_Jcc ( 0, 0, N, ZERO ) ;
        // N, ZERO : use inline|optimize logic which needs to get flags immediately from a 'cmp', jmp if the zero flag is not set
        // for non-inline|optimize ( reverse polarity : cf. _Compile_Jcc comment ) : jmp if cc is not true; cc is set by setcc after 
        // the cmp, or is a value on the stack. 
        // We cmp that value with zero and jmp if this second cmp sets the flag to zero else do the immediately following block code
        // ?? an explanation of the relation of the setcc terms with the flags is not clear to me yet (20110801) from the intel literature ?? 
        // but by trial and error this works; the logic i use is given in _Compile_Jcc.
        // ?? if there are problems check this area ?? cf. http://webster.cs.ucr.edu/AoA/Windows/HTML/IntegerArithmetic.html
        _Stack_PointerToJmpOffset_Set ( ) ;
    }
    else
    {
        Error_Abort ( ( byte* ) "\n\"if\" can only be used in compile mode." ) ;
    }
}
Beispiel #5
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 ) ;
    }
}