source: dev/BasicCompiler_Common/Subroutine.cpp@ 74

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

Parameterクラスを適用。32bit側は動くようになったので、64bitのほうを調整する。

File size: 33.5 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2
3#ifdef _AMD64_
4#include "../BasicCompiler64/opcode.h"
5#else
6#include "../BasicCompiler32/opcode.h"
7#endif
8
9//コンパイル中の関数情報
10SubInfo *pCompilingSubInfo;
11
12int GetCallProcName(char *buffer,char *name){
13 int i2,i3,IsStr=0;
14
15 for(i2=0;;i2++){
16 if(buffer[i2]=='\"') IsStr^=1;
17 if(IsDBCSLeadByte(buffer[i2])){
18 name[i2]=buffer[i2];
19 i2++;
20 name[i2]=buffer[i2];
21 continue;
22 }
23 if(buffer[i2]=='['&&IsStr==0){
24 i3=GetStringInBracket(name+i2,buffer+i2);
25 i2+=i3-1;
26 continue;
27 }
28 if(buffer[i2]=='('&&IsStr==0){
29 name[i2]=0;
30 break;
31 }
32 if(buffer[i2]=='='&&IsStr==0){
33 name[i2]=0;
34 break;
35 }
36
37 name[i2]=buffer[i2];
38 if(buffer[i2]=='\0') break;
39 }
40 return i2;
41}
42
43int GetProc(char *name,void **ppInfo){
44
45 //ユーザー定義関数
46 *ppInfo=(void *)GetSubHash(name);
47 if(*ppInfo) return PROC_DEFAULT;
48
49 //DLL関数
50 *ppInfo=(void *)GetDeclareHash(name);
51 if(*ppInfo) return PROC_DLL;
52
53 //コンパイラ埋め込み型
54 *ppInfo=(void *)(_int64)GetFunctionFromName(name);
55 if(*ppInfo) return PROC_BUILTIN;
56
57 //関数ポインタ
58 int type;
59 LONG_PTR lpIndex;
60 type=GetVarType(name,&lpIndex,0);
61 if(type==DEF_PTR_PROC) return PROC_PTR;
62
63 return 0;
64}
65
66void SplitObjectName(const char *name,char *ObjectName,int *pRefType){
67 int i4;
68 for(i4=lstrlen(name)-1;i4>=0;i4--){
69 if(name[i4]=='.'||(name[i4]==1&&name[i4+1]==ESC_PSMEM))
70 break;
71 }
72 if(i4==-1) ObjectName[0]=0;
73 else{
74 //参照タイプを判別
75 if(name[i4]=='.') *pRefType=DEF_OBJECT;
76 else *pRefType=DEF_PTR_OBJECT;
77
78 if(i4==0) GetWithName(ObjectName);
79 else{
80 memcpy(ObjectName,name,i4);
81 ObjectName[i4]=0;
82 }
83 }
84}
85bool SplitMemberName( const char *desc, char *object, char *member ){
86 int i;
87 for(i=lstrlen(desc)-1;i>=0;i--){
88 if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM))
89 break;
90 }
91 if(i==-1) return false;
92 else{
93 if(desc[i]=='.')
94 lstrcpy(member,desc+i+1);
95 else
96 lstrcpy(member,desc+i+2);
97
98 if( object ){
99 lstrcpy( object, desc );
100 object[i]=0;
101 }
102 }
103
104 return true;
105}
106
107
108int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){
109 int ret_type;
110
111 if(idProc==PROC_DEFAULT){
112 /////////////////////
113 // ユーザー定義関数
114 /////////////////////
115
116 SubInfo *pSub;
117 pSub=(SubInfo *)pInfo;
118
119 //GetSubHash内でエラー提示が行われた場合
120 if(pSub==(SubInfo *)-1) return -1;
121
122
123 //オブジェクト名を取得
124 char ObjectName[VN_SIZE];
125 int RefType;
126 SplitObjectName(name,ObjectName,&RefType);
127
128
129 ////////////////////////
130 // オーバーロードを解決
131 ////////////////////////
132
133 std::vector<SubInfo *> subs;
134 GetOverloadSubHash(name,subs);
135 if(subs.size()){
136 //オーバーロードを解決
137 pSub=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);
138
139 if(!pSub) return 0;
140 }
141
142
143 Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType);
144 if( plpRetIndex ){
145 *plpRetIndex = pSub->u.ReturnIndex;
146 }
147 return pSub->ReturnType;
148 }
149 else if(idProc==PROC_DLL){
150 /////////////////////////
151 // DLL関数
152 /////////////////////////
153 DECLAREINFO *pdi;
154 pdi=(DECLAREINFO *)pInfo;
155
156 ret_type=Opcode_CallDllProc(Parameter,pdi,plpRetIndex);
157 }
158 else if(idProc==PROC_BUILTIN){
159 /////////////////////////
160 // 組み込み関数
161 /////////////////////////
162 int FuncId;
163 FuncId=(int)(_int64)pInfo;
164
165 TYPEINFO ReturnTypeInfo = { DEF_LONG, NULL };
166 Opcode_CallFunc( Parameter, FuncId, ReturnTypeInfo );
167 if( plpRetIndex ){
168 *plpRetIndex = ReturnTypeInfo.u.lpIndex;
169 }
170 return ReturnTypeInfo.type;
171 }
172 else if(idProc==PROC_PTR){
173 /////////////////
174 // 関数ポインタ
175 /////////////////
176
177 LONG_PTR lpIndex;
178 GetVarType(name,&lpIndex,0);
179
180 extern PROCPTRINFO *pProcPtrInfo;
181 ret_type=Opcode_CallProcPtr(name,Parameter,&pProcPtrInfo[lpIndex],plpRetIndex);
182 }
183
184 return ret_type;
185}
186BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){
187 //プロパティ用のメソッドを呼び出す
188
189 //配列要素を取得
190 char VarName[VN_SIZE],ArrayElements[VN_SIZE];
191 GetArrayElement(variable,VarName,ArrayElements);
192
193 //オブジェクト名を取得
194 char ObjectName[VN_SIZE];
195 int RefType;
196 SplitObjectName(VarName,ObjectName,&RefType);
197
198 //オーバーロード用の関数リストを作成
199 std::vector<SubInfo *> subs;
200 GetOverloadSubHash(VarName,subs);
201 if(subs.size()==0){
202 return 0;
203 }
204
205 //パラメータを整備
206 char *Parameter;
207 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(RightSide)+32);
208 lstrcpy(Parameter,ArrayElements);
209 if(RightSide){
210 if(Parameter[0]&&RightSide[0]) lstrcat(Parameter,",");
211 lstrcat(Parameter,RightSide);
212 }
213
214 //オーバーロードを解決
215 SubInfo *pSub;
216 pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);
217
218 if(pSub){
219 //呼び出し
220 Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType);
221
222 if( pRetTypeInfo ){
223 pRetTypeInfo->type = pSub->ReturnType;
224 pRetTypeInfo->u.lpIndex = pSub->u.ReturnIndex;
225 }
226 }
227
228 HeapDefaultFree(Parameter);
229
230 return 1;
231}
232
233
234int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){
235 int ret_type;
236
237 if(idProc==PROC_DEFAULT){
238 /////////////////////
239 // ユーザー定義関数
240 /////////////////////
241
242 SubInfo *pSub;
243 pSub=(SubInfo *)pInfo;
244
245 //GetSubHash内でエラー提示が行われた場合
246 if(pSub==(SubInfo *)-1) return -1;
247
248
249 //オブジェクト名を取得
250 char ObjectName[VN_SIZE];
251 int RefType;
252 SplitObjectName(name,ObjectName,&RefType);
253
254
255 ////////////////////////
256 // オーバーロードを解決
257 ////////////////////////
258
259 std::vector<SubInfo *> subs;
260 GetOverloadSubHash(name,subs);
261 if( subs.size() > 0 ){
262 //オーバーロードを解決
263 pSub=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);
264
265 if(!pSub) return 0;
266 }
267
268
269 ret_type=pSub->ReturnType;
270 *plpRetIndex=pSub->u.ReturnIndex;
271 }
272 else if(idProc==PROC_DLL){
273 /////////////////////////
274 // DLL関数
275 /////////////////////////
276 DECLAREINFO *pdi;
277 pdi=(DECLAREINFO *)pInfo;
278
279 ret_type=pdi->ReturnType;
280 *plpRetIndex=pdi->u.ReturnIndex;
281 }
282 else if(idProc==PROC_BUILTIN){
283 /////////////////////////
284 // 組み込み関数
285 /////////////////////////
286 int FuncId;
287 FuncId=(int)(_int64)pInfo;
288
289 ret_type=GetFunctionType(FuncId);
290 *plpRetIndex=-1;
291 }
292 else if(idProc==PROC_PTR){
293 /////////////////
294 // 関数ポインタ
295 /////////////////
296
297 LONG_PTR lpIndex;
298 GetVarType(name,&lpIndex,0);
299
300 extern PROCPTRINFO *pProcPtrInfo;
301 ret_type=pProcPtrInfo[lpIndex].ReturnType;
302 *plpRetIndex=pProcPtrInfo[lpIndex].u.ReturnIndex;
303 }
304
305 return ret_type;
306}
307BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){
308 //プロパティ用のメソッドを呼び出す
309
310 //配列要素を取得
311 char VarName[VN_SIZE],ArrayElements[VN_SIZE];
312 GetArrayElement(variable,VarName,ArrayElements);
313
314 //オブジェクト名を取得
315 char ObjectName[VN_SIZE];
316 int RefType;
317 SplitObjectName(VarName,ObjectName,&RefType);
318
319 //オーバーロード用の関数リストを作成
320 std::vector<SubInfo *> subs;
321 GetOverloadSubHash(VarName,subs);
322 if(subs.size()==0){
323 return 0;
324 }
325
326 //パラメータを整備
327 char *Parameter;
328 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(RightSide)+32);
329 lstrcpy(Parameter,ArrayElements);
330 if(RightSide){
331 if(Parameter[0]&&RightSide[0]) lstrcat(Parameter,",");
332 lstrcat(Parameter,RightSide);
333 }
334
335 //オーバーロードを解決
336 SubInfo *pSub;
337 pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);
338
339 if(pSub){
340 if(pRetTypeInfo){
341 pRetTypeInfo->type=pSub->ReturnType;
342 pRetTypeInfo->u.lpIndex=pSub->u.ReturnIndex;
343 }
344 }
345
346 return 1;
347}
348
349//インデクサ(getter)の戻り値を取得
350bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo){
351 std::vector<SubInfo *> subs;
352 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs );
353 if( subs.size() == 0 ){
354 return false;
355 }
356
357 RetTypeInfo.type = subs[0]->ReturnType;
358 RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex;
359
360 return true;
361}
362
363
364void AddDeclareData(char *buffer,int NowLine){
365 extern HANDLE hHeap;
366 int i,i2,i3,i4,sw,IsFunction;
367 char temporary[VN_SIZE];
368
369 i=0;
370
371 DWORD dwType;
372 BOOL bCdecl=0;
373
374 //Static/Dynamic
375 if(buffer[i]==ESC_STATIC){
376 dwType=DECLARE_STATIC;
377 i++;
378 }
379 else dwType=DECLARE_DYNAMIC;
380
381 //Sub/Function
382 if(buffer[i]==ESC_SUB) IsFunction=0;
383 else if(buffer[i]==ESC_FUNCTION) IsFunction=1;
384 else{
385 SetError(1,NULL,NowLine);
386 return;
387 }
388 i++;
389
390 //プロシージャ名
391 for(i2=0;;i++,i2++){
392 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL){
393 bCdecl=1;
394
395 i+=2;
396 temporary[i2]=0;
397 break;
398 }
399 if(buffer[i]==','){
400 temporary[i2]=0;
401 break;
402 }
403 if(buffer[i]=='\0'){
404 SetError(1,NULL,NowLine);
405 return;
406 }
407 temporary[i2]=buffer[i];
408 }
409
410 //ユーザー定義関数との重複チェック
411 if(GetSubHash(temporary)){
412 SetError(15,temporary,NowLine);
413 return;
414 }
415
416
417 /////////////////////////////////
418 // 格納位置を計算してpciにセット
419 /////////////////////////////////
420
421 //ハッシュ値を取得
422 int key;
423 key=hash_default(temporary);
424
425 extern DECLAREINFO **ppDeclareHash;
426 DECLAREINFO *pdi;
427 if(ppDeclareHash[key]){
428 pdi=ppDeclareHash[key];
429 while(1){
430 if(lstrcmpi(pdi->name,temporary)==0){
431 //重複エラー
432 SetError(15,temporary,NowLine);
433 return;
434 }
435
436 if(pdi->pNextData==0){
437 pdi->pNextData=(DECLAREINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(DECLAREINFO));
438 break;
439 }
440 pdi=pdi->pNextData;
441 }
442 pdi=pdi->pNextData;
443 }
444 else{
445 ppDeclareHash[key]=(DECLAREINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(DECLAREINFO));
446 pdi=ppDeclareHash[key];
447 }
448
449 pdi->dwType=dwType;
450 pdi->bCdecl=bCdecl;
451
452 pdi->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
453 lstrcpy(pdi->name,temporary);
454 i++;
455
456 //ライブラリ
457 i = GetOneParameter( buffer, i, temporary );
458 int type;
459 LONG_PTR lpIndex;
460 _int64 i64data;
461 type = StaticCalculation( true, temporary, 0, &i64data, &lpIndex );
462 if( type != typeOfPtrChar ){
463 SetError(1,NULL,NowLine);
464 return;
465 }
466 lstrcpy( temporary, (char *)i64data );
467 CharUpper(temporary);
468 if(!strstr(temporary,".")){
469 if(pdi->dwType==DECLARE_STATIC) lstrcat(temporary,".LIB");
470 else{
471 lstrcat(temporary,".DLL");
472 if(lstrlen(temporary)>=16){
473 SetError(7,NULL,NowLine);
474 return;
475 }
476 }
477 }
478 pdi->file=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
479 lstrcpy(pdi->file,temporary);
480
481 //エイリアス
482 i = GetOneParameter( buffer, i, temporary );
483 if( temporary[0] ){
484 type = StaticCalculation( true, temporary, 0, &i64data, &lpIndex );
485 if( type != typeOfPtrChar ){
486 SetError(1,NULL,NowLine);
487 return;
488 }
489 lstrcpy( temporary, (char *)i64data );
490
491 pdi->alias=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
492 lstrcpy(pdi->alias,temporary);
493 }
494 else{
495 //省略されたときは関数名
496 pdi->alias=(char *)HeapAlloc(hHeap,0,lstrlen(pdi->name)+1);
497 lstrcpy(pdi->alias,pdi->name);
498 }
499
500 //パラメータの始めのカッコ
501 if(buffer[i]!='('){
502 SetError(1,NULL,NowLine);
503 return;
504 }
505 i++;
506
507 pdi->pParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,0,1);
508
509 //各パラメータ
510 for(i3=0;;i3++){
511 if(buffer[i]==')') break;
512
513 pdi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,pdi->pParmInfo,(i3+1)*sizeof(PARAMETER_INFO));
514
515 //ByVal
516 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){
517 pdi->pParmInfo[i3].bByVal=1;
518 i+=2;
519 }
520 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){
521 pdi->pParmInfo[i3].bByVal=0;
522 i+=2;
523 }
524 else pdi->pParmInfo[i3].bByVal=1;
525
526 //変数名は無視(temporaryの変数名は型宣言文字判断のため)
527 sw=0;
528 for(i2=0;;i++,i2++){
529 if(buffer[i]=='('){
530 if(!sw) sw=1;
531
532 i4=GetStringInPare(temporary+i2,buffer+i);
533 i2+=i4-1;
534 i+=i4-1;
535 continue;
536 }
537 if(buffer[i]=='['){
538 if(!sw) sw=1;
539
540 i4=GetStringInBracket(temporary+i2,buffer+i);
541 i2+=i4-1;
542 i+=i4-1;
543 continue;
544 }
545 if(!IsVariableChar(buffer[i])){
546 temporary[i2]=0;
547 break;
548 }
549 temporary[i2]=buffer[i];
550 }
551 if(lstrcmp(temporary,"...")==0) pdi->pParmInfo[i3].type=DEF_ELLIPSE;
552 else{
553 //型
554 if(buffer[i]==1&&buffer[i+1]==ESC_AS){
555 i+=2;
556 for(i2=0;;i++,i2++){
557 if(!(IsVariableChar(buffer[i])||buffer[i]=='*')){
558 temporary[i2]=0;
559 break;
560 }
561 temporary[i2]=buffer[i];
562 }
563 pdi->pParmInfo[i3].type=GetTypeFixed(temporary,&pdi->pParmInfo[i3].u.index);
564 }
565 else{
566 pdi->pParmInfo[i3].type=GetTypeFromSimpleName(temporary);
567 SetError(-103,temporary,NowLine);
568 }
569
570 if(sw){
571 //配列ポインタを引き渡すとき
572 pdi->pParmInfo[i3].type=GetPtrType(pdi->pParmInfo[i3].type,pdi->pParmInfo[i3].u.index);
573 }
574 }
575
576 //名前はダミー(使用しないため)
577 pdi->pParmInfo[i3].name="";
578
579 //構造体の場合はエラーチェック
580 if(pdi->pParmInfo[i3].type==-1) SetError(3,temporary,NowLine);
581 if(pdi->pParmInfo[i3].type==DEF_OBJECT){
582 if(pdi->pParmInfo[i3].bByVal) pdi->pParmInfo[i3].type=DEF_LONG;//SetError(28,temporary,NowLine);
583 }
584
585 //構造体アドレスの空白部
586 while(buffer[i]==' ') i++;
587
588 if(buffer[i]==','){
589 i++;
590 continue;
591 }
592 else if(buffer[i]==')') continue;
593 else{
594 SetError(1,NULL,NowLine);
595 break;
596 }
597 }
598 pdi->ParmNum=i3;
599
600 //戻り値
601 i++;
602 if(buffer[i]==1&&buffer[i+1]==ESC_AS){
603 if(IsFunction==0) SetError(1,NULL,NowLine);
604 i+=2;
605 pdi->ReturnType=GetTypeFixed(buffer+i,&pdi->u.ReturnIndex);
606 if(pdi->ReturnType==DEF_NON) SetError(3,buffer+i,NowLine);
607 if(pdi->ReturnType==DEF_OBJECT) SetError(40,NULL,NowLine);
608 }
609 else if(buffer[i]) SetError(1,NULL,NowLine);
610 else pdi->ReturnType=DEF_NON;
611
612 pdi->pos=NowLine;
613}
614
615BOOL CompareParameter(PARAMETER_INFO *ppi1,int pi_num1,PARAMETER_INFO *ppi2,int pi_num2){
616 if(pi_num1!=pi_num2) return 1;
617
618 int i;
619 for(i=0;i<pi_num1;i++){
620 if(ppi1[i].type!=ppi2[i].type){
621
622 if(ppi1[i].bByVal==0&&ppi1[i].type==DEF_ANY&&
623 ppi2[i].bByVal==1&&IsPtrType(ppi2[i].type)||
624 ppi1[i].bByVal==1&&IsPtrType(ppi1[i].type)&&
625 ppi2[i].bByVal==0&&ppi2[i].type==DEF_ANY){
626 /* ByRef var As Any
627
628 var As VoidPtr
629 は同等
630 */
631 continue;
632 }
633
634 return 1;
635 }
636 else{
637 if(NATURAL_TYPE(ppi1[i].type)==DEF_OBJECT
638 || NATURAL_TYPE(ppi1[i].type)==DEF_STRUCT ){
639 if(ppi1[i].u.index!=ppi2[i].u.index) return 1;
640 }
641 }
642 }
643
644 return 0;
645}
646SubInfo *AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){
647 int i,i2,i3,sw;
648 DWORD dwType;
649 char temporary[8192],temp2[VN_SIZE];
650
651 i=1;
652 if(buffer[i]==ESC_SUB) dwType=SUBTYPE_SUB;
653 else if(buffer[i]==ESC_FUNCTION) dwType=SUBTYPE_FUNCTION;
654 else if(buffer[i]==ESC_MACRO) dwType=SUBTYPE_MACRO;
655
656 i++;
657
658 BOOL bExport=0,bCdecl=0;
659 while(1){
660 if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&&bExport==0){
661 bExport=1;
662
663 i+=2;
664 }
665 else if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&&bCdecl==0){
666 bCdecl=1;
667
668 i+=2;
669 }
670 else break;
671 }
672
673 i2=0;
674 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
675 if(!pobj_c){
676 SetError(126,NULL,NowLine);
677 return 0;
678 }
679
680 //オペレータの場合
681 temporary[i2++]=buffer[i++];
682 temporary[i2++]=buffer[i++];
683
684 int iCalcId;
685 if(buffer[i]=='='&&buffer[i+1]=='='){
686 iCalcId=CALC_EQUAL;
687 i3=2;
688 }
689 else if(buffer[i]=='='){
690 iCalcId=CALC_SUBSITUATION;
691 i3=1;
692 }
693 else if(buffer[i]=='('){
694 iCalcId=CALC_AS;
695 i3=0;
696 }
697 else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
698 iCalcId=CALC_ARRAY_SET;
699 i3=3;
700 }
701 else if(buffer[i]=='['&&buffer[i+1]==']'){
702 iCalcId=CALC_ARRAY_GET;
703 i3=2;
704 }
705 else{
706 iCalcId=GetCalcId(buffer+i,&i3);
707 i3++;
708 }
709 if(!iCalcId){
710 SetError(1,NULL,NowLine);
711 return 0;
712 }
713 temporary[i2++]=iCalcId;
714 temporary[i2]=0;
715
716 i+=i3;
717 }
718 else{
719 if(pobj_c){
720 //クラスメンバの場合、デストラクタには~が付くことを考慮
721 if(buffer[i]=='~'){
722 temporary[i2]='~';
723 i++;
724 i2++;
725 }
726 }
727
728 for(;;i++,i2++){
729 if(!IsVariableChar(buffer[i])){
730 temporary[i2]=0;
731 break;
732 }
733 temporary[i2]=buffer[i];
734 }
735 }
736
737 if(dwType==SUBTYPE_MACRO){
738 //大文字に変換
739 CharUpper(temporary);
740
741 //マクロ関数の場合は名前リストに追加
742 extern char **ppMacroNames;
743 extern int MacroNum;
744 ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *));
745 ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
746 lstrcpy(ppMacroNames[MacroNum],temporary);
747 MacroNum++;
748 }
749
750 if(!pobj_c){
751 //クラスメンバ以外の場合のみ
752 //重複チェック
753
754 if(GetDeclareHash(temporary)){
755 SetError(15,temporary,NowLine);
756 return 0;
757 }
758 }
759
760 extern int SubNum;
761 SubNum++;
762
763 SubInfo *pSub = new SubInfo();
764
765 //クラス名
766 pSub->pobj_ParentClass=pobj_c;
767
768 //ID
769 static int id_base=0;
770 pSub->id=(id_base++);
771
772 //関数名
773 pSub->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
774 lstrcpy(pSub->name,temporary);
775
776 //ソースコードの位置
777 pSub->address=NowLine;
778
779 pSub->bExport=bExport;
780 pSub->bCdecl=bCdecl;
781 pSub->bVirtual=bVirtual;
782 if(bExport) pSub->bUse=1;
783 else pSub->bUse=0;
784 pSub->bCompile=0;
785 pSub->bSystem=0;
786
787 pSub->dwType=dwType;
788
789
790 if(pSub->dwType==SUBTYPE_FUNCTION){
791 ///////////////////
792 // 戻り値を取得
793 ///////////////////
794
795 pSub->isReturnRef = false;
796
797 if(pobj_c){
798 if(lstrcmp(pSub->name,pobj_c->name)==0||
799 pSub->name[0]=='~'){
800 //クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす
801 SetError(115,NULL,NowLine);
802 }
803 }
804
805
806 i2=lstrlen(buffer)-2;
807
808 int sw_as=0;
809 for(;i2>0;i2--){
810 if(buffer[i2]==')') break;
811
812 if(buffer[i2]==1&&buffer[i2+1]==ESC_AS){
813 if( buffer[i2-2] == 1 && buffer[i2-1] == ESC_BYREF ){
814 //参照型
815 pSub->isReturnRef = true;
816 }
817
818 i2+=2;
819 i3=0;
820 while(buffer[i2]=='*') temporary[i3++]=buffer[i2++];
821 for(;;i2++,i3++){
822 if(!IsVariableChar(buffer[i2])){
823 temporary[i3]=0;
824 break;
825 }
826 temporary[i3]=buffer[i2];
827 }
828 pSub->ReturnType=GetTypeFixed(temporary,&pSub->u.ReturnIndex);
829 if(pSub->ReturnType==DEF_NON) SetError(3,temporary,NowLine);
830
831 sw_as=1;
832 break;
833 }
834 }
835
836 if(!sw_as){
837 SetError(-104,pSub->name,NowLine);
838
839 pSub->ReturnType=DEF_DOUBLE;
840 }
841 }
842 else{
843 //戻り値なしのSub定義
844 pSub->ReturnType=DEF_NON;
845 pSub->u.ReturnIndex=-1;
846 }
847
848 //パラメータ
849 if(buffer[i]!='('){
850 SetError(1,NULL,NowLine);
851 return 0;
852 }
853 i++;
854 if(buffer[i]!=')'&&pobj_c){
855 //クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす
856 if(pSub->name[0]=='~'){
857 SetError(114,NULL,NowLine);
858 i=JumpStringInPare(buffer,i);
859 }
860 }
861 while(1){
862 if(buffer[i]==')') break;
863
864 //ByRef
865 bool isRef;
866 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){
867 isRef = false;
868 i+=2;
869 }
870 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){
871 isRef = true;
872 i+=2;
873 }
874 else isRef = false;
875
876 //パラメータ名
877 bool isArray = false;
878 int subScripts[MAX_ARRAYDIM];
879 char name[VN_SIZE];
880 sw=0;
881 for(i2=0;;i++,i2++){
882 if(buffer[i]=='('){
883 if(!sw) sw=1;
884
885 i3=GetStringInPare(name+i2,buffer+i);
886 i2+=i3-1;
887 i+=i3-1;
888 continue;
889 }
890 if(buffer[i]=='['){
891 if(!sw) sw=1;
892
893 i3=GetStringInBracket(name+i2,buffer+i);
894 i2+=i3-1;
895 i+=i3-1;
896 continue;
897 }
898 if(!IsVariableChar(buffer[i])){
899 name[i2]=0;
900 break;
901 }
902 name[i2]=buffer[i];
903 }
904 if(sw){
905 //配列パラメータ
906 if( isRef == false ) SetError(29,NULL,NowLine);
907 isArray = true;
908
909 if((name[i2-2]=='('&&name[i2-1]==')')||
910 (name[i2-2]=='['&&name[i2-1]==']')){
911 subScripts[0]=LONG_MAX;
912 subScripts[1]=-1;
913
914 name[i2-2]=0;
915 }
916 else{
917 GetArrange(name,temp2,subScripts);
918 lstrcpy(name,temp2);
919 }
920
921 i2=lstrlen(name);
922 }
923
924 //型
925 Type type( DEF_NON );
926 if(buffer[i]==1&&buffer[i+1]==ESC_AS){
927 i+=2;
928
929 i2=0;
930 while(buffer[i]=='*'){
931 temporary[i2]=buffer[i];
932 i++;
933 i2++;
934 }
935 for(;;i++,i2++){
936 if(!IsVariableChar(buffer[i])){
937 if(buffer[i]==1&&(buffer[i+1]==ESC_FUNCTION||buffer[i+1]==ESC_SUB)){
938 temporary[i2++]=buffer[i++];
939 temporary[i2]=buffer[i];
940 continue;
941 }
942 temporary[i2]=0;
943 break;
944 }
945 temporary[i2]=buffer[i];
946 }
947
948 Type::StringToType( temporary, type );
949
950 if(temporary[0]=='*'&&
951 temporary[1]==1&&
952 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
953 if(buffer[i]!='('){
954 SetError(10,temporary,NowLine);
955 break;
956 }
957 i3=GetStringInPare(temporary+i2,buffer+i);
958 i+=i3;
959 i2+=i3;
960
961 if(temporary[2]==ESC_FUNCTION&&buffer[i]==1&&buffer[i+1]==ESC_AS){
962 temporary[i2++]=buffer[i++];
963 temporary[i2++]=buffer[i++];
964 for(;;i++,i2++){
965 if(!IsVariableChar(buffer[i])){
966 temporary[i2]=0;
967 break;
968 }
969 temporary[i2]=buffer[i];
970 }
971 }
972 }
973 else{
974 //TypeDefをする前のベース型を取得
975 GetOriginalTypeName(temporary);
976 }
977
978 if( type.IsNull() ){
979 SetError(3,temporary,NowLine);
980 type.SetBasicType( DEF_PTR_VOID );
981 }
982 }
983 else{
984 type.SetBasicType( GetTypeFromSimpleName(temporary) );
985 SetError(-103,temporary,NowLine);
986 }
987
988 if( type.IsProcPtr() ){
989 //関数ポインタの場合
990 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2]) );
991 }
992
993 Parameter *pParam = new Parameter( name, type, isRef );
994 if( isArray ){
995 pParam->SetArray( subScripts );
996 }
997
998 //パラメータを追加
999 pSub->params.push_back( pParam );
1000
1001 if(buffer[i]==','){
1002 i++;
1003 continue;
1004 }
1005 else if(buffer[i]==')') continue;
1006 else{
1007 SetError(1,NULL,NowLine);
1008 break;
1009 }
1010 }
1011 pSub->SecondParmNum = (int)pSub->params.size();
1012 i++;
1013 if(buffer[i]=='('){
1014 i++;
1015 while(1){
1016 if(buffer[i]==')') break;
1017
1018 //ByRef
1019 bool isRef;
1020 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){
1021 isRef = false;
1022 i+=2;
1023 }
1024 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){
1025 isRef = true;
1026 i+=2;
1027 }
1028 else isRef = false;
1029
1030 //パラメータ名
1031 bool isArray = false;
1032 int subScripts[MAX_ARRAYDIM];
1033 char name[VN_SIZE];
1034 sw=0;
1035 for(i2=0;;i++,i2++){
1036 if(buffer[i]=='('){
1037 if(!sw) sw=1;
1038
1039 i3=GetStringInPare(name+i2,buffer+i);
1040 i2+=i3-1;
1041 i+=i3-1;
1042 continue;
1043 }
1044 if(buffer[i]=='['){
1045 if(!sw) sw=1;
1046
1047 i3=GetStringInBracket(name+i2,buffer+i);
1048 i2+=i3-1;
1049 i+=i3-1;
1050 continue;
1051 }
1052 if(!IsVariableChar(buffer[i])){
1053 name[i2]=0;
1054 break;
1055 }
1056 name[i2]=buffer[i];
1057 }
1058 if(sw){
1059 //配列パラメータ
1060 if( isRef == false ) SetError(29,NULL,NowLine);
1061 isArray = true;
1062
1063 if((name[i2-2]=='('&&name[i2-1]==')')||
1064 (name[i2-2]=='['&&name[i2-1]==']')){
1065 subScripts[0]=LONG_MAX;
1066 subScripts[1]=-1;
1067
1068 name[i2-2]=0;
1069 }
1070 else{
1071 GetArrange(name,temp2,subScripts);
1072 lstrcpy(name,temp2);
1073 }
1074
1075 i2=lstrlen(name);
1076 }
1077
1078 //型
1079 Type type( DEF_NON );
1080 if(buffer[i]==1&&buffer[i+1]==ESC_AS){
1081 i+=2;
1082
1083 i2=0;
1084 while(buffer[i]=='*'){
1085 temporary[i2]=buffer[i];
1086 i++;
1087 i2++;
1088 }
1089 for(;;i++,i2++){
1090 if(!IsVariableChar(buffer[i])){
1091 if(buffer[i]==1&&(buffer[i+1]==ESC_FUNCTION||buffer[i+1]==ESC_SUB)){
1092 temporary[i2++]=buffer[i++];
1093 temporary[i2]=buffer[i];
1094 continue;
1095 }
1096 temporary[i2]=0;
1097 break;
1098 }
1099 temporary[i2]=buffer[i];
1100 }
1101
1102 Type::StringToType( temporary, type );
1103
1104 if(temporary[0]=='*'&&
1105 temporary[1]==1&&
1106 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
1107 if(buffer[i]!='('){
1108 SetError(10,temporary,NowLine);
1109 break;
1110 }
1111 i3=GetStringInPare(temporary+i2,buffer+i);
1112 i+=i3;
1113 i2+=i3;
1114
1115 if(temporary[2]==ESC_FUNCTION&&buffer[i]==1&&buffer[i+1]==ESC_AS){
1116 temporary[i2++]=buffer[i++];
1117 temporary[i2++]=buffer[i++];
1118 for(;;i++,i2++){
1119 if(!IsVariableChar(buffer[i])){
1120 temporary[i2]=0;
1121 break;
1122 }
1123 temporary[i2]=buffer[i];
1124 }
1125 }
1126 }
1127 else{
1128 //TypeDefをする前のベース型を取得
1129 GetOriginalTypeName(temporary);
1130 }
1131
1132 if( type.IsNull() ){
1133 SetError(3,temporary,NowLine);
1134 type.SetBasicType( DEF_PTR_VOID );
1135 }
1136 }
1137 else{
1138 type.SetBasicType( GetTypeFromSimpleName(temporary) );
1139 SetError(-103,temporary,NowLine);
1140 }
1141
1142 if( type.IsProcPtr() ){
1143 //関数ポインタの場合
1144 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2]) );
1145 }
1146
1147 Parameter *pParam = new Parameter( name, type, isRef );
1148 if( isArray ){
1149 pParam->SetArray( subScripts );
1150 }
1151
1152 //パラメータを追加
1153 pSub->params.push_back( pParam );
1154
1155 if(buffer[i]==','){
1156 i++;
1157 continue;
1158 }
1159 else if(buffer[i]==')') continue;
1160 else{
1161 SetError(1,NULL,NowLine);
1162 break;
1163 }
1164 }
1165 i++;
1166 }
1167
1168 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する場合がある)
1169
1170 if(pobj_c&&bStatic==0){
1171 //オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用
1172 string name = "_System_LocalThis";
1173 Type type( DEF_PTR_VOID );
1174 pSub->realParams.push_back( new Parameter( name, type ) );
1175 }
1176
1177 if(pSub->ReturnType==DEF_STRUCT){
1178 //構造体を戻り値として持つ場合
1179 //※第一パラメータ(Thisポインタありの場合は第二パラメータ)を戻り値用の参照宣言にする
1180
1181 string name = pSub->name;
1182 if(pSub->name[0]==1&&pSub->name[1]==ESC_OPERATOR){
1183 name="_System_ReturnValue";
1184 }
1185 Type type( DEF_STRUCT, pSub->u.ReturnIndex );
1186 pSub->realParams.push_back( new Parameter( name, type, true ) );
1187 }
1188
1189 //パラメータをコピー
1190 foreach( Parameter *pParam, pSub->params ){
1191 pSub->realParams.push_back( new Parameter( *pParam ) );
1192 }
1193
1194
1195 /////////////////////////////////
1196 // ハッシュデータに追加
1197 /////////////////////////////////
1198
1199 int key;
1200 key=hash_default(pSub->name);
1201
1202 extern SubInfo **ppSubHash;
1203 if(ppSubHash[key]){
1204 SubInfo *psi2;
1205 psi2=ppSubHash[key];
1206 while(1){
1207 if(pobj_c==psi2->pobj_ParentClass){
1208 //重複エラーチェックを行う
1209 if(lstrcmp(psi2->name,pSub->name)==0){
1210 if( Parameter::Equals( psi2->params, pSub->params ) ){
1211 SetError(15,pSub->name,NowLine);
1212 return 0;
1213 }
1214 }
1215 }
1216
1217 if(psi2->pNextData==0) break;
1218 psi2=psi2->pNextData;
1219 }
1220 psi2->pNextData=pSub;
1221 }
1222 else{
1223 ppSubHash[key]=pSub;
1224 }
1225
1226 return pSub;
1227}
1228
1229void GetSubInfo(void){ //サブルーチン情報を取得
1230 extern HANDLE hHeap;
1231 extern char *basbuf;
1232 int i,i2,i3;
1233 char temporary[8192];
1234
1235 //Declare(DLL関数)情報を初期化
1236 extern DECLAREINFO **ppDeclareHash;
1237 ppDeclareHash=(DECLAREINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(DECLAREINFO *));
1238
1239 //サブルーチン(ユーザー定義)情報を初期化
1240 extern SubInfo **ppSubHash;
1241 extern int SubNum;
1242 ppSubHash=(SubInfo **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SubInfo *));
1243 SubNum=0;
1244
1245 //マクロ関数の名前リストを初期化
1246 extern char **ppMacroNames;
1247 extern int MacroNum;
1248 ppMacroNames=(char **)HeapAlloc(hHeap,0,1);
1249 MacroNum=0;
1250
1251 i=-1;
1252 while(1){
1253 i++;
1254
1255 if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_INTERFACE)){
1256 /* Class ~ End Class
1257 Interface ~ End Interface
1258 を飛び越す */
1259 i3=GetEndXXXCommand(basbuf[i+1]);
1260 for(i+=2,i2=0;;i++,i2++){
1261 if(basbuf[i]=='\0') break;
1262 if(basbuf[i]==1&&basbuf[i+1]==(char)i3){
1263 i++;
1264 break;
1265 }
1266 }
1267 if(basbuf[i]=='\0') break;
1268 continue;
1269 }
1270
1271 if(basbuf[i]==1&&basbuf[i+1]==ESC_DECLARE){
1272 for(i+=2,i2=0;;i2++,i++){
1273 if(basbuf[i]=='\n'){
1274 temporary[i2]=0;
1275 break;
1276 }
1277 temporary[i2]=basbuf[i];
1278 if(basbuf[i]=='\0') break;
1279 }
1280 AddDeclareData(temporary,i);
1281
1282 continue;
1283 }
1284 if(basbuf[i]==1&&(basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION||basbuf[i+1]==ESC_MACRO)){
1285 for(i2=0;;i2++,i++){
1286 if(IsCommandDelimitation(basbuf[i])){
1287 temporary[i2]=0;
1288 break;
1289 }
1290 temporary[i2]=basbuf[i];
1291 if(basbuf[i]=='\0') break;
1292 }
1293 AddSubData(temporary,i,0,0);
1294
1295 continue;
1296 }
1297
1298 //次の行
1299 for(;;i++){
1300 if(IsCommandDelimitation(basbuf[i])) break;
1301 }
1302 if(basbuf[i]=='\0') break;
1303 }
1304
1305 ////////////
1306 // 特殊関数
1307 ////////////
1308
1309 sprintf(temporary,"%c%c_allrem()",1,ESC_SUB);
1310 AddSubData(temporary,0,0,0);
1311
1312 sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB);
1313 AddSubData(temporary,0,0,0);
1314
1315 sprintf(temporary,"%c%c_allmul()",1,ESC_SUB);
1316 AddSubData(temporary,0,0,0);
1317
1318 sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB);
1319 AddSubData(temporary,0,0,0);
1320
1321 sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB);
1322 AddSubData(temporary,0,0,0);
1323
1324 sprintf(temporary,"%c%c_allshl()",1,ESC_SUB);
1325 AddSubData(temporary,0,0,0);
1326
1327 sprintf(temporary,"%c%c_allshr()",1,ESC_SUB);
1328 AddSubData(temporary,0,0,0);
1329
1330 sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB);
1331 AddSubData(temporary,0,0,0);
1332
1333 sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB);
1334 AddSubData(temporary,0,0,0);
1335}
1336void Delete_si(SubInfo *pSub){
1337 foreach( Parameter *pParam, pSub->params ){
1338 delete pParam;
1339 }
1340
1341 foreach( Parameter *pParam, pSub->realParams ){
1342 delete pParam;
1343 }
1344
1345 if(pSub->pNextData) Delete_si(pSub->pNextData);
1346
1347 HeapDefaultFree(pSub->name);
1348 delete pSub;
1349}
1350void DeleteSubInfo(SubInfo **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放
1351 int i;
1352 for(i=0;i<MAX_HASH;i++){
1353 if(!ppSubHash[i]) continue;
1354
1355 Delete_si(ppSubHash[i]);
1356 }
1357 HeapDefaultFree(ppSubHash);
1358
1359 //マクロの名前リスト
1360 if(ppMacroNames){
1361 for(i=0;i<MacroNum;i++){
1362 HeapDefaultFree(ppMacroNames[i]);
1363 }
1364 HeapDefaultFree(ppMacroNames);
1365 }
1366}
1367void Delete_di(DECLAREINFO *pdi){
1368 if(pdi->pParmInfo) HeapDefaultFree(pdi->pParmInfo);
1369
1370 HeapDefaultFree(pdi->name);
1371 if(pdi->file) HeapDefaultFree(pdi->file);
1372 if(pdi->alias) HeapDefaultFree(pdi->alias);
1373
1374 if(pdi->pNextData) Delete_di(pdi->pNextData);
1375
1376 HeapDefaultFree(pdi);
1377}
1378void DeleteDeclareInfo(void){
1379 //DLL情報を解放
1380 extern DECLAREINFO **ppDeclareHash;
1381 int i;
1382 for(i=0;i<MAX_HASH;i++){
1383 if(!ppDeclareHash[i]) continue;
1384
1385 Delete_di(ppDeclareHash[i]);
1386 }
1387 HeapDefaultFree(ppDeclareHash);
1388}
1389
1390
1391
1392///////////////////////
1393// 関数ポインタの管理
1394///////////////////////
1395
1396int AddProcPtrInfo(char *buffer,DWORD dwProcType){
1397 extern HANDLE hHeap;
1398 extern int cp;
1399 extern PROCPTRINFO *pProcPtrInfo;
1400 extern int ProcPtrInfoNum;
1401 int i,i2,i3,sw;
1402 PROCPTRINFO *pi;
1403 char temporary[VN_SIZE],temp2[VN_SIZE];
1404
1405 pProcPtrInfo=(PROCPTRINFO *)HeapReAlloc(hHeap,0,pProcPtrInfo,(ProcPtrInfoNum+1)*sizeof(PROCPTRINFO));
1406 pi=&pProcPtrInfo[ProcPtrInfoNum];
1407 ProcPtrInfoNum++;
1408
1409 pi->pParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,0,1);
1410 pi->ParmNum=0;
1411
1412 //buffer[0]は'('となっている
1413 i=1;
1414
1415 while(1){
1416 if(buffer[i]==')') break;
1417
1418 pi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,pi->pParmInfo,(pi->ParmNum+1)*sizeof(PARAMETER_INFO));
1419
1420 //ByVal
1421 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){
1422 pi->pParmInfo[pi->ParmNum].bByVal=1;
1423 i+=2;
1424 }
1425 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){
1426 pi->pParmInfo[pi->ParmNum].bByVal=0;
1427 i+=2;
1428 }
1429 else pi->pParmInfo[pi->ParmNum].bByVal=1;
1430
1431 //パラメータ名
1432 sw=0;
1433 for(i2=0;;i++,i2++){
1434 if(buffer[i]=='('){
1435 if(!sw) sw=1;
1436
1437 i3=GetStringInPare(temporary+i2,buffer+i);
1438 i2+=i3-1;
1439 i+=i3-1;
1440 continue;
1441 }
1442 if(buffer[i]=='['){
1443 if(!sw) sw=1;
1444
1445 i3=GetStringInBracket(temporary+i2,buffer+i);
1446 i2+=i3-1;
1447 i+=i3-1;
1448 continue;
1449 }
1450 if(!IsVariableChar(buffer[i])){
1451 temporary[i2]=0;
1452 break;
1453 }
1454 temporary[i2]=buffer[i];
1455 }
1456 pi->pParmInfo[pi->ParmNum].name=0;
1457
1458 if(sw){
1459 //配列パラメータ
1460 if(pi->pParmInfo[pi->ParmNum].bByVal) SetError(29,NULL,cp);
1461 pi->pParmInfo[pi->ParmNum].bArray=1;
1462
1463 if((temporary[i2-2]=='('&&temporary[i2-1]==')')||
1464 (temporary[i2-2]=='['&&temporary[i2-1]==']')){
1465 pi->pParmInfo[pi->ParmNum].SubScripts[0]=LONG_MAX;
1466 pi->pParmInfo[pi->ParmNum].SubScripts[1]=-1;
1467
1468 temporary[i2-2]=0;
1469 }
1470 else{
1471 GetArrange(temporary,temp2,pi->pParmInfo[pi->ParmNum].SubScripts);
1472 lstrcpy(temporary,temp2);
1473 }
1474
1475 i2=lstrlen(temporary);
1476 }
1477 else{
1478 pi->pParmInfo[pi->ParmNum].bArray=0;
1479 pi->pParmInfo[pi->ParmNum].SubScripts[0]=-1;
1480 }
1481
1482 //型
1483 if(buffer[i]==1&&buffer[i+1]==ESC_AS){
1484 i+=2;
1485
1486 i2=0;
1487 while(buffer[i]=='*'){
1488 temporary[i2]=buffer[i];
1489 i++;
1490 i2++;
1491 }
1492 for(;;i++,i2++){
1493 if(!IsVariableChar(buffer[i])){
1494 temporary[i2]=0;
1495 break;
1496 }
1497 temporary[i2]=buffer[i];
1498 }
1499
1500 pi->pParmInfo[pi->ParmNum].type=
1501 GetTypeFixed(temporary,&pi->pParmInfo[pi->ParmNum].u.index);
1502 if(pi->pParmInfo[pi->ParmNum].type==-1){
1503 SetError(3,temporary,cp);
1504 pi->pParmInfo[pi->ParmNum].type=DEF_PTR_VOID;
1505 }
1506 if(pi->pParmInfo[pi->ParmNum].type==DEF_OBJECT){
1507 if(pi->pParmInfo[pi->ParmNum].bByVal) SetError(28,temporary,cp);
1508 }
1509 }
1510 else{
1511 pi->pParmInfo[pi->ParmNum].type=GetTypeFromSimpleName(temporary);
1512 SetError(-103,temporary,cp);
1513 }
1514
1515 pi->ParmNum++;
1516
1517 if(buffer[i]==','){
1518 i++;
1519 continue;
1520 }
1521 else if(buffer[i]==')') continue;
1522 else{
1523 SetError(1,NULL,cp);
1524 return 0;
1525 }
1526 }
1527 i++;
1528
1529 //戻り値
1530 if(dwProcType==ESC_FUNCTION){
1531 if(buffer[i]==1&&buffer[i+1]==ESC_AS){
1532 i+=2;
1533 i2=0;
1534 if(buffer[i]=='*') temporary[i2++]=buffer[i++];
1535 for(;;i++,i2++){
1536 if(!IsVariableChar(buffer[i])){
1537 temporary[i2]=0;
1538 break;
1539 }
1540 temporary[i2]=buffer[i];
1541 }
1542 pi->ReturnType=GetTypeFixed(temporary,&pi->u.ReturnIndex);
1543 if(pi->ReturnType==DEF_NON) SetError(3,temporary,cp);
1544 }
1545 else pi->ReturnType=DEF_DOUBLE;
1546 }
1547 else pi->ReturnType=DEF_NON;
1548
1549 return ProcPtrInfoNum-1;
1550}
1551void DeleteProcPtrInfo(void){
1552 extern PROCPTRINFO *pProcPtrInfo;
1553 extern int ProcPtrInfoNum;
1554 int i;
1555
1556 for(i=0;i<ProcPtrInfoNum;i++){
1557 HeapDefaultFree(pProcPtrInfo[i].pParmInfo);
1558 }
1559
1560 HeapDefaultFree(pProcPtrInfo);
1561}
Note: See TracBrowser for help on using the repository browser.