Changeset 32 for trunk/orca/op.c

Show
Ignore:
Timestamp:
02/08/06 15:31:03 (3 years ago)
Author:
jvargas
Message:

orOpAdd now can handle expressions [tuple + integer]

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/op.c

    r30 r32  
    1818===========================================================================*/ 
    1919 
    20  
     20#include "os.h" 
    2121#include "ovalue.h" 
    2222 
     
    6363        if( b->type == OT_TUPLE ) 
    6464        { 
    65                         int tmp; 
    66                         OValue* res; 
    67                          
    68                         res = orRESULT; 
    69                         orSetTF( res, OT_TUPLE ); 
    70  
    71                         res->argc = a->argc > b->argc ? a->argc : b->argc; 
    72                          
    73                         for( uint8_t i = 0; i < OR_TUPLE_MAX; i++ ) 
    74                         { 
    75                                 tmp = a->tuple[i] + b->tuple[i]; 
    76                                 res->tuple[i] = tmp > 255 ? 255 : tmp; 
    77                         } 
    78                          
    79                         return; 
     65            uint32_t tmp, i; 
     66            OValue* res; 
     67             
     68            res = orRESULT; 
     69            orSetTF( res, OT_TUPLE ); 
     70             
     71            res->argc = a->argc > b->argc ? a->argc : b->argc; 
     72            for( i = 0; i < OR_TUPLE_MAX; i++ ) 
     73            { 
     74                tmp = a->tuple[i] + b->tuple[i]; 
     75                res->tuple[i] = tmp > 255 ? 255 : tmp; 
     76            } 
     77             
     78            return; 
     79        } 
     80        else if( b->type == OT_INTEGER ) 
     81        { 
     82            uint32_t tmp, i; 
     83            OValue *res, t; 
     84 
     85            memSet(&t, 0, sizeof(OValue)); 
     86            orSetTF( &t, OT_TUPLE ); 
     87             
     88            t.argc = a->argc; 
     89            for( i = 0; i < t.argc; i++ ) 
     90            { 
     91                tmp = a->tuple[i] + b->integer; 
     92                t.tuple[i] = tmp > 255 ? 255 : tmp; 
     93            }             
     94 
     95            res = orRESULT; 
     96            memCpy(res, &t, sizeof(OValue)); 
     97            return; 
    8098        } 
    8199#if 0 
    82         else if( b->type == OT_INTEGER ) 
    83         { 
    84                         orResult( OT_TUPLE, b->integer ); 
    85                         return; 
    86         } 
    87                 else if( b->type == OT_INTEGER ) 
    88         { 
    89                         orResult( OT_TUPLE, b->integer ); 
    90                         return; 
     100        else if( b->type == OT_DECIMAL) 
     101        { 
     102            orResult( OT_TUPLE, b->integer ); 
     103            return; 
    91104        } 
    92105#endif 
    93                 a = b; 
     106        a = b; 
    94107    } 
    95108    else if( a->type == OT_TIME )