Changeset 75 in dev for BasicCompiler_Common/Procedure.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Procedure.cpp
r74 r75 1 1 #include "common.h" 2 2 3 SubInfo::SubInfo(): 4 pNextData( NULL ) 5 { 3 bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){ 4 int i = 0; 5 int i2,i3,sw; 6 char temporary[8192],temp2[VN_SIZE]; 7 8 //ソースコードの位置 9 this->codePos = nowLine; 10 11 //パラメータ 12 if(sourceOfParams[i]!='('){ 13 SetError(1,NULL,nowLine); 14 return 0; 15 } 16 i++; 17 if(sourceOfParams[i]!=')'&& this->pParentClass ){ 18 //クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす 19 if(this->GetName()[0]=='~'){ 20 SetError(114,NULL,nowLine); 21 i=JumpStringInPare(sourceOfParams,i); 22 } 23 } 24 while(1){ 25 if(sourceOfParams[i]==')') break; 26 27 //ByRef 28 bool isRef; 29 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){ 30 isRef = false; 31 i+=2; 32 } 33 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){ 34 isRef = true; 35 i+=2; 36 } 37 else isRef = false; 38 39 //パラメータ名 40 bool isArray = false; 41 int subScripts[MAX_ARRAYDIM]; 42 char name[VN_SIZE]; 43 sw=0; 44 for(i2=0;;i++,i2++){ 45 if(sourceOfParams[i]=='('){ 46 if(!sw) sw=1; 47 48 i3=GetStringInPare(name+i2,sourceOfParams+i); 49 i2+=i3-1; 50 i+=i3-1; 51 continue; 52 } 53 if(sourceOfParams[i]=='['){ 54 if(!sw) sw=1; 55 56 i3=GetStringInBracket(name+i2,sourceOfParams+i); 57 i2+=i3-1; 58 i+=i3-1; 59 continue; 60 } 61 if(!IsVariableChar(sourceOfParams[i])){ 62 name[i2]=0; 63 break; 64 } 65 name[i2]=sourceOfParams[i]; 66 } 67 if(sw){ 68 //配列パラメータ 69 if( isRef == false ) SetError(29,NULL,nowLine); 70 isArray = true; 71 72 if((name[i2-2]=='('&&name[i2-1]==')')|| 73 (name[i2-2]=='['&&name[i2-1]==']')){ 74 subScripts[0]=LONG_MAX; 75 subScripts[1]=-1; 76 77 name[i2-2]=0; 78 } 79 else{ 80 GetArrange(name,temp2,subScripts); 81 lstrcpy(name,temp2); 82 } 83 84 i2=lstrlen(name); 85 } 86 87 //型 88 Type type( DEF_NON ); 89 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 90 i+=2; 91 92 i2=0; 93 while(sourceOfParams[i]=='*'){ 94 temporary[i2]=sourceOfParams[i]; 95 i++; 96 i2++; 97 } 98 for(;;i++,i2++){ 99 if(!IsVariableChar(sourceOfParams[i])){ 100 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){ 101 temporary[i2++]=sourceOfParams[i++]; 102 temporary[i2]=sourceOfParams[i]; 103 continue; 104 } 105 temporary[i2]=0; 106 break; 107 } 108 temporary[i2]=sourceOfParams[i]; 109 } 110 111 Type::StringToType( temporary, type ); 112 113 if(temporary[0]=='*'&& 114 temporary[1]==1&& 115 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){ 116 if(sourceOfParams[i]!='('){ 117 SetError(10,temporary,nowLine); 118 break; 119 } 120 i3=GetStringInPare(temporary+i2,sourceOfParams+i); 121 i+=i3; 122 i2+=i3; 123 124 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 125 temporary[i2++]=sourceOfParams[i++]; 126 temporary[i2++]=sourceOfParams[i++]; 127 for(;;i++,i2++){ 128 if(!IsVariableChar(sourceOfParams[i])){ 129 temporary[i2]=0; 130 break; 131 } 132 temporary[i2]=sourceOfParams[i]; 133 } 134 } 135 } 136 else{ 137 //TypeDefをする前のベース型を取得 138 GetOriginalTypeName(temporary); 139 } 140 141 if( type.IsNull() ){ 142 SetError(3,temporary,nowLine); 143 type.SetBasicType( DEF_PTR_VOID ); 144 } 145 } 146 else{ 147 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 148 SetError(-103,temporary,nowLine); 149 } 150 151 if( type.IsProcPtr() ){ 152 //関数ポインタの場合 153 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine) ); 154 } 155 156 Parameter *pParam = new Parameter( name, type, isRef ); 157 if( isArray ){ 158 pParam->SetArray( subScripts ); 159 } 160 161 //パラメータを追加 162 this->params.push_back( pParam ); 163 164 if(sourceOfParams[i]==','){ 165 i++; 166 continue; 167 } 168 else if(sourceOfParams[i]==')') continue; 169 else{ 170 SetError(1,NULL,nowLine); 171 break; 172 } 173 } 174 this->secondParmNum = (int)this->params.size(); 175 i++; 176 if(sourceOfParams[i]=='('){ 177 i++; 178 while(1){ 179 if(sourceOfParams[i]==')') break; 180 181 //ByRef 182 bool isRef; 183 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){ 184 isRef = false; 185 i+=2; 186 } 187 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){ 188 isRef = true; 189 i+=2; 190 } 191 else isRef = false; 192 193 //パラメータ名 194 bool isArray = false; 195 int subScripts[MAX_ARRAYDIM]; 196 char name[VN_SIZE]; 197 sw=0; 198 for(i2=0;;i++,i2++){ 199 if(sourceOfParams[i]=='('){ 200 if(!sw) sw=1; 201 202 i3=GetStringInPare(name+i2,sourceOfParams+i); 203 i2+=i3-1; 204 i+=i3-1; 205 continue; 206 } 207 if(sourceOfParams[i]=='['){ 208 if(!sw) sw=1; 209 210 i3=GetStringInBracket(name+i2,sourceOfParams+i); 211 i2+=i3-1; 212 i+=i3-1; 213 continue; 214 } 215 if(!IsVariableChar(sourceOfParams[i])){ 216 name[i2]=0; 217 break; 218 } 219 name[i2]=sourceOfParams[i]; 220 } 221 if(sw){ 222 //配列パラメータ 223 if( isRef == false ) SetError(29,NULL,nowLine); 224 isArray = true; 225 226 if((name[i2-2]=='('&&name[i2-1]==')')|| 227 (name[i2-2]=='['&&name[i2-1]==']')){ 228 subScripts[0]=LONG_MAX; 229 subScripts[1]=-1; 230 231 name[i2-2]=0; 232 } 233 else{ 234 GetArrange(name,temp2,subScripts); 235 lstrcpy(name,temp2); 236 } 237 238 i2=lstrlen(name); 239 } 240 241 //型 242 Type type( DEF_NON ); 243 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 244 i+=2; 245 246 i2=0; 247 while(sourceOfParams[i]=='*'){ 248 temporary[i2]=sourceOfParams[i]; 249 i++; 250 i2++; 251 } 252 for(;;i++,i2++){ 253 if(!IsVariableChar(sourceOfParams[i])){ 254 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){ 255 temporary[i2++]=sourceOfParams[i++]; 256 temporary[i2]=sourceOfParams[i]; 257 continue; 258 } 259 temporary[i2]=0; 260 break; 261 } 262 temporary[i2]=sourceOfParams[i]; 263 } 264 265 Type::StringToType( temporary, type ); 266 267 if(temporary[0]=='*'&& 268 temporary[1]==1&& 269 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){ 270 if(sourceOfParams[i]!='('){ 271 SetError(10,temporary,nowLine); 272 break; 273 } 274 i3=GetStringInPare(temporary+i2,sourceOfParams+i); 275 i+=i3; 276 i2+=i3; 277 278 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 279 temporary[i2++]=sourceOfParams[i++]; 280 temporary[i2++]=sourceOfParams[i++]; 281 for(;;i++,i2++){ 282 if(!IsVariableChar(sourceOfParams[i])){ 283 temporary[i2]=0; 284 break; 285 } 286 temporary[i2]=sourceOfParams[i]; 287 } 288 } 289 } 290 else{ 291 //TypeDefをする前のベース型を取得 292 GetOriginalTypeName(temporary); 293 } 294 295 if( type.IsNull() ){ 296 SetError(3,temporary,nowLine); 297 type.SetBasicType( DEF_PTR_VOID ); 298 } 299 } 300 else{ 301 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 302 SetError(-103,temporary,nowLine); 303 } 304 305 if( type.IsProcPtr() ){ 306 //関数ポインタの場合 307 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine) ); 308 } 309 310 Parameter *pParam = new Parameter( name, type, isRef ); 311 if( isArray ){ 312 pParam->SetArray( subScripts ); 313 } 314 315 //パラメータを追加 316 this->params.push_back( pParam ); 317 318 if(sourceOfParams[i]==','){ 319 i++; 320 continue; 321 } 322 else if(sourceOfParams[i]==')') continue; 323 else{ 324 SetError(1,NULL,nowLine); 325 break; 326 } 327 } 328 i++; 329 } 330 331 if(sourceOfParams[i]){ 332 /////////////////// 333 // 戻り値を取得 334 /////////////////// 335 336 if( !this->IsFunction() ){ 337 // Sub/Macroの場合 338 SetError(38,this->GetName(),nowLine); 339 } 340 341 if( this->pParentClass ){ 342 if( this->GetName() == this->pParentClass->name || 343 this->GetName()[0]=='~'){ 344 //クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす 345 SetError(115,NULL,nowLine); 346 } 347 } 348 349 350 i2=lstrlen(sourceOfParams)-2; 351 352 int sw_as=0; 353 for(;i2>0;i2--){ 354 if(sourceOfParams[i2]==')') break; 355 356 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){ 357 i2+=2; 358 i3=0; 359 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++]; 360 for(;;i2++,i3++){ 361 if(!IsVariableChar(sourceOfParams[i2])){ 362 temporary[i3]=0; 363 break; 364 } 365 temporary[i3]=sourceOfParams[i2]; 366 } 367 Type::StringToType( temporary, this->returnType ); 368 if( this->returnType.IsNull() ) SetError(3,temporary,nowLine); 369 370 sw_as=1; 371 break; 372 } 373 } 374 375 if(!sw_as){ 376 SetError(-104,this->GetName().c_str(),nowLine); 377 378 this->returnType.SetBasicType( DEF_DOUBLE ); 379 } 380 } 381 else{ 382 //戻り値なしのSub定義 383 this->returnType.SetNull(); 384 } 385 386 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する場合がある) 387 388 if( this->pParentClass && isStatic == false ){ 389 //オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用 390 string name = "_System_LocalThis"; 391 Type type( DEF_PTR_VOID ); 392 this->realParams.push_back( new Parameter( name, type ) ); 393 } 394 395 if( this->returnType.IsStruct() ){ 396 //構造体を戻り値として持つ場合 397 //※第一パラメータ(Thisポインタありの場合は第二パラメータ)を戻り値用の参照宣言にする 398 399 string name = this->GetName(); 400 if(name[0]==1&&name[1]==ESC_OPERATOR){ 401 name="_System_ReturnValue"; 402 } 403 Type type( DEF_STRUCT, this->returnType.GetIndex() ); 404 this->realParams.push_back( new Parameter( name, type, true ) ); 405 } 406 407 //パラメータをコピー 408 foreach( Parameter *pParam, params ){ 409 this->realParams.push_back( new Parameter( *pParam ) ); 410 } 411 412 return true; 6 413 } 414 415 bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 416 int i = 0; 417 int i2,i3,sw; 418 char temporary[8192],temp2[VN_SIZE]; 419 420 //ソースコードの位置 421 this->codePos = nowLine; 422 423 //パラメータ 424 if(sourceOfParams[i]!='('){ 425 SetError(1,NULL,nowLine); 426 return 0; 427 } 428 i++; 429 430 while(1){ 431 if(sourceOfParams[i]==')') break; 432 433 //ByRef 434 bool isRef; 435 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){ 436 isRef = false; 437 i+=2; 438 } 439 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){ 440 isRef = true; 441 i+=2; 442 } 443 else isRef = false; 444 445 //パラメータ名 446 bool isArray = false; 447 int subScripts[MAX_ARRAYDIM]; 448 char name[VN_SIZE]; 449 sw=0; 450 for(i2=0;;i++,i2++){ 451 if(sourceOfParams[i]=='('){ 452 if(!sw) sw=1; 453 454 i3=GetStringInPare(name+i2,sourceOfParams+i); 455 i2+=i3-1; 456 i+=i3-1; 457 continue; 458 } 459 if(sourceOfParams[i]=='['){ 460 if(!sw) sw=1; 461 462 i3=GetStringInBracket(name+i2,sourceOfParams+i); 463 i2+=i3-1; 464 i+=i3-1; 465 continue; 466 } 467 if(!IsVariableChar(sourceOfParams[i])){ 468 name[i2]=0; 469 break; 470 } 471 name[i2]=sourceOfParams[i]; 472 } 473 if(sw){ 474 //配列パラメータ 475 if( isRef == false ) SetError(29,NULL,nowLine); 476 isArray = true; 477 478 if((name[i2-2]=='('&&name[i2-1]==')')|| 479 (name[i2-2]=='['&&name[i2-1]==']')){ 480 subScripts[0]=LONG_MAX; 481 subScripts[1]=-1; 482 483 name[i2-2]=0; 484 } 485 else{ 486 GetArrange(name,temp2,subScripts); 487 lstrcpy(name,temp2); 488 } 489 490 i2=lstrlen(name); 491 } 492 493 //型 494 Type type( DEF_NON ); 495 if(lstrcmp(name,"...")==0) type.SetBasicType( DEF_ELLIPSE ); 496 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 497 i+=2; 498 499 i2=0; 500 while(sourceOfParams[i]=='*'){ 501 temporary[i2]=sourceOfParams[i]; 502 i++; 503 i2++; 504 } 505 for(;;i++,i2++){ 506 if(!IsVariableChar(sourceOfParams[i])){ 507 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){ 508 temporary[i2++]=sourceOfParams[i++]; 509 temporary[i2]=sourceOfParams[i]; 510 continue; 511 } 512 temporary[i2]=0; 513 break; 514 } 515 temporary[i2]=sourceOfParams[i]; 516 } 517 518 Type::StringToType( temporary, type ); 519 520 if(temporary[0]=='*'&& 521 temporary[1]==1&& 522 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){ 523 if(sourceOfParams[i]!='('){ 524 SetError(10,temporary,nowLine); 525 break; 526 } 527 i3=GetStringInPare(temporary+i2,sourceOfParams+i); 528 i+=i3; 529 i2+=i3; 530 531 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 532 temporary[i2++]=sourceOfParams[i++]; 533 temporary[i2++]=sourceOfParams[i++]; 534 for(;;i++,i2++){ 535 if(!IsVariableChar(sourceOfParams[i])){ 536 temporary[i2]=0; 537 break; 538 } 539 temporary[i2]=sourceOfParams[i]; 540 } 541 } 542 } 543 else{ 544 //TypeDefをする前のベース型を取得 545 GetOriginalTypeName(temporary); 546 } 547 548 if( type.IsNull() ){ 549 SetError(3,temporary,nowLine); 550 type.SetBasicType( DEF_PTR_VOID ); 551 } 552 } 553 else{ 554 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 555 SetError(-103,temporary,nowLine); 556 } 557 558 if( type.IsProcPtr() ){ 559 //関数ポインタの場合 560 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine ) ); 561 } 562 563 Parameter *pParam = new Parameter( name, type, isRef ); 564 if( isArray ){ 565 pParam->SetArray( subScripts ); 566 } 567 568 //パラメータを追加 569 this->params.push_back( pParam ); 570 571 if(sourceOfParams[i]==','){ 572 i++; 573 continue; 574 } 575 else if(sourceOfParams[i]==')') continue; 576 else{ 577 SetError(1,NULL,nowLine); 578 break; 579 } 580 } 581 i++; 582 583 if(sourceOfParams[i]){ 584 /////////////////// 585 // 戻り値を取得 586 /////////////////// 587 588 i2=lstrlen(sourceOfParams)-2; 589 590 int sw_as=0; 591 for(;i2>0;i2--){ 592 if(sourceOfParams[i2]==')') break; 593 594 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){ 595 i2+=2; 596 i3=0; 597 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++]; 598 for(;;i2++,i3++){ 599 if(!IsVariableChar(sourceOfParams[i2])){ 600 temporary[i3]=0; 601 break; 602 } 603 temporary[i3]=sourceOfParams[i2]; 604 } 605 Type::StringToType( temporary, this->returnType ); 606 if( this->returnType.IsNull() ) SetError(3,temporary,nowLine); 607 608 sw_as=1; 609 break; 610 } 611 } 612 } 613 else{ 614 //戻り値なしのSub定義 615 this->returnType.SetNull(); 616 } 617 618 return true; 619 } 620 621 bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 622 int i = 0; 623 int i2,i3,sw; 624 char temporary[8192],temp2[VN_SIZE]; 625 626 //ソースコードの位置 627 this->codePos = nowLine; 628 629 //パラメータ 630 if(sourceOfParams[i]!='('){ 631 SetError(1,NULL,nowLine); 632 return 0; 633 } 634 i++; 635 while(1){ 636 if(sourceOfParams[i]==')') break; 637 638 //ByRef 639 bool isRef; 640 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){ 641 isRef = false; 642 i+=2; 643 } 644 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){ 645 isRef = true; 646 i+=2; 647 } 648 else isRef = false; 649 650 //パラメータ名 651 bool isArray = false; 652 int subScripts[MAX_ARRAYDIM]; 653 char name[VN_SIZE]; 654 sw=0; 655 for(i2=0;;i++,i2++){ 656 if(sourceOfParams[i]=='('){ 657 if(!sw) sw=1; 658 659 i3=GetStringInPare(name+i2,sourceOfParams+i); 660 i2+=i3-1; 661 i+=i3-1; 662 continue; 663 } 664 if(sourceOfParams[i]=='['){ 665 if(!sw) sw=1; 666 667 i3=GetStringInBracket(name+i2,sourceOfParams+i); 668 i2+=i3-1; 669 i+=i3-1; 670 continue; 671 } 672 if(!IsVariableChar(sourceOfParams[i])){ 673 name[i2]=0; 674 break; 675 } 676 name[i2]=sourceOfParams[i]; 677 } 678 if(sw){ 679 //配列パラメータ 680 if( isRef == false ) SetError(29,NULL,nowLine); 681 isArray = true; 682 683 if((name[i2-2]=='('&&name[i2-1]==')')|| 684 (name[i2-2]=='['&&name[i2-1]==']')){ 685 subScripts[0]=LONG_MAX; 686 subScripts[1]=-1; 687 688 name[i2-2]=0; 689 } 690 else{ 691 GetArrange(name,temp2,subScripts); 692 lstrcpy(name,temp2); 693 } 694 695 i2=lstrlen(name); 696 } 697 698 //型 699 Type type( DEF_NON ); 700 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 701 i+=2; 702 703 i2=0; 704 while(sourceOfParams[i]=='*'){ 705 temporary[i2]=sourceOfParams[i]; 706 i++; 707 i2++; 708 } 709 for(;;i++,i2++){ 710 if(!IsVariableChar(sourceOfParams[i])){ 711 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){ 712 temporary[i2++]=sourceOfParams[i++]; 713 temporary[i2]=sourceOfParams[i]; 714 continue; 715 } 716 temporary[i2]=0; 717 break; 718 } 719 temporary[i2]=sourceOfParams[i]; 720 } 721 722 Type::StringToType( temporary, type ); 723 724 if(temporary[0]=='*'&& 725 temporary[1]==1&& 726 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){ 727 if(sourceOfParams[i]!='('){ 728 SetError(10,temporary,nowLine); 729 break; 730 } 731 i3=GetStringInPare(temporary+i2,sourceOfParams+i); 732 i+=i3; 733 i2+=i3; 734 735 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 736 temporary[i2++]=sourceOfParams[i++]; 737 temporary[i2++]=sourceOfParams[i++]; 738 for(;;i++,i2++){ 739 if(!IsVariableChar(sourceOfParams[i])){ 740 temporary[i2]=0; 741 break; 742 } 743 temporary[i2]=sourceOfParams[i]; 744 } 745 } 746 } 747 else{ 748 //TypeDefをする前のベース型を取得 749 GetOriginalTypeName(temporary); 750 } 751 752 if( type.IsNull() ){ 753 SetError(3,temporary,nowLine); 754 type.SetBasicType( DEF_PTR_VOID ); 755 } 756 } 757 else{ 758 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 759 SetError(-103,temporary,nowLine); 760 } 761 762 if( type.IsProcPtr() ){ 763 //関数ポインタの場合 764 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine ) ); 765 } 766 767 Parameter *pParam = new Parameter( name, type, isRef ); 768 if( isArray ){ 769 pParam->SetArray( subScripts ); 770 } 771 772 //パラメータを追加 773 this->params.push_back( pParam ); 774 775 if(sourceOfParams[i]==','){ 776 i++; 777 continue; 778 } 779 else if(sourceOfParams[i]==')') continue; 780 else{ 781 SetError(1,NULL,nowLine); 782 break; 783 } 784 } 785 i++; 786 787 if(sourceOfParams[i]){ 788 /////////////////// 789 // 戻り値を取得 790 /////////////////// 791 792 i2=lstrlen(sourceOfParams)-2; 793 794 int sw_as=0; 795 for(;i2>0;i2--){ 796 if(sourceOfParams[i2]==')') break; 797 798 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){ 799 i2+=2; 800 i3=0; 801 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++]; 802 for(;;i2++,i3++){ 803 if(!IsVariableChar(sourceOfParams[i2])){ 804 temporary[i3]=0; 805 break; 806 } 807 temporary[i3]=sourceOfParams[i2]; 808 } 809 Type::StringToType( temporary, this->returnType ); 810 if( this->returnType.IsNull() ) SetError(3,temporary,nowLine); 811 812 sw_as=1; 813 break; 814 } 815 } 816 } 817 else{ 818 //戻り値なしのSub定義 819 this->returnType.SetNull(); 820 } 821 822 //戻り値のエラーチェック 823 if( IsFunction() ){ 824 // Function定義 825 826 if( this->ReturnType().IsNull() ){ 827 // 戻り値がない 828 SetError(26,this->GetName(),nowLine); 829 } 830 } 831 else{ 832 if( !this->ReturnType().IsNull() ){ 833 // Sub定義なのに、戻り値がある 834 SetError(38,this->GetName(),nowLine); 835 } 836 } 837 838 return true; 839 } 840 841 UserProc *UserProc::pCompilingUserProc = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.