Changeset 206 in dev for trunk/abdev/BasicCompiler_Common/calculation.cpp
- Timestamp:
- Jul 12, 2007, 2:58:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/calculation.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 4 … … 498 500 //定数関数 499 501 500 if(!GetConstCalcBuffer(temporary,temp2,Parms)){ 502 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( temporary ); 503 if( !pConstMacro ) 504 { 505 if(enableerror) SetError(3,temporary,cp); 506 return false; 507 } 508 if( !pConstMacro->GetCalcBuffer( temp2, Parms ) ) 509 { 501 510 if(enableerror) SetError(3,temporary,cp); 502 511 return false; … … 554 563 555 564 RELATIVE_VAR RelativeVar; 556 int ss[MAX_ARRAYDIM];557 565 void *offset; 558 566 DWORD dwData; … … 563 571 564 572 Type tempType; 565 i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType ,ss);573 i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType); 566 574 if(i3==0){ 567 575 //式エラー … … 657 665 ///////// 658 666 StrPtr[pnum]=0; 659 type[pnum] = CDBConst::obj.GetBasicType(Parms);667 type[pnum] = compiler.GetMeta().GetGlobalConsts().GetBasicType(Parms); 660 668 if(type[pnum]){ 661 669 if(IsRealNumberType(type[pnum])){ 662 670 //実数型 663 nums[pnum] = CDBConst::obj.GetDoubleData(Parms);671 nums[pnum] = compiler.GetMeta().GetGlobalConsts().GetDoubleData(Parms); 664 672 } 665 673 else if(IsWholeNumberType(type[pnum])){ 666 674 //整数 667 i64nums[pnum] = CDBConst::obj.GetWholeData(Parms);675 i64nums[pnum] = compiler.GetMeta().GetGlobalConsts().GetWholeData(Parms); 668 676 } 669 677 /* else if(type[pnum]==DEF_STRING){ … … 1108 1116 #pragma optimize("", on) 1109 1117 1110 BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer){1111 extern HANDLE hHeap;1112 int i2,i3,i4,num;1113 char temporary[VN_SIZE];1114 char *pParms[MAX_PARMS];1115 1116 CONSTINFO *pci;1117 pci=GetConstHash(name);1118 if(!pci) return 0;1119 1120 num=0;1121 i2=0;1122 while(1){1123 i2=GetOneParameter(Parameter,i2,temporary);1124 1125 pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);1126 lstrcpy(pParms[num],temporary);1127 1128 num++;1129 if(Parameter[i2]=='\0') break;1130 }1131 if(num!=pci->ParmNum){1132 extern int cp;1133 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);1134 SetError(10,name,cp);1135 lstrcpy(pCalcBuffer,"0");1136 return 1;1137 }1138 1139 i2=0;1140 i4=0;1141 while(1){1142 1143 //数式内の項を取得1144 for(i3=0;;i2++,i3++){1145 if(!IsVariableChar(pci->StrValue[i2])){1146 temporary[i3]=0;1147 break;1148 }1149 temporary[i3]=pci->StrValue[i2];1150 }1151 1152 //パラメータと照合する1153 for(i3=0;i3<pci->ParmNum;i3++){1154 if(lstrcmp(pci->ppParm[i3],temporary)==0) break;1155 }1156 1157 if(i3==pci->ParmNum){1158 //パラメータでないとき1159 lstrcpy(pCalcBuffer+i4,temporary);1160 i4+=lstrlen(temporary);1161 }1162 else{1163 //パラメータのとき1164 lstrcpy(pCalcBuffer+i4,pParms[i3]);1165 i4+=lstrlen(pParms[i3]);1166 }1167 1168 //演算子をコピー1169 for(;;i2++,i4++){1170 if(pci->StrValue[i2]==1){1171 pCalcBuffer[i4++]=pci->StrValue[i2++];1172 pCalcBuffer[i4]=pci->StrValue[i2];1173 continue;1174 }1175 if(IsVariableTopChar(pci->StrValue[i2])) break;1176 pCalcBuffer[i4]=pci->StrValue[i2];1177 if(pci->StrValue[i2]=='\0') break;1178 }1179 1180 if(pci->StrValue[i2]=='\0') break;1181 }1182 1183 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);1184 1185 return 1;1186 }1187 DWORD GetConstValue(char *name,double *pDbl,char *buffer,LONG_PTR *plpIndex){1188 CONSTINFO *pci;1189 pci=GetConstHash(name);1190 if(pci){1191 //定数が見つかったとき1192 1193 if(pci->StrValue){1194 //文字列定数1195 1196 //バイト数1197 *pDbl=pci->DblValue;1198 1199 //データ1200 memcpy(buffer,pci->StrValue,(int)pci->DblValue);1201 1202 if(plpIndex) *plpIndex=pci->lpIndex;1203 1204 return DEF_STRING;1205 }1206 else{1207 if(pci->type==DEF_INT64){1208 memcpy(pDbl,&pci->i64Value,sizeof(_int64));1209 return DEF_INT64;1210 }1211 1212 if(plpIndex) *plpIndex=pci->lpIndex;1213 1214 *pDbl=pci->DblValue;1215 return pci->type;1216 }1217 }1218 1219 if(plpIndex) *plpIndex=-1;1220 1221 return -1;1222 }1223 1118 int IsStrCalculation(char *Command){ 1224 1119 int i,i2,i3,i4,PareNum; … … 1283 1178 1284 1179 //ユーザー定義関数 1285 UserProc *pUserProc; 1286 pUserProc=GetSubHash(temporary); 1180 const UserProc *pUserProc = GetSubHash(temporary); 1287 1181 if(pUserProc){ 1288 1182 if( pUserProc->ReturnType().IsStringClass() ){ … … 1300 1194 1301 1195 //定数 1302 CONSTINFO *pci; 1303 pci=GetConstHash(temporary); 1304 if(pci){ 1305 1306 if(pci->ParmNum){ 1307 //マクロ関数の場合 1308 GetStringInPare_RemovePare(temporary,Command+i2+i3+1); 1309 GetConstCalcBuffer(pci->name,temporary,temp2); 1310 return IsStrCalculation(temp2); 1311 } 1312 1313 if(pci->type==DEF_STRING) return 1; 1314 else return 0; 1196 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( temporary ); 1197 if(pConstMacro){ 1198 //マクロ関数の場合 1199 GetStringInPare_RemovePare(temporary,Command+i2+i3+1); 1200 pConstMacro->GetCalcBuffer( temporary, temp2 ); 1201 return IsStrCalculation(temp2); 1315 1202 } 1316 1203 } 1317 1204 1318 1205 //定数 1319 i3 = CDBConst::obj.GetBasicType(Command+i2);1206 i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(Command+i2); 1320 1207 if(i3==DEF_STRING) return 1; //文字列 1321 1208 if(i3) return 0; //数値
Note:
See TracChangeset
for help on using the changeset viewer.