[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[182] | 3 | #include <jenga/include/smoothie/Smoothie.h>
|
---|
| 4 |
|
---|
[193] | 5 | #include <Compiler.h>
|
---|
| 6 |
|
---|
[4] | 7 | #include "common.h"
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | int MakeWholeType(int size,int bSigned){
|
---|
| 11 | switch(size){
|
---|
| 12 | case 1:
|
---|
[55] | 13 | if(bSigned) return DEF_SBYTE;
|
---|
[4] | 14 | else return DEF_BYTE;
|
---|
| 15 | break;
|
---|
| 16 | case 2:
|
---|
| 17 | if(bSigned) return DEF_INTEGER;
|
---|
| 18 | else return DEF_WORD;
|
---|
| 19 | break;
|
---|
| 20 | case 4:
|
---|
| 21 | if(bSigned) return DEF_LONG;
|
---|
| 22 | else return DEF_DWORD;
|
---|
| 23 | break;
|
---|
| 24 | case 8:
|
---|
| 25 | if(bSigned) return DEF_INT64;
|
---|
| 26 | else return DEF_QWORD;
|
---|
| 27 | break;
|
---|
| 28 | }
|
---|
| 29 | return 0;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | int AutoBigCast(int BaseType,int CalcType){
|
---|
| 33 | int type;
|
---|
| 34 | type=CalcType;
|
---|
| 35 |
|
---|
[75] | 36 | if(BaseType==0||BaseType==-1){
|
---|
[4] | 37 | //ベースタイプが未定のとき
|
---|
| 38 | return type;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | if(!IsWholeNumberType(type)){
|
---|
| 42 | //整数型ではないときは暗黙の変換は必要なし
|
---|
| 43 | return type;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[75] | 46 | if(BaseType==DEF_OBJECT||BaseType==DEF_STRUCT){
|
---|
[4] | 47 | //ベースタイプがオブジェクトのときは暗黙の変換は必要なし
|
---|
| 48 | return type;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | int BaseTypeSize;
|
---|
[290] | 52 | BaseTypeSize=Type(BaseType,-1).GetSize();
|
---|
[4] | 53 |
|
---|
| 54 | if(IsRealNumberType(BaseType)){
|
---|
[290] | 55 | if(Type(CalcType,-1).GetSize()<4)
|
---|
[4] | 56 | type=MakeWholeType(4,IsSignedType(CalcType));
|
---|
| 57 | }
|
---|
[290] | 58 | else if(BaseTypeSize>Type(CalcType,-1).GetSize()){
|
---|
[4] | 59 | //要求される型のほうがサイズが大きいとき
|
---|
| 60 | type=MakeWholeType(BaseTypeSize,IsSignedType(CalcType));
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | if(!type){
|
---|
[5] | 64 | extern int cp;
|
---|
[4] | 65 | SetError(300,NULL,cp);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | return type;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | BOOL CheckCalcType(int idCalc,int *type,int sp){
|
---|
| 72 | //演算子の右辺、左辺の型をチェック
|
---|
| 73 | extern int cp;
|
---|
| 74 |
|
---|
| 75 | //演算子名を取得
|
---|
| 76 | char temporary[255];
|
---|
| 77 | GetCalcName(idCalc,temporary);
|
---|
| 78 |
|
---|
| 79 | switch(idCalc){
|
---|
| 80 |
|
---|
| 81 | /////////////////////////////////////
|
---|
| 82 | // 実数に対する論理演算はエラー
|
---|
| 83 | /////////////////////////////////////
|
---|
| 84 |
|
---|
| 85 | case CALC_XOR:
|
---|
| 86 | case CALC_OR:
|
---|
| 87 | case CALC_AND:
|
---|
| 88 | if(IsRealNumberType(type[sp-2])||IsRealNumberType(type[sp-1])){
|
---|
| 89 | //いずれかの項が実数のとき
|
---|
| 90 | SetError(45,temporary,cp);
|
---|
| 91 | return 0;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | //As以外の演算子に型名が指定されていないかをチェック
|
---|
| 95 | if((type[sp-2]&FLAG_CAST)||(type[sp-1]&FLAG_CAST)){
|
---|
| 96 | SetError(48,temporary,cp);
|
---|
| 97 | return 0;
|
---|
| 98 | }
|
---|
| 99 | break;
|
---|
| 100 |
|
---|
| 101 | case CALC_NOT:
|
---|
| 102 | if(IsRealNumberType(type[sp-1])){
|
---|
| 103 | //実数のとき
|
---|
| 104 | SetError(45,temporary,cp);
|
---|
| 105 | return 0;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | //As以外の演算子に型名が指定されていないかをチェック
|
---|
| 109 | if(type[sp-1]&FLAG_CAST){
|
---|
| 110 | SetError(48,temporary,cp);
|
---|
| 111 | return 0;
|
---|
| 112 | }
|
---|
| 113 | break;
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | /////////////////////////////////////
|
---|
| 118 | // 比較演算はチェック項目なし
|
---|
| 119 | /////////////////////////////////////
|
---|
| 120 |
|
---|
| 121 | case CALC_PE:
|
---|
| 122 | case CALC_QE:
|
---|
| 123 | case CALC_NOTEQUAL:
|
---|
| 124 | case CALC_EQUAL:
|
---|
| 125 | case CALC_P:
|
---|
| 126 | case CALC_Q:
|
---|
| 127 | //As以外の演算子に型名が指定されていないかをチェック
|
---|
| 128 | if((type[sp-2]&FLAG_CAST)||(type[sp-1]&FLAG_CAST)){
|
---|
| 129 | SetError(48,temporary,cp);
|
---|
| 130 | return 0;
|
---|
| 131 | }
|
---|
| 132 | break;
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 | /////////////////////////////////////
|
---|
| 137 | // 算術演算をチェック
|
---|
| 138 | /////////////////////////////////////
|
---|
| 139 |
|
---|
| 140 | case CALC_ADDITION:
|
---|
| 141 | case CALC_SUBTRACTION:
|
---|
| 142 | case CALC_PRODUCT:
|
---|
| 143 | case CALC_QUOTIENT:
|
---|
| 144 | case CALC_POWER:
|
---|
| 145 | //As以外の演算子に型名が指定されていないかをチェック
|
---|
| 146 | if((type[sp-2]&FLAG_CAST)||(type[sp-1]&FLAG_CAST)){
|
---|
| 147 | SetError(48,temporary,cp);
|
---|
| 148 | return 0;
|
---|
| 149 | }
|
---|
| 150 | break;
|
---|
| 151 |
|
---|
| 152 | case CALC_SHL:
|
---|
| 153 | case CALC_SHR:
|
---|
| 154 | case CALC_MOD:
|
---|
| 155 | case CALC_INTQUOTIENT:
|
---|
| 156 | if(IsRealNumberType(type[sp-2])||IsRealNumberType(type[sp-1])){
|
---|
| 157 | //いずれかの項が実数のとき
|
---|
| 158 | SetError(45,temporary,cp);
|
---|
| 159 | return 0;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | //As以外の演算子に型名が指定されていないかをチェック
|
---|
| 163 | if((type[sp-2]&FLAG_CAST)||(type[sp-1]&FLAG_CAST)){
|
---|
| 164 | SetError(48,temporary,cp);
|
---|
| 165 | return 0;
|
---|
| 166 | }
|
---|
| 167 | break;
|
---|
| 168 |
|
---|
| 169 | case CALC_AS:
|
---|
| 170 | if((type[sp-1]&FLAG_CAST)==0){
|
---|
| 171 | //型名が指定されていないときはエラー
|
---|
| 172 | SetError(47,NULL,cp);
|
---|
| 173 | return 0;
|
---|
| 174 | }
|
---|
| 175 | break;
|
---|
| 176 |
|
---|
[41] | 177 | case CALC_BYVAL:
|
---|
| 178 | if(type[sp-1]&FLAG_CAST){
|
---|
| 179 | //型名が指定されていないときはエラー
|
---|
| 180 | SetError(47,NULL,cp);
|
---|
| 181 | return 0;
|
---|
| 182 | }
|
---|
| 183 | break;
|
---|
| 184 |
|
---|
[4] | 185 | case CALC_MINUSMARK:
|
---|
| 186 | //As以外の演算子に型名が指定されていないかをチェック
|
---|
| 187 | if(type[sp-1]&FLAG_CAST){
|
---|
| 188 | SetError(48,temporary,cp);
|
---|
| 189 | return 0;
|
---|
| 190 | }
|
---|
| 191 | break;
|
---|
| 192 | }
|
---|
| 193 | return 1;
|
---|
| 194 | }
|
---|
| 195 |
|
---|
[424] | 196 | int GetReturnType_OperatorProc(int idCalc,const Type &baseType,int *type_stack,LONG_PTR *index_stack,int &sp){
|
---|
| 197 | Type leftType( type_stack[sp-2], index_stack[sp-2] );
|
---|
| 198 | Type rightType( type_stack[sp-1] & (~FLAG_CAST), index_stack[sp-1] );
|
---|
[4] | 199 |
|
---|
[424] | 200 | //オーバーロードされたオペレータ関数を呼び出す
|
---|
| 201 | const CClass *pobj_c = &leftType.GetClass();
|
---|
| 202 |
|
---|
[206] | 203 | std::vector<const UserProc *> subs;
|
---|
[342] | 204 | pobj_c->GetDynamicMethods().Enum( idCalc, subs );
|
---|
[50] | 205 | if( subs.size() == 0 ){
|
---|
[4] | 206 | return 0;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | //項の数
|
---|
| 211 | BOOL bTwoTerm=1;
|
---|
| 212 | if(idCalc==CALC_AS) bTwoTerm=0;
|
---|
| 213 |
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | /////////////////////////////////////////////
|
---|
| 217 | // オーバーロード解決用のパラメータを設定
|
---|
| 218 | /////////////////////////////////////////////
|
---|
| 219 |
|
---|
| 220 |
|
---|
| 221 | //_System_LocalThis
|
---|
[75] | 222 | Parameters params;
|
---|
[4] | 223 |
|
---|
| 224 | if(bTwoTerm){
|
---|
[424] | 225 | params.push_back( new Parameter( "", rightType ) );
|
---|
[4] | 226 | }
|
---|
| 227 |
|
---|
| 228 |
|
---|
| 229 | //オーバーロードを解決
|
---|
| 230 | char temporary[255];
|
---|
| 231 | if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
|
---|
| 232 | else GetCalcName(idCalc,temporary);
|
---|
[424] | 233 | const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType, leftType );
|
---|
[4] | 234 |
|
---|
[75] | 235 | if(bTwoTerm){
|
---|
| 236 | delete params[0];
|
---|
| 237 | }
|
---|
[50] | 238 |
|
---|
[75] | 239 | if(!pUserProc){
|
---|
[4] | 240 | return 0;
|
---|
| 241 | }
|
---|
| 242 | else{
|
---|
| 243 | //オーバーロードされていないが、パラメータ個数が一致しないとき
|
---|
[75] | 244 | if(params.size()!=pUserProc->Params().size()){
|
---|
[4] | 245 | return 0;
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | sp--;
|
---|
[424] | 250 | type_stack[sp-1]=pUserProc->ReturnType().GetBasicType();
|
---|
[75] | 251 | index_stack[sp-1]=pUserProc->ReturnType().GetIndex();
|
---|
[4] | 252 |
|
---|
| 253 | return 1;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[75] | 256 | bool Operator_New_GetType(const char *Parameter,const Type &baseType, Type &resultType ){
|
---|
[355] | 257 | char TypeName[VN_SIZE],objectSizeStr[VN_SIZE];
|
---|
[64] | 258 | int i,i2;
|
---|
| 259 |
|
---|
| 260 | i=0;
|
---|
| 261 |
|
---|
| 262 | if(Parameter[0]=='['){
|
---|
| 263 | i=GetStringInBracket(objectSizeStr,Parameter);
|
---|
| 264 |
|
---|
| 265 | SlideString(objectSizeStr+1,-1);
|
---|
| 266 | objectSizeStr[i-2]=0;
|
---|
| 267 | }
|
---|
| 268 | else objectSizeStr[0]=0;
|
---|
| 269 |
|
---|
| 270 | for(i2=0;;i++,i2++){
|
---|
[355] | 271 | if(Parameter[i]=='(' || Parameter[i]=='['){
|
---|
[64] | 272 | TypeName[i2]=0;
|
---|
| 273 | break;
|
---|
| 274 | }
|
---|
| 275 | TypeName[i2]=Parameter[i];
|
---|
| 276 | if(Parameter[i]=='\0'){
|
---|
| 277 | break;
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 |
|
---|
[396] | 281 | if( !compiler.StringToType( TypeName, resultType ) )
|
---|
| 282 | {
|
---|
| 283 | SetError(3,TypeName,cp);
|
---|
[75] | 284 | return false;
|
---|
| 285 | }
|
---|
[64] | 286 |
|
---|
[368] | 287 | if( !resultType.IsObject() )
|
---|
| 288 | {
|
---|
| 289 | SetError(121,NULL,cp);
|
---|
| 290 | return false;
|
---|
| 291 | }
|
---|
| 292 |
|
---|
[75] | 293 | if( baseType.IsObject() ){
|
---|
| 294 | resultType.SetBasicType( DEF_OBJECT );
|
---|
[64] | 295 | }
|
---|
[75] | 296 | else{
|
---|
| 297 | resultType.SetBasicType( DEF_PTR_OBJECT );
|
---|
| 298 | }
|
---|
| 299 | return true;
|
---|
[64] | 300 | }
|
---|
| 301 |
|
---|
[415] | 302 | bool GetMemberTermType( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool *pIsVariable )
|
---|
[334] | 303 | {
|
---|
| 304 | ////////////////////////////////
|
---|
| 305 | // インデクサ(getアクセサ)
|
---|
| 306 | ////////////////////////////////
|
---|
| 307 |
|
---|
| 308 | char VarName[VN_SIZE],ArrayElements[VN_SIZE];
|
---|
| 309 | GetArrayElement(member,VarName,ArrayElements);
|
---|
| 310 | if(ArrayElements[0]){
|
---|
| 311 | Type classType;
|
---|
| 312 | GetMemberType( leftType, VarName, classType, 0, false );
|
---|
| 313 | if( classType.IsObject() ){
|
---|
| 314 | if( !GetReturnTypeOfIndexerGetterProc( classType, resultType ) ){
|
---|
| 315 | SetError(1,NULL,cp);
|
---|
| 316 | return false;
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 | return true;
|
---|
| 320 | }
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 |
|
---|
| 324 | ///////////////////////////////////////////////////////////////////
|
---|
| 325 | // メンバを検索
|
---|
| 326 | ///////////////////////////////////////////////////////////////////
|
---|
| 327 | if( GetMemberType( leftType, member, resultType, 0, false ) ){
|
---|
| 328 | // メンバが見つかったとき
|
---|
[415] | 329 |
|
---|
| 330 | if( pIsVariable )
|
---|
| 331 | {
|
---|
| 332 | *pIsVariable = true;
|
---|
| 333 | }
|
---|
| 334 |
|
---|
[334] | 335 | return true;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
| 338 |
|
---|
| 339 | ///////////////////////////////////////////////////////////////////
|
---|
| 340 | // 動的メソッドを検索
|
---|
| 341 | ///////////////////////////////////////////////////////////////////
|
---|
| 342 | char methodName[VN_SIZE] ,lpPtrOffset[VN_SIZE], dummy[1];
|
---|
| 343 | char parameter[VN_SIZE];
|
---|
| 344 | ReferenceKind refType;
|
---|
| 345 | lstrcpy( methodName, member );
|
---|
| 346 | GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
|
---|
| 347 |
|
---|
| 348 | vector<const UserProc *> userProcs;
|
---|
[350] | 349 | leftType.GetClass().EnumDynamicMethodsOrInterfaceMethods( methodName, userProcs );
|
---|
[334] | 350 | if(userProcs.size()){
|
---|
| 351 | //オーバーロードを解決
|
---|
| 352 | const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
|
---|
| 353 |
|
---|
| 354 | if( pUserProc ){
|
---|
| 355 | resultType = pUserProc->ReturnType();
|
---|
| 356 |
|
---|
| 357 | // 型パラメータを解決
|
---|
| 358 | ResolveFormalGenericTypeParameter( resultType, leftType, pUserProc );
|
---|
| 359 |
|
---|
| 360 | return true;
|
---|
| 361 | }
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | return false;
|
---|
| 365 | }
|
---|
| 366 |
|
---|
[415] | 367 | bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName, bool *pIsVariable )
|
---|
[292] | 368 | {
|
---|
[97] | 369 | char parameter[VN_SIZE];
|
---|
| 370 |
|
---|
| 371 | // Withを解決
|
---|
| 372 | char termFull[VN_SIZE];
|
---|
| 373 | if(term[0]=='.'){
|
---|
| 374 | GetWithName(termFull);
|
---|
| 375 | lstrcat(termFull,term);
|
---|
| 376 | }
|
---|
| 377 | else lstrcpy(termFull,term);
|
---|
| 378 |
|
---|
| 379 | char termLeft[VN_SIZE];
|
---|
| 380 | lstrcpy(termLeft,termFull);
|
---|
| 381 |
|
---|
| 382 | // パース
|
---|
| 383 | char member[VN_SIZE];
|
---|
[206] | 384 | ReferenceKind refType;
|
---|
| 385 | if( SplitMemberName( termFull, termLeft, member, refType ) ){
|
---|
[97] | 386 | ///////////////////////////////////////////////////////////////////
|
---|
| 387 | // オブジェクトとメンバに分解できるとき
|
---|
| 388 | // termLeft.member
|
---|
| 389 | ///////////////////////////////////////////////////////////////////
|
---|
| 390 |
|
---|
| 391 | isLiteral = false;
|
---|
| 392 |
|
---|
| 393 | // オブジェクト側の型を取得
|
---|
| 394 | bool isClassName = false;
|
---|
| 395 | Type leftType;
|
---|
[331] | 396 | if( GetTermType( termLeft, Type(), leftType, isLiteral, &isClassName ) ){
|
---|
[265] | 397 | if( isClassName == false && compiler.GetObjectModule().meta.GetBlittableTypes().IsExist( leftType ) ){
|
---|
[128] | 398 | // 左側のオブジェクト部分がBlittable型のとき
|
---|
| 399 |
|
---|
| 400 | char temporary[VN_SIZE];
|
---|
| 401 | lstrcpy( temporary, termLeft );
|
---|
| 402 | sprintf( termLeft, "%s(%s)",
|
---|
[265] | 403 | compiler.GetObjectModule().meta.GetBlittableTypes().Find( leftType ).GetCreateStaticMethodFullName().c_str(),
|
---|
[128] | 404 | temporary );
|
---|
| 405 |
|
---|
[331] | 406 | if( !GetTermType( termLeft, Type(), leftType, isLiteral, &isClassName ) ){
|
---|
[128] | 407 | goto globalArea;
|
---|
| 408 | }
|
---|
| 409 | }
|
---|
| 410 | }
|
---|
| 411 | else{
|
---|
[103] | 412 | goto globalArea;
|
---|
[97] | 413 | }
|
---|
| 414 |
|
---|
| 415 | if( isClassName ){
|
---|
| 416 | // 静的メンバ/メソッドの場合
|
---|
| 417 | goto globalArea;
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | if( !leftType.HasMember() ){
|
---|
| 421 | // メンバを持たない型の場合
|
---|
| 422 | return false;
|
---|
| 423 | }
|
---|
| 424 |
|
---|
[415] | 425 | return GetMemberTermType( leftType, baseType, resultType, termFull, termLeft, member, pIsVariable );
|
---|
[97] | 426 | }
|
---|
| 427 |
|
---|
| 428 |
|
---|
| 429 | //////////////////////////////////////////////
|
---|
| 430 | // クラス名かどうかをチェック(静的メンバ用)
|
---|
| 431 | //////////////////////////////////////////////
|
---|
| 432 |
|
---|
| 433 | if( pIsClassName ){
|
---|
[265] | 434 | if( compiler.GetObjectModule().meta.GetClasses().Find( termFull ) ){
|
---|
[97] | 435 | *pIsClassName = true;
|
---|
| 436 | return true;
|
---|
| 437 | }
|
---|
| 438 | }
|
---|
| 439 |
|
---|
| 440 |
|
---|
| 441 | /////////////////////////////////////////////////////////////////
|
---|
| 442 | // グローバル属性
|
---|
| 443 | /////////////////////////////////////////////////////////////////
|
---|
| 444 | globalArea:
|
---|
| 445 |
|
---|
| 446 |
|
---|
| 447 | if(lstrcmpi(termFull,"This")==0){
|
---|
[412] | 448 | if( compiler.pCompilingClass == NULL )
|
---|
| 449 | {
|
---|
| 450 | return false;
|
---|
| 451 | }
|
---|
| 452 |
|
---|
[97] | 453 | //Thisオブジェクト
|
---|
[206] | 454 | resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
|
---|
[98] | 455 | isLiteral = false;
|
---|
[97] | 456 | return true;
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 |
|
---|
| 460 | //////////////////////////////////////
|
---|
| 461 | // 関数(DLL、ユーザー定義、組み込み)
|
---|
| 462 | //////////////////////////////////////
|
---|
| 463 | char procName[VN_SIZE];
|
---|
| 464 | char temporary[8192];
|
---|
| 465 |
|
---|
| 466 | int i2=GetCallProcName(termFull,procName);
|
---|
| 467 | if(termFull[i2]=='('){
|
---|
| 468 | int i4=GetStringInPare_RemovePare(parameter,termFull+i2+1);
|
---|
| 469 |
|
---|
| 470 | void *pProc;
|
---|
| 471 | int idProc=GetProc(procName,(void **)&pProc);
|
---|
| 472 |
|
---|
| 473 | if(idProc){
|
---|
| 474 | //閉じカッコ")"に続く文字がNULLでないとき
|
---|
| 475 | if(termFull[i2+1+i4+1]!='\0'){
|
---|
| 476 | SetError(42,NULL,cp);
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 |
|
---|
| 480 | ////////////////
|
---|
| 481 | // 呼び出し
|
---|
| 482 | ////////////////
|
---|
| 483 |
|
---|
[331] | 484 | if( !CallProc(idProc,pProc,procName,parameter, baseType, resultType, false ) ){
|
---|
[97] | 485 | return false;
|
---|
| 486 | }
|
---|
| 487 | if( resultType.IsNull() ){
|
---|
| 488 | //戻り値が存在しないとき
|
---|
| 489 | return false;
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | isLiteral = false;
|
---|
| 493 |
|
---|
| 494 | return true;
|
---|
| 495 | }
|
---|
[206] | 496 | else
|
---|
| 497 | {
|
---|
[265] | 498 | ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find( procName );
|
---|
[206] | 499 | if( pConstMacro )
|
---|
| 500 | {
|
---|
| 501 | if( pConstMacro->GetCalcBuffer( parameter, temporary ) )
|
---|
| 502 | {
|
---|
| 503 | /////////////////////////
|
---|
| 504 | // マクロ関数
|
---|
| 505 | /////////////////////////
|
---|
[97] | 506 |
|
---|
[206] | 507 | //閉じカッコ")"に続く文字がNULLでないときはエラーにする
|
---|
| 508 | if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
|
---|
[97] | 509 |
|
---|
[206] | 510 | //マクロ関数の場合
|
---|
| 511 | if( !NumOpe_GetType(temporary,Type(),resultType) ){
|
---|
| 512 | return false;
|
---|
| 513 | }
|
---|
[97] | 514 |
|
---|
[206] | 515 | if( !IS_LITERAL( resultType.GetIndex() ) ){
|
---|
| 516 | //リテラル値ではなかったとき
|
---|
| 517 | isLiteral = false;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | return true;
|
---|
| 521 | }
|
---|
[97] | 522 | }
|
---|
| 523 | }
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 |
|
---|
| 527 | ////////////////////////////////
|
---|
| 528 | // インデクサ(getアクセサ)
|
---|
| 529 | ////////////////////////////////
|
---|
| 530 |
|
---|
| 531 | char VarName[VN_SIZE],ArrayElements[VN_SIZE];
|
---|
| 532 | GetArrayElement(termFull,VarName,ArrayElements);
|
---|
| 533 | if(ArrayElements[0]){
|
---|
[292] | 534 | Type classType;
|
---|
| 535 | GetVarType(VarName,classType,false);
|
---|
| 536 | if( classType.IsObject() ){
|
---|
| 537 | if( !GetReturnTypeOfIndexerGetterProc( classType, resultType ) ){
|
---|
[97] | 538 | SetError(1,NULL,cp);
|
---|
| 539 | return false;
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 | isLiteral = false;
|
---|
| 543 |
|
---|
| 544 | return true;
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 |
|
---|
| 549 | ////////////////////////////////
|
---|
| 550 | // 変数
|
---|
| 551 | ////////////////////////////////
|
---|
| 552 |
|
---|
| 553 | if( GetVarType( termFull, resultType, false ) ){
|
---|
| 554 | if( resultType.GetBasicType() & FLAG_PTR ){
|
---|
| 555 | //配列ポインタ
|
---|
| 556 | resultType.SetBasicType( GetPtrType( resultType.GetBasicType()^FLAG_PTR ) );
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | isLiteral = false;
|
---|
| 560 |
|
---|
[415] | 561 | if( pIsVariable )
|
---|
| 562 | {
|
---|
| 563 | // 変数である
|
---|
| 564 | *pIsVariable = true;
|
---|
| 565 | }
|
---|
| 566 |
|
---|
[97] | 567 | return true;
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 |
|
---|
| 571 | /////////////////////////////////
|
---|
| 572 | // プロパティ用のメソッド
|
---|
| 573 | /////////////////////////////////
|
---|
| 574 |
|
---|
| 575 | //配列要素を排除
|
---|
| 576 | GetArrayElement(termFull,VarName,ArrayElements);
|
---|
| 577 |
|
---|
| 578 | if(GetSubHash(VarName,0)){
|
---|
| 579 | GetReturnTypeOfPropertyMethod(termFull,NULL,resultType);
|
---|
| 580 |
|
---|
| 581 | isLiteral = false;
|
---|
| 582 |
|
---|
| 583 | return true;
|
---|
| 584 | }
|
---|
| 585 |
|
---|
| 586 |
|
---|
| 587 | return false;
|
---|
| 588 | }
|
---|
| 589 |
|
---|
[415] | 590 | bool GetTermType( const char *term, Type &resultType )
|
---|
| 591 | {
|
---|
| 592 | bool isLiteral;
|
---|
| 593 | return GetTermType( term, Type(), resultType, isLiteral );
|
---|
| 594 | }
|
---|
| 595 |
|
---|
| 596 | bool GetTermTypeOnlyVariable( const char *term, Type &resultType )
|
---|
| 597 | {
|
---|
| 598 | bool isLiteral, isVariable = false;
|
---|
| 599 | bool result = GetTermType( term, Type(), resultType, isLiteral, NULL, &isVariable );
|
---|
| 600 | return ( result && isVariable );
|
---|
| 601 | }
|
---|
| 602 |
|
---|
[254] | 603 | bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation ){
|
---|
[4] | 604 | extern int cp;
|
---|
[97] | 605 | int i,i3;
|
---|
[4] | 606 |
|
---|
[254] | 607 | //リテラル値のみの計算かどうかを判別するためのフラグ
|
---|
| 608 | bool dummyBool;
|
---|
| 609 | if( pIsLiteralCalculation == NULL )
|
---|
| 610 | {
|
---|
| 611 | pIsLiteralCalculation = &dummyBool;
|
---|
| 612 | }
|
---|
| 613 | *pIsLiteralCalculation = true;
|
---|
| 614 |
|
---|
[75] | 615 | if(expression[0]=='\0'){
|
---|
[4] | 616 | SetError(1,NULL,cp);
|
---|
[75] | 617 | return false;
|
---|
[4] | 618 | }
|
---|
| 619 |
|
---|
[355] | 620 | if(expression[0]==1&& ( expression[1]==ESC_NEW || expression[1] == ESC_SYSTEM_STATIC_NEW ) ){
|
---|
[4] | 621 | //New演算子(オブジェクト生成)
|
---|
[254] | 622 | *pIsLiteralCalculation = false;
|
---|
[75] | 623 | return Operator_New_GetType(expression+2,baseType, resultType );
|
---|
[4] | 624 | }
|
---|
| 625 |
|
---|
[94] | 626 | if( expression[0] == '[' ){
|
---|
| 627 | if( !baseType.IsPointer() ){
|
---|
| 628 | return false;
|
---|
| 629 | }
|
---|
[4] | 630 |
|
---|
[94] | 631 | resultType = baseType;
|
---|
| 632 | return true;
|
---|
| 633 | }
|
---|
| 634 |
|
---|
| 635 |
|
---|
[4] | 636 | /////////////////////////////////
|
---|
| 637 | // 式要素を逆ポーランド式で取得
|
---|
| 638 | /////////////////////////////////
|
---|
| 639 |
|
---|
| 640 | char *values[255];
|
---|
| 641 | long calc[255];
|
---|
| 642 | long stack[255];
|
---|
| 643 | int pnum;
|
---|
[75] | 644 | if(!GetNumOpeElements(expression,&pnum,values,calc,stack)){
|
---|
[4] | 645 | for(i=0;i<pnum;i++){
|
---|
| 646 | if(values[i]) HeapDefaultFree(values[i]);
|
---|
| 647 | }
|
---|
[75] | 648 | return false;
|
---|
[4] | 649 | }
|
---|
| 650 |
|
---|
| 651 |
|
---|
| 652 |
|
---|
| 653 | ////////////////////////////////
|
---|
| 654 | // 演算部分のコード生成を開始
|
---|
| 655 | ////////////////////////////////
|
---|
| 656 |
|
---|
| 657 | BOOL bError;
|
---|
| 658 | bError=0;
|
---|
| 659 |
|
---|
| 660 | int sp;
|
---|
[75] | 661 | int type_stack[255];
|
---|
[4] | 662 | LONG_PTR index_stack[255];
|
---|
[79] | 663 | bool isNothing_stack[255];
|
---|
[4] | 664 | _int64 i64data;
|
---|
| 665 | int idCalc;
|
---|
| 666 | for(i=0,sp=0;i<pnum;i++){
|
---|
| 667 | idCalc=calc[i]%100;
|
---|
| 668 |
|
---|
| 669 | if(idCalc){
|
---|
[75] | 670 | if(type_stack[sp-2]==DEF_OBJECT){
|
---|
[79] | 671 | if( idCalc == CALC_AS
|
---|
| 672 | && type_stack[sp-1] == ( DEF_OBJECT | FLAG_CAST )
|
---|
| 673 | && index_stack[sp-1] == index_stack[sp-2]
|
---|
| 674 | || isNothing_stack[sp-2] ){
|
---|
| 675 | // 同一の型、またはNothingに対するAsはAs演算子を呼び出さない
|
---|
[4] | 676 | }
|
---|
[94] | 677 | else if( idCalc == CALC_AS
|
---|
| 678 | && type_stack[sp-1] == ( DEF_OBJECT | FLAG_CAST )
|
---|
| 679 | && ( ((CClass *)index_stack[sp-1])->IsEqualsOrSubClass( (CClass *)index_stack[sp-2] ) || ((CClass *)index_stack[sp-2])->IsEqualsOrSubClass( (CClass *)index_stack[sp-1] )
|
---|
| 680 | )){
|
---|
| 681 | // ダウンキャストを許可する
|
---|
| 682 | }
|
---|
[129] | 683 | else if( idCalc == CALC_AS ){
|
---|
| 684 | // NumOpe_GetTypeではすべてのキャストを許可する
|
---|
| 685 | }
|
---|
[79] | 686 | else{
|
---|
| 687 | //オーバーロードされたオペレータを呼び出す
|
---|
| 688 | if(!GetReturnType_OperatorProc(idCalc,baseType,type_stack,index_stack,sp)){
|
---|
| 689 | goto error;
|
---|
| 690 | }
|
---|
[4] | 691 |
|
---|
[79] | 692 | continue;
|
---|
| 693 | }
|
---|
[4] | 694 | }
|
---|
| 695 |
|
---|
[75] | 696 | if(!CheckCalcType(idCalc,type_stack,sp)) goto error;
|
---|
[4] | 697 | }
|
---|
| 698 |
|
---|
| 699 | switch(idCalc){
|
---|
| 700 | //数値
|
---|
| 701 | case 0:
|
---|
| 702 | index_stack[sp]=-1;
|
---|
[79] | 703 | isNothing_stack[sp] = false;
|
---|
[4] | 704 |
|
---|
[49] | 705 | char *term;
|
---|
| 706 | term = values[i];
|
---|
| 707 |
|
---|
[97] | 708 | if( calc[i+1]%100 == CALC_AS ){
|
---|
| 709 | // As演算子の右辺値
|
---|
| 710 | //型名
|
---|
[198] | 711 | if( compiler.StringToType( term, resultType ) ){
|
---|
[128] | 712 |
|
---|
| 713 | if( resultType.IsObject() ){
|
---|
| 714 | if( resultType.GetClass().IsBlittableType() ){
|
---|
| 715 | // Blittable型のときは基本型として扱う
|
---|
| 716 | // ※ただし、コンパイル中のメソッドがBlittable型クラスに属していないこと
|
---|
| 717 | if( UserProc::IsLocalAreaCompiling()
|
---|
| 718 | && UserProc::CompilingUserProc().HasParentClass()
|
---|
| 719 | && UserProc::CompilingUserProc().GetParentClass().IsBlittableType() )
|
---|
| 720 | {
|
---|
| 721 | // コンパイル中のメソッドがBlittable型クラスに属している
|
---|
| 722 | }
|
---|
| 723 | else{
|
---|
| 724 | resultType = resultType.GetClass().GetBlittableType();
|
---|
| 725 | }
|
---|
| 726 | }
|
---|
| 727 | }
|
---|
| 728 |
|
---|
[97] | 729 | resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST );
|
---|
| 730 | }
|
---|
| 731 | else{
|
---|
| 732 | SetError(3, term, cp );
|
---|
| 733 | goto error;
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | type_stack[sp] = resultType.GetBasicType();
|
---|
| 737 | index_stack[sp] = resultType.GetIndex();
|
---|
| 738 | sp++;
|
---|
| 739 |
|
---|
| 740 | break;
|
---|
| 741 | }
|
---|
| 742 |
|
---|
[49] | 743 | if(term[0]=='\"'){
|
---|
[4] | 744 | StrLiteral:
|
---|
| 745 |
|
---|
[350] | 746 | if( !baseType.IsPointer() ){
|
---|
[97] | 747 | //要求タイプがオブジェクト、または未定のとき
|
---|
[75] | 748 | type_stack[sp]=DEF_OBJECT;
|
---|
[265] | 749 | index_stack[sp]=(LONG_PTR)compiler.GetObjectModule().meta.GetClasses().GetStringClassPtr();
|
---|
[254] | 750 | *pIsLiteralCalculation = false;
|
---|
[4] | 751 |
|
---|
[75] | 752 | sp++;
|
---|
| 753 | break;
|
---|
[4] | 754 | }
|
---|
| 755 |
|
---|
[75] | 756 | type_stack[sp]=typeOfPtrChar;
|
---|
[254] | 757 | *pIsLiteralCalculation = false;
|
---|
[4] | 758 | }
|
---|
[49] | 759 | else if((term[0]=='e'||term[0]=='E')&&
|
---|
| 760 | (term[1]=='x'||term[1]=='X')&&
|
---|
| 761 | term[2]=='\"'){
|
---|
[4] | 762 | //拡張版リテラル文字列(エスケープシーケンス可能)
|
---|
| 763 | goto StrLiteral;
|
---|
| 764 | }
|
---|
[49] | 765 | else if(IsVariableTopChar(term[0])||
|
---|
| 766 | term[0]=='*'||
|
---|
[334] | 767 | (term[0]=='.'&&IsVariableTopChar(term[1])))
|
---|
| 768 | {
|
---|
[4] | 769 | //////////////////
|
---|
| 770 | // 何らかの識別子
|
---|
| 771 |
|
---|
[97] | 772 | bool isLiteral = true;
|
---|
[331] | 773 | if( GetTermType( term, baseType, resultType, isLiteral ) ){
|
---|
[97] | 774 | type_stack[sp] = resultType.GetBasicType();
|
---|
| 775 | index_stack[sp] = resultType.GetIndex();
|
---|
[4] | 776 |
|
---|
[97] | 777 | if( !isLiteral ){
|
---|
[254] | 778 | *pIsLiteralCalculation = false;
|
---|
[4] | 779 | }
|
---|
| 780 |
|
---|
[97] | 781 | sp++;
|
---|
| 782 | break;
|
---|
[4] | 783 | }
|
---|
| 784 |
|
---|
[38] | 785 |
|
---|
[67] | 786 | // Nothing
|
---|
| 787 | if( lstrcmp( term, "Nothing" ) == 0 ){
|
---|
[79] | 788 | isNothing_stack[sp] = true;
|
---|
| 789 |
|
---|
[75] | 790 | type_stack[sp] = DEF_OBJECT;
|
---|
| 791 | if( baseType.IsObject() ){
|
---|
| 792 | index_stack[sp] = baseType.GetIndex();
|
---|
[67] | 793 | }
|
---|
| 794 | else{
|
---|
[265] | 795 | index_stack[sp] = (LONG_PTR)compiler.GetObjectModule().meta.GetClasses().GetObjectClassPtr();
|
---|
[67] | 796 | }
|
---|
[254] | 797 | *pIsLiteralCalculation = false;
|
---|
[67] | 798 | sp++;
|
---|
| 799 | break;
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 |
|
---|
[4] | 803 | //////////////
|
---|
| 804 | // 定数の場合
|
---|
| 805 | //////////////
|
---|
| 806 |
|
---|
[265] | 807 | i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(term);
|
---|
[7] | 808 | if(i3){
|
---|
[265] | 809 | if( compiler.GetObjectModule().meta.GetGlobalConsts().IsStringPtr( term ) ){
|
---|
[103] | 810 | //リテラル文字列
|
---|
| 811 | goto StrLiteral;
|
---|
| 812 | }
|
---|
| 813 |
|
---|
[75] | 814 | type_stack[sp]=i3;
|
---|
[4] | 815 | if(IsRealNumberType(i3)){
|
---|
| 816 | //実数
|
---|
| 817 | goto Literal;
|
---|
| 818 | }
|
---|
| 819 | else if(IsWholeNumberType(i3)){
|
---|
| 820 | //整数
|
---|
| 821 | goto Literal;
|
---|
| 822 | }
|
---|
| 823 | else if(Is64Type(i3)){
|
---|
| 824 | //64ビット整数値
|
---|
| 825 | goto Literal;
|
---|
| 826 | }
|
---|
| 827 | else{
|
---|
| 828 | SetError(1,NULL,0);
|
---|
| 829 | goto error;
|
---|
| 830 | }
|
---|
| 831 | }
|
---|
| 832 |
|
---|
| 833 |
|
---|
| 834 | /////////////////////////////////
|
---|
| 835 | // プロパティ用のメソッド
|
---|
| 836 | /////////////////////////////////
|
---|
| 837 |
|
---|
| 838 | //配列要素を排除
|
---|
[97] | 839 | char VarName[VN_SIZE],ArrayElements[VN_SIZE];
|
---|
[49] | 840 | GetArrayElement(term,VarName,ArrayElements);
|
---|
[4] | 841 |
|
---|
| 842 | if(GetSubHash(VarName,0)){
|
---|
[97] | 843 | SetError();
|
---|
[75] | 844 | Type tempType;
|
---|
| 845 | GetReturnTypeOfPropertyMethod(term,NULL,tempType);
|
---|
[4] | 846 |
|
---|
| 847 | //大きな型への暗黙の変換
|
---|
[75] | 848 | type_stack[sp]=tempType.GetBasicType();
|
---|
[4] | 849 |
|
---|
[75] | 850 | index_stack[sp]=tempType.GetIndex();
|
---|
[254] | 851 | *pIsLiteralCalculation = false;
|
---|
[4] | 852 |
|
---|
| 853 | sp++;
|
---|
| 854 | break;
|
---|
| 855 | }
|
---|
| 856 |
|
---|
| 857 |
|
---|
| 858 |
|
---|
| 859 | //該当する識別子が見当たらないときはエラー扱いにする
|
---|
| 860 | bError=1;
|
---|
[49] | 861 | SetError(3,term,cp);
|
---|
[75] | 862 | type_stack[sp]=DEF_DOUBLE;
|
---|
[4] | 863 | }
|
---|
| 864 | else{
|
---|
| 865 | //リテラル値
|
---|
[75] | 866 | int base_type = 0;
|
---|
| 867 | if( !baseType.IsNull() ) base_type = baseType.GetBasicType();
|
---|
| 868 | type_stack[sp]=GetLiteralValue(term,&i64data,base_type);
|
---|
[4] | 869 | Literal:
|
---|
| 870 | if((long)i64data==0&&index_stack[sp]==-1) index_stack[sp]=LITERAL_NULL;
|
---|
| 871 | }
|
---|
| 872 |
|
---|
| 873 | sp++;
|
---|
| 874 | break;
|
---|
| 875 |
|
---|
| 876 | //論理演算子
|
---|
| 877 | case CALC_XOR:
|
---|
| 878 | case CALC_OR:
|
---|
| 879 | case CALC_AND:
|
---|
| 880 | sp--;
|
---|
[75] | 881 | type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
|
---|
[4] | 882 | break;
|
---|
| 883 | case CALC_NOT:
|
---|
| 884 | //values[sp-1]=Not values[sp-1]
|
---|
| 885 | //NOT演算子
|
---|
| 886 | break;
|
---|
| 887 |
|
---|
| 888 | //比較演算子
|
---|
| 889 | case CALC_PE: //values[sp-2] <= values[sp-1]
|
---|
| 890 | case CALC_QE: //values[sp-2] >= values[sp-1]
|
---|
| 891 | case CALC_P: //values[sp-2] < values[sp-1]
|
---|
| 892 | case CALC_Q: //values[sp-2] > values[sp-1]
|
---|
| 893 | case CALC_NOTEQUAL: //values[sp-2] <> values[sp-1]
|
---|
| 894 | case CALC_EQUAL: //values[sp-2] = values[sp-1]
|
---|
| 895 | sp--;
|
---|
[75] | 896 | type_stack[sp-1]=DEF_LONG;
|
---|
[4] | 897 | break;
|
---|
| 898 |
|
---|
| 899 | //ビットシフト
|
---|
| 900 | case CALC_SHL: //values[sp-2] << values[sp-1]
|
---|
| 901 | case CALC_SHR: //values[sp-2] >> values[sp-1]
|
---|
| 902 | sp--;
|
---|
| 903 | break;
|
---|
| 904 |
|
---|
| 905 | //算術演算
|
---|
| 906 | case CALC_ADDITION:
|
---|
| 907 | case CALC_SUBTRACTION:
|
---|
| 908 | case CALC_PRODUCT:
|
---|
| 909 | sp--;
|
---|
[75] | 910 | type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
|
---|
[4] | 911 | break;
|
---|
| 912 | case CALC_MOD:
|
---|
| 913 | //values[sp-2]%=values[sp-1]
|
---|
| 914 | //剰余演算
|
---|
| 915 | sp--;
|
---|
[75] | 916 | type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
|
---|
[4] | 917 | break;
|
---|
| 918 | case CALC_QUOTIENT:
|
---|
| 919 | //values[sp-2]/=values[sp-1];
|
---|
| 920 | //除算
|
---|
| 921 | sp--;
|
---|
[75] | 922 | type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
|
---|
[4] | 923 | break;
|
---|
| 924 | case CALC_INTQUOTIENT:
|
---|
| 925 | //values[sp-2]/=values[sp-1]
|
---|
| 926 | //整数除算
|
---|
| 927 | sp--;
|
---|
[75] | 928 | type_stack[sp-1]=NeutralizationType(type_stack[sp-1],index_stack[sp-1],type_stack[sp],index_stack[sp]);
|
---|
[4] | 929 | break;
|
---|
| 930 | case CALC_MINUSMARK:
|
---|
| 931 | //values[sp-1]=-values[sp-1]
|
---|
| 932 | //符号反転
|
---|
| 933 | break;
|
---|
| 934 | case CALC_POWER:
|
---|
| 935 | //べき乗演算(浮動小数点演算のみ)
|
---|
| 936 | sp--;
|
---|
| 937 | //未完成
|
---|
| 938 | break;
|
---|
| 939 | case CALC_AS:
|
---|
| 940 | //キャスト
|
---|
[75] | 941 | type_stack[sp-2]=type_stack[sp-1]&(~FLAG_CAST);
|
---|
[4] | 942 | index_stack[sp-2]=index_stack[sp-1];
|
---|
| 943 |
|
---|
| 944 | sp--;
|
---|
| 945 | break;
|
---|
[41] | 946 |
|
---|
| 947 | case CALC_BYVAL:
|
---|
| 948 | //ポインタ型→参照型
|
---|
[75] | 949 | if( PTR_LEVEL( type_stack[sp-1] ) <= 0 ){
|
---|
[41] | 950 | //ポインタ型ではないとき
|
---|
| 951 | SetError( 3, NULL, cp );
|
---|
| 952 | goto error;
|
---|
| 953 | }
|
---|
| 954 |
|
---|
[75] | 955 | type_stack[sp-1] = PTR_LEVEL_DOWN( type_stack[sp-1] );
|
---|
[41] | 956 | break;
|
---|
[4] | 957 | }
|
---|
| 958 | }
|
---|
| 959 |
|
---|
| 960 | if(bError) goto error;
|
---|
| 961 |
|
---|
| 962 | if(sp!=1){
|
---|
| 963 | SetError(1,NULL,cp);
|
---|
| 964 | goto error;
|
---|
| 965 | }
|
---|
| 966 |
|
---|
[254] | 967 | if( *pIsLiteralCalculation ){
|
---|
[4] | 968 | //右辺値が数値の定数式の場合
|
---|
[75] | 969 | int base_type = 0;
|
---|
| 970 | if( !baseType.IsNull() ) base_type = baseType.GetBasicType();
|
---|
| 971 | Type tempType;
|
---|
| 972 | StaticCalculation(true, expression,base_type,&i64data,tempType);
|
---|
[4] | 973 |
|
---|
[75] | 974 | type_stack[0]=tempType.GetBasicType();
|
---|
| 975 | index_stack[0]=tempType.GetIndex();
|
---|
[4] | 976 | }
|
---|
| 977 | else{
|
---|
| 978 | //右辺値が数値の定数式ではないとき
|
---|
| 979 | if(IS_LITERAL(index_stack[0])) index_stack[0]=-1;
|
---|
| 980 | }
|
---|
| 981 |
|
---|
[75] | 982 | resultType.SetType( type_stack[0], index_stack[0] );
|
---|
[4] | 983 |
|
---|
[75] | 984 | bool isSuccessful = true;
|
---|
[4] | 985 | goto finish;
|
---|
| 986 |
|
---|
| 987 |
|
---|
| 988 | //////////////////
|
---|
| 989 | // エラー処理
|
---|
| 990 | //////////////////
|
---|
| 991 |
|
---|
| 992 | error:
|
---|
[75] | 993 | isSuccessful = false;
|
---|
[4] | 994 | goto finish;
|
---|
| 995 |
|
---|
| 996 |
|
---|
| 997 | finish:
|
---|
| 998 | for(i=0;i<pnum;i++){
|
---|
| 999 | if(values[i]) HeapDefaultFree(values[i]);
|
---|
| 1000 | }
|
---|
[75] | 1001 | return isSuccessful;
|
---|
[4] | 1002 | }
|
---|