Changeset 103 in dev
- Timestamp:
- May 2, 2007, 4:08:58 AM (18 years ago)
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/MakePeHdr.cpp
r100 r103 351 351 352 352 if(!bDll){ 353 // 名前空間が初期化されているかをチェック 354 if( Smoothie::Lexical::liveingNamespaceScopes.size() ){ 355 SetError(); 356 } 357 353 358 //ラベル用のメモリを確保 354 359 extern LABEL *pLabelNames; … … 445 450 HeapDefaultFree(WithInfo.ppName); 446 451 HeapDefaultFree(WithInfo.pWithCp); 452 453 // 名前空間が正しく閉じられているかをチェック 454 if( Smoothie::Lexical::liveingNamespaceScopes.size() ){ 455 SetError(63,NULL,-1); 456 } 457 447 458 } 448 459 else{ -
BasicCompiler32/NumOpe.cpp
r102 r103 257 257 Type leftType; 258 258 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){ 259 return false;259 goto globalArea; 260 260 } 261 261 … … 836 836 ////////////// 837 837 838 i3 = CDBConst::obj.Get Type(term);838 i3 = CDBConst::obj.GetBasicType(term); 839 839 if(i3){ 840 if( CDBConst::obj.IsStringPtr( term ) ){ 841 //リテラル文字列 842 843 double dbl = CDBConst::obj.GetDoubleData(term); 844 memcpy(&i64data,&dbl,sizeof(double)); 845 846 //バイト数 847 i3=lstrlen((char *)i64data); 848 849 memcpy(term,(char *)i64data,i3); 850 term[i3]=0; 851 goto StrLiteral; 852 } 853 840 854 type_stack[sp]=i3; 841 855 if(IsRealNumberType(i3)){ … … 850 864 goto Literal; 851 865 } 852 /*else if(i3==DEF_STRING){853 //リテラル文字列854 855 //バイト数856 i3=(int)dbl;857 858 memcpy(term,temporary,i3);859 goto StrLiteral;860 }*/861 866 else{ 862 867 SetError(300,NULL,cp); -
BasicCompiler64/Compile_Var.cpp
r97 r103 562 562 if(member[0]){ 563 563 lstrcpy(temporary,member); 564 565 // TODO: 名前空間を考慮したコードになっていない 564 566 565 567 char tempMember[VN_SIZE]; -
BasicCompiler64/MakePeHdr.cpp
r100 r103 302 302 303 303 if(!bDll){ 304 // 名前空間が初期化されているかをチェック 305 if( Smoothie::Lexical::liveingNamespaceScopes.size() ){ 306 SetError(); 307 } 308 304 309 //ラベル用のメモリを確保 305 310 extern LABEL *pLabelNames; … … 411 416 HeapDefaultFree(WithInfo.ppName); 412 417 HeapDefaultFree(WithInfo.pWithCp); 418 419 // 名前空間が正しく閉じられているかをチェック 420 if( Smoothie::Lexical::liveingNamespaceScopes.size() ){ 421 SetError(63,NULL,-1); 422 } 423 413 424 } 414 425 else{ -
BasicCompiler64/NumOpe.cpp
r102 r103 239 239 lstrcpy(termLeft,termFull); 240 240 241 if( (string)term=="DayOfWeek"){242 int test=0;243 }244 245 241 // パース 246 242 char member[VN_SIZE]; … … 258 254 Type leftType; 259 255 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){ 260 return false;256 goto globalArea; 261 257 } 262 258 … … 273 269 return TermMemberOpe( leftType.GetClass(), baseType, resultType, termFull, termLeft, member ); 274 270 } 275 271 globalArea: 276 272 277 273 ////////////////////////////////////////////// … … 290 286 // グローバル属性エリア 291 287 ///////////////////////////////////////////////////////////////// 292 globalArea:293 288 294 289 int UseReg=pobj_reg->GetNextReg(); … … 783 778 // 何らかの識別子 784 779 780 if( (string)term=="ParentArea.NamespaceEnumTest.x"){ 781 int test=0; 782 } 783 785 784 bool isLiteral; 786 785 if( TermOpe( term, baseType, resultType, isLiteral, &bUseHeap[sp] ) ){ … … 870 869 ////////////// 871 870 872 i3 = CDBConst::obj.Get Type(term);871 i3 = CDBConst::obj.GetBasicType(term); 873 872 if(i3){ 873 if( CDBConst::obj.IsStringPtr( term ) ){ 874 //リテラル文字列 875 876 double dbl = CDBConst::obj.GetDoubleData(term); 877 memcpy(&i64data,&dbl,sizeof(double)); 878 879 //バイト数 880 i3=lstrlen((char *)i64data); 881 882 memcpy(term,(char *)i64data,i3); 883 term[i3]=0; 884 goto StrLiteral; 885 } 886 874 887 type_stack[sp] = i3; 875 888 if(IsRealNumberType(i3)){ -
BasicCompiler_Common/Compile.cpp
r99 r103 222 222 223 223 case ESC_NAMESPACE: 224 Smoothie::Lexical::liveingNamespaceScopes.push_back( Command + 2 ); 225 break; 224 226 case ESC_ENDNAMESPACE: 227 if( Smoothie::Lexical::liveingNamespaceScopes.size() <= 0 ){ 228 SetError(12,"End Namespace",cp); 229 } 230 Smoothie::Lexical::liveingNamespaceScopes.pop_back(); 225 231 break; 226 232 -
BasicCompiler_Common/Const.cpp
r75 r103 7 7 8 8 9 CConstBase::CConstBase(char *Name){ 10 this->Name = (char *)malloc(lstrlen(Name)+1); 11 lstrcpy(this->Name, Name); 12 } 13 CConstBase::~CConstBase(){ 14 free(Name); 15 Name=0; 16 } 17 18 char *CConstBase::GetName(){ 19 return Name; 20 } 21 22 23 24 CConst::CConst(char *Name, int Type, _int64 i64data):CConstBase(Name) 25 { 26 this->Type = Type; 27 this->i64data = i64data; 28 29 //連結リストを初期化 30 pNext = 0; 31 } 32 CConst::CConst(char *Name, int value):CConstBase(Name) 33 { 34 Type = DEF_LONG; 35 i64data = value; 36 37 //連結リストを初期化 38 pNext = 0; 9 bool ConstBase::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 10 { 11 if( GetName() != name ){ 12 return false; 13 } 14 return NamespaceScopes::IsSameArea( this->namespaceScopes, namespaceScopes ); 15 } 16 bool ConstBase::IsEqualSymbol( const string &fullName ) const 17 { 18 char AreaName[VN_SIZE] = ""; //オブジェクト変数 19 char NestName[VN_SIZE] = ""; //入れ子メンバ 20 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 21 22 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName ); 23 } 24 25 26 27 28 CConst::CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, _int64 i64data) 29 : ConstBase( namespaceScopes, name ) 30 , type( type ) 31 , i64data( i64data ) 32 , pNext( NULL ) 33 { 34 } 35 CConst::CConst( const NamespaceScopes &namespaceScopes, const string &name, int value) 36 : ConstBase( namespaceScopes, name ) 37 , type( Type(DEF_LONG) ) 38 , i64data( value ) 39 , pNext( NULL ) 40 { 39 41 } 40 42 CConst::~CConst(){ … … 46 48 } 47 49 48 intCConst::GetType(){49 return Type;50 Type CConst::GetType(){ 51 return type; 50 52 } 51 53 _int64 CConst::GetWholeData(){ … … 60 62 61 63 62 CConstMacro::CConstMacro(char *Name, char *Expression):CConstBase(Name) 64 CConstMacro::CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression) 65 : ConstBase( namespaceScopes, name ) 63 66 { 64 67 } … … 99 102 100 103 void AddConstData(char *Command); 101 void CDBConst::Add( char *buffer){104 void CDBConst::Add( const NamespaceScopes &namespaceScopes, char *buffer ){ 102 105 int i; 103 106 … … 117 120 118 121 //重複チェック 119 if(Get Type(Name)){122 if(GetBasicType(Name)){ 120 123 SetError(15,Name,cp); 121 124 return; … … 132 135 char *Expression = buffer + i + 1; 133 136 134 AddConst( Name,Expression);135 } 136 } 137 138 void CDBConst::AddConst( char *Name, CConst *newconst){139 int key = hash_default( Name);137 AddConst( namespaceScopes, Name,Expression); 138 } 139 } 140 141 void CDBConst::AddConst( const string &name, CConst *newconst){ 142 int key = hash_default(name.c_str()); 140 143 141 144 //ハッシュリストに追加 … … 152 155 } 153 156 } 154 void CDBConst::AddConst( char *Name, char *Expression){157 void CDBConst::AddConst( const NamespaceScopes &namespaceScopes, const string &name , char *Expression){ 155 158 _int64 i64data; 156 159 Type resultType; … … 164 167 //登録を行う 165 168 166 CConst *newconst = new CConst(Name, resultType.GetBasicType(), i64data); 167 168 AddConst(Name, newconst); 169 } 170 void CDBConst::AddConst(char *Name, int value){ 171 CConst *newconst = new CConst(Name, value); 172 173 AddConst(Name, newconst); 174 } 175 176 CConst *CDBConst::GetObjectPtr(char *Name){ 169 CConst *newconst = new CConst(namespaceScopes, name, resultType, i64data); 170 171 AddConst( name, newconst); 172 } 173 void CDBConst::AddConst(const NamespaceScopes &namespaceScopes, const string &name, int value){ 174 CConst *newconst = new CConst( namespaceScopes, name, value); 175 176 AddConst(name, newconst); 177 } 178 179 CConst *CDBConst::GetObjectPtr( const string &name ){ 180 char ObjName[VN_SIZE]; //オブジェクト変数 181 char NestMember[VN_SIZE]; //入れ子メンバ 182 bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember ); 183 177 184 //ハッシュ値を取得 178 185 int key; 179 key=hash_default( Name);186 key=hash_default( NestMember ); 180 187 181 188 //格納位置を取得 … … 183 190 pConst=ppHash[key]; 184 191 while(pConst){ 185 if( lstrcmp(pConst->GetName(),Name)==0) break;192 if( pConst->IsEqualSymbol( name ) ) break; 186 193 187 194 pConst=pConst->pNext; … … 192 199 193 200 194 int CDBConst::Get Type(char *Name){201 int CDBConst::GetBasicType(char *Name){ 195 202 CConst *pConst = GetObjectPtr(Name); 196 203 197 204 if(!pConst) return 0; 198 205 199 return pConst->GetType() ;206 return pConst->GetType().GetBasicType(); 200 207 } 201 208 _int64 CDBConst::GetWholeData(char *Name){ … … 213 220 return pConst->GetDoubleData(); 214 221 } 222 bool CDBConst::IsStringPtr( char *Name ){ 223 CConst *pConst = GetObjectPtr(Name); 224 225 if(!pConst) return false; 226 227 const Type &type = pConst->GetType(); 228 229 return ( type.GetBasicType() == typeOfPtrChar && type.GetIndex() == LITERAL_STRING ); 230 } -
BasicCompiler_Common/Const.h
r7 r103 2 2 3 3 //定数の基底クラス 4 class CConstBase{ 5 char *Name; 4 class ConstBase{ 5 const string name; 6 const NamespaceScopes namespaceScopes; 6 7 7 8 public: 8 9 9 CConstBase(char *Name); 10 ~CConstBase(); 10 ConstBase( const NamespaceScopes &namespaceScopes, const string &name ) 11 : namespaceScopes( namespaceScopes ) 12 , name( name ) 13 { 14 } 15 ~ConstBase() 16 { 17 } 11 18 12 char *GetName(); 19 const string &GetName() const 20 { 21 return name; 22 } 23 24 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 25 bool IsEqualSymbol( const string &name ) const; 13 26 }; 14 27 15 28 //定数 16 class CConst:public C ConstBase{17 int Type;29 class CConst:public ConstBase{ 30 Type type; 18 31 _int64 i64data; 19 32 … … 21 34 CConst *pNext; 22 35 23 CConst( char *Name, int Type, _int64 i64data);24 CConst( char *Name, int value);36 CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, _int64 i64data); 37 CConst( const NamespaceScopes &namespaceScopes, const string &name, int value); 25 38 ~CConst(); 26 39 27 intGetType();40 Type GetType(); 28 41 _int64 GetWholeData(); 29 42 double GetDoubleData(); … … 31 44 32 45 //定数マクロ 33 class CConstMacro:public C ConstBase{46 class CConstMacro:public ConstBase{ 34 47 int ParmNum; 35 48 char **ppParm; 36 49 public: 37 50 38 CConstMacro( char *Name, char *Expression);51 CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 39 52 ~CConstMacro(); 40 53 }; … … 57 70 void Init(); 58 71 59 void Add( char *buffer);72 void Add( const NamespaceScopes &namespaceScopes, char *buffer); 60 73 private: 61 void AddConst( char *Name, CConst *newconst);74 void AddConst( const string &name, CConst *newconst); 62 75 public: 63 void AddConst( char *Name, char *Expression);64 void AddConst( char *Name, int value);76 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 77 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value); 65 78 66 79 private: 67 CConst *GetObjectPtr( char *Name);80 CConst *GetObjectPtr( const string &name ); 68 81 public: 69 82 70 int Get Type(char *Name);83 int GetBasicType(char *Name); 71 84 _int64 GetWholeData(char *Name); 72 85 double GetDoubleData(char *Name); 86 bool IsStringPtr(char *Name); 73 87 74 88 -
BasicCompiler_Common/Enum.cpp
r92 r103 15 15 16 16 17 CEnumParent::CEnumParent(const char *buffer,int nowLine){ 17 CEnumParent::CEnumParent( const NamespaceScopes &namespaceScopes, const char *buffer,int nowLine) 18 : namespaceScopes( namespaceScopes ) 19 { 18 20 ppobj_EnumMember=(CEnumMember **)HeapAlloc(hHeap,0,1); 19 21 iEnumMemberNum=0; … … 38 40 } 39 41 40 TypeName=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 41 lstrcpy(TypeName,temporary); 42 name = temporary; 42 43 43 44 if(buffer[i]=='\0'){ … … 93 94 } 94 95 CEnumParent::~CEnumParent(){ 95 HeapDefaultFree(TypeName);96 97 96 int i; 98 97 for(i=0;i<iEnumMemberNum;i++){ … … 110 109 const char *source = Smoothie::Lexical::source.GetBuffer(); 111 110 112 int i; 113 for(i=0;;i++){ 111 // 名前空間管理 112 NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes; 113 namespaceScopes.clear(); 114 115 int i2; 116 char temporary[VN_SIZE]; 117 for(int i=0;;i++){ 114 118 if(source[i]=='\0') break; 119 120 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 121 for(i+=2,i2=0;;i2++,i++){ 122 if( IsCommandDelimitation( source[i] ) ){ 123 temporary[i2]=0; 124 break; 125 } 126 temporary[i2]=source[i]; 127 } 128 namespaceScopes.push_back( temporary ); 129 130 continue; 131 } 132 else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){ 133 if( namespaceScopes.size() <= 0 ){ 134 SetError(12, "End Namespace", i ); 135 } 136 else{ 137 namespaceScopes.pop_back(); 138 } 139 140 i += 2; 141 continue; 142 } 115 143 116 144 if(source[i]==1&&source[i+1]==ESC_ENUM){ … … 119 147 } 120 148 ppobj_EnumParent=(CEnumParent **)HeapReAlloc(hHeap,0,ppobj_EnumParent,(iEnumParentNum+1)*sizeof(CEnumParent *)); 121 ppobj_EnumParent[iEnumParentNum]=new CEnumParent( source+i,i);149 ppobj_EnumParent[iEnumParentNum]=new CEnumParent( namespaceScopes, source+i,i); 122 150 iEnumParentNum++; 123 151 } … … 133 161 134 162 char *CEnumParent::GenerateCodes(void){ 135 int i,i2;136 137 163 char *buffer; 138 164 int MaxSize,length; … … 143 169 buffer[0]=0; 144 170 145 for(i =0;i<iEnumParentNum;i++){171 for(int i=0;i<iEnumParentNum;i++){ 146 172 CEnumParent *parent; 147 173 parent=ppobj_EnumParent[i]; 148 174 149 sprintf(buffer+length,"Class Enum %s\n",parent->TypeName); 175 BOOST_FOREACH( const string &namespaceStr, parent->GetNamespaceScopes() ){ 176 sprintf(buffer+length,"Namespace %s\n",namespaceStr.c_str()); 177 length+=lstrlen(buffer+length); 178 } 179 180 sprintf(buffer+length,"Class Enum %s\n",parent->GetName().c_str()); 150 181 length+=lstrlen(buffer+length); 151 182 lstrcpy(buffer+length,"\tInherits EnumBase\n"); 152 183 length+=lstrlen(buffer+length); 153 sprintf(buffer+length,"\tSub %s(value As Long,lpszName As LPSTR)\n",parent-> TypeName);184 sprintf(buffer+length,"\tSub %s(value As Long,lpszName As LPSTR)\n",parent->GetName().c_str()); 154 185 length+=lstrlen(buffer+length); 155 186 lstrcpy(buffer+length,"\t\tEnumBase(value,lpszName)\n"); … … 159 190 lstrcpy(buffer+length,"Public\n"); 160 191 length+=lstrlen(buffer+length); 161 sprintf(buffer+length,"\tSub %s()\n",parent-> TypeName);192 sprintf(buffer+length,"\tSub %s()\n",parent->GetName().c_str()); 162 193 length+=lstrlen(buffer+length); 163 194 if(parent->iEnumMemberNum){ … … 169 200 lstrcpy(buffer+length,"\tEnd Sub\n"); 170 201 length+=lstrlen(buffer+length); 171 sprintf(buffer+length,"\tSub ~%s()\n",parent->TypeName); 172 length+=lstrlen(buffer+length); 173 lstrcpy(buffer+length,"\tEnd Sub\n"); 174 length+=lstrlen(buffer+length); 175 202 sprintf(buffer+length,"\tSub ~%s()\n",parent->GetName().c_str()); 203 length+=lstrlen(buffer+length); 204 lstrcpy(buffer+length,"\tEnd Sub\n"); 205 length+=lstrlen(buffer+length); 206 207 for(int i2=0;i2<parent->iEnumMemberNum;i2++){ 208 CEnumMember *member; 209 member=parent->ppobj_EnumMember[i2]; 210 211 sprintf(buffer+length,"\tStatic %s As %s(%d,\"%s\")\n", 212 member->m_name, 213 parent->GetName().c_str(), 214 member->m_value, 215 member->m_name); 216 length+=lstrlen(buffer+length); 217 } 218 219 /* 220 sprintf(buffer+length,"\tOverride Function ToString() As String\n",parent->TypeName); 221 length+=lstrlen(buffer+length); 222 lstrcpy(buffer+length,"\t\tSelect Case value\n"); 223 length+=lstrlen(buffer+length); 176 224 for(i2=0;i2<parent->iEnumMemberNum;i2++){ 177 225 CEnumMember *member; 178 226 member=parent->ppobj_EnumMember[i2]; 179 227 180 sprintf(buffer+length,"\tStatic %s As %s(%d,\"%s\")\n", 181 member->m_name, 182 parent->TypeName, 183 member->m_value, 184 member->m_name); 185 length+=lstrlen(buffer+length); 186 } 187 188 /* 189 sprintf(buffer+length,"\tOverride Function ToString() As String\n",parent->TypeName); 228 sprintf(buffer+length,"\t\t\tCase %d\n",member->m_value); 229 length+=lstrlen(buffer+length); 230 sprintf(buffer+length,"\t\t\t\tReturn \"%s\"\n",member->m_name); 231 length+=lstrlen(buffer+length); 232 } 233 lstrcpy(buffer+length,"\t\tEnd Select\n"); 234 length+=lstrlen(buffer+length); 235 lstrcpy(buffer+length,"\tEnd Function\n"); 236 length+=lstrlen(buffer+length); 237 238 239 sprintf(buffer+length,"\tSub Operator= (ByRef value As %s)\n",parent->TypeName); 240 length+=lstrlen(buffer+length); 241 lstrcpy(buffer+length,"\t\tThis.Copy(ByVal VarPtr(value))\n"); 242 length+=lstrlen(buffer+length); 243 lstrcpy(buffer+length,"\tEnd Sub\n"); 244 length+=lstrlen(buffer+length); 245 246 sprintf(buffer+length,"\tSub Operator= (ByRef value As String)\n",parent->TypeName); 190 247 length+=lstrlen(buffer+length); 191 248 lstrcpy(buffer+length,"\t\tSelect Case value\n"); … … 195 252 member=parent->ppobj_EnumMember[i2]; 196 253 197 sprintf(buffer+length,"\t\t\tCase %d\n",member->m_value);198 length+=lstrlen(buffer+length); 199 sprintf(buffer+length,"\t\t\t\t Return \"%s\"\n",member->m_name);254 sprintf(buffer+length,"\t\t\tCase \"%s\"\n",member->m_name); 255 length+=lstrlen(buffer+length); 256 sprintf(buffer+length,"\t\t\t\tThis=%s.%s\n",parent->TypeName,member->m_name); 200 257 length+=lstrlen(buffer+length); 201 258 } 202 259 lstrcpy(buffer+length,"\t\tEnd Select\n"); 203 260 length+=lstrlen(buffer+length); 204 lstrcpy(buffer+length,"\tEnd Function\n");205 length+=lstrlen(buffer+length);206 207 208 sprintf(buffer+length,"\tSub Operator= (ByRef value As %s)\n",parent->TypeName);209 length+=lstrlen(buffer+length);210 lstrcpy(buffer+length,"\t\tThis.Copy(ByVal VarPtr(value))\n");211 length+=lstrlen(buffer+length);212 lstrcpy(buffer+length,"\tEnd Sub\n");213 length+=lstrlen(buffer+length);214 215 sprintf(buffer+length,"\tSub Operator= (ByRef value As String)\n",parent->TypeName);216 length+=lstrlen(buffer+length);217 lstrcpy(buffer+length,"\t\tSelect Case value\n");218 length+=lstrlen(buffer+length);219 for(i2=0;i2<parent->iEnumMemberNum;i2++){220 CEnumMember *member;221 member=parent->ppobj_EnumMember[i2];222 223 sprintf(buffer+length,"\t\t\tCase \"%s\"\n",member->m_name);224 length+=lstrlen(buffer+length);225 sprintf(buffer+length,"\t\t\t\tThis=%s.%s\n",parent->TypeName,member->m_name);226 length+=lstrlen(buffer+length);227 }228 lstrcpy(buffer+length,"\t\tEnd Select\n");229 length+=lstrlen(buffer+length);230 261 lstrcpy(buffer+length,"\tEnd Sub\n"); 231 262 length+=lstrlen(buffer+length); … … 240 271 lstrcpy(buffer+length,"End Class\n"); 241 272 length+=lstrlen(buffer+length); 273 274 BOOST_FOREACH( const string &namespaceStr, parent->GetNamespaceScopes() ){ 275 lstrcpy( buffer+length, "End Namespace\n" ); 276 length+=lstrlen(buffer+length); 277 } 242 278 243 279 -
BasicCompiler_Common/Enum.h
r88 r103 10 10 11 11 class CEnumParent{ 12 char *TypeName; 12 NamespaceScopes namespaceScopes; 13 string name; 14 13 15 BOOL bConst; 14 16 … … 17 19 public: 18 20 19 CEnumParent( const char *buffer,int nowLine);21 CEnumParent( const NamespaceScopes &namespaceScopes, const char *buffer,int nowLine); 20 22 ~CEnumParent(); 21 23 24 const NamespaceScopes &GetNamespaceScopes() const 25 { 26 return namespaceScopes; 27 } 28 const string &GetName() const 29 { 30 return name; 31 } 22 32 23 33 public: -
BasicCompiler_Common/Intermediate_Step2.cpp
r100 r103 165 165 } 166 166 } 167 void AddConstEnum( char *buffer){167 void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){ 168 168 extern int cp; 169 169 int i=0,i2; … … 235 235 236 236 //定数を追加 237 CDBConst::obj.AddConst( temporary, NextValue);237 CDBConst::obj.AddConst( namespaceScopes, temporary, NextValue); 238 238 } 239 239 } … … 243 243 //////////////////////////////////////////// 244 244 245 int i ,i2;245 int i2; 246 246 char temporary[1024]; 247 248 // 名前空間管理 249 NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes; 250 namespaceScopes.clear(); 247 251 248 252 //定数に関する情報 … … 251 255 252 256 extern char *basbuf; 253 for(i =0;;i++){257 for(int i=0;;i++){ 254 258 if( basbuf[i] == '\0' ) break; 259 260 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){ 261 for(i+=2,i2=0;;i2++,i++){ 262 if( IsCommandDelimitation( basbuf[i] ) ){ 263 temporary[i2]=0; 264 break; 265 } 266 temporary[i2]=basbuf[i]; 267 } 268 namespaceScopes.push_back( temporary ); 269 270 continue; 271 } 272 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){ 273 if( namespaceScopes.size() <= 0 ){ 274 SetError(12, "End Namespace", i ); 275 } 276 else{ 277 namespaceScopes.pop_back(); 278 } 279 280 i += 2; 281 continue; 282 } 283 255 284 if( basbuf[i] == 1 ){ 256 285 if(basbuf[i]==1&&basbuf[i+1]==ESC_CONST){ … … 262 291 263 292 if(basbuf[i]==1&&basbuf[i+1]==ESC_ENUM){ 264 AddConstEnum( basbuf+i);293 AddConstEnum( namespaceScopes, basbuf+i); 265 294 continue; 266 295 } … … 281 310 temporary[i2]=basbuf[i]; 282 311 } 283 CDBConst::obj.Add( temporary);312 CDBConst::obj.Add( namespaceScopes, temporary); 284 313 if(basbuf[i]=='\0') break; 285 314 } -
BasicCompiler_Common/NumOpe_GetType.cpp
r102 r103 323 323 Type leftType; 324 324 if( !GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){ 325 return false;325 goto globalArea; 326 326 } 327 327 … … 658 658 // 何らかの識別子 659 659 660 if( (string)term=="ParentArea2.xxxxxx"){ 661 int test=0; 662 } 663 660 664 bool isLiteral = true; 661 665 if( GetTermType( term, resultType, isLiteral ) ){ … … 693 697 ////////////// 694 698 695 i3 = CDBConst::obj.Get Type(term);699 i3 = CDBConst::obj.GetBasicType(term); 696 700 if(i3){ 701 if( CDBConst::obj.IsStringPtr( term ) ){ 702 //リテラル文字列 703 goto StrLiteral; 704 } 705 697 706 type_stack[sp]=i3; 698 707 if(IsRealNumberType(i3)){ … … 708 717 goto Literal; 709 718 } 710 else if(i3==DEF_STRING){711 //リテラル文字列712 goto StrLiteral;713 }714 719 else{ 715 720 SetError(1,NULL,0); -
BasicCompiler_Common/Variable.cpp
r75 r103 1 #include "common.h" 2 3 bool Variable::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 4 { 5 if( GetName() != name ){ 6 return false; 7 } 8 return NamespaceScopes::IsSameArea( this->namespaceScopes, namespaceScopes ); 9 } 10 bool Variable::IsEqualSymbol( const string &fullName ) const 11 { 12 char AreaName[VN_SIZE] = ""; //オブジェクト変数 13 char NestName[VN_SIZE] = ""; //入れ子メンバ 14 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 15 16 if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){ 17 return true; 18 } 19 20 if( isNest ){ 21 // 静的メンバを考慮 22 23 char AreaName2[VN_SIZE] = ""; //オブジェクト変数 24 char NestName2[VN_SIZE] = ""; //入れ子メンバ 25 bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 ); 26 lstrcat( NestName2, "." ); 27 lstrcat( NestName2, NestName ); 28 29 return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 ); 30 } 31 32 return false; 33 } -
BasicCompiler_Common/Variable.h
r100 r103 5 5 class Variable : public Type 6 6 { 7 const NamespaceScopes namespaceScopes; 7 8 string name; 8 9 bool isConst; … … 14 15 15 16 public: 16 Variable( const string &name, const Type &type, bool isConst = false, bool isRef = false ) :17 Type( type ),18 name( name ),19 isConst( isConst ),20 isRef( isRef ),21 isArray( false ),22 isParameter( false)17 Variable( const string &name, const Type &type, bool isConst = false, bool isRef = false ) 18 : Type( type ) 19 , name( name ) 20 , isConst( isConst ) 21 , isRef( isRef ) 22 , isArray( false ) 23 , isParameter( false) 23 24 { 24 25 subScripts[0] = -1; 25 26 } 26 Variable( const Variable &var ): 27 Type( var ), 28 name( var.name ), 29 isConst( var.isConst ), 30 isRef( var.isRef ), 31 isArray( false ), 32 isParameter( false ) 27 Variable( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, bool isConst = false, bool isRef = false ) 28 : namespaceScopes( namespaceScopes ) 29 , Type( type ) 30 , name( name ) 31 , isConst( isConst ) 32 , isRef( isRef ) 33 , isArray( false ) 34 , isParameter( false) 35 { 36 subScripts[0] = -1; 37 } 38 Variable( const Variable &var ) 39 : Type( var ) 40 , name( var.name ) 41 , isConst( var.isConst ) 42 , isRef( var.isRef ) 43 , isArray( false ) 44 , isParameter( false ) 33 45 { 34 46 subScripts[0] = -1; … … 48 60 return name; 49 61 } 62 63 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 64 bool IsEqualSymbol( const string &name ) const; 50 65 51 66 void ConstOff(){ … … 150 165 && var.ScopeLevel == obj_LexScopes.GetNowLevel() //現在のスコープと同一レベル 151 166 ){ 152 if( var. GetName() == varName){167 if( var.IsEqualSymbol( varName ) ){ 153 168 return true; 154 169 } … … 166 181 && var.ScopeLevel <= obj_LexScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) 167 182 ){ 168 if( var. GetName() == varName){183 if( var.IsEqualSymbol( varName ) ){ 169 184 return &var; 170 185 } … … 179 194 for( int i=0; i<max; i++ ){ 180 195 Variable *pVar = (*this)[i]; 181 if( pVar-> GetName() == varName){196 if( pVar->IsEqualSymbol( varName ) ){ 182 197 return pVar; 183 198 } -
BasicCompiler_Common/VariableOpe.cpp
r97 r103 1045 1045 bool isConst = ( dwFlag & DIMFLAG_CONST ) ? true:false; 1046 1046 1047 Variable *pVar = new Variable( name, type, isConst );1047 Variable *pVar = new Variable( Smoothie::Lexical::liveingNamespaceScopes, name, type, isConst ); 1048 1048 1049 1049 if( SubScripts[0] != -1 ){ … … 1172 1172 1173 1173 //定数と2重定義されていないる場合は抜け出す 1174 if(CDBConst::obj.Get Type(VarName)){1174 if(CDBConst::obj.GetBasicType(VarName)){ 1175 1175 return; 1176 1176 } … … 1192 1192 1193 1193 //定数と2重定義されていないかを調べる 1194 if(CDBConst::obj.Get Type(VarName)){1194 if(CDBConst::obj.GetBasicType(VarName)){ 1195 1195 SetError(15,VarName,cp); 1196 1196 return; -
BasicCompiler_Common/calculation.cpp
r97 r103 653 653 ///////// 654 654 StrPtr[pnum]=0; 655 type[pnum] = CDBConst::obj.Get Type(Parms);655 type[pnum] = CDBConst::obj.GetBasicType(Parms); 656 656 if(type[pnum]){ 657 657 if(IsRealNumberType(type[pnum])){ … … 900 900 } 901 901 } 902 903 if( type_stack[sp-1] == DEF_OBJECT || type_stack[sp-1] == DEF_STRUCT ){ 904 // リテラル値ではないため抜け出す 905 return false; 906 } 907 902 908 type_stack[sp-2]=type_stack[sp-1]; 903 909 index_stack[sp-2]=index_stack[sp-1]; … … 1299 1305 1300 1306 //定数 1301 i3 = CDBConst::obj.Get Type(Command+i2);1307 i3 = CDBConst::obj.GetBasicType(Command+i2); 1302 1308 if(i3==DEF_STRING) return 1; //文字列 1303 1309 if(i3) return 0; //数値 -
BasicCompiler_Common/error.cpp
r85 r103 151 151 if(num==61) sprintf(msg,"\"%s\" は定数です。書き込みアクセスはできません。",tempKeyWord); 152 152 if(num==62) sprintf(msg,"グローバル領域でのReturnは禁止されています。",tempKeyWord); 153 if(num==63) lstrcpy(msg,"名前空間が正しく閉じられていません。"); 153 154 154 155
Note:
See TracChangeset
for help on using the changeset viewer.