source: dev/BasicCompiler_Common/Procedure.cpp@ 101

Last change on this file since 101 was 101, checked in by dai_9181, 17 years ago

名前空間機能をグローバル関数に適用(作業完了)。

File size: 19.5 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( namespaceScopes.size() ){
515 if( GetNamespaceScopes().IsCoverd( namespaceScopes ) ){
516 if( GetName() == name ){
517 return true;
518 }
519 }
520 }
521 else{
522 if( GetNamespaceScopes().size() ){
523 // 名前空間の判断が必要なとき
524 if( !GetNamespaceScopes().IsUsing()
525 && !GetNamespaceScopes().IsLiving() ){
526 // この名前空間は暗黙的に参照できないとき
527 return false;
528 }
529 }
530 else{
531 if( GetName() == name ){
532 return true;
533 }
534 }
535 }
536
537 return false;
538}
539bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const
540{
541 return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );
542}
543bool GlobalProc::IsEqualSymbol( const string &fullName ) const
544{
545 char AreaName[VN_SIZE] = ""; //オブジェクト変数
546 char NestName[VN_SIZE] = ""; //入れ子メンバ
547 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
548
549 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
550}
551
552bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
553 int i = 0;
554 int i2,i3,sw;
555 char temporary[8192],temp2[VN_SIZE];
556
557 //ソースコードの位置
558 this->codePos = nowLine;
559
560 //パラメータ
561 if(sourceOfParams[i]!='('){
562 SetError(1,NULL,nowLine);
563 return 0;
564 }
565 i++;
566
567 while(1){
568 if(sourceOfParams[i]==')') break;
569
570 //ByRef
571 bool isRef;
572 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){
573 isRef = false;
574 i+=2;
575 }
576 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){
577 isRef = true;
578 i+=2;
579 }
580 else isRef = false;
581
582 //パラメータ名
583 bool isArray = false;
584 int subScripts[MAX_ARRAYDIM];
585 char name[VN_SIZE];
586 sw=0;
587 for(i2=0;;i++,i2++){
588 if(sourceOfParams[i]=='('){
589 if(!sw) sw=1;
590
591 i3=GetStringInPare(name+i2,sourceOfParams+i);
592 i2+=i3-1;
593 i+=i3-1;
594 continue;
595 }
596 if(sourceOfParams[i]=='['){
597 if(!sw) sw=1;
598
599 i3=GetStringInBracket(name+i2,sourceOfParams+i);
600 i2+=i3-1;
601 i+=i3-1;
602 continue;
603 }
604 if(!IsVariableChar(sourceOfParams[i])){
605 name[i2]=0;
606 break;
607 }
608 name[i2]=sourceOfParams[i];
609 }
610 if(sw){
611 //配列パラメータ
612 if( isRef == false ) SetError(29,NULL,nowLine);
613 isArray = true;
614
615 if((name[i2-2]=='('&&name[i2-1]==')')||
616 (name[i2-2]=='['&&name[i2-1]==']')){
617 subScripts[0]=LONG_MAX;
618 subScripts[1]=-1;
619
620 name[i2-2]=0;
621 }
622 else{
623 GetArrange(name,temp2,subScripts);
624 lstrcpy(name,temp2);
625 }
626
627 i2=lstrlen(name);
628 }
629
630 //型
631 Type type( DEF_NON );
632 if(lstrcmp(name,"...")==0) type.SetBasicType( DEF_ELLIPSE );
633 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
634 i+=2;
635
636 i2=0;
637 while(sourceOfParams[i]=='*'){
638 temporary[i2]=sourceOfParams[i];
639 i++;
640 i2++;
641 }
642 for(;;i++,i2++){
643 if(!IsVariableChar(sourceOfParams[i])){
644 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){
645 temporary[i2++]=sourceOfParams[i++];
646 temporary[i2]=sourceOfParams[i];
647 continue;
648 }
649 temporary[i2]=0;
650 break;
651 }
652 temporary[i2]=sourceOfParams[i];
653 }
654
655 Type::StringToType( temporary, type );
656
657 if( type.IsNull() ){
658 SetError(3,temporary,nowLine);
659 type.SetBasicType( DEF_PTR_VOID );
660 }
661 }
662 else{
663 type.SetBasicType( GetTypeFromSimpleName(temporary) );
664 SetError(-103,temporary,nowLine);
665 }
666
667 Parameter *pParam = new Parameter( name, type, isRef );
668 if( isArray ){
669 pParam->SetArray( subScripts );
670 }
671
672 //パラメータを追加
673 this->params.push_back( pParam );
674
675 if(sourceOfParams[i]==','){
676 i++;
677 continue;
678 }
679 else if(sourceOfParams[i]==')') continue;
680 else{
681 SetError(1,NULL,nowLine);
682 break;
683 }
684 }
685 i++;
686
687 if(sourceOfParams[i]){
688 ///////////////////
689 // 戻り値を取得
690 ///////////////////
691
692 i2=lstrlen(sourceOfParams)-2;
693
694 int sw_as=0;
695 for(;i2>0;i2--){
696 if(sourceOfParams[i2]==')') break;
697
698 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){
699 i2+=2;
700 i3=0;
701 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];
702 for(;;i2++,i3++){
703 if(!IsVariableChar(sourceOfParams[i2])){
704 temporary[i3]=0;
705 break;
706 }
707 temporary[i3]=sourceOfParams[i2];
708 }
709 Type::StringToType( temporary, this->returnType );
710 if( this->returnType.IsNull() ) SetError(3,temporary,nowLine);
711
712 sw_as=1;
713 break;
714 }
715 }
716 }
717 else{
718 //戻り値なしのSub定義
719 this->returnType.SetNull();
720 }
721
722 return true;
723}
724
725bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
726 int i = 0;
727 int i2,i3,sw;
728 char temporary[8192],temp2[VN_SIZE];
729
730 //ソースコードの位置
731 this->codePos = nowLine;
732
733 //パラメータ
734 if(sourceOfParams[i]!='('){
735 SetError(1,NULL,nowLine);
736 return 0;
737 }
738 i++;
739 while(1){
740 if(sourceOfParams[i]==')') break;
741
742 //ByRef
743 bool isRef;
744 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){
745 isRef = false;
746 i+=2;
747 }
748 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){
749 isRef = true;
750 i+=2;
751 }
752 else isRef = false;
753
754 //パラメータ名
755 bool isArray = false;
756 int subScripts[MAX_ARRAYDIM];
757 char name[VN_SIZE];
758 sw=0;
759 for(i2=0;;i++,i2++){
760 if(sourceOfParams[i]=='('){
761 if(!sw) sw=1;
762
763 i3=GetStringInPare(name+i2,sourceOfParams+i);
764 i2+=i3-1;
765 i+=i3-1;
766 continue;
767 }
768 if(sourceOfParams[i]=='['){
769 if(!sw) sw=1;
770
771 i3=GetStringInBracket(name+i2,sourceOfParams+i);
772 i2+=i3-1;
773 i+=i3-1;
774 continue;
775 }
776 if(!IsVariableChar(sourceOfParams[i])){
777 name[i2]=0;
778 break;
779 }
780 name[i2]=sourceOfParams[i];
781 }
782 if(sw){
783 //配列パラメータ
784 if( isRef == false ) SetError(29,NULL,nowLine);
785 isArray = true;
786
787 if((name[i2-2]=='('&&name[i2-1]==')')||
788 (name[i2-2]=='['&&name[i2-1]==']')){
789 subScripts[0]=LONG_MAX;
790 subScripts[1]=-1;
791
792 name[i2-2]=0;
793 }
794 else{
795 GetArrange(name,temp2,subScripts);
796 lstrcpy(name,temp2);
797 }
798
799 i2=lstrlen(name);
800 }
801
802 //型
803 Type type( DEF_NON );
804 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
805 i+=2;
806
807 i2=0;
808 while(sourceOfParams[i]=='*'){
809 temporary[i2]=sourceOfParams[i];
810 i++;
811 i2++;
812 }
813 for(;;i++,i2++){
814 if(!IsVariableChar(sourceOfParams[i])){
815 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){
816 temporary[i2++]=sourceOfParams[i++];
817 temporary[i2]=sourceOfParams[i];
818 continue;
819 }
820 temporary[i2]=0;
821 break;
822 }
823 temporary[i2]=sourceOfParams[i];
824 }
825
826 Type::StringToType( temporary, type );
827
828 if( type.IsNull() ){
829 SetError(3,temporary,nowLine);
830 type.SetBasicType( DEF_PTR_VOID );
831 }
832 }
833 else{
834 type.SetBasicType( GetTypeFromSimpleName(temporary) );
835 SetError(-103,temporary,nowLine);
836 }
837
838 Parameter *pParam = new Parameter( name, type, isRef );
839 if( isArray ){
840 pParam->SetArray( subScripts );
841 }
842
843 //パラメータを追加
844 this->params.push_back( pParam );
845
846 if(sourceOfParams[i]==','){
847 i++;
848 continue;
849 }
850 else if(sourceOfParams[i]==')') continue;
851 else{
852 SetError(1,NULL,nowLine);
853 break;
854 }
855 }
856 i++;
857
858 if(sourceOfParams[i]){
859 ///////////////////
860 // 戻り値を取得
861 ///////////////////
862
863 i2=lstrlen(sourceOfParams)-2;
864
865 int sw_as=0;
866 for(;i2>0;i2--){
867 if(sourceOfParams[i2]==')') break;
868
869 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){
870 i2+=2;
871 i3=0;
872 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];
873 for(;;i2++,i3++){
874 if(!IsVariableChar(sourceOfParams[i2])){
875 temporary[i3]=0;
876 break;
877 }
878 temporary[i3]=sourceOfParams[i2];
879 }
880 Type::StringToType( temporary, this->returnType );
881 if( this->returnType.IsNull() ) SetError(3,temporary,nowLine);
882
883 sw_as=1;
884 break;
885 }
886 }
887 }
888 else{
889 //戻り値なしのSub定義
890 this->returnType.SetNull();
891 }
892
893 //戻り値のエラーチェック
894 if( IsFunction() ){
895 // Function定義
896
897 if( this->ReturnType().IsNull() ){
898 // 戻り値がない
899 SetError(26,this->GetName(),nowLine);
900 }
901 }
902 else{
903 if( !this->ReturnType().IsNull() ){
904 // Sub定義なのに、戻り値がある
905 SetError(38,this->GetName(),nowLine);
906 }
907 }
908
909 return true;
910}
911
912UserProc *UserProc::pCompilingUserProc = NULL;
Note: See TracBrowser for help on using the repository browser.