Changeset 73 in dev for BasicCompiler_Common/Subroutine.cpp
- Timestamp:
- Mar 16, 2007, 11:07:14 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Subroutine.cpp
r69 r73 8 8 9 9 //コンパイル中の関数情報 10 S UBINFO*pCompilingSubInfo;10 SubInfo *pCompilingSubInfo; 11 11 12 12 int GetCallProcName(char *buffer,char *name){ … … 114 114 ///////////////////// 115 115 116 S UBINFO *psi;117 p si=(SUBINFO*)pInfo;116 SubInfo *pSub; 117 pSub=(SubInfo *)pInfo; 118 118 119 119 //GetSubHash内でエラー提示が行われた場合 120 if(p si==(SUBINFO*)-1) return -1;120 if(pSub==(SubInfo *)-1) return -1; 121 121 122 122 … … 131 131 //////////////////////// 132 132 133 std::vector<S UBINFO*> subs;133 std::vector<SubInfo *> subs; 134 134 GetOverloadSubHash(name,subs); 135 135 if(subs.size()){ 136 136 //オーバーロードを解決 137 p si=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);138 139 if(!p si) return 0;140 } 141 142 143 Opcode_CallProc(Parameter,p si,0,ObjectName,RefType);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 144 if( plpRetIndex ){ 145 *plpRetIndex = p si->u.ReturnIndex;146 } 147 return p si->ReturnType;145 *plpRetIndex = pSub->u.ReturnIndex; 146 } 147 return pSub->ReturnType; 148 148 } 149 149 else if(idProc==PROC_DLL){ … … 197 197 198 198 //オーバーロード用の関数リストを作成 199 std::vector<S UBINFO*> subs;199 std::vector<SubInfo *> subs; 200 200 GetOverloadSubHash(VarName,subs); 201 201 if(subs.size()==0){ … … 213 213 214 214 //オーバーロードを解決 215 S UBINFO *psi;216 p si=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);217 218 if(p si){215 SubInfo *pSub; 216 pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 217 218 if(pSub){ 219 219 //呼び出し 220 Opcode_CallProc(Parameter,p si,0,ObjectName,RefType);220 Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType); 221 221 222 222 if( pRetTypeInfo ){ 223 pRetTypeInfo->type = p si->ReturnType;224 pRetTypeInfo->u.lpIndex = p si->u.ReturnIndex;223 pRetTypeInfo->type = pSub->ReturnType; 224 pRetTypeInfo->u.lpIndex = pSub->u.ReturnIndex; 225 225 } 226 226 } … … 240 240 ///////////////////// 241 241 242 S UBINFO *psi;243 p si=(SUBINFO*)pInfo;242 SubInfo *pSub; 243 pSub=(SubInfo *)pInfo; 244 244 245 245 //GetSubHash内でエラー提示が行われた場合 246 if(p si==(SUBINFO*)-1) return -1;246 if(pSub==(SubInfo *)-1) return -1; 247 247 248 248 … … 257 257 //////////////////////// 258 258 259 std::vector<S UBINFO*> subs;259 std::vector<SubInfo *> subs; 260 260 GetOverloadSubHash(name,subs); 261 261 if( subs.size() > 0 ){ 262 262 //オーバーロードを解決 263 p si=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);264 265 if(!p si) return 0;266 } 267 268 269 ret_type=p si->ReturnType;270 *plpRetIndex=p si->u.ReturnIndex;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 271 } 272 272 else if(idProc==PROC_DLL){ … … 318 318 319 319 //オーバーロード用の関数リストを作成 320 std::vector<S UBINFO*> subs;320 std::vector<SubInfo *> subs; 321 321 GetOverloadSubHash(VarName,subs); 322 322 if(subs.size()==0){ … … 334 334 335 335 //オーバーロードを解決 336 S UBINFO *psi;337 p si=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);338 339 if(p si){336 SubInfo *pSub; 337 pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 338 339 if(pSub){ 340 340 if(pRetTypeInfo){ 341 pRetTypeInfo->type=p si->ReturnType;342 pRetTypeInfo->u.lpIndex=p si->u.ReturnIndex;341 pRetTypeInfo->type=pSub->ReturnType; 342 pRetTypeInfo->u.lpIndex=pSub->u.ReturnIndex; 343 343 } 344 344 } … … 349 349 //インデクサ(getter)の戻り値を取得 350 350 bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo){ 351 std::vector<S UBINFO*> subs;351 std::vector<SubInfo *> subs; 352 352 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 353 353 if( subs.size() == 0 ){ … … 644 644 return 0; 645 645 } 646 S UBINFO*AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){646 SubInfo *AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){ 647 647 int i,i2,i3,sw; 648 648 DWORD dwType; … … 761 761 SubNum++; 762 762 763 SUBINFO *psi; 764 psi=(SUBINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(SUBINFO)); 763 SubInfo *pSub = new SubInfo(); 765 764 766 765 //クラス名 767 p si->pobj_ParentClass=pobj_c;766 pSub->pobj_ParentClass=pobj_c; 768 767 769 768 //ID 770 769 static int id_base=0; 771 p si->id=(id_base++);770 pSub->id=(id_base++); 772 771 773 772 //関数名 774 p si->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);775 lstrcpy(p si->name,temporary);773 pSub->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 774 lstrcpy(pSub->name,temporary); 776 775 777 776 //ソースコードの位置 778 p si->address=NowLine;779 780 p si->bExport=bExport;781 p si->bCdecl=bCdecl;782 p si->bVirtual=bVirtual;783 if(bExport) p si->bUse=1;784 else p si->bUse=0;785 p si->bCompile=0;786 p si->bSystem=0;787 788 p si->dwType=dwType;789 790 791 if(p si->dwType==SUBTYPE_FUNCTION){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){ 792 791 /////////////////// 793 792 // 戻り値を取得 794 793 /////////////////// 795 794 796 p si->isReturnRef = false;795 pSub->isReturnRef = false; 797 796 798 797 if(pobj_c){ 799 if(lstrcmp(p si->name,pobj_c->name)==0||800 p si->name[0]=='~'){798 if(lstrcmp(pSub->name,pobj_c->name)==0|| 799 pSub->name[0]=='~'){ 801 800 //クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす 802 801 SetError(115,NULL,NowLine); … … 814 813 if( buffer[i2-2] == 1 && buffer[i2-1] == ESC_BYREF ){ 815 814 //参照型 816 p si->isReturnRef = true;815 pSub->isReturnRef = true; 817 816 } 818 817 … … 827 826 temporary[i3]=buffer[i2]; 828 827 } 829 p si->ReturnType=GetTypeFixed(temporary,&psi->u.ReturnIndex);830 if(p si->ReturnType==DEF_NON) SetError(3,temporary,NowLine);828 pSub->ReturnType=GetTypeFixed(temporary,&pSub->u.ReturnIndex); 829 if(pSub->ReturnType==DEF_NON) SetError(3,temporary,NowLine); 831 830 832 831 sw_as=1; … … 836 835 837 836 if(!sw_as){ 838 SetError(-104,p si->name,NowLine);839 840 p si->ReturnType=DEF_DOUBLE;837 SetError(-104,pSub->name,NowLine); 838 839 pSub->ReturnType=DEF_DOUBLE; 841 840 } 842 841 } 843 842 else{ 844 843 //戻り値なしのSub定義 845 psi->ReturnType=DEF_NON; 846 psi->u.ReturnIndex=-1; 847 } 848 849 850 851 psi->pParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(PARAMETER_INFO)*2); 852 psi->ParmNum=0; 844 pSub->ReturnType=DEF_NON; 845 pSub->u.ReturnIndex=-1; 846 } 853 847 854 848 //パラメータ … … 860 854 if(buffer[i]!=')'&&pobj_c){ 861 855 //クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす 862 if(p si->name[0]=='~'){856 if(pSub->name[0]=='~'){ 863 857 SetError(114,NULL,NowLine); 864 858 i=JumpStringInPare(buffer,i); … … 868 862 if(buffer[i]==')') break; 869 863 870 psi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,psi->pParmInfo,(psi->ParmNum+1)*sizeof(PARAMETER_INFO)); 871 872 //ByVal 864 //ByRef 865 bool isRef; 873 866 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){ 874 psi->pParmInfo[psi->ParmNum].bByVal=1;867 isRef = false; 875 868 i+=2; 876 869 } 877 870 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){ 878 psi->pParmInfo[psi->ParmNum].bByVal=0;871 isRef = true; 879 872 i+=2; 880 873 } 881 else psi->pParmInfo[psi->ParmNum].bByVal=1;874 else isRef = false; 882 875 883 876 //パラメータ名 877 bool isArray = false; 878 int subScripts[MAX_ARRAYDIM]; 879 char name[VN_SIZE]; 884 880 sw=0; 885 881 for(i2=0;;i++,i2++){ … … 887 883 if(!sw) sw=1; 888 884 889 i3=GetStringInPare( temporary+i2,buffer+i);885 i3=GetStringInPare(name+i2,buffer+i); 890 886 i2+=i3-1; 891 887 i+=i3-1; … … 895 891 if(!sw) sw=1; 896 892 897 i3=GetStringInBracket( temporary+i2,buffer+i);893 i3=GetStringInBracket(name+i2,buffer+i); 898 894 i2+=i3-1; 899 895 i+=i3-1; … … 901 897 } 902 898 if(!IsVariableChar(buffer[i])){ 903 temporary[i2]=0;899 name[i2]=0; 904 900 break; 905 901 } 906 temporary[i2]=buffer[i];902 name[i2]=buffer[i]; 907 903 } 908 904 if(sw){ 909 905 //配列パラメータ 910 if( psi->pParmInfo[psi->ParmNum].bByVal) SetError(29,NULL,NowLine);911 psi->pParmInfo[psi->ParmNum].bArray=1;912 913 if(( temporary[i2-2]=='('&&temporary[i2-1]==')')||914 ( temporary[i2-2]=='['&&temporary[i2-1]==']')){915 psi->pParmInfo[psi->ParmNum].SubScripts[0]=LONG_MAX;916 psi->pParmInfo[psi->ParmNum].SubScripts[1]=-1;917 918 temporary[i2-2]=0;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; 919 915 } 920 916 else{ 921 GetArrange(temporary,temp2,psi->pParmInfo[psi->ParmNum].SubScripts); 922 lstrcpy(temporary,temp2); 923 } 924 925 i2=lstrlen(temporary); 926 } 927 else{ 928 psi->pParmInfo[psi->ParmNum].bArray=0; 929 psi->pParmInfo[psi->ParmNum].SubScripts[0]=-1; 930 } 931 psi->pParmInfo[psi->ParmNum].name=(char *)HeapAlloc(hHeap,0,i2+1); 932 lstrcpy(psi->pParmInfo[psi->ParmNum].name,temporary); 917 GetArrange(name,temp2,subScripts); 918 lstrcpy(name,temp2); 919 } 920 921 i2=lstrlen(name); 922 } 933 923 934 924 //型 925 Type type( DEF_NON ); 935 926 if(buffer[i]==1&&buffer[i+1]==ESC_AS){ 936 927 i+=2; … … 955 946 } 956 947 957 psi->pParmInfo[psi->ParmNum].type= 958 GetTypeFixed(temporary,&psi->pParmInfo[psi->ParmNum].u.index); 948 Type::StringToType( temporary, type ); 959 949 960 950 if(temporary[0]=='*'&& … … 963 953 if(buffer[i]!='('){ 964 954 SetError(10,temporary,NowLine); 965 return 0;955 break; 966 956 } 967 957 i3=GetStringInPare(temporary+i2,buffer+i); … … 986 976 } 987 977 988 if( psi->pParmInfo[psi->ParmNum].type==-1){978 if( type.IsNull() ){ 989 979 SetError(3,temporary,NowLine); 990 psi->pParmInfo[psi->ParmNum].type=DEF_PTR_VOID; 991 } 992 993 /*未完成(構造体パラメータを値参照として渡してよいものか!?) 994 if(psi->pParmInfo[psi->ParmNum].type==DEF_OBJECT){ 995 if(psi->pParmInfo[psi->ParmNum].bByVal) SetError(28,temporary,NowLine); 996 }*/ 980 type.SetBasicType( DEF_PTR_VOID ); 981 } 997 982 } 998 983 else{ 999 psi->pParmInfo[psi->ParmNum].type=GetTypeFromSimpleName(temporary);984 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 1000 985 SetError(-103,temporary,NowLine); 1001 986 } 1002 987 1003 if( psi->pParmInfo[psi->ParmNum].type==DEF_PTR_PROC){988 if( type.IsProcPtr() ){ 1004 989 //関数ポインタの場合 1005 psi->pParmInfo[psi->ParmNum].u.index=AddProcPtrInfo(temporary+3,temporary[2]); 1006 } 1007 1008 //パラメータの数を更新 1009 psi->ParmNum++; 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 ); 1010 1000 1011 1001 if(buffer[i]==','){ … … 1016 1006 else{ 1017 1007 SetError(1,NULL,NowLine); 1018 return 0;1019 } 1020 } 1021 p si->SecondParmNum=psi->ParmNum;1008 break; 1009 } 1010 } 1011 pSub->SecondParmNum = (int)pSub->params.size(); 1022 1012 i++; 1023 1013 if(buffer[i]=='('){ … … 1026 1016 if(buffer[i]==')') break; 1027 1017 1028 psi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,psi->pParmInfo,(psi->ParmNum+1)*sizeof(PARAMETER_INFO)); 1029 1030 //ByVal 1018 //ByRef 1019 bool isRef; 1031 1020 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){ 1032 psi->pParmInfo[psi->ParmNum].bByVal=1;1021 isRef = false; 1033 1022 i+=2; 1034 1023 } 1035 1024 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){ 1036 psi->pParmInfo[psi->ParmNum].bByVal=0;1025 isRef = true; 1037 1026 i+=2; 1038 1027 } 1039 else psi->pParmInfo[psi->ParmNum].bByVal=1;1028 else isRef = false; 1040 1029 1041 1030 //パラメータ名 1031 bool isArray = false; 1032 int subScripts[MAX_ARRAYDIM]; 1033 char name[VN_SIZE]; 1042 1034 sw=0; 1043 1035 for(i2=0;;i++,i2++){ … … 1045 1037 if(!sw) sw=1; 1046 1038 1047 i3=GetStringInPare( temporary+i2,buffer+i);1039 i3=GetStringInPare(name+i2,buffer+i); 1048 1040 i2+=i3-1; 1049 1041 i+=i3-1; … … 1053 1045 if(!sw) sw=1; 1054 1046 1055 i3=GetStringInBracket( temporary+i2,buffer+i);1047 i3=GetStringInBracket(name+i2,buffer+i); 1056 1048 i2+=i3-1; 1057 1049 i+=i3-1; … … 1059 1051 } 1060 1052 if(!IsVariableChar(buffer[i])){ 1061 temporary[i2]=0;1053 name[i2]=0; 1062 1054 break; 1063 1055 } 1064 temporary[i2]=buffer[i];1056 name[i2]=buffer[i]; 1065 1057 } 1066 1058 if(sw){ 1067 1059 //配列パラメータ 1068 if( psi->pParmInfo[psi->ParmNum].bByVal) SetError(29,NULL,NowLine);1069 psi->pParmInfo[psi->ParmNum].bArray=1;1070 1071 if(( temporary[i2-2]=='('&&temporary[i2-1]==')')||1072 ( temporary[i2-2]=='['&&temporary[i2-1]==']')){1073 psi->pParmInfo[psi->ParmNum].SubScripts[0]=LONG_MAX;1074 psi->pParmInfo[psi->ParmNum].SubScripts[1]=-1;1075 1076 temporary[i2-2]=0;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; 1077 1069 } 1078 1070 else{ 1079 GetArrange(temporary,temp2,psi->pParmInfo[psi->ParmNum].SubScripts); 1080 lstrcpy(temporary,temp2); 1081 } 1082 1083 i2=lstrlen(temporary); 1084 } 1085 else{ 1086 psi->pParmInfo[psi->ParmNum].bArray=0; 1087 psi->pParmInfo[psi->ParmNum].SubScripts[0]=-1; 1088 } 1089 psi->pParmInfo[psi->ParmNum].name=(char *)HeapAlloc(hHeap,0,i2+1); 1090 lstrcpy(psi->pParmInfo[psi->ParmNum].name,temporary); 1071 GetArrange(name,temp2,subScripts); 1072 lstrcpy(name,temp2); 1073 } 1074 1075 i2=lstrlen(name); 1076 } 1091 1077 1092 1078 //型 1079 Type type( DEF_NON ); 1093 1080 if(buffer[i]==1&&buffer[i+1]==ESC_AS){ 1094 1081 i+=2; 1082 1095 1083 i2=0; 1096 1084 while(buffer[i]=='*'){ … … 1101 1089 for(;;i++,i2++){ 1102 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 } 1103 1096 temporary[i2]=0; 1104 1097 break; … … 1106 1099 temporary[i2]=buffer[i]; 1107 1100 } 1108 psi->pParmInfo[psi->ParmNum].type= 1109 GetTypeFixed(temporary,&psi->pParmInfo[psi->ParmNum].u.index); 1110 if(psi->pParmInfo[psi->ParmNum].type==-1) SetError(3,temporary,NowLine); 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 } 1111 1136 } 1112 1137 else{ 1113 psi->pParmInfo[psi->ParmNum].type=GetTypeFromSimpleName(temporary);1138 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 1114 1139 SetError(-103,temporary,NowLine); 1115 1140 } 1116 1141 1117 psi->ParmNum++; 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 ); 1118 1154 1119 1155 if(buffer[i]==','){ … … 1124 1160 else{ 1125 1161 SetError(1,NULL,NowLine); 1126 return 0;1162 break; 1127 1163 } 1128 1164 } … … 1130 1166 } 1131 1167 1132 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する) 1133 psi->pRealParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,0,(psi->ParmNum+2)*sizeof(PARAMETER_INFO)); 1134 psi->RealParmNum=0; 1168 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する場合がある) 1135 1169 1136 1170 if(pobj_c&&bStatic==0){ 1137 i = psi->RealParmNum;1138 1139 1171 //オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用 1140 psi->pRealParmInfo[i].name = "_System_LocalThis"; 1141 psi->pRealParmInfo[i].type=DEF_PTR_VOID; 1142 psi->pRealParmInfo[i].u.index=-1; 1143 psi->pRealParmInfo[i].bByVal=1; 1144 psi->pRealParmInfo[i].bArray=0; 1145 psi->pRealParmInfo[i].SubScripts[0]=-1; 1146 1147 psi->RealParmNum++; 1148 } 1149 1150 if(psi->ReturnType==DEF_STRUCT){ 1151 i = psi->RealParmNum; 1152 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){ 1153 1178 //構造体を戻り値として持つ場合 1154 1179 //※第一パラメータ(Thisポインタありの場合は第二パラメータ)を戻り値用の参照宣言にする 1155 1180 1156 if(psi->name[0]==1&&psi->name[1]==ESC_OPERATOR) 1157 psi->pRealParmInfo[i].name="_System_ReturnValue"; 1158 else psi->pRealParmInfo[i].name=psi->name; 1159 psi->pRealParmInfo[i].type=DEF_STRUCT; 1160 psi->pRealParmInfo[i].u.index=psi->u.ReturnIndex; 1161 psi->pRealParmInfo[i].bByVal=0; 1162 psi->pRealParmInfo[i].bArray=0; 1163 psi->pRealParmInfo[i].SubScripts[0]=-1; 1164 1165 psi->RealParmNum++; 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 ) ); 1166 1187 } 1167 1188 1168 1189 //パラメータをコピー 1169 for ( i = 0; i < psi->ParmNum; i++, psi->RealParmNum++){1170 p si->pRealParmInfo[psi->RealParmNum]=psi->pParmInfo[i];1190 foreach( Parameter *pParam, pSub->params ){ 1191 pSub->realParams.push_back( new Parameter( *pParam ) ); 1171 1192 } 1172 1193 … … 1177 1198 1178 1199 int key; 1179 key=hash_default(p si->name);1180 1181 extern S UBINFO**ppSubHash;1200 key=hash_default(pSub->name); 1201 1202 extern SubInfo **ppSubHash; 1182 1203 if(ppSubHash[key]){ 1183 S UBINFO*psi2;1204 SubInfo *psi2; 1184 1205 psi2=ppSubHash[key]; 1185 1206 while(1){ 1186 1207 if(pobj_c==psi2->pobj_ParentClass){ 1187 1208 //重複エラーチェックを行う 1188 if(lstrcmp(psi2->name,p si->name)==0){1189 if( CompareParameter(psi2->pParmInfo,psi2->ParmNum,psi->pParmInfo,psi->ParmNum)==0){1190 SetError(15,p si->name,NowLine);1209 if(lstrcmp(psi2->name,pSub->name)==0){ 1210 if( Parameter::Equals( psi2->params, pSub->params ) ){ 1211 SetError(15,pSub->name,NowLine); 1191 1212 return 0; 1192 1213 } … … 1197 1218 psi2=psi2->pNextData; 1198 1219 } 1199 psi2->pNextData=p si;1220 psi2->pNextData=pSub; 1200 1221 } 1201 1222 else{ 1202 ppSubHash[key]=p si;1203 } 1204 1205 return p si;1223 ppSubHash[key]=pSub; 1224 } 1225 1226 return pSub; 1206 1227 } 1207 1228 … … 1217 1238 1218 1239 //サブルーチン(ユーザー定義)情報を初期化 1219 extern S UBINFO**ppSubHash;1240 extern SubInfo **ppSubHash; 1220 1241 extern int SubNum; 1221 ppSubHash=(S UBINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SUBINFO*));1242 ppSubHash=(SubInfo **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SubInfo *)); 1222 1243 SubNum=0; 1223 1244 … … 1313 1334 AddSubData(temporary,0,0,0); 1314 1335 } 1315 void Delete_si(SUBINFO *psi){ 1316 int i2; 1317 1318 for(i2=0;i2<psi->ParmNum;i2++){ 1319 HeapDefaultFree(psi->pParmInfo[i2].name); 1320 } 1321 HeapDefaultFree(psi->pRealParmInfo); 1322 if(psi->pParmInfo) HeapDefaultFree(psi->pParmInfo); 1323 psi->pRealParmInfo=0; 1324 psi->pParmInfo=0; 1325 1326 if(psi->pNextData) Delete_si(psi->pNextData); 1327 1328 HeapDefaultFree(psi->name); 1329 HeapDefaultFree(psi); 1330 } 1331 void DeleteSubInfo(SUBINFO **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放 1336 void 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 } 1350 void DeleteSubInfo(SubInfo **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放 1332 1351 int i; 1333 1352 for(i=0;i<MAX_HASH;i++){
Note:
See TracChangeset
for help on using the changeset viewer.