Changeset 79 in dev for BasicCompiler_Common/VariableOpe.cpp
- Timestamp:
- Mar 25, 2007, 5:58:57 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/VariableOpe.cpp
r78 r79 179 179 return MAKE_PTR_TYPE(NATURAL_TYPE(type),PTR_LEVEL(type)+1); 180 180 } 181 int GetTypeFixed(const char *TypeName,LONG_PTR *lpNum){182 int type;183 184 if(lpNum) *lpNum=-1;185 186 if(TypeName[0]=='*'){187 if(TypeName[1]==1&&(TypeName[2]==ESC_FUNCTION||TypeName[2]==ESC_SUB)){188 //関数ポインタ(*Function)189 return DEF_PTR_PROC;190 }191 192 type=GetTypeFixed(TypeName+1,lpNum);193 if(type==-1) return -1;194 195 return GetPtrType(type);196 }197 198 //整数型199 if(lstrcmpi(TypeName,"SByte")==0) return DEF_SBYTE;200 else if(lstrcmpi(TypeName,"Byte")==0) return DEF_BYTE;201 else if(lstrcmpi(TypeName,"Integer")==0) return DEF_INTEGER;202 else if(lstrcmpi(TypeName,"WORD")==0) return DEF_WORD;203 else if(lstrcmpi(TypeName,"Long")==0) return DEF_LONG;204 else if(lstrcmpi(TypeName,"DWORD")==0) return DEF_DWORD;205 else if(lstrcmpi(TypeName,"Int64")==0) return DEF_INT64;206 else if(lstrcmpi(TypeName,"QWORD")==0) return DEF_QWORD;207 208 //実数型209 else if(lstrcmpi(TypeName,"Single")==0) return DEF_SINGLE;210 else if(lstrcmpi(TypeName,"Double")==0) return DEF_DOUBLE;211 212 //文字型213 //else if( lstrcmpi( TypeName, "Char" ) == 0 ) return DEF_CHAR;214 215 //bool型216 else if( lstrcmpi( TypeName, "Boolean" ) == 0 ) return DEF_BOOLEAN;217 218 //ポインタ型219 //※VoidPtr型以外のポインタ型はTypeDef宣言により定義される220 else if(lstrcmpi(TypeName,"VoidPtr")==0) return DEF_PTR_VOID;221 222 //その他223 else if(lstrcmpi(TypeName,"Any")==0) return DEF_ANY;224 225 226 ////////////////////227 // TypeDefされた型228 ////////////////////229 int i;230 i=House::typeDefs.GetIndex(TypeName);231 if(i!=-1){232 *lpNum = House::typeDefs[i].GetBaseType().GetIndex();233 return House::typeDefs[i].GetBaseType().GetBasicType();234 }235 236 if(!lpNum) return -1;237 238 //クラス239 CClass *pobj_c;240 pobj_c=pobj_DBClass->check(TypeName);241 if(pobj_c){242 *lpNum=(LONG_PTR)pobj_c;243 244 if( pobj_c->IsStructure() ){245 return DEF_STRUCT;246 }247 else{248 return DEF_OBJECT;249 }250 }251 252 return -1;253 }254 /*255 TODO: 消す(TypeDef関連の変更)256 void GetOriginalTypeName_Old(char *buffer){257 // TypeDefされた型に対して、オリジナルの型の名前に変更する258 259 if(buffer[0]=='*'){260 if(buffer[1]==1&&(buffer[2]==ESC_FUNCTION||buffer[2]==ESC_SUB)) return;261 262 GetOriginalTypeName_Old(buffer+1);263 return;264 }265 266 int i;267 i=House::typeDefs.GetIndex(buffer);268 if(i!=-1){269 lstrcpy(buffer,House::typeDefs[i].GetBaseName().c_str());270 GetOriginalTypeName_Old(buffer);271 }272 }*/273 181 BOOL GetTypeName(int type,LONG_PTR lpIndex,char *name){ 274 182 if(PTR_LEVEL(type)){ … … 948 856 // 初期化データが指定されいるとき 949 857 //////////////////////////////////// 950 951 for(i++,i2=0,IsStr=0;;i++,i2++){ 952 if(buffer[i]=='\"') IsStr^=1; 953 if(buffer[i]=='('&&IsStr==0){ 954 i3=GetStringInPare(InitBuf+i2,buffer+i); 955 i+=i3-1; 956 i2+=i3-1; 957 continue; 958 } 959 if(buffer[i]=='['&&IsStr==0){ 960 i3=GetStringInBracket(InitBuf+i2,buffer+i); 961 i+=i3-1; 962 i2+=i3-1; 963 continue; 964 } 965 if((buffer[i]==1&&buffer[i+1]==ESC_AS)|| 966 (buffer[i]==','&&IsStr==0)|| 967 buffer[i]=='\0'){ 968 InitBuf[i2]=0; 969 break; 970 } 971 InitBuf[i2]=buffer[i]; 858 i++; 859 860 if( buffer[i]=='[' ){ 861 // 構造初期データの場合 862 863 i3=GetStringInBracket(InitBuf,buffer+i); 864 i+=i3; 865 } 866 else{ 867 // 代入初期データの場合 868 869 for(i2=0,IsStr=0;;i++,i2++){ 870 if(buffer[i]=='\"') IsStr^=1; 871 if(buffer[i]=='('&&IsStr==0){ 872 i3=GetStringInPare(InitBuf+i2,buffer+i); 873 i+=i3-1; 874 i2+=i3-1; 875 continue; 876 } 877 if(buffer[i]=='['&&IsStr==0){ 878 i3=GetStringInBracket(InitBuf+i2,buffer+i); 879 i+=i3-1; 880 i2+=i3-1; 881 continue; 882 } 883 if((buffer[i]==','&&IsStr==0)|| 884 buffer[i]=='\0'){ 885 InitBuf[i2]=0; 886 break; 887 } 888 InitBuf[i2]=buffer[i]; 889 } 972 890 } 973 891 } … … 1052 970 return false; 1053 971 } 972 973 if( IS_LITERAL( type.GetIndex() ) ){ 974 type.SetIndex( -1 ); 975 } 1054 976 } 1055 977 … … 1099 1021 1100 1022 1101 void AddGlobalVariable( bool isRef,const char *name,int *SubScripts, const Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlag){1023 void AddGlobalVariable( const char *name,int *SubScripts, const Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlag){ 1102 1024 ///////////////////////// 1103 1025 // グローバル変数を追加 … … 1114 1036 bool isConst = ( dwFlag & DIMFLAG_CONST ) ? true:false; 1115 1037 1116 Variable *pVar = new Variable( name, type, isConst , isRef);1038 Variable *pVar = new Variable( name, type, isConst ); 1117 1039 1118 1040 if( SubScripts[0] != -1 ){ … … 1217 1139 char VarName[VN_SIZE]; 1218 1140 1219 //参照型かどうか1220 bool isRef = false;1221 1222 1141 i2 = 0; 1223 1142 1224 1143 if( Parameter[i2] == 1 && Parameter[i2+1] == ESC_BYREF ){ 1225 1144 //参照型 1226 isRef = true;1145 SetError(); 1227 1146 Parameter += 2; 1228 1147 } … … 1290 1209 GetNowStaticVarFullName(VarName,temporary); 1291 1210 1292 dim( isRef,temporary,SubScripts,type,InitBuf,ConstractParameter,dwFlags );1211 dim( temporary,SubScripts,type,InitBuf,ConstractParameter,dwFlags ); 1293 1212 1294 1213 /* … … 1298 1217 } 1299 1218 else{ 1300 dim( isRef,VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags );1219 dim( VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags ); 1301 1220 } 1302 1221 }
Note:
See TracChangeset
for help on using the changeset viewer.