Esempio n. 1
0
// implement of mod, by using division
BigInt* DoMod(BigInt* a, BigInt* b, BigInt* remainder)
{
    BigInt c;

    DoDiv(a, b, &c, remainder);

    return remainder;
}
Esempio n. 2
0
// Division
char* Div(char* s1, char* s2, char* result, char* remainder)
{
    BigInt a, b, c, d;

    StrToBigInt(s1, &a);
    StrToBigInt(s2, &b);
    DoDiv(&a, &b, &c, &d);
    BigIntToStr(&d, remainder);

    return BigIntToStr(&c, result);
}
Esempio n. 3
0
static void DoMinusScaled( void )
{
    stack_entry *left;

    left = StkEntry( 1 );
    LRValue( left );
    RValue( ExprSP );
    switch( left->info.kind ) {
    case TK_POINTER:
        switch( ExprSP->info.kind ) {
        case TK_POINTER:
            /* Have to check if base type sizes are the same */
            PushBaseSize();
            DupStack();
            SwapStack( 3 );
            PushBaseSize();
            MoveSP( 1 );
            SwapStack( 3 );
            MoveSP( -1 );
            if( !TstEQ( 1 ) ) {
                Error( ERR_NONE, LIT( ERR_ILL_TYPE ) );
            }
            PopEntry();
            MoveSP( 1 );
            DoMinus();
            MoveSP( -1 );
            DoDiv();
            return;
        default:
            ScaleInt();
            break;
        }
        break;
    default:
        switch( ExprSP->info.kind ) {
        case TK_POINTER:
            Error( ERR_NONE, LIT( ERR_ILL_TYPE ) );
            break;
        }
    }
    DoMinus();
}
Esempio n. 4
0
double DoOperation(char operation, double op1, double op2, int* isErr)
{
	switch (operation)
	{
	case '+':
		return DoAdd(op1, op2);
		break;
	case '-':
		return DoSub(op1, op2);
		break;	
	case '*':
		return DoMul(op1, op2);
		break;
	case '/':
		return DoDiv(op1, op2, isErr);
		break;
	}
	return op2;
	//return WinCalculator->DoOperation(operation, op1, op2, isErr);
}
Esempio n. 5
0
static unsigned MechDo( unsigned select, unsigned parm )
{
    unsigned long       size;
    unsigned            result = 0;
    DIPHDL( type, th );
    dip_type_info       info;
    mad_type_info       mti;

    switch( select ) {
    case 0:
        DoAssign();
        break;
    case 1:
        DoMul();
        break;
    case 2:
        DoDiv();
        break;
    case 3:
        DoMod();
        break;
    case 4:
        DoMinus();
        break;
    case 5:
        DoShift();
        break;
    case 6:
        DoAnd();
        break;
    case 7:
        DoXor();
        break;
    case 8:
        DoOr();
        break;
    case 9:
        DoAddr();
        break;
    case 10:
        ClassToTypeInfo( parm, &info );
        DoPoints( info.kind );
        break;
    case 11:
        DoField();
        break;
    case 12:
        DoCall( Num, parm );
        break;
    case 13:
        DoConvert();
        break;
    case 14:
        DoPlus();
        break;
    case 15:
        MakeAddr();
        break;
    case 16:
        result = TstEQ( parm );
        break;
    case 17:
        result = TstLT( parm );
        break;
    case 18:
        result = TstTrue( parm );
        break;
    case 19:
        result = TstExist( parm );
        break;
    case 20:
        size = ExprSP->info.size;
        PopEntry();
        PushNum( size );
        break;
    case 21:
        TypeBase( ExprSP->th, th, NULL, NULL );
        PopEntry();
        PushType( th );
        break;
    case 22:
        GetMADTypeDefault( MTK_ADDRESS, &mti );
        size = (mti.b.bits - mti.a.seg.bits) / BITS_PER_BYTE;
        if( parm ) {
            size += sizeof( addr_seg );
            TypePointer( ExprSP->th, TM_FAR, size, th );
        } else {
            TypePointer( ExprSP->th, TM_NEAR, size, th );
        }
        PopEntry();
        PushType( th );
        break;
    case 23:
        result = UserType( th );
        if( result ) {
            PopEntry();
            PushType( th );
        }
        break;
    case 24:
        DoMakeComplex();
        break;
    case 25:
        DoStringConcat();
        break;
    case 26:
        DoLConvert();
        break;
    case 27:
        DoPlusScaled();
        break;
    case 28:
        DoMinusScaled();
        break;
    case 29:
        DoPoints( TI_KIND_EXTRACT( parm ) );
        break;
    case 30:
        info.kind = TK_POINTER;
        info.size = TI_SIZE_EXTRACT( parm );
        info.modifier = TI_MOD_EXTRACT( parm );
        FillInDefaults( &info );
        TypePointer( ExprSP->th, info.modifier, info.size, th );
        PopEntry();
        PushType( th );
        break;
    case 31:
        if( parm ) {
            /* file scope */
            if( ExprSP->flags & SF_NAME ) {
                ExprSP->v.li.file_scope = TRUE;
            } else {
                Error( ERR_LOC, LIT( ERR_WANT_NAME ) );
            }
        } else {
            /* in a namespace */
            DoScope();
        }
        break;
    }
    return( result );
}
Esempio n. 6
0
static ssl_value MechDo( unsigned select, ssl_value parm )
{
    unsigned long       size;
    ssl_value           result;
    DIPHDL( type, th );
    dig_type_info       ti;
    mad_type_info       mti;

    result = 0;
    switch( select ) {
    case 0:
        DoAssign();
        break;
    case 1:
        DoMul();
        break;
    case 2:
        DoDiv();
        break;
    case 3:
        DoMod();
        break;
    case 4:
        DoMinus();
        break;
    case 5:
        DoShift();
        break;
    case 6:
        DoAnd();
        break;
    case 7:
        DoXor();
        break;
    case 8:
        DoOr();
        break;
    case 9:
        DoAddr();
        break;
    case 10:
        ClassToTypeInfo( parm, &ti );
        DoPoints( ti.kind );
        break;
    case 11:
        DoField();
        break;
    case 12:
        DoCall( Num, SSL2BOOL( parm ) );
        break;
    case 13:
        DoConvert();
        break;
    case 14:
        DoPlus();
        break;
    case 15:
        MakeAddr();
        break;
    case 16:
        result = ( TstEQ( SSL2INT( parm ) ) != 0 );
        break;
    case 17:
        result = ( TstLT( SSL2INT( parm ) ) != 0 );
        break;
    case 18:
        result = ( TstTrue( SSL2INT( parm ) ) != 0 );
        break;
    case 19:
        result = ( TstExist( SSL2INT( parm ) ) != 0 );
        break;
    case 20:
        size = ExprSP->ti.size;
        PopEntry();
        PushNum( size );
        break;
    case 21:
        DIPTypeBase( ExprSP->th, th, NULL, NULL );
        PopEntry();
        PushType( th );
        break;
    case 22:
        GetMADTypeDefault( MTK_ADDRESS, &mti );
        size = BITS2BYTES( mti.b.bits - mti.a.seg.bits );
        if( parm ) {
            size += sizeof( addr_seg );
            DIPTypePointer( ExprSP->th, TM_FAR, size, th );
        } else {
            DIPTypePointer( ExprSP->th, TM_NEAR, size, th );
        }
        PopEntry();
        PushType( th );
        break;
    case 23:
        result = UserType( th );
        if( result ) {
            PopEntry();
            PushType( th );
        }
        break;
    case 24:
        DoMakeComplex();
        break;
    case 25:
        DoStringConcat();
        break;
    case 26:
        DoLConvert();
        break;
    case 27:
        DoPlusScaled();
        break;
    case 28:
        DoMinusScaled();
        break;
    case 29:
        DoPoints( TI_KIND_EXTRACT( parm ) );
        break;
    case 30:
        ti.kind = TK_POINTER;
        ti.size = TI_SIZE_EXTRACT( parm );
        ti.modifier = TI_MOD_EXTRACT( parm );
        ti.deref = false;
        FillInDefaults( &ti );
        DIPTypePointer( ExprSP->th, ti.modifier, ti.size, th );
        PopEntry();
        PushType( th );
        break;
    case 31:
        if( SSL2BOOL( parm ) ) {
            /* file scope */
            if( ExprSP->flags & SF_NAME ) {
                ExprSP->v.li.file_scope = true;
            } else {
                Error( ERR_LOC, LIT_ENG( ERR_WANT_NAME ) );
            }
        } else {
            /* in a namespace */
            DoScope();
        }
        break;
    }
    return( result );
}