| [4] | 1 | #include "../BasicCompiler_Common/common.h" | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #ifdef _AMD64_ | 
|---|
|  | 4 | #include "../BasicCompiler64/opcode.h" | 
|---|
|  | 5 | #else | 
|---|
| [5] | 6 | #include "../BasicCompiler32/opcode.h" | 
|---|
| [4] | 7 | #endif | 
|---|
|  | 8 |  | 
|---|
|  | 9 | double dbl_stack[255]; | 
|---|
|  | 10 | _int64 i64stack[255]; | 
|---|
|  | 11 |  | 
|---|
| [15] | 12 | bool IsNumberTopChar(const char *buffer){ | 
|---|
| [14] | 13 | int c = buffer[0]; | 
|---|
|  | 14 | if('0' <= c && c <= '9') return true; | 
|---|
| [15] | 15 | if(c == '&' && (buffer[1] == 'h' || buffer[1] == 'H' || buffer[1] == 'o' || buffer[1] == 'O')) return true; | 
|---|
| [14] | 16 |  | 
|---|
|  | 17 | return false; | 
|---|
|  | 18 | } | 
|---|
| [15] | 19 | bool IsNumberChar(const char c){ | 
|---|
| [14] | 20 | if('0' <= c && c <= '9') return true; | 
|---|
|  | 21 | if('a' <= c && c <= 'f') return true; | 
|---|
|  | 22 | if('A' <= c && c <= 'F') return true; | 
|---|
| [15] | 23 | if(c=='.' || c=='e'||c=='E') return true; | 
|---|
| [14] | 24 |  | 
|---|
|  | 25 | return false; | 
|---|
|  | 26 | } | 
|---|
| [15] | 27 | BOOL IsJudgMark(const char *Command,int p){ | 
|---|
| [4] | 28 | if(Command[p]==1){ | 
|---|
|  | 29 | if(Command[p+1]==ESC_AND) return 1; | 
|---|
|  | 30 | if(Command[p+1]==ESC_OR) return 1; | 
|---|
|  | 31 | if(Command[p+1]==ESC_XOR) return 1; | 
|---|
|  | 32 | if(Command[p+1]==ESC_NOT) return 1; | 
|---|
|  | 33 | } | 
|---|
|  | 34 | return 0; | 
|---|
|  | 35 | } | 
|---|
| [15] | 36 | BOOL IsNumCalcMark(const char *Command,int p){ | 
|---|
| [4] | 37 | if(Command[p]=='^'||Command[p]=='*'||Command[p]=='/'||Command[p]=='\\'|| | 
|---|
|  | 38 | (Command[p]==1&&Command[p+1]==ESC_MOD)||Command[p]=='+'||Command[p]=='-'|| | 
|---|
|  | 39 | Command[p]=='='||Command[p]=='<'||Command[p]=='>'|| | 
|---|
|  | 40 | IsJudgMark(Command,p)|| | 
|---|
| [41] | 41 | (Command[p]==1&&Command[p+1]==ESC_AS)|| | 
|---|
|  | 42 | (Command[p]==1&&Command[p+1]==ESC_BYVAL)) return 1; | 
|---|
| [4] | 43 | return 0; | 
|---|
|  | 44 | } | 
|---|
| [15] | 45 | BOOL IsNumCalcMark_Back(const char *Command,int p){ | 
|---|
| [4] | 46 | if(p==0){ | 
|---|
|  | 47 | if(Command[p]=='^'||Command[p]=='*'||Command[p]=='/'||Command[p]=='\\'|| | 
|---|
|  | 48 | Command[p]=='+'||Command[p]=='-'|| | 
|---|
|  | 49 | Command[p]=='='||Command[p]=='<'||Command[p]=='>') return 1; | 
|---|
|  | 50 | } | 
|---|
|  | 51 | else{ | 
|---|
|  | 52 | if(Command[p]=='^'||Command[p]=='*'||Command[p]=='/'||Command[p]=='\\'|| | 
|---|
|  | 53 | (Command[p-1]==1&&Command[p]==ESC_MOD)||Command[p]=='+'||Command[p]=='-'|| | 
|---|
|  | 54 | Command[p]=='='||Command[p]=='<'||Command[p]=='>'|| | 
|---|
|  | 55 | IsJudgMark(Command,p-1)|| | 
|---|
|  | 56 | (Command[p-1]==1&&Command[p]==ESC_AS)) return 1; | 
|---|
|  | 57 | } | 
|---|
|  | 58 | return 0; | 
|---|
|  | 59 | } | 
|---|
| [15] | 60 | BOOL IsStrCalcMark(const char c){ | 
|---|
| [4] | 61 | if(c=='+'||c=='&') return 1; | 
|---|
|  | 62 | return 0; | 
|---|
|  | 63 | } | 
|---|
| [15] | 64 | BOOL IsExponent(const char *Command,int p){ | 
|---|
| [4] | 65 | int i,sw; | 
|---|
|  | 66 | for(i=p-2,sw=FALSE;i>=0;i--){ | 
|---|
|  | 67 | if(Command[i]>='0'&&Command[i]<='9') sw=TRUE; | 
|---|
|  | 68 | if(!((Command[i]>='0'&&Command[i]<='9')||Command[i]=='.')){ | 
|---|
|  | 69 | if((IsNumCalcMark(Command,i)||Command[i]=='('||Command[i]==')')&&sw) return TRUE; | 
|---|
|  | 70 | return FALSE; | 
|---|
|  | 71 | } | 
|---|
|  | 72 | if(i==0&&sw) return TRUE; | 
|---|
|  | 73 | } | 
|---|
|  | 74 | return FALSE; | 
|---|
|  | 75 | } | 
|---|
|  | 76 |  | 
|---|
|  | 77 | int CompStr(char *str1,int len1,char *str2,int len2){ | 
|---|
|  | 78 | int i,len; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | if(len1<len2) len=len1; | 
|---|
|  | 81 | else len=len2; | 
|---|
|  | 82 |  | 
|---|
|  | 83 | for(i=0;i<len;i++){ | 
|---|
|  | 84 | if((unsigned char *)str1[i]>(unsigned char *)str2[i]) return 1; | 
|---|
|  | 85 | else if((unsigned char *)str1[i]<(unsigned char *)str2[i]) return -1; | 
|---|
|  | 86 | } | 
|---|
|  | 87 | if(len1>len2) return 1; | 
|---|
|  | 88 | else if(len1<len2) return -1; | 
|---|
|  | 89 | return 0; | 
|---|
|  | 90 | } | 
|---|
|  | 91 | void TypeErrorCheck(_int64 *stack,int sp,long calc){ | 
|---|
|  | 92 | extern int cp; | 
|---|
|  | 93 | if(sp==0||calc==0) return; | 
|---|
|  | 94 | if(sp==1){ | 
|---|
|  | 95 | if(stack[0]){ | 
|---|
|  | 96 | SetError(9,NULL,cp); | 
|---|
|  | 97 | return; | 
|---|
|  | 98 | } | 
|---|
|  | 99 | return; | 
|---|
|  | 100 | } | 
|---|
|  | 101 | if(CALC_PE<=calc&&calc<=CALC_Q||calc==CALC_ADDITION){ | 
|---|
|  | 102 | //文字列演算が可能な演算子 | 
|---|
|  | 103 | if((stack[sp-2]&&stack[sp-1]==0)||(stack[sp-2]==0&&stack[sp-1])){ | 
|---|
|  | 104 | SetError(9,NULL,cp); | 
|---|
|  | 105 | return; | 
|---|
|  | 106 | } | 
|---|
|  | 107 | } | 
|---|
|  | 108 | else{ | 
|---|
|  | 109 | //文字列演算ができない演算子 | 
|---|
|  | 110 | if(stack[sp-2]||stack[sp-1]){ | 
|---|
|  | 111 | SetError(9,NULL,cp); | 
|---|
|  | 112 | return; | 
|---|
|  | 113 | } | 
|---|
|  | 114 | } | 
|---|
|  | 115 | } | 
|---|
|  | 116 |  | 
|---|
|  | 117 |  | 
|---|
|  | 118 | int GetLiteralIndex(_int64 i64data){ | 
|---|
|  | 119 | if(i64data==0) return LITERAL_NULL; | 
|---|
|  | 120 | else if(-128<=i64data&&i64data<0) return LITERAL_M128_0; | 
|---|
|  | 121 | else if(0<i64data&&i64data<256) return LITERAL_0_255; | 
|---|
|  | 122 | else if(-32768<=i64data&&i64data<0) return LITERAL_M32768_0; | 
|---|
|  | 123 | else if(0<i64data&&i64data<65536) return LITERAL_0_65535; | 
|---|
|  | 124 | else if(i64data<0) return LITERAL_OTHER_MINUS; | 
|---|
|  | 125 | return LITERAL_OTHER_PLUS; | 
|---|
|  | 126 | } | 
|---|
|  | 127 |  | 
|---|
|  | 128 |  | 
|---|
|  | 129 | int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2){ | 
|---|
|  | 130 |  | 
|---|
|  | 131 | if(type1==DEF_DOUBLE||type2==DEF_DOUBLE) return DEF_DOUBLE; | 
|---|
|  | 132 | if(type1==DEF_SINGLE||type2==DEF_SINGLE) return DEF_SINGLE; | 
|---|
|  | 133 |  | 
|---|
|  | 134 | int size1,size2; | 
|---|
|  | 135 | size1=GetTypeSize(type1,index1); | 
|---|
|  | 136 | size2=GetTypeSize(type2,index2); | 
|---|
|  | 137 | if(size1<size2){ | 
|---|
|  | 138 | size1=size2; | 
|---|
|  | 139 | } | 
|---|
|  | 140 | else if(type1==type2) return type1; | 
|---|
|  | 141 |  | 
|---|
|  | 142 | if(IsPtrType(type1)||IsPtrType(type2)){ | 
|---|
|  | 143 | if(IsPtrType(type1)) return type1; | 
|---|
|  | 144 | else return type2; | 
|---|
|  | 145 | } | 
|---|
|  | 146 |  | 
|---|
|  | 147 |  | 
|---|
|  | 148 | ///////////////////////////// | 
|---|
|  | 149 | // 片方がリテラル値の場合 | 
|---|
|  | 150 | // ※柔軟に符号を除去する | 
|---|
|  | 151 | ///////////////////////////// | 
|---|
|  | 152 | if(IsSignedType(type1)&&IS_POSITIVE_LITERAL(index1)&& | 
|---|
|  | 153 | IsSignedType(type2)==0){ | 
|---|
|  | 154 | type1=GetUnsignedType(type1); | 
|---|
|  | 155 | } | 
|---|
|  | 156 | if(IsSignedType(type1)==0&& | 
|---|
|  | 157 | IsSignedType(type2)&&IS_POSITIVE_LITERAL(index2)){ | 
|---|
|  | 158 | type2=GetUnsignedType(type2); | 
|---|
|  | 159 | } | 
|---|
|  | 160 |  | 
|---|
|  | 161 |  | 
|---|
|  | 162 | if(IsSignedType(type1)||IsSignedType(type2)){ | 
|---|
|  | 163 | //符号あり | 
|---|
| [55] | 164 | if(size1==sizeof(char))     return DEF_SBYTE; | 
|---|
| [4] | 165 | if(size1==sizeof(short))    return DEF_INTEGER; | 
|---|
|  | 166 | if(size1==sizeof(long))     return DEF_LONG; | 
|---|
|  | 167 | if(size1==sizeof(_int64))   return DEF_INT64; | 
|---|
|  | 168 | } | 
|---|
|  | 169 | else{ | 
|---|
|  | 170 | //符号なし | 
|---|
|  | 171 | if(size1==sizeof(char))     return DEF_BYTE; | 
|---|
|  | 172 | if(size1==sizeof(short))    return DEF_WORD; | 
|---|
|  | 173 | if(size1==sizeof(long))     return DEF_DWORD; | 
|---|
|  | 174 | if(size1==sizeof(_int64))   return DEF_QWORD; | 
|---|
|  | 175 | } | 
|---|
|  | 176 |  | 
|---|
|  | 177 | extern int cp; | 
|---|
|  | 178 | SetError(300,NULL,cp); | 
|---|
|  | 179 | return 0; | 
|---|
|  | 180 | } | 
|---|
|  | 181 |  | 
|---|
|  | 182 | void StaticTwoTerm(int idCalc,int *type_stack,LONG_PTR *index_stack,int *pStackPointer,int BaseType){ | 
|---|
|  | 183 | int sp,AnswerType; | 
|---|
|  | 184 |  | 
|---|
|  | 185 | sp=*pStackPointer; | 
|---|
|  | 186 |  | 
|---|
|  | 187 | AnswerType=NeutralizationType(type_stack[sp-2],index_stack[sp-2],type_stack[sp-1],index_stack[sp-1]); | 
|---|
|  | 188 |  | 
|---|
|  | 189 | if(IsRealNumberType(BaseType)&&idCalc==CALC_QUOTIENT) AnswerType=BaseType; | 
|---|
|  | 190 |  | 
|---|
|  | 191 | if(IsRealNumberType(AnswerType)){ | 
|---|
|  | 192 | /////////////// | 
|---|
|  | 193 | // 実数演算 | 
|---|
|  | 194 | /////////////// | 
|---|
|  | 195 |  | 
|---|
|  | 196 | if(IsWholeNumberType(type_stack[sp-2])) dbl_stack[sp-2]=(double)i64stack[sp-2]; | 
|---|
|  | 197 | if(IsWholeNumberType(type_stack[sp-1])) dbl_stack[sp-1]=(double)i64stack[sp-1]; | 
|---|
|  | 198 |  | 
|---|
|  | 199 |  | 
|---|
|  | 200 | //比較演算 | 
|---|
|  | 201 | if(idCalc==CALC_PE){ | 
|---|
|  | 202 | if(dbl_stack[sp-2]<=dbl_stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 203 | else i64stack[sp-2]=0; | 
|---|
|  | 204 | AnswerType=DEF_LONG; | 
|---|
|  | 205 | } | 
|---|
|  | 206 | else if(idCalc==CALC_QE){ | 
|---|
|  | 207 | if(dbl_stack[sp-2]>=dbl_stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 208 | else i64stack[sp-2]=0; | 
|---|
|  | 209 | AnswerType=DEF_LONG; | 
|---|
|  | 210 | } | 
|---|
|  | 211 | else if(idCalc==CALC_P){ | 
|---|
|  | 212 | if(dbl_stack[sp-2]<dbl_stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 213 | else i64stack[sp-2]=0; | 
|---|
|  | 214 | AnswerType=DEF_LONG; | 
|---|
|  | 215 | } | 
|---|
|  | 216 | else if(idCalc==CALC_Q){ | 
|---|
|  | 217 | if(dbl_stack[sp-2]>dbl_stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 218 | else i64stack[sp-2]=0; | 
|---|
|  | 219 | AnswerType=DEF_LONG; | 
|---|
|  | 220 | } | 
|---|
|  | 221 | else if(idCalc==CALC_NOTEQUAL){ | 
|---|
|  | 222 | if(dbl_stack[sp-2]!=dbl_stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 223 | else i64stack[sp-2]=0; | 
|---|
|  | 224 | AnswerType=DEF_LONG; | 
|---|
|  | 225 | } | 
|---|
|  | 226 | else if(idCalc==CALC_EQUAL){ | 
|---|
|  | 227 | if(dbl_stack[sp-2]==dbl_stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 228 | else i64stack[sp-2]=0; | 
|---|
|  | 229 | AnswerType=DEF_LONG; | 
|---|
|  | 230 | } | 
|---|
|  | 231 |  | 
|---|
|  | 232 | //論理演算 | 
|---|
|  | 233 | else if(idCalc==CALC_XOR)           dbl_stack[sp-2]=(double)((long)dbl_stack[sp-2]^(long)dbl_stack[sp-1]); | 
|---|
|  | 234 | else if(idCalc==CALC_OR)            dbl_stack[sp-2]=(double)((long)dbl_stack[sp-2]|(long)dbl_stack[sp-1]); | 
|---|
|  | 235 | else if(idCalc==CALC_AND)           dbl_stack[sp-2]=(double)((long)dbl_stack[sp-2]&(long)dbl_stack[sp-1]); | 
|---|
|  | 236 |  | 
|---|
|  | 237 | //シフト演算 | 
|---|
|  | 238 | else if(idCalc==CALC_SHL)           dbl_stack[sp-2]=(double)((DWORD)dbl_stack[sp-2]<<(DWORD)dbl_stack[sp-1]); | 
|---|
|  | 239 | else if(idCalc==CALC_SHR)           dbl_stack[sp-2]=(double)((DWORD)dbl_stack[sp-2]>>(DWORD)dbl_stack[sp-1]); | 
|---|
|  | 240 |  | 
|---|
|  | 241 | //算術演算 | 
|---|
|  | 242 | else if(idCalc==CALC_ADDITION)      dbl_stack[sp-2]+=dbl_stack[sp-1]; | 
|---|
|  | 243 | else if(idCalc==CALC_SUBTRACTION)   dbl_stack[sp-2]-=dbl_stack[sp-1]; | 
|---|
|  | 244 | else if(idCalc==CALC_MOD)           dbl_stack[sp-2]=(double)((long)dbl_stack[sp-2]%(long)dbl_stack[sp-1]); | 
|---|
|  | 245 | else if(idCalc==CALC_PRODUCT)       dbl_stack[sp-2]*=dbl_stack[sp-1]; | 
|---|
|  | 246 | else if(idCalc==CALC_QUOTIENT){ | 
|---|
|  | 247 | if(dbl_stack[sp-1]) | 
|---|
|  | 248 | dbl_stack[sp-2]/=dbl_stack[sp-1]; | 
|---|
|  | 249 | else{ | 
|---|
|  | 250 | //ゼロ割りエラーを検地 | 
|---|
|  | 251 | SetError(56,NULL,cp); | 
|---|
|  | 252 | } | 
|---|
|  | 253 | } | 
|---|
|  | 254 | else if(idCalc==CALC_INTQUOTIENT){ | 
|---|
|  | 255 | if(dbl_stack[sp-1]) | 
|---|
|  | 256 | dbl_stack[sp-2]=(double)(long)(dbl_stack[sp-2]/dbl_stack[sp-1]); | 
|---|
|  | 257 | else{ | 
|---|
|  | 258 | //ゼロ割りエラーを検地 | 
|---|
|  | 259 | SetError(56,NULL,cp); | 
|---|
|  | 260 | } | 
|---|
|  | 261 | } | 
|---|
|  | 262 | else if(idCalc==CALC_POWER)         dbl_stack[sp-2]=pow(dbl_stack[sp-2],dbl_stack[sp-1]); | 
|---|
|  | 263 | } | 
|---|
|  | 264 | else{ | 
|---|
|  | 265 | /////////////// | 
|---|
|  | 266 | // 整数演算 | 
|---|
|  | 267 | /////////////// | 
|---|
|  | 268 |  | 
|---|
|  | 269 | if(IsRealNumberType(type_stack[sp-2])) i64stack[sp-2]=(_int64)dbl_stack[sp-2]; | 
|---|
|  | 270 | if(IsRealNumberType(type_stack[sp-1])) i64stack[sp-1]=(_int64)dbl_stack[sp-1]; | 
|---|
|  | 271 |  | 
|---|
|  | 272 |  | 
|---|
|  | 273 | //比較演算 | 
|---|
|  | 274 | if(idCalc==CALC_PE){ | 
|---|
|  | 275 | if(IsSignedType(AnswerType)){ | 
|---|
|  | 276 | if(i64stack[sp-2]<=i64stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 277 | else i64stack[sp-2]=0; | 
|---|
|  | 278 | } | 
|---|
|  | 279 | else{ | 
|---|
|  | 280 | if(((unsigned _int64)i64stack[sp-2])<=((unsigned _int64)i64stack[sp-1])) i64stack[sp-2]=-1; | 
|---|
|  | 281 | else i64stack[sp-2]=0; | 
|---|
|  | 282 | } | 
|---|
|  | 283 | AnswerType=DEF_LONG; | 
|---|
|  | 284 | } | 
|---|
|  | 285 | else if(idCalc==CALC_QE){ | 
|---|
|  | 286 | if(IsSignedType(AnswerType)){ | 
|---|
|  | 287 | if(i64stack[sp-2]>=i64stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 288 | else i64stack[sp-2]=0; | 
|---|
|  | 289 | } | 
|---|
|  | 290 | else{ | 
|---|
|  | 291 | if(((unsigned _int64)i64stack[sp-2])>=((unsigned _int64)i64stack[sp-1])) i64stack[sp-2]=-1; | 
|---|
|  | 292 | else i64stack[sp-2]=0; | 
|---|
|  | 293 | } | 
|---|
|  | 294 | AnswerType=DEF_LONG; | 
|---|
|  | 295 | } | 
|---|
|  | 296 | else if(idCalc==CALC_P){ | 
|---|
|  | 297 | if(IsSignedType(AnswerType)){ | 
|---|
|  | 298 | if(i64stack[sp-2]<i64stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 299 | else i64stack[sp-2]=0; | 
|---|
|  | 300 | } | 
|---|
|  | 301 | else{ | 
|---|
|  | 302 | if(((unsigned _int64)i64stack[sp-2])<((unsigned _int64)i64stack[sp-1])) i64stack[sp-2]=-1; | 
|---|
|  | 303 | else i64stack[sp-2]=0; | 
|---|
|  | 304 | } | 
|---|
|  | 305 | AnswerType=DEF_LONG; | 
|---|
|  | 306 | } | 
|---|
|  | 307 | else if(idCalc==CALC_Q){ | 
|---|
|  | 308 | if(IsSignedType(AnswerType)){ | 
|---|
|  | 309 | AnswerType=NeutralizationType(type_stack[sp-2],index_stack[sp-2],type_stack[sp-1],index_stack[sp-1]); | 
|---|
|  | 310 | if(i64stack[sp-2]>i64stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 311 | else i64stack[sp-2]=0; | 
|---|
|  | 312 | } | 
|---|
|  | 313 | else{ | 
|---|
|  | 314 | if(((unsigned _int64)i64stack[sp-2])>((unsigned _int64)i64stack[sp-1])) i64stack[sp-2]=-1; | 
|---|
|  | 315 | else i64stack[sp-2]=0; | 
|---|
|  | 316 | } | 
|---|
|  | 317 | AnswerType=DEF_LONG; | 
|---|
|  | 318 | } | 
|---|
|  | 319 | else if(idCalc==CALC_NOTEQUAL){ | 
|---|
|  | 320 | if(i64stack[sp-2]!=i64stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 321 | else i64stack[sp-2]=0; | 
|---|
|  | 322 | AnswerType=DEF_LONG; | 
|---|
|  | 323 | } | 
|---|
|  | 324 | else if(idCalc==CALC_EQUAL){ | 
|---|
|  | 325 | if(i64stack[sp-2]==i64stack[sp-1]) i64stack[sp-2]=-1; | 
|---|
|  | 326 | else i64stack[sp-2]=0; | 
|---|
|  | 327 | AnswerType=DEF_LONG; | 
|---|
|  | 328 | } | 
|---|
|  | 329 |  | 
|---|
|  | 330 | //論理演算 | 
|---|
|  | 331 | else if(idCalc==CALC_XOR)           i64stack[sp-2]^=i64stack[sp-1]; | 
|---|
|  | 332 | else if(idCalc==CALC_OR)            i64stack[sp-2]|=i64stack[sp-1]; | 
|---|
|  | 333 | else if(idCalc==CALC_AND)           i64stack[sp-2]&=i64stack[sp-1]; | 
|---|
|  | 334 |  | 
|---|
|  | 335 | //シフト演算 | 
|---|
|  | 336 | else if(idCalc==CALC_SHL){ | 
|---|
|  | 337 | i64stack[sp-2]<<=(DWORD)i64stack[sp-1]; | 
|---|
|  | 338 | if(IsSignedType(AnswerType)) AnswerType=DEF_LONG; | 
|---|
|  | 339 | else AnswerType=DEF_DWORD; | 
|---|
|  | 340 | } | 
|---|
|  | 341 | else if(idCalc==CALC_SHR){ | 
|---|
|  | 342 | i64stack[sp-2]>>=(DWORD)i64stack[sp-1]; | 
|---|
|  | 343 | if(IsSignedType(AnswerType)) AnswerType=DEF_LONG; | 
|---|
|  | 344 | else AnswerType=DEF_DWORD; | 
|---|
|  | 345 | } | 
|---|
|  | 346 |  | 
|---|
|  | 347 | //算術演算 | 
|---|
|  | 348 | else if(idCalc==CALC_ADDITION)      i64stack[sp-2]+=i64stack[sp-1]; | 
|---|
|  | 349 | else if(idCalc==CALC_SUBTRACTION)   i64stack[sp-2]-=i64stack[sp-1]; | 
|---|
|  | 350 | else if(idCalc==CALC_MOD)           i64stack[sp-2]%=i64stack[sp-1]; | 
|---|
|  | 351 | else if(idCalc==CALC_PRODUCT)       i64stack[sp-2]*=i64stack[sp-1]; | 
|---|
|  | 352 | else if(idCalc==CALC_QUOTIENT|| | 
|---|
|  | 353 | idCalc==CALC_INTQUOTIENT){ | 
|---|
|  | 354 | if(i64stack[sp-1]) | 
|---|
|  | 355 | i64stack[sp-2]/=i64stack[sp-1]; | 
|---|
|  | 356 | else{ | 
|---|
|  | 357 | //ゼロ割りエラーを検地 | 
|---|
|  | 358 | SetError(56,NULL,cp); | 
|---|
|  | 359 | } | 
|---|
|  | 360 | } | 
|---|
|  | 361 | else if(idCalc==CALC_POWER)         i64stack[sp-2]=(_int64)pow((double)i64stack[sp-2],(double)i64stack[sp-1]); | 
|---|
|  | 362 |  | 
|---|
|  | 363 | if(IsSignedType(AnswerType)){ | 
|---|
| [55] | 364 | if(AnswerType==DEF_SBYTE&&(i64stack[sp-2]<CHAR_MIN||CHAR_MAX<i64stack[sp-2])){ | 
|---|
| [4] | 365 | //符号有り8ビット値をはみ出したとき | 
|---|
|  | 366 | AnswerType=DEF_INTEGER; | 
|---|
|  | 367 | } | 
|---|
|  | 368 | if(AnswerType==DEF_INTEGER&&(i64stack[sp-2]<SHRT_MIN||SHRT_MAX<i64stack[sp-2])){ | 
|---|
|  | 369 | //符号有り16ビット値をはみ出したとき | 
|---|
|  | 370 | AnswerType=DEF_LONG; | 
|---|
|  | 371 | } | 
|---|
|  | 372 | if(i64stack[sp-2]<LONG_MIN||LONG_MAX<i64stack[sp-2]){ | 
|---|
|  | 373 | //符号有り32ビット値をはみ出したとき | 
|---|
|  | 374 | AnswerType=DEF_INT64; | 
|---|
|  | 375 | } | 
|---|
|  | 376 | } | 
|---|
|  | 377 | else{ | 
|---|
|  | 378 | if(UINT_MAX<((unsigned _int64)i64stack[sp-2])){ | 
|---|
|  | 379 | //符号無し32ビット値をはみ出したとき | 
|---|
|  | 380 | AnswerType=DEF_QWORD; | 
|---|
|  | 381 | } | 
|---|
|  | 382 | } | 
|---|
|  | 383 | } | 
|---|
|  | 384 |  | 
|---|
|  | 385 | type_stack[sp-2]=AnswerType; | 
|---|
|  | 386 | index_stack[sp-2]=-1; | 
|---|
|  | 387 |  | 
|---|
|  | 388 | sp--; | 
|---|
|  | 389 | *pStackPointer=sp; | 
|---|
|  | 390 | } | 
|---|
|  | 391 |  | 
|---|
| [15] | 392 | int StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList){ | 
|---|
| [4] | 393 | extern HANDLE hHeap; | 
|---|
|  | 394 | extern int cp; | 
|---|
|  | 395 | int i,i2,i3,PareNum; | 
|---|
|  | 396 | char Parms[1024],temporary[VN_SIZE],temp2[VN_SIZE]; | 
|---|
|  | 397 |  | 
|---|
|  | 398 | _int64 i64data; | 
|---|
|  | 399 | double nums[255]; | 
|---|
|  | 400 | _int64 i64nums[255]; | 
|---|
|  | 401 | char *StrPtr[255]; | 
|---|
|  | 402 | long calc[255]; | 
|---|
|  | 403 | _int64 stack[255]; | 
|---|
|  | 404 | int type[255]; | 
|---|
|  | 405 | LONG_PTR before_index[255]; | 
|---|
|  | 406 | int sp,pnum; | 
|---|
|  | 407 |  | 
|---|
|  | 408 | *pi64data=0; | 
|---|
|  | 409 | if(Command[0]=='\0') return 0; | 
|---|
|  | 410 |  | 
|---|
|  | 411 | for(i=0,i2=0,sp=0,pnum=0,PareNum=0;;i++,i2++){ | 
|---|
|  | 412 | if(Command[i]=='\"'){ | 
|---|
|  | 413 | Parms[i2]=Command[i]; | 
|---|
|  | 414 | for(i++,i2++;;i++,i2++){ | 
|---|
|  | 415 | Parms[i2]=Command[i]; | 
|---|
|  | 416 | if(Command[i]=='\"') break; | 
|---|
|  | 417 | } | 
|---|
|  | 418 | continue; | 
|---|
|  | 419 | } | 
|---|
|  | 420 | else if(Command[i]=='['){ | 
|---|
|  | 421 | i3=GetStringInBracket(Parms+i2,Command+i); | 
|---|
|  | 422 | i+=i3-1; | 
|---|
|  | 423 | i2+=i3-1; | 
|---|
|  | 424 | continue; | 
|---|
|  | 425 | } | 
|---|
|  | 426 | else if(Command[i]=='('){ | 
|---|
|  | 427 | if(i==0){ | 
|---|
|  | 428 | PareNum++; | 
|---|
|  | 429 | i2=-1; | 
|---|
|  | 430 | continue; | 
|---|
|  | 431 | } | 
|---|
|  | 432 | else if(IsNumCalcMark_Back(Command,i-1)||Command[i-1]=='('){ | 
|---|
|  | 433 | PareNum++; | 
|---|
|  | 434 | i2=-1; | 
|---|
|  | 435 | continue; | 
|---|
|  | 436 | } | 
|---|
|  | 437 | else{ | 
|---|
|  | 438 | //配列変数の場合を考慮 | 
|---|
|  | 439 | i3=GetStringInPare(Parms+i2,Command+i); | 
|---|
|  | 440 | i+=i3-1; | 
|---|
|  | 441 | i2+=i3-1; | 
|---|
|  | 442 | continue; | 
|---|
|  | 443 | } | 
|---|
|  | 444 | } | 
|---|
|  | 445 | else if(Command[i]==')'){ | 
|---|
|  | 446 | PareNum--; | 
|---|
|  | 447 | i2--; | 
|---|
|  | 448 | continue; | 
|---|
|  | 449 | } | 
|---|
|  | 450 | else if(IsNumCalcMark(Command,i)||Command[i]=='\0'){ | 
|---|
|  | 451 | if((Command[i]=='+'||Command[i]=='-')&&(Command[i-1]=='e'||Command[i-1]=='E')){ | 
|---|
|  | 452 | if(IsExponent(Command,i)){ | 
|---|
|  | 453 | Parms[i2]=Command[i]; | 
|---|
|  | 454 | continue; | 
|---|
|  | 455 | } | 
|---|
|  | 456 | } | 
|---|
|  | 457 | Parms[i2]=0; | 
|---|
|  | 458 |  | 
|---|
|  | 459 | if(stack[sp-1]==CALC_AS&&Command[i]=='*'){ | 
|---|
|  | 460 | for(i3=0;i3<i2;i3++){ | 
|---|
|  | 461 | if(Parms[i2]!='*') break; | 
|---|
|  | 462 | } | 
|---|
|  | 463 | if(i3==i2){ | 
|---|
|  | 464 | //"*"をポインタ指定文字として認識する | 
|---|
|  | 465 | Parms[i2]=Command[i]; | 
|---|
|  | 466 | continue; | 
|---|
|  | 467 | } | 
|---|
|  | 468 | } | 
|---|
|  | 469 |  | 
|---|
|  | 470 | calc[pnum]=0; | 
|---|
|  | 471 | if(i2){ | 
|---|
|  | 472 | before_index[pnum]=-1; | 
|---|
|  | 473 |  | 
|---|
|  | 474 | i3=GetCallProcName(Parms,temporary); | 
|---|
|  | 475 | if(Parms[i3]=='('){ | 
|---|
|  | 476 | lstrcpy(temp2,Parms+i3+1); | 
|---|
|  | 477 | temp2[lstrlen(temp2)-1]=0; | 
|---|
|  | 478 |  | 
|---|
|  | 479 | if(lstrcmpi(temporary,"SizeOf")==0){ | 
|---|
|  | 480 | //SizeOf関数 | 
|---|
|  | 481 |  | 
|---|
|  | 482 | type[pnum]=DEF_LONG; | 
|---|
|  | 483 |  | 
|---|
|  | 484 | LONG_PTR lpIndex; | 
|---|
|  | 485 | i3=GetTypeFixed(temp2,&lpIndex); | 
|---|
|  | 486 | if(i3==-1){ | 
|---|
|  | 487 | extern int cp; | 
|---|
|  | 488 | if(enableerror) SetError(3,temp2,cp); | 
|---|
|  | 489 | return 0; | 
|---|
|  | 490 | } | 
|---|
|  | 491 | i64nums[pnum]=GetTypeSize(i3,lpIndex); | 
|---|
|  | 492 | StrPtr[pnum]=0; | 
|---|
|  | 493 | } | 
|---|
|  | 494 | else{ | 
|---|
|  | 495 | //定数関数 | 
|---|
|  | 496 |  | 
|---|
|  | 497 | if(!GetConstCalcBuffer(temporary,temp2,Parms)){ | 
|---|
|  | 498 | if(enableerror) SetError(3,temporary,cp); | 
|---|
|  | 499 | return 0; | 
|---|
|  | 500 | } | 
|---|
|  | 501 |  | 
|---|
|  | 502 | type[pnum]=StaticCalculation(true, Parms,BaseType,&i64data,&before_index[pnum]); | 
|---|
|  | 503 | if(IsRealNumberType(type[pnum])){ | 
|---|
|  | 504 | //整数型 | 
|---|
|  | 505 | memcpy(&nums[pnum],&i64data,sizeof(double)); | 
|---|
|  | 506 | } | 
|---|
|  | 507 | else{ | 
|---|
|  | 508 | //整数型 | 
|---|
|  | 509 | i64nums[pnum]=i64data; | 
|---|
|  | 510 | } | 
|---|
|  | 511 |  | 
|---|
|  | 512 | StrPtr[pnum]=0; | 
|---|
|  | 513 | } | 
|---|
|  | 514 | } | 
|---|
|  | 515 | else{ | 
|---|
|  | 516 | if(Parms[0]=='\"'){ | 
|---|
|  | 517 | //文字列の場合(比較演算子を考慮) | 
|---|
|  | 518 | RemoveStringQuotes(Parms); | 
|---|
|  | 519 | i2=lstrlen(Parms); | 
|---|
|  | 520 |  | 
|---|
|  | 521 | nums[pnum]=i2; | 
|---|
|  | 522 | StrPtr[pnum]=(char *)HeapAlloc(hHeap,0,i2+1); | 
|---|
|  | 523 | memcpy(StrPtr[pnum],Parms,i2); | 
|---|
|  | 524 | StrPtr[pnum][i2]=0; | 
|---|
|  | 525 |  | 
|---|
|  | 526 | type[pnum]=DEF_PTR_BYTE; | 
|---|
|  | 527 | before_index[pnum]=LITERAL_STRING; | 
|---|
|  | 528 | } | 
|---|
|  | 529 | else if((Parms[0]=='e'||Parms[0]=='E')&& | 
|---|
|  | 530 | (Parms[1]=='x'||Parms[1]=='X')&& | 
|---|
|  | 531 | Parms[2]=='\"'){ | 
|---|
|  | 532 | //拡張文字列 | 
|---|
|  | 533 | RemoveStringQuotes(Parms+2); | 
|---|
|  | 534 | i2=FormatString_EscapeSequence(Parms+2); | 
|---|
|  | 535 | nums[pnum]=i2; | 
|---|
|  | 536 | StrPtr[pnum]=(char *)HeapAlloc(hHeap,0,(int)i2+1); | 
|---|
|  | 537 | memcpy(StrPtr[pnum],Parms+2,i2); | 
|---|
|  | 538 | StrPtr[pnum][i2]=0; | 
|---|
|  | 539 |  | 
|---|
|  | 540 | type[pnum]=DEF_PTR_BYTE; | 
|---|
|  | 541 | before_index[pnum]=LITERAL_STRING; | 
|---|
|  | 542 | } | 
|---|
|  | 543 | else if(IsVariableTopChar(Parms[0])||Parms[0]=='*'){ | 
|---|
|  | 544 | if(bDebuggingWatchList){ | 
|---|
|  | 545 | ////////////////////////// | 
|---|
|  | 546 | // 変数(デバッグ時のみ) | 
|---|
|  | 547 | ////////////////////////// | 
|---|
|  | 548 |  | 
|---|
|  | 549 | RELATIVE_VAR RelativeVar; | 
|---|
|  | 550 | LONG_PTR lpIndex; | 
|---|
|  | 551 | int ss[MAX_ARRAYDIM]; | 
|---|
|  | 552 | void *offset; | 
|---|
|  | 553 | DWORD dwData; | 
|---|
|  | 554 | SIZE_T stAccBytes; | 
|---|
|  | 555 | float flt; | 
|---|
|  | 556 |  | 
|---|
|  | 557 | extern HANDLE hDebugProcess; | 
|---|
|  | 558 |  | 
|---|
|  | 559 | i3=Debugging_GetVarOffset(Parms,&i2,&RelativeVar,&lpIndex,ss); | 
|---|
|  | 560 | if(i3==0){ | 
|---|
|  | 561 | //式エラー | 
|---|
|  | 562 | return 0; | 
|---|
|  | 563 | } | 
|---|
|  | 564 | if(i3==-1){ | 
|---|
|  | 565 | //メモリにアクセスできないとき | 
|---|
|  | 566 | return -1; | 
|---|
|  | 567 | } | 
|---|
|  | 568 |  | 
|---|
|  | 569 | if(i3){ | 
|---|
|  | 570 | StrPtr[pnum]=0; | 
|---|
|  | 571 | offset=(void *)Debugging_GetVarPtr(&RelativeVar); | 
|---|
|  | 572 |  | 
|---|
|  | 573 | type[pnum]=i2; | 
|---|
|  | 574 |  | 
|---|
|  | 575 | if(i2==DEF_DOUBLE){ | 
|---|
|  | 576 | i3=ReadProcessMemory(hDebugProcess,offset,&nums[pnum],sizeof(double),&stAccBytes); | 
|---|
|  | 577 | } | 
|---|
|  | 578 | else if(i2==DEF_SINGLE){ | 
|---|
|  | 579 | if(i3=ReadProcessMemory(hDebugProcess,offset,&flt,sizeof(float),&stAccBytes)){ | 
|---|
|  | 580 | nums[pnum]=(double)flt; | 
|---|
|  | 581 | } | 
|---|
|  | 582 | } | 
|---|
|  | 583 | else if(IsPtrType(i2)){ | 
|---|
|  | 584 | LONG_PTR lpData; | 
|---|
|  | 585 | if(i3=ReadProcessMemory(hDebugProcess,offset,&lpData,sizeof(LONG_PTR),&stAccBytes)){ | 
|---|
|  | 586 | i64nums[pnum]=(_int64)lpData; | 
|---|
|  | 587 | } | 
|---|
|  | 588 | } | 
|---|
|  | 589 | else if(Is64Type(i2)){ | 
|---|
|  | 590 | type[pnum]=DEF_INT64; | 
|---|
|  | 591 |  | 
|---|
|  | 592 | i3=ReadProcessMemory(hDebugProcess,offset,&i64nums[pnum],sizeof(_int64),&stAccBytes); | 
|---|
|  | 593 | } | 
|---|
|  | 594 |  | 
|---|
|  | 595 | else if(i2==DEF_LONG){ | 
|---|
|  | 596 | long lData; | 
|---|
|  | 597 | if(i3=ReadProcessMemory(hDebugProcess,offset,&lData,sizeof(long),&stAccBytes)){ | 
|---|
|  | 598 | i64nums[pnum]=(_int64)lData; | 
|---|
|  | 599 | } | 
|---|
|  | 600 | } | 
|---|
|  | 601 | else if(i2==DEF_DWORD){ | 
|---|
|  | 602 | if(i3=ReadProcessMemory(hDebugProcess,offset,&dwData,sizeof(DWORD),&stAccBytes)){ | 
|---|
|  | 603 | i64nums[pnum]=(_int64)dwData; | 
|---|
|  | 604 | } | 
|---|
|  | 605 | } | 
|---|
| [55] | 606 | else if(i2==DEF_INTEGER || (isUnicode&&i2==DEF_CHAR)){ | 
|---|
| [4] | 607 | short shortData; | 
|---|
|  | 608 | if(i3=ReadProcessMemory(hDebugProcess,offset,&shortData,sizeof(short),&stAccBytes)){ | 
|---|
|  | 609 | i64nums[pnum]=(_int64)shortData; | 
|---|
|  | 610 | } | 
|---|
|  | 611 | } | 
|---|
|  | 612 | else if(i2==DEF_WORD){ | 
|---|
|  | 613 | WORD wData; | 
|---|
|  | 614 | if(i3=ReadProcessMemory(hDebugProcess,offset,&wData,sizeof(WORD),&stAccBytes)){ | 
|---|
|  | 615 | i64nums[pnum]=(_int64)wData; | 
|---|
|  | 616 | } | 
|---|
|  | 617 | } | 
|---|
| [55] | 618 | else if(i2==DEF_SBYTE || (isUnicode==false&&i2==DEF_CHAR)){ | 
|---|
| [4] | 619 | char charData; | 
|---|
|  | 620 | if(i3=ReadProcessMemory(hDebugProcess,offset,&charData,sizeof(char),&stAccBytes)){ | 
|---|
|  | 621 | i64nums[pnum]=(_int64)charData; | 
|---|
|  | 622 | } | 
|---|
|  | 623 | } | 
|---|
|  | 624 | else if(i2==DEF_BYTE){ | 
|---|
|  | 625 | BYTE byteData; | 
|---|
|  | 626 | if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){ | 
|---|
|  | 627 | i64nums[pnum]=(_int64)byteData; | 
|---|
|  | 628 | } | 
|---|
|  | 629 | } | 
|---|
| [36] | 630 | else if(i2==DEF_BOOLEAN){ | 
|---|
|  | 631 | BYTE byteData; | 
|---|
|  | 632 | if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){ | 
|---|
|  | 633 | i64nums[pnum]=(_int64)byteData; | 
|---|
|  | 634 | } | 
|---|
|  | 635 | } | 
|---|
| [4] | 636 | else return 0; | 
|---|
|  | 637 |  | 
|---|
|  | 638 | if(!i3){ | 
|---|
|  | 639 | //読み込みに失敗 | 
|---|
|  | 640 | return -1; | 
|---|
|  | 641 | } | 
|---|
|  | 642 | goto JumpConst; | 
|---|
|  | 643 | } | 
|---|
|  | 644 | } | 
|---|
|  | 645 |  | 
|---|
|  | 646 |  | 
|---|
|  | 647 | ///////// | 
|---|
|  | 648 | //定数 | 
|---|
|  | 649 | ///////// | 
|---|
|  | 650 | StrPtr[pnum]=0; | 
|---|
| [7] | 651 | type[pnum] = CDBConst::obj.GetType(Parms); | 
|---|
|  | 652 | if(type[pnum]){ | 
|---|
| [4] | 653 | if(IsRealNumberType(type[pnum])){ | 
|---|
|  | 654 | //実数型 | 
|---|
| [7] | 655 | nums[pnum] = CDBConst::obj.GetDoubleData(Parms); | 
|---|
| [4] | 656 | } | 
|---|
|  | 657 | else if(IsWholeNumberType(type[pnum])){ | 
|---|
|  | 658 | //整数 | 
|---|
| [7] | 659 | i64nums[pnum] = CDBConst::obj.GetWholeData(Parms); | 
|---|
| [4] | 660 | } | 
|---|
| [7] | 661 | /*                          else if(type[pnum]==DEF_STRING){ | 
|---|
| [4] | 662 | //リテラル文字列 | 
|---|
|  | 663 |  | 
|---|
|  | 664 | //バイト数 | 
|---|
|  | 665 | nums[pnum]=dbl; | 
|---|
|  | 666 | i2=(int)dbl; | 
|---|
|  | 667 |  | 
|---|
|  | 668 | memcpy(Parms,temporary,(int)nums[pnum]); | 
|---|
|  | 669 | goto StrLiteral; | 
|---|
| [7] | 670 | }*/ | 
|---|
| [4] | 671 | else{ | 
|---|
|  | 672 | //エラー | 
|---|
|  | 673 | if(enableerror) SetError(300,NULL,cp); | 
|---|
|  | 674 | return -1; | 
|---|
|  | 675 | } | 
|---|
|  | 676 | goto JumpConst; | 
|---|
|  | 677 | } | 
|---|
|  | 678 |  | 
|---|
|  | 679 |  | 
|---|
|  | 680 | ////////////// | 
|---|
|  | 681 | // 型名の場合 | 
|---|
|  | 682 | ////////////// | 
|---|
|  | 683 |  | 
|---|
|  | 684 | type[pnum]=GetTypeFixed(Parms,&before_index[pnum]); | 
|---|
|  | 685 |  | 
|---|
|  | 686 | if(type[pnum]==-1){ | 
|---|
|  | 687 | if(bDebuggingWatchList) return -1; | 
|---|
|  | 688 | //エラー | 
|---|
| [7] | 689 | if(enableerror) SetError(3,Parms,cp); | 
|---|
| [4] | 690 | return 0; | 
|---|
|  | 691 | } | 
|---|
|  | 692 | JumpConst:; | 
|---|
|  | 693 | } | 
|---|
|  | 694 | else{ | 
|---|
|  | 695 | //リテラル値 | 
|---|
|  | 696 | StrPtr[pnum]=0; | 
|---|
|  | 697 | type[pnum]=GetLiteralValue(Parms,&i64data,BaseType); | 
|---|
|  | 698 | if(IsRealNumberType(type[pnum])){ | 
|---|
|  | 699 | //実数型 | 
|---|
|  | 700 | memcpy(&nums[pnum],&i64data,sizeof(double)); | 
|---|
|  | 701 | } | 
|---|
|  | 702 | else{ | 
|---|
|  | 703 | //整数型 | 
|---|
|  | 704 | i64nums[pnum]=i64data; | 
|---|
|  | 705 | before_index[pnum]=GetLiteralIndex(i64data); | 
|---|
|  | 706 | } | 
|---|
|  | 707 | } | 
|---|
|  | 708 | } | 
|---|
|  | 709 |  | 
|---|
|  | 710 | pnum++; | 
|---|
|  | 711 | } | 
|---|
|  | 712 | else{ | 
|---|
|  | 713 | if(!(Command[i]=='+'||Command[i]=='-'||(Command[i]==1&&Command[i+1]==ESC_NOT))){ | 
|---|
|  | 714 | if(enableerror) SetError(1,NULL,cp); | 
|---|
|  | 715 | return 0; | 
|---|
|  | 716 | } | 
|---|
|  | 717 | if(Command[i]=='+'){ | 
|---|
|  | 718 | i2=-1; | 
|---|
|  | 719 | continue; | 
|---|
|  | 720 | } | 
|---|
|  | 721 | } | 
|---|
|  | 722 |  | 
|---|
|  | 723 | if(Command[i]=='\0'){ | 
|---|
|  | 724 | for(;sp>0;pnum++){ | 
|---|
|  | 725 | sp--; | 
|---|
|  | 726 | calc[pnum]=(int)stack[sp]; | 
|---|
|  | 727 | } | 
|---|
|  | 728 | break; | 
|---|
|  | 729 | } | 
|---|
|  | 730 |  | 
|---|
|  | 731 | //論理演算子 | 
|---|
|  | 732 | if(Command[i]==1&&Command[i+1]==ESC_XOR) i3=CALC_XOR; | 
|---|
|  | 733 | else if(Command[i]==1&&Command[i+1]==ESC_OR) i3=CALC_OR; | 
|---|
|  | 734 | else if(Command[i]==1&&Command[i+1]==ESC_AND) i3=CALC_AND; | 
|---|
|  | 735 | else if(Command[i]==1&&Command[i+1]==ESC_NOT) i3=CALC_NOT; | 
|---|
|  | 736 |  | 
|---|
|  | 737 | //ビット演算子(優先順位は算術演算子の後部) | 
|---|
|  | 738 | else if(Command[i]=='<'&&Command[i+1]=='<'){ | 
|---|
|  | 739 | i3=CALC_SHL; | 
|---|
|  | 740 | i++; | 
|---|
|  | 741 | } | 
|---|
|  | 742 | else if(Command[i]=='>'&&Command[i+1]=='>'){ | 
|---|
|  | 743 | i3=CALC_SHR; | 
|---|
|  | 744 | i++; | 
|---|
|  | 745 | } | 
|---|
|  | 746 |  | 
|---|
|  | 747 | //比較演算子 | 
|---|
|  | 748 | else if(Command[i]=='<'&&Command[i+1]=='='|| | 
|---|
|  | 749 | Command[i]=='='&&Command[i+1]=='<'){ | 
|---|
|  | 750 | i3=CALC_PE; | 
|---|
|  | 751 | i++; | 
|---|
|  | 752 | } | 
|---|
|  | 753 | else if(Command[i]=='>'&&Command[i+1]=='='|| | 
|---|
|  | 754 | Command[i]=='='&&Command[i+1]=='>'){ | 
|---|
|  | 755 | i3=CALC_QE; | 
|---|
|  | 756 | i++; | 
|---|
|  | 757 | } | 
|---|
|  | 758 | else if(Command[i]=='<'&&Command[i+1]=='>'|| | 
|---|
|  | 759 | Command[i]=='>'&&Command[i+1]=='<'){ | 
|---|
|  | 760 | i3=CALC_NOTEQUAL; | 
|---|
|  | 761 | i++; | 
|---|
|  | 762 | } | 
|---|
|  | 763 | else if(Command[i]=='=') i3=CALC_EQUAL; | 
|---|
|  | 764 | else if(Command[i]=='<') i3=CALC_P; | 
|---|
|  | 765 | else if(Command[i]=='>') i3=CALC_Q; | 
|---|
|  | 766 |  | 
|---|
|  | 767 | //算術演算子 | 
|---|
|  | 768 | else if(Command[i]=='+'||Command[i]=='&') i3=CALC_ADDITION; | 
|---|
|  | 769 | else if(Command[i]=='-'&&i2) i3=CALC_SUBTRACTION; | 
|---|
|  | 770 | else if(Command[i]==1&&Command[i+1]==ESC_MOD) i3=CALC_MOD; | 
|---|
|  | 771 | else if(Command[i]=='*') i3=CALC_PRODUCT; | 
|---|
|  | 772 | else if(Command[i]=='/') i3=CALC_QUOTIENT; | 
|---|
|  | 773 | else if(Command[i]=='\\') i3=CALC_INTQUOTIENT; | 
|---|
|  | 774 | else if(Command[i]=='-'&&i2==0) i3=CALC_MINUSMARK; | 
|---|
|  | 775 | else if(Command[i]=='^') i3=CALC_POWER; | 
|---|
|  | 776 | else if(Command[i]==1&&Command[i+1]==ESC_AS) i3=CALC_AS; | 
|---|
| [41] | 777 | else if(Command[i]==1&&Command[i+1]==ESC_BYVAL) i3=CALC_BYVAL; | 
|---|
| [4] | 778 |  | 
|---|
|  | 779 | i3+=PareNum*100; | 
|---|
|  | 780 | if(sp){ | 
|---|
|  | 781 | if(stack[sp-1]>i3-3&& | 
|---|
|  | 782 | (!( | 
|---|
|  | 783 | (stack[sp-1]%100==CALC_MINUSMARK||stack[sp-1]%100==CALC_NOT)&& | 
|---|
|  | 784 | (i3%100==CALC_MINUSMARK||i3%100==CALC_NOT) | 
|---|
|  | 785 | )) | 
|---|
|  | 786 | ){ | 
|---|
|  | 787 | for(;sp>0;){ | 
|---|
|  | 788 | sp--; | 
|---|
|  | 789 | calc[pnum]=(int)stack[sp]; | 
|---|
|  | 790 | pnum++; | 
|---|
|  | 791 | if(!(stack[sp-1]>i3-3)) break; | 
|---|
|  | 792 | } | 
|---|
|  | 793 | } | 
|---|
|  | 794 | } | 
|---|
|  | 795 | stack[sp]=i3; | 
|---|
|  | 796 | sp++; | 
|---|
|  | 797 |  | 
|---|
|  | 798 | if(Command[i]==1) i++; | 
|---|
|  | 799 | i2=-1; | 
|---|
|  | 800 | continue; | 
|---|
|  | 801 | } | 
|---|
|  | 802 | Parms[i2]=Command[i]; | 
|---|
|  | 803 | } | 
|---|
|  | 804 |  | 
|---|
|  | 805 | int type_stack[255]; | 
|---|
|  | 806 | LONG_PTR index_stack[255]; | 
|---|
|  | 807 | int idCalc; | 
|---|
|  | 808 | for(i=0,sp=0;i<pnum;i++){ | 
|---|
|  | 809 |  | 
|---|
|  | 810 | //型チェック(正常でない場合はエラーにする) | 
|---|
|  | 811 | TypeErrorCheck(stack,sp,calc[i]%100); | 
|---|
|  | 812 |  | 
|---|
|  | 813 | idCalc=calc[i]%100; | 
|---|
|  | 814 |  | 
|---|
|  | 815 | switch(idCalc){ | 
|---|
|  | 816 | //数値 | 
|---|
|  | 817 | case 0: | 
|---|
|  | 818 | dbl_stack[sp]=nums[i]; | 
|---|
|  | 819 | i64stack[sp]=i64nums[i]; | 
|---|
|  | 820 | type_stack[sp]=type[i]; | 
|---|
|  | 821 | index_stack[sp]=before_index[i]; | 
|---|
|  | 822 |  | 
|---|
|  | 823 | stack[sp]=(_int64)StrPtr[i]; | 
|---|
|  | 824 | sp++; | 
|---|
|  | 825 | break; | 
|---|
|  | 826 |  | 
|---|
|  | 827 | //論理演算 | 
|---|
|  | 828 | case CALC_NOT: | 
|---|
|  | 829 | if(IsRealNumberType(type_stack[sp-1])){ | 
|---|
|  | 830 | //実数演算 | 
|---|
|  | 831 | dbl_stack[sp-1]=(double)(~(long)dbl_stack[sp-1]); | 
|---|
|  | 832 | } | 
|---|
|  | 833 | else{ | 
|---|
|  | 834 | //整数演算 | 
|---|
|  | 835 | i64stack[sp-1]=~i64stack[sp-1]; | 
|---|
|  | 836 | } | 
|---|
|  | 837 | break; | 
|---|
|  | 838 |  | 
|---|
|  | 839 | //比較演算 | 
|---|
|  | 840 | case CALC_PE: | 
|---|
|  | 841 | case CALC_QE: | 
|---|
|  | 842 | case CALC_P: | 
|---|
|  | 843 | case CALC_Q: | 
|---|
|  | 844 | case CALC_NOTEQUAL: | 
|---|
|  | 845 | case CALC_EQUAL: | 
|---|
|  | 846 |  | 
|---|
|  | 847 | //論理演算 | 
|---|
|  | 848 | case CALC_XOR: | 
|---|
|  | 849 | case CALC_OR: | 
|---|
|  | 850 | case CALC_AND: | 
|---|
|  | 851 |  | 
|---|
|  | 852 | //シフト演算 | 
|---|
|  | 853 | case CALC_SHL: | 
|---|
|  | 854 | case CALC_SHR: | 
|---|
|  | 855 |  | 
|---|
|  | 856 | //算術演算 | 
|---|
|  | 857 | case CALC_ADDITION: | 
|---|
|  | 858 | case CALC_SUBTRACTION: | 
|---|
|  | 859 | case CALC_MOD: | 
|---|
|  | 860 | case CALC_PRODUCT: | 
|---|
|  | 861 | case CALC_QUOTIENT: | 
|---|
|  | 862 | case CALC_INTQUOTIENT: | 
|---|
|  | 863 | case CALC_POWER: | 
|---|
|  | 864 | StaticTwoTerm(idCalc,type_stack,index_stack,&sp,BaseType); | 
|---|
|  | 865 | break; | 
|---|
|  | 866 |  | 
|---|
|  | 867 | case CALC_MINUSMARK: | 
|---|
|  | 868 | if(IsRealNumberType(type_stack[sp-1])){ | 
|---|
|  | 869 | //実数演算 | 
|---|
|  | 870 | dbl_stack[sp-1]=-dbl_stack[sp-1]; | 
|---|
|  | 871 | } | 
|---|
|  | 872 | else{ | 
|---|
|  | 873 | //整数演算 | 
|---|
|  | 874 | i64stack[sp-1]=-i64stack[sp-1]; | 
|---|
|  | 875 | } | 
|---|
|  | 876 | break; | 
|---|
|  | 877 | case CALC_AS: | 
|---|
|  | 878 | if(IsWholeNumberType(type_stack[sp-2])){ | 
|---|
|  | 879 | if(IsRealNumberType(type_stack[sp-1])){ | 
|---|
|  | 880 | dbl_stack[sp-2]=(double)i64stack[sp-2]; | 
|---|
|  | 881 | } | 
|---|
|  | 882 | } | 
|---|
|  | 883 | if(IsRealNumberType(type_stack[sp-2])){ | 
|---|
|  | 884 | if(IsWholeNumberType(type_stack[sp-1])){ | 
|---|
|  | 885 | i64stack[sp-2]=(_int64)dbl_stack[sp-2]; | 
|---|
|  | 886 | } | 
|---|
|  | 887 | } | 
|---|
|  | 888 | type_stack[sp-2]=type_stack[sp-1]; | 
|---|
|  | 889 | index_stack[sp-2]=index_stack[sp-1]; | 
|---|
|  | 890 | sp--; | 
|---|
|  | 891 | break; | 
|---|
| [41] | 892 | case CALC_BYVAL: | 
|---|
|  | 893 | //エラー | 
|---|
|  | 894 | break; | 
|---|
| [4] | 895 | } | 
|---|
|  | 896 | } | 
|---|
|  | 897 | if(stack[0]){ | 
|---|
|  | 898 | //文字列ポインタ | 
|---|
|  | 899 | *pi64data=(_int64)stack[0]; | 
|---|
|  | 900 | *plpIndex=index_stack[0]; | 
|---|
|  | 901 | return type_stack[0]; | 
|---|
|  | 902 | } | 
|---|
|  | 903 |  | 
|---|
|  | 904 | if(IsRealNumberType(type_stack[0])){ | 
|---|
|  | 905 | //実数 | 
|---|
|  | 906 | memcpy(pi64data,&dbl_stack[0],sizeof(double)); | 
|---|
|  | 907 | return type_stack[0]; | 
|---|
|  | 908 | } | 
|---|
|  | 909 |  | 
|---|
|  | 910 | //整数 | 
|---|
|  | 911 | *pi64data=i64stack[0]; | 
|---|
|  | 912 |  | 
|---|
|  | 913 | if(plpIndex){ | 
|---|
|  | 914 | *plpIndex=index_stack[0]; | 
|---|
|  | 915 | if(*plpIndex==-1){ | 
|---|
|  | 916 | if(Is64Type(type_stack[0])==0&&IsRealNumberType(type_stack[0])==0){ | 
|---|
|  | 917 | //整数(符号有り/無し) | 
|---|
|  | 918 | i64data=*pi64data; | 
|---|
|  | 919 |  | 
|---|
|  | 920 | *plpIndex=GetLiteralIndex(i64data); | 
|---|
|  | 921 | } | 
|---|
|  | 922 | } | 
|---|
|  | 923 | } | 
|---|
|  | 924 |  | 
|---|
|  | 925 | return type_stack[0]; | 
|---|
|  | 926 | } | 
|---|
|  | 927 |  | 
|---|
|  | 928 | #pragma optimize("", off) | 
|---|
|  | 929 | DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType){ | 
|---|
|  | 930 | extern HANDLE hHeap; | 
|---|
|  | 931 | extern int cp; | 
|---|
|  | 932 | int i,i2,i3,sw1,sw2,bDbl; | 
|---|
|  | 933 | double dbl; | 
|---|
|  | 934 | char temporary[255]; | 
|---|
|  | 935 |  | 
|---|
|  | 936 | if(value[0]=='&'){ | 
|---|
|  | 937 | _int64 i64temp; | 
|---|
|  | 938 | lstrcpy(temporary,value); | 
|---|
|  | 939 |  | 
|---|
|  | 940 | if(temporary[1]=='o'||temporary[1]=='O'){ | 
|---|
|  | 941 | for(i=2;;i++){ | 
|---|
|  | 942 | i3=temporary[i]-0x30; | 
|---|
|  | 943 | if(i3<0||7<i3) break; | 
|---|
|  | 944 | temporary[i]=i3; | 
|---|
|  | 945 | } | 
|---|
|  | 946 | if(temporary[i]){ | 
|---|
|  | 947 | SetError(57,NULL,cp); | 
|---|
|  | 948 | return DEF_BYTE; | 
|---|
|  | 949 | } | 
|---|
|  | 950 |  | 
|---|
|  | 951 | i64temp=1; | 
|---|
|  | 952 | *pi64=0; | 
|---|
|  | 953 | for(i--;i>=2;i--){ | 
|---|
|  | 954 | *pi64=(*pi64)+(_int64)(i64temp*temporary[i]); | 
|---|
|  | 955 | i64temp*=8; | 
|---|
|  | 956 | } | 
|---|
|  | 957 | } | 
|---|
|  | 958 | else if(temporary[1]=='h'||temporary[1]=='H'){ | 
|---|
|  | 959 | CharUpper(temporary+2); | 
|---|
|  | 960 | for(i=2;;i++){ | 
|---|
|  | 961 | i3=temporary[i]-0x30; | 
|---|
|  | 962 | if(i3<0||9<i3){ | 
|---|
|  | 963 | i3=temporary[i]-0x41+10; | 
|---|
|  | 964 | if(i3<0xA||0xF<i3) break; | 
|---|
|  | 965 | } | 
|---|
|  | 966 | temporary[i]=i3; | 
|---|
|  | 967 | } | 
|---|
|  | 968 | if(temporary[i]){ | 
|---|
|  | 969 | SetError(58,NULL,cp); | 
|---|
|  | 970 | return DEF_BYTE; | 
|---|
|  | 971 | } | 
|---|
|  | 972 |  | 
|---|
|  | 973 | i64temp=1; | 
|---|
|  | 974 | *pi64=0; | 
|---|
|  | 975 | for(i--;i>=2;i--){ | 
|---|
|  | 976 | *pi64=(*pi64)+(_int64)(i64temp*temporary[i]); | 
|---|
|  | 977 | i64temp*=0x10; | 
|---|
|  | 978 | } | 
|---|
|  | 979 | } | 
|---|
|  | 980 | else{ | 
|---|
|  | 981 | SetError(12,"&",cp); | 
|---|
|  | 982 | return DEF_BYTE; | 
|---|
|  | 983 | } | 
|---|
|  | 984 |  | 
|---|
|  | 985 | if(BaseType==DEF_INT64||BaseType==DEF_QWORD) return DEF_QWORD; | 
|---|
|  | 986 |  | 
|---|
|  | 987 | if(((unsigned _int64)*pi64)<=UCHAR_MAX){ | 
|---|
|  | 988 | //符号無し8ビット整数のリテラル値 | 
|---|
|  | 989 | return DEF_BYTE; | 
|---|
|  | 990 | } | 
|---|
|  | 991 | else if(((unsigned _int64)*pi64)<=USHRT_MAX){ | 
|---|
|  | 992 | //符号無し16ビット整数のリテラル値 | 
|---|
|  | 993 | return DEF_WORD; | 
|---|
|  | 994 | } | 
|---|
|  | 995 | else if(((unsigned _int64)*pi64)<=UINT_MAX){ | 
|---|
|  | 996 | //符号無し32ビット整数のリテラル値 | 
|---|
|  | 997 | return DEF_DWORD; | 
|---|
|  | 998 | } | 
|---|
|  | 999 | else{ | 
|---|
|  | 1000 | //符号無し64ビット整数のリテラル値 | 
|---|
|  | 1001 | return DEF_QWORD; | 
|---|
|  | 1002 | } | 
|---|
|  | 1003 | } | 
|---|
|  | 1004 | else if((value[0]>='0'&&value[0]<='9')||value[0]=='+'||value[0]=='-'||(value[0]=='.'&&(!IsVariableTopChar(value[1])))){ | 
|---|
|  | 1005 | for(i=0;;i++){ | 
|---|
|  | 1006 | if(value[i]!='-') break; | 
|---|
|  | 1007 | } | 
|---|
|  | 1008 | if(value[i]=='.'){ | 
|---|
|  | 1009 | SlideString(value+i,1); | 
|---|
|  | 1010 | value[i]='0'; | 
|---|
|  | 1011 | } | 
|---|
|  | 1012 |  | 
|---|
|  | 1013 | //エラーチェック | 
|---|
|  | 1014 | bDbl=0; | 
|---|
|  | 1015 | sw1=0; | 
|---|
|  | 1016 | sw2=0; | 
|---|
|  | 1017 | for(i2=i;;i2++){ | 
|---|
|  | 1018 | if(value[i2]=='\0') break; | 
|---|
|  | 1019 | if(value[i2]=='.') bDbl=1; | 
|---|
|  | 1020 | if(!((value[i2]>='0'&&value[i2]<='9')||value[i2]=='.')){ | 
|---|
|  | 1021 | if((value[i2]=='e'||value[i2]=='E')&&sw1==0){ | 
|---|
|  | 1022 | bDbl=1; | 
|---|
|  | 1023 | sw1=1; | 
|---|
|  | 1024 | } | 
|---|
|  | 1025 | else if((value[i2]=='+'||value[i2]=='-')&&sw1==1&&sw2==0) sw2=1; | 
|---|
|  | 1026 | else{ | 
|---|
|  | 1027 | extern BOOL bDebugRun; | 
|---|
|  | 1028 | if(bDebugRun) return DEF_DOUBLE; | 
|---|
|  | 1029 |  | 
|---|
|  | 1030 | SetError(3,value,cp); | 
|---|
|  | 1031 | return DEF_DOUBLE; | 
|---|
|  | 1032 | } | 
|---|
|  | 1033 | } | 
|---|
|  | 1034 | } | 
|---|
|  | 1035 |  | 
|---|
|  | 1036 | if(bDbl){ | 
|---|
|  | 1037 | //実数のリテラル値 | 
|---|
|  | 1038 | if(i%2) dbl=-atof(value+i); | 
|---|
|  | 1039 | else dbl=atof(value+i); | 
|---|
|  | 1040 |  | 
|---|
|  | 1041 | memcpy(pi64,&dbl,sizeof(double)); | 
|---|
|  | 1042 |  | 
|---|
|  | 1043 | if(BaseType==DEF_SINGLE) return DEF_SINGLE; | 
|---|
|  | 1044 |  | 
|---|
|  | 1045 | return DEF_DOUBLE; | 
|---|
|  | 1046 | } | 
|---|
|  | 1047 | else{ | 
|---|
|  | 1048 | *pi64=_atoi64(value+i); | 
|---|
|  | 1049 | if(i%2) *pi64=-(*pi64); | 
|---|
|  | 1050 |  | 
|---|
|  | 1051 | if(BaseType==DEF_INT64||BaseType==DEF_QWORD) return BaseType; | 
|---|
|  | 1052 |  | 
|---|
|  | 1053 | if(LONG_MIN<=*pi64&&*pi64<=LONG_MAX){ | 
|---|
|  | 1054 | //符号有り32ビット整数のリテラル値 | 
|---|
|  | 1055 | return DEF_LONG; | 
|---|
|  | 1056 | } | 
|---|
|  | 1057 | else if(*pi64<=UINT_MAX){ | 
|---|
|  | 1058 | //符号無し32ビット整数のリテラル値 | 
|---|
|  | 1059 | return DEF_DWORD; | 
|---|
|  | 1060 | } | 
|---|
|  | 1061 | else{ | 
|---|
|  | 1062 | //符号有り64ビット整数のリテラル値 | 
|---|
|  | 1063 | return DEF_INT64; | 
|---|
|  | 1064 | } | 
|---|
|  | 1065 | } | 
|---|
|  | 1066 | } | 
|---|
|  | 1067 |  | 
|---|
|  | 1068 | extern BOOL bDebugRun; | 
|---|
|  | 1069 | if(bDebugRun) return DEF_DOUBLE; | 
|---|
|  | 1070 |  | 
|---|
|  | 1071 | SetError(33,NULL,cp); | 
|---|
|  | 1072 | return DEF_DOUBLE; | 
|---|
|  | 1073 | } | 
|---|
|  | 1074 | #pragma optimize("", on) | 
|---|
|  | 1075 |  | 
|---|
|  | 1076 | BOOL GetConstCalcBuffer(char *name,char *Parameter,char *pCalcBuffer){ | 
|---|
|  | 1077 | extern HANDLE hHeap; | 
|---|
|  | 1078 | int i2,i3,i4,num; | 
|---|
|  | 1079 | char temporary[VN_SIZE]; | 
|---|
|  | 1080 | char *pParms[MAX_PARMS]; | 
|---|
|  | 1081 |  | 
|---|
|  | 1082 | CONSTINFO *pci; | 
|---|
|  | 1083 | pci=GetConstHash(name); | 
|---|
|  | 1084 | if(!pci) return 0; | 
|---|
|  | 1085 |  | 
|---|
|  | 1086 | num=0; | 
|---|
|  | 1087 | i2=0; | 
|---|
|  | 1088 | while(1){ | 
|---|
|  | 1089 | i2=GetOneParameter(Parameter,i2,temporary); | 
|---|
|  | 1090 |  | 
|---|
|  | 1091 | pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); | 
|---|
|  | 1092 | lstrcpy(pParms[num],temporary); | 
|---|
|  | 1093 |  | 
|---|
|  | 1094 | num++; | 
|---|
|  | 1095 | if(Parameter[i2]=='\0') break; | 
|---|
|  | 1096 | } | 
|---|
|  | 1097 | if(num!=pci->ParmNum){ | 
|---|
|  | 1098 | extern int cp; | 
|---|
|  | 1099 | for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]); | 
|---|
|  | 1100 | SetError(10,name,cp); | 
|---|
|  | 1101 | lstrcpy(pCalcBuffer,"0"); | 
|---|
|  | 1102 | return 1; | 
|---|
|  | 1103 | } | 
|---|
|  | 1104 |  | 
|---|
|  | 1105 | i2=0; | 
|---|
|  | 1106 | i4=0; | 
|---|
|  | 1107 | while(1){ | 
|---|
|  | 1108 |  | 
|---|
|  | 1109 | //数式内の項を取得 | 
|---|
|  | 1110 | for(i3=0;;i2++,i3++){ | 
|---|
|  | 1111 | if(!IsVariableChar(pci->StrValue[i2])){ | 
|---|
|  | 1112 | temporary[i3]=0; | 
|---|
|  | 1113 | break; | 
|---|
|  | 1114 | } | 
|---|
|  | 1115 | temporary[i3]=pci->StrValue[i2]; | 
|---|
|  | 1116 | } | 
|---|
|  | 1117 |  | 
|---|
|  | 1118 | //パラメータと照合する | 
|---|
|  | 1119 | for(i3=0;i3<pci->ParmNum;i3++){ | 
|---|
|  | 1120 | if(lstrcmp(pci->ppParm[i3],temporary)==0) break; | 
|---|
|  | 1121 | } | 
|---|
|  | 1122 |  | 
|---|
|  | 1123 | if(i3==pci->ParmNum){ | 
|---|
|  | 1124 | //パラメータでないとき | 
|---|
|  | 1125 | lstrcpy(pCalcBuffer+i4,temporary); | 
|---|
|  | 1126 | i4+=lstrlen(temporary); | 
|---|
|  | 1127 | } | 
|---|
|  | 1128 | else{ | 
|---|
|  | 1129 | //パラメータのとき | 
|---|
|  | 1130 | lstrcpy(pCalcBuffer+i4,pParms[i3]); | 
|---|
|  | 1131 | i4+=lstrlen(pParms[i3]); | 
|---|
|  | 1132 | } | 
|---|
|  | 1133 |  | 
|---|
|  | 1134 | //演算子をコピー | 
|---|
|  | 1135 | for(;;i2++,i4++){ | 
|---|
|  | 1136 | if(pci->StrValue[i2]==1){ | 
|---|
|  | 1137 | pCalcBuffer[i4++]=pci->StrValue[i2++]; | 
|---|
|  | 1138 | pCalcBuffer[i4]=pci->StrValue[i2]; | 
|---|
|  | 1139 | continue; | 
|---|
|  | 1140 | } | 
|---|
|  | 1141 | if(IsVariableTopChar(pci->StrValue[i2])) break; | 
|---|
|  | 1142 | pCalcBuffer[i4]=pci->StrValue[i2]; | 
|---|
|  | 1143 | if(pci->StrValue[i2]=='\0') break; | 
|---|
|  | 1144 | } | 
|---|
|  | 1145 |  | 
|---|
|  | 1146 | if(pci->StrValue[i2]=='\0') break; | 
|---|
|  | 1147 | } | 
|---|
|  | 1148 |  | 
|---|
|  | 1149 | for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]); | 
|---|
|  | 1150 |  | 
|---|
|  | 1151 | return 1; | 
|---|
|  | 1152 | } | 
|---|
|  | 1153 | DWORD GetConstValue(char *name,double *pDbl,char *buffer,LONG_PTR *plpIndex){ | 
|---|
|  | 1154 | CONSTINFO *pci; | 
|---|
|  | 1155 | pci=GetConstHash(name); | 
|---|
|  | 1156 | if(pci){ | 
|---|
|  | 1157 | //定数が見つかったとき | 
|---|
|  | 1158 |  | 
|---|
|  | 1159 | if(pci->StrValue){ | 
|---|
|  | 1160 | //文字列定数 | 
|---|
|  | 1161 |  | 
|---|
|  | 1162 | //バイト数 | 
|---|
|  | 1163 | *pDbl=pci->DblValue; | 
|---|
|  | 1164 |  | 
|---|
|  | 1165 | //データ | 
|---|
|  | 1166 | memcpy(buffer,pci->StrValue,(int)pci->DblValue); | 
|---|
|  | 1167 |  | 
|---|
|  | 1168 | if(plpIndex) *plpIndex=pci->lpIndex; | 
|---|
|  | 1169 |  | 
|---|
|  | 1170 | return DEF_STRING; | 
|---|
|  | 1171 | } | 
|---|
|  | 1172 | else{ | 
|---|
|  | 1173 | if(pci->type==DEF_INT64){ | 
|---|
|  | 1174 | memcpy(pDbl,&pci->i64Value,sizeof(_int64)); | 
|---|
|  | 1175 | return DEF_INT64; | 
|---|
|  | 1176 | } | 
|---|
|  | 1177 |  | 
|---|
|  | 1178 | if(plpIndex) *plpIndex=pci->lpIndex; | 
|---|
|  | 1179 |  | 
|---|
|  | 1180 | *pDbl=pci->DblValue; | 
|---|
|  | 1181 | return pci->type; | 
|---|
|  | 1182 | } | 
|---|
|  | 1183 | } | 
|---|
|  | 1184 |  | 
|---|
|  | 1185 | if(plpIndex) *plpIndex=-1; | 
|---|
|  | 1186 |  | 
|---|
|  | 1187 | return -1; | 
|---|
|  | 1188 | } | 
|---|
|  | 1189 | BOOL IsStringObjectType(TYPEINFO *pTypeInfo){ | 
|---|
|  | 1190 | if(pTypeInfo->type==DEF_OBJECT){ | 
|---|
|  | 1191 | if(lstrcmp(pTypeInfo->u.pobj_Class->name,"String")==0){ | 
|---|
|  | 1192 | return 1; | 
|---|
|  | 1193 | } | 
|---|
|  | 1194 | } | 
|---|
|  | 1195 | return 0; | 
|---|
|  | 1196 | } | 
|---|
|  | 1197 | BOOL IsStringSubsituation(CClass *pobj_c){ | 
|---|
|  | 1198 | //String受け入れ可能な "=" 演算子をオーバーロードしているかどうかを調べる | 
|---|
|  | 1199 | BOOL bRet=0; | 
|---|
|  | 1200 |  | 
|---|
| [50] | 1201 | std::vector<SUBINFO *> subs; | 
|---|
|  | 1202 | pobj_c->EnumMethod( CALC_SUBSITUATION, subs ); | 
|---|
|  | 1203 | if( subs.size() == 0 ){ | 
|---|
| [4] | 1204 | bRet=0; | 
|---|
|  | 1205 | goto finish; | 
|---|
|  | 1206 | } | 
|---|
|  | 1207 |  | 
|---|
| [50] | 1208 | foreach( SUBINFO *psi, subs ){ | 
|---|
|  | 1209 | if(psi->ParmNum==2){ | 
|---|
|  | 1210 | TYPEINFO TypeInfo={psi->pParmInfo[1].type,psi->pParmInfo[1].u.index}; | 
|---|
| [4] | 1211 | if(IsStringObjectType(&TypeInfo)){ | 
|---|
|  | 1212 | bRet=1; | 
|---|
|  | 1213 | goto finish; | 
|---|
|  | 1214 | } | 
|---|
|  | 1215 | } | 
|---|
|  | 1216 | } | 
|---|
|  | 1217 |  | 
|---|
|  | 1218 | finish: | 
|---|
|  | 1219 | return bRet; | 
|---|
|  | 1220 | } | 
|---|
|  | 1221 | int IsStrCalculation(char *Command){ | 
|---|
|  | 1222 | int i,i2,i3,i4,type,PareNum; | 
|---|
|  | 1223 | char temporary[VN_SIZE],temp2[8192]; | 
|---|
|  | 1224 |  | 
|---|
|  | 1225 | for(i=0,i2=0;;i++){ | 
|---|
|  | 1226 | if(Command[i]=='('){ | 
|---|
|  | 1227 | for(i++,PareNum=1;;i++){ | 
|---|
|  | 1228 | if(Command[i]=='(') PareNum++; | 
|---|
|  | 1229 | else if(Command[i]==')'){ | 
|---|
|  | 1230 | PareNum--; | 
|---|
|  | 1231 | if(PareNum==0) break; | 
|---|
|  | 1232 | } | 
|---|
|  | 1233 | } | 
|---|
|  | 1234 | continue; | 
|---|
|  | 1235 | } | 
|---|
|  | 1236 | if(Command[i]=='['){ | 
|---|
|  | 1237 | for(i++,PareNum=1;;i++){ | 
|---|
|  | 1238 | if(Command[i]=='[') PareNum++; | 
|---|
|  | 1239 | else if(Command[i]==']'){ | 
|---|
|  | 1240 | PareNum--; | 
|---|
|  | 1241 | if(PareNum==0) break; | 
|---|
|  | 1242 | } | 
|---|
|  | 1243 | } | 
|---|
|  | 1244 | continue; | 
|---|
|  | 1245 | } | 
|---|
|  | 1246 | if(Command[i]=='\"'){ | 
|---|
|  | 1247 | i++; | 
|---|
|  | 1248 | while(Command[i]!='\"') i++; | 
|---|
|  | 1249 | continue; | 
|---|
|  | 1250 | } | 
|---|
|  | 1251 | if(Command[i]=='\0'){ | 
|---|
|  | 1252 | if(IsVariableTopChar(Command[i2])|| | 
|---|
|  | 1253 | Command[i2]=='.'&&IsVariableTopChar(Command[i2+1])){ | 
|---|
|  | 1254 |  | 
|---|
|  | 1255 | if((Command[i2]=='e'||Command[i2]=='E')&& | 
|---|
|  | 1256 | (Command[i2+1]=='x'||Command[i2+1]=='X')&& | 
|---|
|  | 1257 | Command[i2+2]=='\"'){ | 
|---|
|  | 1258 | //拡張文字列 | 
|---|
|  | 1259 | return 1; | 
|---|
|  | 1260 | } | 
|---|
|  | 1261 |  | 
|---|
|  | 1262 | for(i3=0;;i3++){ | 
|---|
|  | 1263 | if(Command[i2+i3]=='('){ | 
|---|
|  | 1264 | temporary[i3]=0; | 
|---|
|  | 1265 | break; | 
|---|
|  | 1266 | } | 
|---|
|  | 1267 | temporary[i3]=Command[i2+i3]; | 
|---|
|  | 1268 | if(Command[i2+i3]=='\0') break; | 
|---|
|  | 1269 | } | 
|---|
|  | 1270 | if(Command[i2+i3]=='('){ | 
|---|
|  | 1271 | TYPEINFO TypeInfo; | 
|---|
|  | 1272 |  | 
|---|
|  | 1273 | //DLL関数の場合 | 
|---|
|  | 1274 | DECLAREINFO *pdi; | 
|---|
|  | 1275 | pdi=GetDeclareHash(temporary); | 
|---|
|  | 1276 | if(pdi){ | 
|---|
|  | 1277 | TypeInfo.type=pdi->ReturnType; | 
|---|
|  | 1278 | TypeInfo.u.lpIndex=pdi->u.ReturnIndex; | 
|---|
|  | 1279 | if(IsStringObjectType(&TypeInfo)) return 1; | 
|---|
|  | 1280 | return 0; | 
|---|
|  | 1281 | } | 
|---|
|  | 1282 |  | 
|---|
|  | 1283 | //ユーザー定義関数 | 
|---|
|  | 1284 | SUBINFO *psi; | 
|---|
|  | 1285 | psi=GetSubHash(temporary); | 
|---|
|  | 1286 | if(psi){ | 
|---|
|  | 1287 | TypeInfo.type=psi->ReturnType; | 
|---|
|  | 1288 | TypeInfo.u.lpIndex=psi->u.ReturnIndex; | 
|---|
|  | 1289 | if(IsStringObjectType(&TypeInfo)) return 1; | 
|---|
|  | 1290 | return 0; | 
|---|
|  | 1291 | } | 
|---|
|  | 1292 |  | 
|---|
|  | 1293 | //組み込み関数 | 
|---|
|  | 1294 | i4=GetFunctionFromName(temporary); | 
|---|
|  | 1295 | if(i4){ | 
|---|
|  | 1296 | //組み込み関数は文字列を返さない | 
|---|
|  | 1297 | return 0; | 
|---|
|  | 1298 | } | 
|---|
|  | 1299 |  | 
|---|
|  | 1300 | //定数 | 
|---|
|  | 1301 | CONSTINFO *pci; | 
|---|
|  | 1302 | pci=GetConstHash(temporary); | 
|---|
|  | 1303 | if(pci){ | 
|---|
|  | 1304 |  | 
|---|
|  | 1305 | if(pci->ParmNum){ | 
|---|
|  | 1306 | //マクロ関数の場合 | 
|---|
|  | 1307 | GetStringInPare_RemovePare(temporary,Command+i2+i3+1); | 
|---|
|  | 1308 | GetConstCalcBuffer(pci->name,temporary,temp2); | 
|---|
|  | 1309 | return IsStrCalculation(temp2); | 
|---|
|  | 1310 | } | 
|---|
|  | 1311 |  | 
|---|
|  | 1312 | if(pci->type==DEF_STRING) return 1; | 
|---|
|  | 1313 | else return 0; | 
|---|
|  | 1314 | } | 
|---|
|  | 1315 | } | 
|---|
|  | 1316 |  | 
|---|
|  | 1317 | //定数 | 
|---|
| [7] | 1318 | i3 = CDBConst::obj.GetType(Command+i2); | 
|---|
| [4] | 1319 | if(i3==DEF_STRING) return 1;    //文字列 | 
|---|
| [7] | 1320 | if(i3) return 0;            //数値 | 
|---|
| [4] | 1321 |  | 
|---|
|  | 1322 | //変数 | 
|---|
|  | 1323 | CClass *pobj_Class; | 
|---|
| [11] | 1324 | type = GetVarType(Command+i2,(LONG_PTR *)&pobj_Class,1); | 
|---|
|  | 1325 | if(type==-1 || type ==0){ | 
|---|
| [4] | 1326 | //エラー | 
|---|
|  | 1327 | return -1; | 
|---|
|  | 1328 | } | 
|---|
|  | 1329 | if(type==DEF_OBJECT){ | 
|---|
|  | 1330 | if(lstrcmp(pobj_Class->name,"String")==0){ | 
|---|
|  | 1331 | return 1; | 
|---|
|  | 1332 | } | 
|---|
|  | 1333 | return 0; | 
|---|
|  | 1334 | } | 
|---|
|  | 1335 | } | 
|---|
|  | 1336 | else if(Command[i2]=='\"') return 1; | 
|---|
|  | 1337 | break; | 
|---|
|  | 1338 | } | 
|---|
|  | 1339 | if(IsNumCalcMark(Command,i)||IsStrCalcMark(Command[i])){ | 
|---|
|  | 1340 | if(IsStrCalcMark(Command[i])){ | 
|---|
|  | 1341 |  | 
|---|
|  | 1342 | //&H、&O表記の場合を考慮 | 
|---|
|  | 1343 | if(i==0) continue; | 
|---|
|  | 1344 | if(IsNumCalcMark(Command,i-1)) continue; | 
|---|
|  | 1345 |  | 
|---|
|  | 1346 | if(Command[i+1]=='(') break; | 
|---|
|  | 1347 | i2=i+1; | 
|---|
|  | 1348 | continue; | 
|---|
|  | 1349 | } | 
|---|
|  | 1350 | break; | 
|---|
|  | 1351 | } | 
|---|
|  | 1352 | } | 
|---|
|  | 1353 | return 0; | 
|---|
|  | 1354 | } | 
|---|
|  | 1355 |  | 
|---|
| [15] | 1356 | BYTE GetCalcId(const char *Command,int *pi){ | 
|---|
| [4] | 1357 | *pi=0; | 
|---|
|  | 1358 |  | 
|---|
|  | 1359 | if(Command[0]==1) *pi=1; | 
|---|
|  | 1360 |  | 
|---|
|  | 1361 | //論理演算子 | 
|---|
|  | 1362 | if(Command[0]==1&&Command[1]==ESC_XOR) return CALC_XOR; | 
|---|
|  | 1363 | else if(Command[0]==1&&Command[1]==ESC_OR) return CALC_OR; | 
|---|
|  | 1364 | else if(Command[0]==1&&Command[1]==ESC_AND) return CALC_AND; | 
|---|
|  | 1365 | else if(Command[0]==1&&Command[1]==ESC_NOT) return CALC_NOT; | 
|---|
|  | 1366 |  | 
|---|
|  | 1367 | //ビット演算子(優先順位は算術演算子の後部) | 
|---|
|  | 1368 | else if(Command[0]=='<'&&Command[1]=='<'){ | 
|---|
|  | 1369 | *pi=1; | 
|---|
|  | 1370 | return CALC_SHL; | 
|---|
|  | 1371 | } | 
|---|
|  | 1372 | else if(Command[0]=='>'&&Command[1]=='>'){ | 
|---|
|  | 1373 | *pi=1; | 
|---|
|  | 1374 | return CALC_SHR; | 
|---|
|  | 1375 | } | 
|---|
|  | 1376 |  | 
|---|
|  | 1377 | //比較演算子 | 
|---|
|  | 1378 | else if(Command[0]=='<'&&Command[1]=='='|| | 
|---|
|  | 1379 | Command[0]=='='&&Command[1]=='<'){ | 
|---|
|  | 1380 | *pi=1; | 
|---|
|  | 1381 | return CALC_PE; | 
|---|
|  | 1382 | } | 
|---|
|  | 1383 | else if(Command[0]=='>'&&Command[1]=='='|| | 
|---|
|  | 1384 | Command[0]=='='&&Command[1]=='>'){ | 
|---|
|  | 1385 | *pi=1; | 
|---|
|  | 1386 | return CALC_QE; | 
|---|
|  | 1387 | } | 
|---|
|  | 1388 | else if(Command[0]=='<'&&Command[1]=='>'|| | 
|---|
|  | 1389 | Command[0]=='>'&&Command[1]=='<'){ | 
|---|
|  | 1390 | *pi=1; | 
|---|
|  | 1391 | return CALC_NOTEQUAL; | 
|---|
|  | 1392 | } | 
|---|
|  | 1393 | else if(Command[0]=='=') return CALC_EQUAL; | 
|---|
|  | 1394 | else if(Command[0]=='<') return CALC_P; | 
|---|
|  | 1395 | else if(Command[0]=='>') return CALC_Q; | 
|---|
|  | 1396 |  | 
|---|
|  | 1397 | //算術演算子 | 
|---|
|  | 1398 | else if(Command[0]=='+') return CALC_ADDITION; | 
|---|
|  | 1399 | else if(Command[0]=='-') return CALC_SUBTRACTION; | 
|---|
|  | 1400 | else if(Command[0]=='&') return CALC_STRPLUS; | 
|---|
|  | 1401 | else if(Command[0]==1&&Command[1]==ESC_MOD) return CALC_MOD; | 
|---|
|  | 1402 | else if(Command[0]=='*') return CALC_PRODUCT; | 
|---|
|  | 1403 | else if(Command[0]=='/') return CALC_QUOTIENT; | 
|---|
|  | 1404 | else if(Command[0]=='\\') return CALC_INTQUOTIENT; | 
|---|
|  | 1405 | else if(Command[0]=='^') return CALC_POWER; | 
|---|
|  | 1406 | else if(Command[0]==1&&Command[1]==ESC_AS) return CALC_AS; | 
|---|
| [41] | 1407 | else if(Command[0]==1&&Command[1]==ESC_BYVAL) return CALC_BYVAL; | 
|---|
| [4] | 1408 |  | 
|---|
|  | 1409 | return 0; | 
|---|
|  | 1410 | } | 
|---|
| [15] | 1411 | BOOL GetNumOpeElements(const char *Command,int *pnum, | 
|---|
| [4] | 1412 | char *values[255],long calc[255],long stack[255]){ | 
|---|
|  | 1413 | extern int cp; | 
|---|
|  | 1414 | extern HANDLE hHeap; | 
|---|
|  | 1415 | int i,i2,i3,i4,PareNum,sp; | 
|---|
|  | 1416 | char temporary[1024]; | 
|---|
|  | 1417 |  | 
|---|
|  | 1418 | for(i=0,i2=0,sp=0,*pnum=0,PareNum=0;;i++,i2++){ | 
|---|
|  | 1419 | if(Command[i]=='\"'){ | 
|---|
|  | 1420 | temporary[i2]=Command[i]; | 
|---|
|  | 1421 | for(i++,i2++;;i++,i2++){ | 
|---|
|  | 1422 | temporary[i2]=Command[i]; | 
|---|
|  | 1423 | if(Command[i]=='\"') break; | 
|---|
|  | 1424 | } | 
|---|
|  | 1425 | continue; | 
|---|
|  | 1426 | } | 
|---|
|  | 1427 | else if(Command[i]=='['){ | 
|---|
|  | 1428 | i3=GetStringInBracket(temporary+i2,Command+i); | 
|---|
|  | 1429 | i+=i3-1; | 
|---|
|  | 1430 | i2+=i3-1; | 
|---|
|  | 1431 | continue; | 
|---|
|  | 1432 | } | 
|---|
|  | 1433 | else if(Command[i]=='('){ | 
|---|
|  | 1434 | if(i==0){ | 
|---|
|  | 1435 | PareNum++; | 
|---|
|  | 1436 | i2=-1; | 
|---|
|  | 1437 | continue; | 
|---|
|  | 1438 | } | 
|---|
|  | 1439 | else if(IsNumCalcMark_Back(Command,i-1)||Command[i-1]=='('){ | 
|---|
|  | 1440 | PareNum++; | 
|---|
|  | 1441 | i2=-1; | 
|---|
|  | 1442 | continue; | 
|---|
|  | 1443 | } | 
|---|
|  | 1444 | else{ | 
|---|
|  | 1445 | //配列変数の場合を考慮 | 
|---|
|  | 1446 | i3=GetStringInPare(temporary+i2,Command+i); | 
|---|
|  | 1447 | i+=i3-1; | 
|---|
|  | 1448 | i2+=i3-1; | 
|---|
|  | 1449 | continue; | 
|---|
|  | 1450 | } | 
|---|
|  | 1451 | } | 
|---|
|  | 1452 | else if(Command[i]==')'){ | 
|---|
|  | 1453 | PareNum--; | 
|---|
|  | 1454 | i2--; | 
|---|
|  | 1455 | continue; | 
|---|
|  | 1456 | } | 
|---|
|  | 1457 | else if(IsNumCalcMark(Command,i)||(Command[i]=='&'&&i2!=0)){ | 
|---|
|  | 1458 | if((Command[i]=='+'||Command[i]=='-')&&(Command[i-1]=='e'||Command[i-1]=='E')){ | 
|---|
|  | 1459 | if(IsExponent(Command,i)){ | 
|---|
|  | 1460 | temporary[i2]=Command[i]; | 
|---|
|  | 1461 | continue; | 
|---|
|  | 1462 | } | 
|---|
|  | 1463 | } | 
|---|
|  | 1464 | temporary[i2]=0; | 
|---|
|  | 1465 |  | 
|---|
|  | 1466 | if((stack[sp-1]%100)==CALC_AS&&Command[i]=='*'){ | 
|---|
|  | 1467 | for(i3=0;i3<i2;i3++){ | 
|---|
|  | 1468 | if(temporary[i2]!='*') break; | 
|---|
|  | 1469 | } | 
|---|
|  | 1470 | if(i3==i2){ | 
|---|
|  | 1471 | //"*"をポインタ指定文字として認識する | 
|---|
|  | 1472 | temporary[i2]=Command[i]; | 
|---|
|  | 1473 | continue; | 
|---|
|  | 1474 | } | 
|---|
|  | 1475 | } | 
|---|
|  | 1476 |  | 
|---|
|  | 1477 | calc[*pnum]=0; | 
|---|
|  | 1478 | if(i2){ | 
|---|
|  | 1479 | values[*pnum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+255); | 
|---|
|  | 1480 | lstrcpy(values[*pnum],temporary); | 
|---|
|  | 1481 | (*pnum)++; | 
|---|
|  | 1482 | } | 
|---|
|  | 1483 | else{ | 
|---|
| [41] | 1484 | if(!( | 
|---|
|  | 1485 | Command[i]=='+'|| | 
|---|
|  | 1486 | Command[i]=='-'|| | 
|---|
|  | 1487 | (Command[i]==1&&Command[i+1]==ESC_NOT)|| | 
|---|
|  | 1488 | (Command[i]==1&&Command[i+1]==ESC_BYVAL) | 
|---|
|  | 1489 | )){ | 
|---|
|  | 1490 | SetError(1,NULL,cp); | 
|---|
|  | 1491 | return 0; | 
|---|
| [4] | 1492 | } | 
|---|
|  | 1493 | if(Command[i]=='+'){ | 
|---|
|  | 1494 | i2=-1; | 
|---|
|  | 1495 | continue; | 
|---|
|  | 1496 | } | 
|---|
|  | 1497 | } | 
|---|
|  | 1498 |  | 
|---|
|  | 1499 | if(Command[i]=='-'&&i2==0){ | 
|---|
|  | 1500 | i3=CALC_MINUSMARK; | 
|---|
|  | 1501 | } | 
|---|
|  | 1502 | else{ | 
|---|
|  | 1503 | i3=GetCalcId(Command+i,&i4); | 
|---|
|  | 1504 | i+=i4; | 
|---|
|  | 1505 | if(!i3){ | 
|---|
|  | 1506 | SetError(1,NULL,cp); | 
|---|
|  | 1507 | return 0; | 
|---|
|  | 1508 | } | 
|---|
|  | 1509 | } | 
|---|
|  | 1510 |  | 
|---|
|  | 1511 | i3+=PareNum*100; | 
|---|
|  | 1512 | if(sp){ | 
|---|
|  | 1513 | if(stack[sp-1]>i3-3&& | 
|---|
|  | 1514 | (!( | 
|---|
|  | 1515 | (stack[sp-1]%100==CALC_MINUSMARK || stack[sp-1]%100==CALC_NOT || stack[sp-1]%100==CALC_POWER)&& | 
|---|
|  | 1516 | (i3%100==CALC_MINUSMARK || i3%100==CALC_NOT) | 
|---|
|  | 1517 | )) | 
|---|
|  | 1518 | ){ | 
|---|
|  | 1519 | for(;sp>0;){ | 
|---|
|  | 1520 | sp--; | 
|---|
|  | 1521 | calc[*pnum]=stack[sp]; | 
|---|
|  | 1522 | values[*pnum]=0; | 
|---|
|  | 1523 | (*pnum)++; | 
|---|
|  | 1524 | if(!(stack[sp-1]>i3-3)) break; | 
|---|
|  | 1525 | } | 
|---|
|  | 1526 | } | 
|---|
|  | 1527 | } | 
|---|
|  | 1528 | stack[sp]=i3; | 
|---|
|  | 1529 | sp++; | 
|---|
|  | 1530 |  | 
|---|
|  | 1531 | i2=-1; | 
|---|
|  | 1532 | continue; | 
|---|
|  | 1533 | } | 
|---|
|  | 1534 | temporary[i2]=Command[i]; | 
|---|
|  | 1535 | if(Command[i]=='\0'){ | 
|---|
|  | 1536 | calc[*pnum]=0; | 
|---|
|  | 1537 |  | 
|---|
|  | 1538 | values[*pnum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+255); | 
|---|
|  | 1539 | lstrcpy(values[*pnum],temporary); | 
|---|
|  | 1540 | (*pnum)++; | 
|---|
|  | 1541 |  | 
|---|
|  | 1542 | for(;sp>0;(*pnum)++){ | 
|---|
|  | 1543 | sp--; | 
|---|
|  | 1544 | calc[*pnum]=stack[sp]; | 
|---|
|  | 1545 | values[*pnum]=0; | 
|---|
|  | 1546 | } | 
|---|
|  | 1547 | break; | 
|---|
|  | 1548 | } | 
|---|
|  | 1549 | } | 
|---|
|  | 1550 |  | 
|---|
|  | 1551 | return 1; | 
|---|
|  | 1552 | } | 
|---|