source: dev/BasicCompiler_Common/Procedure.cpp@ 102

Last change on this file since 102 was 102, checked in by dai_9181, 18 years ago

名前空間機能をクラスに適用。

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