Changeset 93 in dev


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

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

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/NumOpe.cpp

    r92 r93  
    103103            return false;
    104104        }
     105
     106        return true;
     107    }
     108
     109    if( !baseType.IsNull() && expression[0] == '[' ){
     110        // リテラル配列の場合
     111
     112        if( !baseType.IsPointer() ){
     113            SetError(1,NULL,cp);
     114            return false;
     115        }
     116        Type tempBaseType( baseType );
     117        tempBaseType.PtrLevelDown();
     118
     119        char *buffer = (char *)malloc( lstrlen( expression ) + 1 );
     120        lstrcpy( buffer, expression );
     121        RemoveStringBracket( buffer );
     122
     123        void *binary = malloc( 1 );
     124        int num = 0;
     125
     126        i = 0;
     127        while( buffer[i] ){
     128            i = GetOneParameter( buffer, i, temporary );
     129            if( buffer[i] == ',' ){
     130                i++;
     131            }
     132
     133            Type resultType;
     134            _int64 i64data;
     135            if( !StaticCalculation( true, temporary, tempBaseType.GetBasicType(), &i64data, resultType ) ){
     136                return false;
     137            }
     138            if( !resultType.IsWhole() ){
     139                // TODO: 実数に未対応
     140                SetError();
     141                return false;
     142            }
     143
     144            binary = realloc( binary, ( num + 1 ) * tempBaseType.GetSize() );
     145            memcpy( (char *)binary + (num * tempBaseType.GetSize()), &i64data, tempBaseType.GetSize() );
     146            num++;
     147        }
     148
     149        i2 = dataTable.AddBinary( binary, num * tempBaseType.GetSize() );
     150
     151        //mov eax,i2
     152        op_mov_RV(REG_EAX,i2);
     153        obp-=sizeof(long);
     154        pobj_DataTableSchedule->add();
     155        obp+=sizeof(long);
     156
     157        free( buffer );
     158
     159        resultType = baseType;
     160
     161        //push eax
     162        op_push( REG_EAX );
    105163
    106164        return true;
  • 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;
  • BasicCompiler_Common/common.h

    r91 r93  
    4747
    4848#ifdef _AMD64_
    49 #define VER_INFO        "(x64) β rev.206"
     49#define VER_INFO        "(x64) β rev.209"
    5050#else
    51 #define VER_INFO        "β rev.206"
     51#define VER_INFO        "β rev.209"
    5252#endif
    5353
Note: See TracChangeset for help on using the changeset viewer.