Changeset 93 in dev for BasicCompiler64/NumOpe.cpp


Ignore:
Timestamp:
Apr 11, 2007, 3:23:14 AM (17 years ago)
Author:
dai_9181
Message:

"a=[10,20,30]" などのように、リテラルバイナリデータを指定できるようにした。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler64/NumOpe.cpp

    r79 r93  
    106106        //mov reg,rax
    107107        op_mov_RR( *pReg, REG_RAX );
     108
     109        return true;
     110    }
     111
     112    if( !baseType.IsNull() && expression[0] == '[' ){
     113        // リテラル配列の場合
     114
     115        if( !baseType.IsPointer() ){
     116            SetError(1,NULL,cp);
     117            return false;
     118        }
     119        Type tempBaseType( baseType );
     120        tempBaseType.PtrLevelDown();
     121
     122        char *buffer = (char *)malloc( lstrlen( expression ) + 1 );
     123        lstrcpy( buffer, expression );
     124        RemoveStringBracket( buffer );
     125
     126        void *binary = malloc( 1 );
     127        int num = 0;
     128
     129        i = 0;
     130        while( buffer[i] ){
     131            i = GetOneParameter( buffer, i, temporary );
     132            if( buffer[i] == ',' ){
     133                i++;
     134            }
     135
     136            Type resultType;
     137            _int64 i64data;
     138            if( !StaticCalculation( true, temporary, tempBaseType.GetBasicType(), &i64data, resultType ) ){
     139                return false;
     140            }
     141            if( !resultType.IsWhole() ){
     142                // TODO: 実数に未対応
     143                SetError();
     144                return false;
     145            }
     146
     147            binary = realloc( binary, ( num + 1 ) * tempBaseType.GetSize() );
     148            memcpy( (char *)binary + (num * tempBaseType.GetSize()), &i64data, tempBaseType.GetSize() );
     149            num++;
     150        }
     151
     152        i2 = dataTable.AddBinary( binary, num * tempBaseType.GetSize() );
     153
     154        //mov reg,i2
     155        op_mov_RV(sizeof(_int64),*pReg,i2);
     156        obp-=sizeof(long);
     157        pobj_DataTableSchedule->add();
     158        obp+=sizeof(long);
     159
     160        free( buffer );
     161
     162        resultType = baseType;
    108163
    109164        return true;
Note: See TracChangeset for help on using the changeset viewer.