source: dev/trunk/abdev/BasicCompiler_Common/Subroutine.cpp@ 150

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

Smoothie::Metaクラス内を整理

File size: 20.2 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
9int GetCallProcName(char *buffer,char *name){
10 int i2,i3,IsStr=0;
11
12 for(i2=0;;i2++){
13 if(buffer[i2]=='\"') IsStr^=1;
14 if(IsDBCSLeadByte(buffer[i2])){
15 name[i2]=buffer[i2];
16 i2++;
17 name[i2]=buffer[i2];
18 continue;
19 }
20 if(buffer[i2]=='['&&IsStr==0){
21 i3=GetStringInBracket(name+i2,buffer+i2);
22 i2+=i3-1;
23 continue;
24 }
25 if(buffer[i2]=='('&&IsStr==0){
26 name[i2]=0;
27 break;
28 }
29 if(buffer[i2]=='='&&IsStr==0){
30 name[i2]=0;
31 break;
32 }
33
34 name[i2]=buffer[i2];
35 if(buffer[i2]=='\0') break;
36 }
37 return i2;
38}
39
40int GetProc(char *name,void **ppInfo){
41
42 //ユーザー定義関数
43 *ppInfo=(void *)GetSubHash(name);
44 if(*ppInfo) return PROC_DEFAULT;
45
46 //DLL関数
47 *ppInfo=(void *)GetDeclareHash(name);
48 if(*ppInfo) return PROC_DLL;
49
50 //コンパイラ埋め込み型
51 *ppInfo=(void *)(_int64)GetFunctionFromName(name);
52 if(*ppInfo) return PROC_BUILTIN;
53
54 //関数ポインタ
55 Type type;
56 if( !GetVarType( name, type, false ) ){
57 return 0;
58 }
59 if( type.IsProcPtr() ){
60 return PROC_PTR;
61 }
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, CClass::RefType &refType ){
86 int lastIndex = -1;
87 for( int i=0; desc[i]; i++ ){
88 if( desc[i] == '(' ){
89 i=JumpStringInPare(desc,i+1);
90 continue;
91 }
92 else if( desc[i] == '[' ){
93 i=JumpStringInBracket(desc,i+1);
94 continue;
95 }
96 else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){
97 lastIndex = i;
98 }
99 }
100 if( lastIndex == -1 ){
101 lstrcpy( member, desc );
102 return false;
103 }
104
105 if(desc[lastIndex]=='.'){
106 lstrcpy(member,desc+lastIndex+1);
107 refType = CClass::Dot;
108 }
109 else{
110 lstrcpy(member,desc+lastIndex+2);
111 refType = CClass::Pointer;
112 }
113
114 if( object ){
115 lstrcpy( object, desc );
116 object[lastIndex]=0;
117 }
118
119 return true;
120}
121bool SplitMemberName( const char *desc, char *object, char *member ){
122 CClass::RefType dummyRefType;
123 return SplitMemberName( desc, object, member, dummyRefType );
124}
125
126bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, Type &resultType, bool isCallOn ){
127
128 //GetSubHash内でエラー提示が行われた場合
129 if(pProc==(Procedure *)-1){
130 return false;
131 }
132
133 if(kind==PROC_DEFAULT){
134 /////////////////////
135 // ユーザー定義関数
136 /////////////////////
137
138 UserProc *pUserProc = (UserProc *)pProc;
139
140 //オブジェクト名を取得
141 char ObjectName[VN_SIZE];
142 int RefType;
143 SplitObjectName(fullCallName,ObjectName,&RefType);
144
145
146 ////////////////////////
147 // オーバーロードを解決
148 ////////////////////////
149
150 std::vector<UserProc *> subs;
151 GetOverloadSubHash(fullCallName,subs);
152 if(subs.size()){
153 //オーバーロードを解決
154 pUserProc=OverloadSolutionWithStrParam(fullCallName,subs,lpszParms,ObjectName);
155
156 if(!pUserProc){
157 return false;
158 }
159 }
160
161 resultType = pUserProc->ReturnType();
162
163 if( isCallOn ){
164 if( !Opcode_CallProc(lpszParms,pUserProc,0,ObjectName,RefType) ){
165 return false;
166 }
167 }
168 }
169 else if(kind==PROC_DLL){
170 /////////////////////////
171 // DLL関数
172 /////////////////////////
173 DllProc *pDllProc = (DllProc *)pProc;
174
175 resultType = pDllProc->ReturnType();
176
177 if( isCallOn ){
178 if( !Opcode_CallDllProc(lpszParms,pDllProc) ){
179 return false;
180 }
181 }
182 }
183 else if(kind==PROC_BUILTIN){
184 /////////////////////////
185 // 組み込み関数
186 /////////////////////////
187 int FuncId = (int)(_int64)pProc;
188
189 if( !Opcode_CallFunc( lpszParms, FuncId, resultType, isCallOn ) ){
190 return false;
191 }
192 }
193 else if(kind==PROC_PTR){
194 /////////////////
195 // 関数ポインタ
196 /////////////////
197
198 Type type;
199 GetVarType(fullCallName,type,false);
200
201 ProcPointer *pProcPtr = Smoothie::Meta::procPointers[type.GetIndex()];
202 resultType = pProcPtr->ReturnType();
203
204 if( isCallOn ){
205 if( !Opcode_CallProcPtr(fullCallName,lpszParms,pProcPtr) ){
206 return false;
207 }
208 }
209 }
210 else{
211 return false;
212 }
213
214 return true;
215}
216bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType){
217 //プロパティ用のメソッドを呼び出す
218
219 //配列要素を取得
220 char VarName[VN_SIZE],ArrayElements[VN_SIZE];
221 GetArrayElement(variable,VarName,ArrayElements);
222
223 //オブジェクト名を取得
224 char ObjectName[VN_SIZE];
225 int RefType;
226 SplitObjectName(VarName,ObjectName,&RefType);
227
228 //オーバーロード用の関数リストを作成
229 std::vector<UserProc *> subs;
230 GetOverloadSubHash(VarName,subs);
231 if(subs.size()==0){
232 return false;
233 }
234
235 //パラメータを整備
236 char *Parameter;
237 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(rightSide)+32);
238 lstrcpy(Parameter,ArrayElements);
239 if(rightSide){
240 if(Parameter[0]&&rightSide[0]) lstrcat(Parameter,",");
241 lstrcat(Parameter,rightSide);
242 }
243
244 //オーバーロードを解決
245 UserProc *pUserProc;
246 pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
247
248 if(pUserProc){
249 //呼び出し
250 Opcode_CallProc(Parameter,pUserProc,0,ObjectName,RefType);
251
252 resultType = pUserProc->ReturnType();
253 }
254
255 HeapDefaultFree(Parameter);
256
257 return true;
258}
259
260bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType ){
261 //プロパティ用のメソッドを呼び出す
262
263 //配列要素を取得
264 char VarName[VN_SIZE],ArrayElements[VN_SIZE];
265 GetArrayElement(variable,VarName,ArrayElements);
266
267 //オブジェクト名を取得
268 char ObjectName[VN_SIZE];
269 int RefType;
270 SplitObjectName(VarName,ObjectName,&RefType);
271
272 //オーバーロード用の関数リストを作成
273 std::vector<UserProc *> subs;
274 GetOverloadSubHash(VarName,subs);
275 if(subs.size()==0){
276 return 0;
277 }
278
279 //パラメータを整備
280 char *Parameter;
281 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(rightSide)+32);
282 lstrcpy(Parameter,ArrayElements);
283 if(rightSide){
284 if(Parameter[0]&&rightSide[0]) lstrcat(Parameter,",");
285 lstrcat(Parameter,rightSide);
286 }
287
288 //オーバーロードを解決
289 UserProc *pUserProc;
290 pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
291
292 if(pUserProc){
293 resultType = pUserProc->ReturnType();
294 }
295
296 return 1;
297}
298
299//インデクサ(getter)の戻り値を取得
300bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){
301 vector<UserProc *> subs;
302 objClass.GetMethods().Enum( CALC_ARRAY_GET, subs );
303 if( subs.size() == 0 ){
304 return false;
305 }
306
307 resultType = subs[0]->ReturnType();
308
309 return true;
310}
311
312
313void AddDeclareData(const NamespaceScopes &namespaceScopes, char *buffer,int nowLine){
314 extern HANDLE hHeap;
315 int i2;
316
317 int i=0;
318
319 //Sub/Function
320 Procedure::Kind kind = Procedure::Sub;
321 if(buffer[i]==ESC_SUB){
322 }
323 else if(buffer[i]==ESC_FUNCTION){
324 kind = Procedure::Function;
325 }
326 else{
327 SetError(1,NULL,nowLine);
328 return;
329 }
330 i++;
331
332 //プロシージャ名
333 char procName[VN_SIZE];
334 bool isCdecl = false;
335 for(i2=0;;i++,i2++){
336 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL){
337 isCdecl = true;
338
339 i+=2;
340 procName[i2]=0;
341 break;
342 }
343 if(buffer[i]==','){
344 procName[i2]=0;
345 break;
346 }
347 if(buffer[i]=='\0'){
348 SetError(1,NULL,nowLine);
349 return;
350 }
351 procName[i2]=buffer[i];
352 }
353 i++;
354
355 //ユーザー定義関数との重複チェック
356 if(GetSubHash(procName)){
357 SetError(15,procName,nowLine);
358 return;
359 }
360
361
362 //ライブラリ
363 char dllFileName[MAX_PATH];
364 i = GetOneParameter( buffer, i, dllFileName );
365 Type resultType;
366 _int64 i64data;
367 if( !StaticCalculation( true, dllFileName, 0, &i64data, resultType ) ){
368 return;
369 }
370 if( resultType.GetBasicType() != typeOfPtrChar ){
371 SetError(1,NULL,nowLine);
372 return;
373 }
374 lstrcpy( dllFileName, (char *)i64data );
375 CharUpper(dllFileName);
376 if(!strstr(dllFileName,".")){
377 lstrcat(dllFileName,".DLL");
378 if(lstrlen(dllFileName)>=16){
379 SetError(7,NULL,nowLine);
380 return;
381 }
382 }
383
384 //エイリアス
385 char alias[VN_SIZE];
386 i = GetOneParameter( buffer, i, alias );
387 if( alias[0] ){
388 if( !StaticCalculation( true, alias, 0, &i64data, resultType ) ){
389 return;
390 }
391 if( resultType.GetBasicType() != typeOfPtrChar ){
392 SetError(1,NULL,nowLine);
393 return;
394 }
395 lstrcpy( alias, (char *)i64data );
396 }
397 else{
398 //省略されたときは関数名
399 lstrcpy( alias, procName );
400 }
401
402
403 // オブジェクトを生成
404 DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );
405
406 // パラメータを解析
407 // ※第1パラメータにに指定するデータの例:"( s As String ) As String"
408 pDllProc->SetParamsAndReturnType( buffer + i, nowLine );
409
410 // パラメータのエラーチェック
411 foreach( const Parameter *pParam, pDllProc->Params() ){
412 if( pParam->IsObject() ){
413 SetError(25,pParam->GetVarName(),nowLine);
414 }
415 if( !pParam->IsRef() ){
416 if( pParam->IsStruct() ){
417 SetError(28,pParam->GetVarName(),nowLine);
418 }
419 }
420 }
421
422 //戻り値のエラーチェック
423 if( pDllProc->IsFunction() ){
424 // Function定義
425
426 if( pDllProc->ReturnType().IsObject() ){
427 // DLL関数ではオブジェクトを戻り値にできない
428 SetError(40,pDllProc->GetName(),nowLine);
429 }
430 }
431
432
433 /////////////////////////////////
434 // 格納位置を計算してppDeclareHashにセット
435 /////////////////////////////////
436
437 //ハッシュ値を取得
438 int key;
439 key=hash_default(procName);
440
441 extern DllProc **ppDeclareHash;
442 if(ppDeclareHash[key]){
443 DllProc *pTempProc = ppDeclareHash[key];
444 while(1){
445 if( pTempProc->IsEqualSymbol( pDllProc->GetNamespaceScopes(), pDllProc->GetName() ) ){
446 //重複エラー
447 SetError(15,procName,nowLine);
448 return;
449 }
450
451 if(pTempProc->pNextData==0){
452 pTempProc->pNextData=pDllProc;
453 break;
454 }
455 pTempProc=pTempProc->pNextData;
456 }
457 pTempProc=pTempProc->pNextData;
458 }
459 else{
460 ppDeclareHash[key]=pDllProc;
461 }
462}
463
464GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic){
465 int i2,i3;
466 char temporary[8192];
467
468 int i=1;
469
470 Procedure::Kind kind = Procedure::Sub;
471 bool isMacro = false;
472 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
473 if(buffer[i]==ESC_MACRO){
474 isMacro = true;
475 }
476
477 i++;
478
479 bool isCdecl = false;
480 bool isExport = false;
481 while(1){
482 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
483 isCdecl = true;
484
485 i+=2;
486 }
487 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
488 isExport = true;
489
490 i+=2;
491 }
492 else break;
493 }
494
495 i2=0;
496 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
497 if(!pobj_c){
498 SetError(126,NULL,nowLine);
499 return 0;
500 }
501
502 //オペレータの場合
503 temporary[i2++]=buffer[i++];
504 temporary[i2++]=buffer[i++];
505
506 int iCalcId;
507 if(buffer[i]=='='&&buffer[i+1]=='='){
508 iCalcId=CALC_EQUAL;
509 i3=2;
510 }
511 else if(buffer[i]=='='){
512 iCalcId=CALC_SUBSITUATION;
513 i3=1;
514 }
515 else if(buffer[i]=='('){
516 iCalcId=CALC_AS;
517 i3=0;
518 }
519 else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
520 iCalcId=CALC_ARRAY_SET;
521 i3=3;
522 }
523 else if(buffer[i]=='['&&buffer[i+1]==']'){
524 iCalcId=CALC_ARRAY_GET;
525 i3=2;
526 }
527 else{
528 iCalcId=GetCalcId(buffer+i,&i3);
529 i3++;
530 }
531 if(!iCalcId){
532 SetError(1,NULL,nowLine);
533 return 0;
534 }
535 temporary[i2++]=iCalcId;
536 temporary[i2]=0;
537
538 i+=i3;
539 }
540 else{
541 if(pobj_c){
542 //クラスメンバの場合、デストラクタには~が付くことを考慮
543 if(buffer[i]=='~'){
544 temporary[i2]='~';
545 i++;
546 i2++;
547 }
548 }
549
550 for(;;i++,i2++){
551 if(!IsVariableChar(buffer[i])){
552 temporary[i2]=0;
553 break;
554 }
555 temporary[i2]=buffer[i];
556 }
557 }
558
559 if( isMacro ){
560 //大文字に変換
561 CharUpper(temporary);
562
563 //マクロ関数の場合は名前リストに追加
564 extern char **ppMacroNames;
565 extern int MacroNum;
566 ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *));
567 ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
568 lstrcpy(ppMacroNames[MacroNum],temporary);
569 MacroNum++;
570 }
571
572 if(!pobj_c){
573 //クラスメンバ以外の場合のみ
574 //重複チェック
575
576 if(GetDeclareHash(temporary)){
577 SetError(15,temporary,nowLine);
578 return 0;
579 }
580 }
581
582 extern int SubNum;
583 SubNum++;
584
585 GlobalProc *pUserProc = new GlobalProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport );
586 pUserProc->SetParentClass( pobj_c );
587 if( Smoothie::isFullCompile ){
588 // すべての関数・メソッドをコンパイルする
589 pUserProc->Using();
590 }
591
592 //ID
593 static int id_base=0;
594 pUserProc->id = (id_base++);
595
596 if(isExport){
597 pUserProc->Using();
598 }
599
600 // パラメータを解析
601 // ※第1パラメータにに指定するデータの例:"( s As String ) As String"
602 pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
603
604 pUserProc->_paramStr = buffer + i;
605
606
607 /////////////////////////////////
608 // ハッシュデータに追加
609 /////////////////////////////////
610
611 int key;
612 key=hash_default(pUserProc->GetName().c_str());
613
614 extern GlobalProc **ppSubHash;
615 if(ppSubHash[key]){
616 GlobalProc *psi2;
617 psi2=ppSubHash[key];
618 while(1){
619 if(pobj_c==psi2->GetParentClassPtr()){
620 //重複エラーチェックを行う
621 if( pUserProc->IsEqualSymbol( *psi2 ) ){
622 if( psi2->Params().Equals( pUserProc->Params() ) ){
623 SetError(15,pUserProc->GetName().c_str(),nowLine);
624 return 0;
625 }
626 }
627 }
628
629 if(psi2->pNextData==0) break;
630 psi2=psi2->pNextData;
631 }
632 psi2->pNextData=pUserProc;
633 }
634 else{
635 ppSubHash[key]=pUserProc;
636 }
637
638 return pUserProc;
639}
640
641void GetSubInfo(void){ //サブルーチン情報を取得
642 extern HANDLE hHeap;
643 extern char *basbuf;
644 int i,i2,i3;
645 char temporary[8192];
646
647 //Declare(DLL関数)情報を初期化
648 extern DllProc **ppDeclareHash;
649 ppDeclareHash=(DllProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(DllProc *));
650
651 //サブルーチン(ユーザー定義)情報を初期化
652 extern GlobalProc **ppSubHash;
653 extern int SubNum;
654 ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *));
655 SubNum=0;
656
657 //マクロ関数の名前リストを初期化
658 extern char **ppMacroNames;
659 extern int MacroNum;
660 ppMacroNames=(char **)HeapAlloc(hHeap,0,1);
661 MacroNum=0;
662
663 // 名前空間管理
664 NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes;
665 namespaceScopes.clear();
666
667 // Importsされた名前空間の管理
668 NamespaceScopesCollection &importedNamespaces = Smoothie::Temp::importedNamespaces;
669 importedNamespaces.clear();
670
671 i=-1;
672 while(1){
673 i++;
674
675 if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_INTERFACE)){
676 /* Class ~ End Class
677 Interface ~ End Interface
678 を飛び越す */
679 i3=GetEndXXXCommand(basbuf[i+1]);
680 for(i+=2,i2=0;;i++,i2++){
681 if(basbuf[i]=='\0') break;
682 if(basbuf[i]==1&&basbuf[i+1]==(char)i3){
683 i++;
684 break;
685 }
686 }
687 if(basbuf[i]=='\0') break;
688 continue;
689 }
690
691 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
692 for(i+=2,i2=0;;i2++,i++){
693 if( IsCommandDelimitation( basbuf[i] ) ){
694 temporary[i2]=0;
695 break;
696 }
697 temporary[i2]=basbuf[i];
698 }
699 namespaceScopes.push_back( temporary );
700
701 continue;
702 }
703 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
704 if( namespaceScopes.size() <= 0 ){
705 SetError(12, "End Namespace", i );
706 }
707 else{
708 namespaceScopes.pop_back();
709 }
710
711 i += 2;
712 continue;
713 }
714 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){
715 for(i+=2,i2=0;;i2++,i++){
716 if( IsCommandDelimitation( basbuf[i] ) ){
717 temporary[i2]=0;
718 break;
719 }
720 temporary[i2]=basbuf[i];
721 }
722 importedNamespaces.Imports( temporary );
723
724 continue;
725 }
726 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
727 importedNamespaces.clear();
728 continue;
729 }
730
731 if(basbuf[i]==1&&basbuf[i+1]==ESC_DECLARE){
732 for(i+=2,i2=0;;i2++,i++){
733 if(basbuf[i]=='\n'){
734 temporary[i2]=0;
735 break;
736 }
737 temporary[i2]=basbuf[i];
738 if(basbuf[i]=='\0') break;
739 }
740 AddDeclareData(namespaceScopes,temporary,i);
741
742 continue;
743 }
744 if(basbuf[i]==1&&(basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION||basbuf[i+1]==ESC_MACRO)){
745 char statementChar = basbuf[i+1];
746
747 for(i2=0;;i2++,i++){
748 if(IsCommandDelimitation(basbuf[i])){
749 temporary[i2]=0;
750 break;
751 }
752 temporary[i2]=basbuf[i];
753 if(basbuf[i]=='\0') break;
754 }
755 AddSubData(namespaceScopes, importedNamespaces, temporary,i,0,0);
756
757 /* Sub ~ End Sub
758 Function ~ End Function
759 Macro ~ End Macro
760 を飛び越す */
761 char endStatementChar = GetEndXXXCommand( statementChar );
762 for(i2=0;;i++,i2++){
763 if( basbuf[i] == '\0' ) break;
764 if( basbuf[i] == 1 && basbuf[i+1] == endStatementChar ){
765 i++;
766 break;
767 }
768 }
769 if(basbuf[i]=='\0') break;
770 continue;
771 }
772
773 //次の行
774 for(;;i++){
775 if(IsCommandDelimitation(basbuf[i])) break;
776 }
777 if(basbuf[i]=='\0') break;
778 }
779
780 ////////////
781 // 特殊関数
782 ////////////
783 namespaceScopes.clear();
784 importedNamespaces.clear();
785
786 sprintf(temporary,"%c%c_allrem()",1,ESC_SUB);
787 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
788
789 sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB);
790 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
791
792 sprintf(temporary,"%c%c_allmul()",1,ESC_SUB);
793 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
794
795 sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB);
796 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
797
798 sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB);
799 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
800
801 sprintf(temporary,"%c%c_allshl()",1,ESC_SUB);
802 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
803
804 sprintf(temporary,"%c%c_allshr()",1,ESC_SUB);
805 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
806
807 sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB);
808 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
809
810 sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB);
811 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
812}
813void Delete_si(GlobalProc *pUserProc){
814 if(pUserProc->pNextData) Delete_si(pUserProc->pNextData);
815 delete pUserProc;
816}
817void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放
818 int i;
819 for(i=0;i<MAX_HASH;i++){
820 if(!ppSubHash[i]) continue;
821
822 Delete_si(ppSubHash[i]);
823 }
824 HeapDefaultFree(ppSubHash);
825
826 //マクロの名前リスト
827 if(ppMacroNames){
828 for(i=0;i<MacroNum;i++){
829 HeapDefaultFree(ppMacroNames[i]);
830 }
831 HeapDefaultFree(ppMacroNames);
832 }
833}
834void Delete_di(DllProc *pDllProc){
835 if(pDllProc->pNextData) Delete_di(pDllProc->pNextData);
836
837 delete pDllProc;
838}
839void DeleteDeclareInfo(void){
840 //DLL情報を解放
841 extern DllProc **ppDeclareHash;
842 int i;
843 for(i=0;i<MAX_HASH;i++){
844 if(!ppDeclareHash[i]) continue;
845
846 Delete_di(ppDeclareHash[i]);
847 }
848 HeapDefaultFree(ppDeclareHash);
849}
850
851
852
853///////////////////////
854// 関数ポインタの管理
855///////////////////////
856
857int AddProcPtrInfo( const string &typeExpression, int nowLine ){
858 DWORD dwProcType = (DWORD)typeExpression[2];
859 const string &paramStr = typeExpression.substr( 3 );
860
861 Procedure::Kind kind = Procedure::Sub;
862 if( dwProcType == ESC_FUNCTION ){
863 kind = Procedure::Function;
864 }
865
866 ProcPointer *pProcPointer = new ProcPointer( kind );
867
868 //buffer[0]は'('となっている
869 pProcPointer->SetParamsAndReturnType( paramStr.c_str(), nowLine );
870
871 Smoothie::Meta::procPointers.push_back( pProcPointer );
872
873 return (int)Smoothie::Meta::procPointers.size()-1;
874}
875void DeleteProcPtrInfo(void){
876 BOOST_FOREACH( ProcPointer *pProcPointer, Smoothie::Meta::procPointers ){
877 delete pProcPointer;
878 }
879
880 Smoothie::Meta::procPointers.clear();
881}
882
883
884
885bool IsNeedProcCompile(){
886 for(int i2=0;i2<MAX_HASH;i2++){
887 extern GlobalProc **ppSubHash;
888 GlobalProc *pUserProc=ppSubHash[i2];
889 while(pUserProc){
890 if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
891 return true;
892 }
893
894 pUserProc=pUserProc->pNextData;
895 }
896 }
897 return false;
898}
Note: See TracBrowser for help on using the repository browser.