Changeset 8 in dev for BasicCompiler32
- Timestamp:
- Dec 7, 2006, 3:10:05 AM (18 years ago)
- Location:
- BasicCompiler32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_Var.cpp
r3 r8 853 853 int CalcType; 854 854 LONG_PTR lpCalcIndex; 855 CalcType=StaticCalculation(true, InitBuf,type,&i64data,&lpCalcIndex); 855 CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex); 856 if(!CalcType){ 857 //動的データだった場合 858 return 0; 859 } 856 860 if(IsRealNumberType(CalcType)){ 857 861 memcpy(&dbl,&i64data,sizeof(double)); … … 995 999 extern HANDLE hHeap; 996 1000 int i2,i3,VarSize; 1001 char VarName[VN_SIZE]; 1002 1003 1004 if(dwFlag & DIMFLAG_CONST){ 1005 ////////////////////////////////// 1006 // 定数変数の場合を考慮 1007 ////////////////////////////////// 1008 for(i2=0;;i2++){ 1009 if(Parameter[i2] == '=' || 1010 Parameter[i2] == 1 && Parameter[i2] == ESC_AS || 1011 Parameter[i2] =='('){ 1012 VarName[i2] = 0; 1013 break; 1014 } 1015 VarName[i2] = Parameter[i2]; 1016 } 1017 1018 //定数と2重定義されていないる場合は抜け出す 1019 if(CDBConst::obj.GetType(VarName)){ 1020 return; 1021 } 1022 1023 //定数マクロとして定義されている場合は抜け出す 1024 if(GetConstHash(VarName)){ 1025 return; 1026 } 1027 } 1028 997 1029 998 1030 //構文を解析 999 char VarName[VN_SIZE];1000 1031 int SubScripts[MAX_ARRAYDIM]; 1001 1032 TYPEINFO TypeInfo; … … 1005 1036 return; 1006 1037 1038 1039 //定数と2重定義されていないかを調べる 1040 if(CDBConst::obj.GetType(VarName)){ 1041 SetError(15,VarName,cp); 1042 return; 1043 } 1044 1045 //定数マクロとして定義されている場合 1046 if(GetConstHash(VarName)){ 1047 SetError(15,VarName,cp); 1048 return; 1049 } 1050 1051 1007 1052 //タイプサイズを取得 1008 1053 int TypeSize; 1009 1054 TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex); 1010 1011 //定数と2重定義されていないかを調べる1012 if(GetConstHash(VarName)){1013 SetError(15,VarName,cp);1014 return;1015 }1016 1055 1017 1056 if(dwFlag&DIMFLAG_STATIC){ … … 1071 1110 if(VarSize%4) VarSize+=4-(VarSize%4); 1072 1111 1112 VARIABLE *pVar = &LocalVar[MaxLocalVarNum]; 1113 1114 MaxLocalVarNum++; 1115 1073 1116 //変数データを追加 1074 lstrcpy(LocalVar[MaxLocalVarNum].name,VarName); 1075 LocalVar[MaxLocalVarNum].fRef=0; 1076 if(SubScripts[0]==-1) LocalVar[MaxLocalVarNum].bArray=0; 1077 else LocalVar[MaxLocalVarNum].bArray=1; 1078 LocalVar[MaxLocalVarNum].type=TypeInfo.type; 1079 LocalVar[MaxLocalVarNum].u.index=TypeInfo.u.lpIndex; 1117 lstrcpy(pVar->name,VarName); 1118 pVar->fRef=0; 1119 if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1; 1120 else pVar->bConst = 0; 1121 if(SubScripts[0]==-1) pVar->bArray=0; 1122 else pVar->bArray=1; 1123 pVar->type=TypeInfo.type; 1124 pVar->u.index=TypeInfo.u.lpIndex; 1080 1125 AllLocalVarSize+=VarSize; 1081 LocalVar[MaxLocalVarNum].offset=AllLocalVarSize;1126 pVar->offset=AllLocalVarSize; 1082 1127 1083 1128 //レキシカルスコープ 1084 LocalVar[MaxLocalVarNum].ScopeLevel=obj_LexScopes.GetNowLevel();1085 LocalVar[MaxLocalVarNum].ScopeStartAddress=obj_LexScopes.GetStartAddress();1086 LocalVar[MaxLocalVarNum].bLiving=TRUE;1129 pVar->ScopeLevel=obj_LexScopes.GetNowLevel(); 1130 pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress(); 1131 pVar->bLiving=TRUE; 1087 1132 1088 1133 if(InitBuf[0]){ 1089 InitLocalVar(-LocalVar[MaxLocalVarNum].offset,1090 LocalVar[MaxLocalVarNum].type,1091 LocalVar[MaxLocalVarNum].u.index,1092 LocalVar[MaxLocalVarNum].SubScripts,1134 int result = InitLocalVar(-pVar->offset, 1135 pVar->type, 1136 pVar->u.index, 1137 pVar->SubScripts, 1093 1138 InitBuf); 1139 1140 if(!result){ 1141 //動的な式だった場合は代入演算を行う 1142 char temporary[8192]; 1143 sprintf(temporary,"%s=%s",VarName,InitBuf); 1144 OpcodeCalc(temporary); 1145 } 1094 1146 } 1095 1147 else{ … … 1106 1158 //add eax,offset 1107 1159 OpBuffer[obp++]=(char)0x05; 1108 *((long *)(OpBuffer+obp))=- LocalVar[MaxLocalVarNum].offset;1160 *((long *)(OpBuffer+obp))=-pVar->offset; 1109 1161 AddLocalVarAddrSchedule(); 1110 1162 obp+=sizeof(long); … … 1122 1174 obp+=sizeof(long); 1123 1175 } 1124 1125 MaxLocalVarNum++;1126 1176 } 1127 1177 -
BasicCompiler32/NumOpe.cpp
r3 r8 438 438 ////////////// 439 439 440 i3 =GetConstValue(term,&dbl,temporary,&index_stack[sp]);441 if(i3 !=-1){440 i3 = CDBConst::obj.GetType(term); 441 if(i3){ 442 442 type[sp]=i3; 443 443 if(IsRealNumberType(i3)){ 444 444 //実数 445 double dbl = CDBConst::obj.GetDoubleData(term); 445 446 memcpy(&i64data,&dbl,sizeof(double)); 446 447 goto Literal; … … 448 449 else if(IsWholeNumberType(i3)){ 449 450 //整数 450 i64data =(_int64)dbl;451 i64data = CDBConst::obj.GetWholeData(term); 451 452 goto Literal; 452 453 } 453 else if(Is64Type(i3)){ 454 //64ビット整数値 455 memcpy(&i64data,&dbl,sizeof(_int64)); 456 goto Literal; 457 } 458 else if(i3==DEF_STRING){ 454 /*else if(i3==DEF_STRING){ 459 455 //リテラル文字列 460 456 … … 464 460 memcpy(term,temporary,i3); 465 461 goto StrLiteral; 466 } 462 }*/ 467 463 else{ 468 464 SetError(300,NULL,cp); -
BasicCompiler32/Opcode.h
r3 r8 174 174 BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0); 175 175 BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf); 176 #define DIMFLAG_INITDEBUGVAR 1 177 #define DIMFLAG_NONCALL_CONSTRACTOR 2 178 #define DIMFLAG_STATIC 4 176 #define DIMFLAG_INITDEBUGVAR 1 177 #define DIMFLAG_NONCALL_CONSTRACTOR 2 178 #define DIMFLAG_STATIC 4 179 #define DIMFLAG_CONST 8 179 180 void OpcodeDim(char *Parameter,DWORD dwFlag); 180 181 void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
Note:
See TracChangeset
for help on using the changeset viewer.