Changeset 36 for trunk/orca/op.c

Show
Ignore:
Timestamp:
02/09/06 11:18:55 (3 years ago)
Author:
jvargas
Message:

Finished support of tuples for all operator actions.
XOR OR and AND have slightly different behavior than REBOL when arguments are a tuple and a number. ie:

O> 1.2.1 xor 2015.345 ;== 222.221.222
R> 1.2.1 xor 2015.345 ;== 255.255.255

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/op.c

    r35 r36  
    546546                return CMP_LESS; 
    547547            return CMP_EQUAL; 
     548        } 
     549        return CMP_ERROR_B; 
     550    } 
     551    else if( a->type == OT_TUPLE ) 
     552    { 
     553        if( b->type == OT_TUPLE ) 
     554        { 
     555            int i, argc;             
     556            argc = a->argc > b->argc ? a->argc : b->argc; 
     557            for( i = 0; i < argc; i++ ) 
     558            { 
     559                if ( a->tuple[i] > b->tuple[i] ) 
     560                    return CMP_GREATER; 
     561                if ( a->tuple[i] < b->tuple[i] ) 
     562                    return CMP_LESS; 
     563            } 
     564            return CMP_EQUAL;; 
    548565        } 
    549566        return CMP_ERROR_B; 
     
    700717 
    701718            case OT_TUPLE: 
    702                 logic = tupleSame( a, b ); 
     719                logic = compareValue( a, b ); // tupleSame( a, b ); 
    703720                break; 
    704721 
     
    822839        else if( a->type == OT_TUPLE ) 
    823840        { 
    824             logic = tupleSame( a, b ); 
     841            logic = compareValue( a, b ); // tupleSame( a, b ); 
    825842        } 
    826843    } 
     
    898915        a = b; 
    899916    } 
     917    else if( a->type == OT_TUPLE ) 
     918    { 
     919        if( b->type == OT_TUPLE ) 
     920        { 
     921            int argc, i;             
     922            argc = a->argc > b->argc ? a->argc : b->argc; 
     923            for( i = 0; i < argc; i++ ) 
     924            { 
     925                a->tuple[i] = a->tuple[i] & b->tuple[i]; 
     926            } 
     927            return; 
     928        } 
     929        else if( b->type == OT_INTEGER ) 
     930        { 
     931            int i; 
     932            for( i = 0; i < a->argc; i++ ) 
     933            { 
     934                a->tuple[i] = a->tuple[i] & b->integer; 
     935            }             
     936            return; 
     937        } 
     938        else if( b->type == OT_DECIMAL) 
     939        { 
     940            int i; 
     941            for( i = 0; i < a->argc; i++ ) 
     942            { 
     943                a->tuple[i] = a->tuple[i] & (int) b->num.decimal; 
     944            }             
     945            return; 
     946        } 
     947        a = b; 
     948    } 
    900949    orErrorOp( "and", a ); 
    901950} 
     
    923972        a = b; 
    924973    } 
     974    else if( a->type == OT_TUPLE ) 
     975    { 
     976        if( b->type == OT_TUPLE ) 
     977        { 
     978            int argc, i;             
     979            argc = a->argc > b->argc ? a->argc : b->argc; 
     980            for( i = 0; i < argc; i++ ) 
     981            { 
     982                a->tuple[i] = a->tuple[i] | b->tuple[i]; 
     983            } 
     984            return; 
     985        } 
     986        else if( b->type == OT_INTEGER ) 
     987        { 
     988            int i; 
     989            for( i = 0; i < a->argc; i++ ) 
     990            { 
     991                a->tuple[i] = a->tuple[i] | b->integer; 
     992            }             
     993            return; 
     994        } 
     995        else if( b->type == OT_DECIMAL) 
     996        { 
     997            int i; 
     998            for( i = 0; i < a->argc; i++ ) 
     999            { 
     1000                a->tuple[i] = a->tuple[i] | (int) b->num.decimal; 
     1001            }             
     1002            return; 
     1003        } 
     1004        a = b; 
     1005    } 
    9251006    orErrorOp( "or", a ); 
    9261007} 
     
    9441025        { 
    9451026            orResult( OT_LOGIC, a->integer ^ b->integer ); 
     1027            return; 
     1028        } 
     1029        a = b; 
     1030    } 
     1031    else if( a->type == OT_TUPLE ) 
     1032    { 
     1033        if( b->type == OT_TUPLE ) 
     1034        { 
     1035            int argc, i;             
     1036            argc = a->argc > b->argc ? a->argc : b->argc; 
     1037            for( i = 0; i < argc; i++ ) 
     1038            { 
     1039                a->tuple[i] = a->tuple[i] ^ b->tuple[i]; 
     1040            } 
     1041            return; 
     1042        } 
     1043        else if( b->type == OT_INTEGER ) 
     1044        { 
     1045            int i; 
     1046            for( i = 0; i < a->argc; i++ ) 
     1047            { 
     1048                a->tuple[i] = a->tuple[i] ^ b->integer; 
     1049            }             
     1050            return; 
     1051        } 
     1052        else if( b->type == OT_DECIMAL) 
     1053        { 
     1054            int i; 
     1055            for( i = 0; i < a->argc; i++ ) 
     1056            { 
     1057                a->tuple[i] = a->tuple[i] ^ (int) b->num.decimal; 
     1058            }             
    9461059            return; 
    9471060        }