Changeset 54 for trunk/orca/op.c

Show
Ignore:
Timestamp:
02/17/06 15:30:01 (3 years ago)
Author:
krobillard
Message:

Now using orDecimal() & orInt() where appropriate.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/op.c

    r51 r54  
    3535        if( orIs(b, OT_INTEGER) ) 
    3636        { 
    37             orResult( OT_INTEGER, a->integer + b->integer ); 
    38             return; 
    39         } 
    40         else if( orIs(b, OT_DECIMAL) ) 
    41         { 
    42             orResultDECIMAL( (double) a->integer + b->num.decimal ); 
     37            orResult( OT_INTEGER, orInt(a) + orInt(b) ); 
     38            return; 
     39        } 
     40        else if( orIs(b, OT_DECIMAL) ) 
     41        { 
     42            orResultDECIMAL( (double) orInt(a) + orDecimal(b) ); 
    4343            return; 
    4444        } 
     
    5252            for( i = 0; i < res->argc; i++ ) 
    5353            { 
    54                 tmp = a->integer + b->tuple[i]; 
     54                tmp = orInt(a) + b->tuple[i]; 
    5555                res->tuple[i] = orToByteRange(tmp); 
    5656            }    
     
    6565        if( orIs(b, OT_INTEGER) ) 
    6666        { 
    67             orResultDECIMAL( a->num.decimal + (double) b->integer ); 
    68             return; 
    69         } 
    70         else if( orIs(b, OT_DECIMAL) ) 
    71         { 
    72             orResultDECIMAL( a->num.decimal + b->num.decimal ); 
     67            orResultDECIMAL( orDecimal(a) + (double) orInt(b) ); 
     68            return; 
     69        } 
     70        else if( orIs(b, OT_DECIMAL) ) 
     71        { 
     72            orResultDECIMAL( orDecimal(a) + orDecimal(b) ); 
    7373            return; 
    7474        } 
     
    8282            for( i = 0; i < res->argc; i++ ) 
    8383            { 
    84                 tmp = (int) a->num.decimal + b->tuple[i]; 
     84                tmp = (int) orDecimal(a) + b->tuple[i]; 
    8585                res->tuple[i] = orToByteRange(tmp); 
    8686            }    
     
    117117            for( i = 0; i < res->argc; i++ ) 
    118118            { 
    119                 tmp = a->tuple[i] + b->integer; 
     119                tmp = a->tuple[i] + orInt(b); 
    120120                res->tuple[i] = orToByteRange(tmp); 
    121121            }             
     
    131131            for( i = 0; i < res->argc; i++ ) 
    132132            { 
    133                 tmp = a->tuple[i] + (int) b->num.decimal; 
     133                tmp = a->tuple[i] + (int) orDecimal(b); 
    134134                res->tuple[i] = orToByteRange(tmp); 
    135135            }             
     
    170170        if( orIs(b, OT_INTEGER) ) 
    171171        { 
    172             orResult( OT_INTEGER, a->integer - b->integer ); 
    173             return; 
    174         } 
    175         else if( orIs(b, OT_DECIMAL) ) 
    176         { 
    177             orResultDECIMAL( (double) a->integer - b->num.decimal ); 
     172            orResult( OT_INTEGER, orInt(a) - orInt(b) ); 
     173            return; 
     174        } 
     175        else if( orIs(b, OT_DECIMAL) ) 
     176        { 
     177            orResultDECIMAL( (double) orInt(a) - orDecimal(b) ); 
    178178            return; 
    179179        } 
     
    185185        if( orIs(b, OT_INTEGER) ) 
    186186        { 
    187             orResultDECIMAL( a->num.decimal - (double) b->integer ); 
    188             return; 
    189         } 
    190         else if( orIs(b, OT_DECIMAL) ) 
    191         { 
    192             orResultDECIMAL( a->num.decimal - b->num.decimal ); 
     187            orResultDECIMAL( orDecimal(a) - (double) orInt(b) ); 
     188            return; 
     189        } 
     190        else if( orIs(b, OT_DECIMAL) ) 
     191        { 
     192            orResultDECIMAL( orDecimal(a) - orDecimal(b) ); 
    193193            return; 
    194194        } 
     
    221221            for( i = 0; i < res->argc; i++ ) 
    222222            { 
    223                 tmp = a->tuple[i] - b->integer; 
     223                tmp = a->tuple[i] - orInt(b); 
    224224                res->tuple[i] = orToByteRange(tmp); 
    225225            }             
     
    235235            for( i = 0; i < res->argc; i++ ) 
    236236            { 
    237                 tmp = a->tuple[i] - (int) b->num.decimal; 
     237                tmp = a->tuple[i] - (int) orDecimal(b); 
    238238                res->tuple[i] = orToByteRange(tmp); 
    239239            }             
     
    288288        if( orIs(b, OT_INTEGER) ) 
    289289        { 
    290             orResult( OT_INTEGER, a->integer * b->integer ); 
    291             return; 
    292         } 
    293         else if( orIs(b, OT_DECIMAL) ) 
    294         { 
    295             orResultDECIMAL( (double) a->integer * b->num.decimal ); 
     290            orResult( OT_INTEGER, orInt(a) * orInt(b) ); 
     291            return; 
     292        } 
     293        else if( orIs(b, OT_DECIMAL) ) 
     294        { 
     295            orResultDECIMAL( (double) orInt(a) * orDecimal(b) ); 
    296296            return; 
    297297        } 
     
    305305            for( i = 0; i < res->argc; i++ ) 
    306306            { 
    307                 tmp = a->integer * b->tuple[i]; 
     307                tmp = orInt(a) * b->tuple[i]; 
    308308                res->tuple[i] = orToByteRange(tmp); 
    309309            }    
     
    318318        if( orIs(b, OT_INTEGER) ) 
    319319        { 
    320             orResultDECIMAL( a->num.decimal * (double) b->integer ); 
    321             return; 
    322         } 
    323         else if( orIs(b, OT_DECIMAL) ) 
    324         { 
    325             orResultDECIMAL( a->num.decimal * b->num.decimal ); 
     320            orResultDECIMAL( orDecimal(a) * (double) orInt(b) ); 
     321            return; 
     322        } 
     323        else if( orIs(b, OT_DECIMAL) ) 
     324        { 
     325            orResultDECIMAL( orDecimal(a) * orDecimal(b) ); 
    326326            return; 
    327327        } 
     
    335335            for( i = 0; i < res->argc; i++ ) 
    336336            { 
    337                 tmp = a->num.decimal * b->tuple[i]; 
     337                tmp = orDecimal(a) * b->tuple[i]; 
    338338                res->tuple[i] = orToByteRange(tmp); 
    339339            }    
     
    370370            for( i = 0; i < res->argc; i++ ) 
    371371            { 
    372                 tmp = a->tuple[i] * b->integer; 
     372                tmp = a->tuple[i] * orInt(b); 
    373373                res->tuple[i] = orToByteRange(tmp); 
    374374            }             
     
    384384            for( i = 0; i < res->argc; i++ ) 
    385385            { 
    386                 tmp = a->tuple[i] * b->num.decimal; 
     386                tmp = a->tuple[i] * orDecimal(b); 
    387387                res->tuple[i] = orToByteRange(tmp); 
    388388            }             
     
    402402        if( orIs(b, OT_INTEGER) ) 
    403403        { 
    404             if( b->integer == 0 ) 
     404            if( orInt(b) == 0 ) 
    405405                goto div0; 
    406             orResult( OT_INTEGER, a->integer / b->integer ); 
    407             return; 
    408         } 
    409         else if( orIs(b, OT_DECIMAL) ) 
    410         { 
    411             if( b->num.decimal == 0.0 ) 
     406            orResult( OT_INTEGER, orInt(a) / orInt(b) ); 
     407            return; 
     408        } 
     409        else if( orIs(b, OT_DECIMAL) ) 
     410        { 
     411            if( orDecimal(b) == 0.0 ) 
    412412                goto div0; 
    413             orResultDECIMAL( (double) a->integer / b->num.decimal ); 
     413            orResultDECIMAL( (double) orInt(a) / orDecimal(b) ); 
    414414            return; 
    415415        } 
     
    420420        if( orIs(b, OT_INTEGER) ) 
    421421        { 
    422             if( b->integer == 0 ) 
     422            if( orInt(b) == 0 ) 
    423423                goto div0; 
    424             orResultDECIMAL( a->num.decimal / (double) b->integer ); 
    425             return; 
    426         } 
    427         else if( orIs(b, OT_DECIMAL) ) 
    428         { 
    429             if( b->num.decimal == 0.0 ) 
     424            orResultDECIMAL( orDecimal(a) / (double) orInt(b) ); 
     425            return; 
     426        } 
     427        else if( orIs(b, OT_DECIMAL) ) 
     428        { 
     429            if( orDecimal(b) == 0.0 ) 
    430430                goto div0; 
    431             orResultDECIMAL( a->num.decimal / b->num.decimal ); 
     431            orResultDECIMAL( orDecimal(a) / orDecimal(b) ); 
    432432            return; 
    433433        } 
     
    462462            for( i = 0; i < res->argc; i++ ) 
    463463            { 
    464                 if (b->integer == 0) 
     464                if (orInt(b) == 0) 
    465465                    goto div0; 
    466                 tmp = a->tuple[i] / b->integer; 
     466                tmp = a->tuple[i] / orInt(b); 
    467467                res->tuple[i] = orToByteRange(tmp); 
    468468            }             
     
    478478            for( i = 0; i < res->argc; i++ ) 
    479479            { 
    480                 if (b->num.decimal == 0) 
     480                if (orDecimal(b) == 0) 
    481481                    goto div0; 
    482                 tmp = a->tuple[i] / b->num.decimal; 
     482                tmp = a->tuple[i] / orDecimal(b); 
    483483                res->tuple[i] = orToByteRange(tmp); 
    484484            }             
     
    722722 
    723723            case OT_DECIMAL: 
    724                 if( a->num.decimal == b->num.decimal ) 
     724                if( orDecimal(a) == orDecimal(b) ) 
    725725                    logic = 1; 
    726726                break; 
     
    729729            case OT_LOGIC: 
    730730            case OT_INTEGER: 
    731                 if( a->integer == b->integer ) 
     731                if( orInt(a) == orInt(b) ) 
    732732                    logic = 1; 
    733733                break; 
     
    750750        if( orIs(b, OT_INTEGER) ) 
    751751        { 
    752             if( a->integer == b->integer ) 
     752            if( orInt(a) == orInt(b) ) 
    753753                return 1; 
    754754        } 
    755755        else if( orIs(b, OT_DECIMAL) ) 
    756756        { 
    757             if( ((double) a->integer) == b->num.decimal ) 
     757            if( ((double) orInt(a)) == orDecimal(b) ) 
    758758                return 1; 
    759759        } 
     
    764764        if( orIs(b, OT_INTEGER) ) 
    765765        { 
    766             if( a->num.decimal == ((double) b->integer) ) 
     766            if( orDecimal(a) == ((double) orInt(b)) ) 
    767767                return 1; 
    768768        } 
    769769        else if( orIs(b, OT_DECIMAL) ) 
    770770        { 
    771             if( a->num.decimal == b->num.decimal ) 
     771            if( orDecimal(a) == orDecimal(b) ) 
    772772                return 1; 
    773773        } 
     
    808808    { 
    809809        if( orIs(b, OT_INTEGER) ) 
    810             logic = (a->integer == b->integer); 
    811         else if( orIs(b, OT_DECIMAL) ) 
    812             logic = ((double) a->integer == b->num.decimal); 
     810            logic = (orInt(a) == orInt(b)); 
     811        else if( orIs(b, OT_DECIMAL) ) 
     812            logic = ((double) orInt(a) == orDecimal(b)); 
    813813    } 
    814814    else if( orIs(a, OT_DECIMAL) ) 
    815815    { 
    816816        if( orIs(b, OT_INTEGER) ) 
    817             logic = (a->num.decimal == (double) b->integer); 
    818         else if( orIs(b, OT_DECIMAL) ) 
    819             logic = (a->num.decimal == b->num.decimal); 
     817            logic = (orDecimal(a) == (double) orInt(b)); 
     818        else if( orIs(b, OT_DECIMAL) ) 
     819            logic = (orDecimal(a) == orDecimal(b)); 
    820820    } 
    821821    else if( orType(a) == orType(b) ) 
     
    896896        if( orIs(b, OT_INTEGER) ) 
    897897        { 
    898             orResult( OT_INTEGER, a->integer & b->integer ); 
     898            orResult( OT_INTEGER, orInt(a) & orInt(b) ); 
    899899            return; 
    900900        } 
     
    905905        if( orIs(b, OT_LOGIC) ) 
    906906        { 
    907             orResult( OT_LOGIC, a->integer & b->integer ); 
     907            orResult( OT_LOGIC, orInt(a) & orInt(b) ); 
    908908            return; 
    909909        } 
     
    933933            for( i = 0; i < a->argc; i++ ) 
    934934            { 
    935                 a->tuple[i] = a->tuple[i] & b->integer; 
     935                a->tuple[i] = a->tuple[i] & orInt(b); 
    936936            }             
    937937            return; 
     
    942942            for( i = 0; i < a->argc; i++ ) 
    943943            { 
    944                 a->tuple[i] = a->tuple[i] & (int) b->num.decimal; 
     944                a->tuple[i] = a->tuple[i] & (int) orDecimal(b); 
    945945            }             
    946946            return; 
     
    959959        if( orIs(b, OT_INTEGER) ) 
    960960        { 
    961             orResult( OT_INTEGER, a->integer | b->integer ); 
     961            orResult( OT_INTEGER, orInt(a) | orInt(b) ); 
    962962            return; 
    963963        } 
     
    968968        if( orIs(b, OT_LOGIC) ) 
    969969        { 
    970             orResult( OT_LOGIC, a->integer | b->integer ); 
     970            orResult( OT_LOGIC, orInt(a) | orInt(b) ); 
    971971            return; 
    972972        } 
     
    990990            for( i = 0; i < a->argc; i++ ) 
    991991            { 
    992                 a->tuple[i] = a->tuple[i] | b->integer; 
     992                a->tuple[i] = a->tuple[i] | orInt(b); 
    993993            }             
    994994            return; 
     
    999999            for( i = 0; i < a->argc; i++ ) 
    10001000            { 
    1001                 a->tuple[i] = a->tuple[i] | (int) b->num.decimal; 
     1001                a->tuple[i] = a->tuple[i] | (int) orDecimal(b); 
    10021002            }             
    10031003            return; 
     
    10161016        if( orIs(b, OT_INTEGER) ) 
    10171017        { 
    1018             orResult( OT_INTEGER, a->integer ^ b->integer ); 
     1018            orResult( OT_INTEGER, orInt(a) ^ orInt(b) ); 
    10191019            return; 
    10201020        } 
     
    10251025        if( orIs(b, OT_LOGIC) ) 
    10261026        { 
    1027             orResult( OT_LOGIC, a->integer ^ b->integer ); 
     1027            orResult( OT_LOGIC, orInt(a) ^ orInt(b) ); 
    10281028            return; 
    10291029        } 
     
    10471047            for( i = 0; i < a->argc; i++ ) 
    10481048            { 
    1049                 a->tuple[i] = a->tuple[i] ^ b->integer; 
     1049                a->tuple[i] = a->tuple[i] ^ orInt(b); 
    10501050            }             
    10511051            return; 
     
    10561056            for( i = 0; i < a->argc; i++ ) 
    10571057            { 
    1058                 a->tuple[i] = a->tuple[i] ^ (int) b->num.decimal; 
     1058                a->tuple[i] = a->tuple[i] ^ (int) orDecimal(b); 
    10591059            }             
    10601060            return; 
     
    10701070    int logic = 0; 
    10711071    if( orIs(a1, OT_DECIMAL) ) 
    1072         logic = ((int) a1->num.decimal) & 1; 
     1072        logic = ((int) orDecimal(a1)) & 1; 
    10731073    else 
    1074         logic = a1->integer & 1; 
     1074        logic = orInt(a1) & 1; 
    10751075    orResult( OT_LOGIC, logic ); 
    10761076} 
     
    10801080{ 
    10811081    orOddNative( a1 ); 
    1082     a1->integer ^= 1; 
     1082    orInt(a1) ^= 1; 
    10831083} 
    10841084