Changeset 637 in dev for trunk/ab5.0/abdev/ab_common/src/Lexical
- Timestamp:
- Jun 11, 2008, 10:10:26 PM (16 years ago)
- Location:
- trunk/ab5.0/abdev/ab_common/src/Lexical
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp
r636 r637 2 2 3 3 4 CClass::CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name)5 : ClassPrototype( namespaceScopes, name)4 CClass::CClass( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces ) 5 : ClassPrototype( symbol ) 6 6 , importedNamespaces( importedNamespaces ) 7 7 , classType( Class ) … … 21 21 } 22 22 23 CClass::CClass( const NamespaceScopes &namespaceScopes, 23 CClass::CClass( 24 const Symbol &symbol, 24 25 const NamespaceScopesCollection &importedNamespaces, 25 const std::string &name,26 26 ClassType classType, 27 27 const GenericTypes &formalGenericTypes, … … 31 31 int vtblNum, 32 32 int fixedAlignment ) 33 : ClassPrototype( namespaceScopes, name)33 : ClassPrototype( symbol ) 34 34 , importedNamespaces( importedNamespaces ) 35 35 , classType( classType ) … … 868 868 } 869 869 } 870 871 bool CClass::Resolve() 872 { 873 // TODO: Resolve 874 return true; 875 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/Const.cpp
r603 r637 7 7 } 8 8 9 void Consts::Add( const NamespaceScopes &namespaceScopes, const std::string &name, _int64 i64data, const Type &type)9 bool CConst::Resolve() 10 10 { 11 CConst *newconst = new CConst(namespaceScopes, name, type, i64data); 11 // TODO: Resolve 12 return true; 13 } 14 15 void Consts::Add( const Symbol &symbol, _int64 i64data, const Type &type ) 16 { 17 CConst *newconst = new CConst( symbol, type, i64data ); 12 18 13 19 //ハッシュリストに追加 14 20 Put( newconst ); 15 21 } 16 void Consts::Add(const NamespaceScopes &namespaceScopes, const std::string &name, int value){17 CConst *newconst = new CConst( namespaceScopes, name, value);22 void Consts::Add(const Symbol &symbol, int value){ 23 CConst *newconst = new CConst( symbol, value); 18 24 19 25 //ハッシュリストに追加 … … 72 78 } 73 79 80 bool ConstMacro::Resolve() 81 { 82 // TODO: Resolve 83 return true; 84 } 85 74 86 // マクロ定数を追加するための関数 75 bool ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr )87 bool ConstMacros::Add( const Symbol &symbol, const char *parameterStr ) 76 88 { 77 89 std::vector<std::string> parameters; … … 113 125 lstrcpy(temporary,parameterStr+i+1); 114 126 115 this->Put( new ConstMacro( namespaceScopes, name, parameters, temporary ) );127 this->Put( new ConstMacro( symbol, parameters, temporary ) ); 116 128 117 129 return true; -
trunk/ab5.0/abdev/ab_common/src/Lexical/DataTable.cpp
r603 r637 77 77 } 78 78 } 79 80 void DataTable::Resolve() 81 { 82 // TODO: Resolve 83 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/Delegate.cpp
r603 r637 18 18 return false; 19 19 } 20 21 bool Delegate::Resolve() 22 { 23 // TODO: Resolve 24 return true; 25 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/Meta.cpp
r636 r637 50 50 { 51 51 UserProc *pUserProc = meta.GetUserProcs().Iterator_GetNext(); 52 pUserProc->isTargetObjectModule = false; 52 if( pUserProc->IsExternal() ) 53 { 54 // 外部参照の場合は取り込まない 55 continue; 56 } 57 58 pUserProc->ResetRelationalObjectModuleIndex( relationTable ); 53 59 54 60 pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset ); 55 pUserProc->GetNativeCode().ResetSourceIndexes( relationTable );56 61 57 62 this->userProcs.Put( pUserProc ); … … 64 69 { 65 70 DllProc *pDllProc = meta.GetDllProcs().Iterator_GetNext(); 66 pDllProc->isTargetObjectModule = false; 71 if( pDllProc->IsExternal() ) 72 { 73 // 外部参照の場合は取り込まない 74 continue; 75 } 76 77 pDllProc->ResetRelationalObjectModuleIndex( relationTable ); 67 78 this->dllProcs.Put( pDllProc ); 68 79 } … … 74 85 { 75 86 CClass *pClass = meta.GetClasses().Iterator_GetNext(); 76 pClass->isTargetObjectModule = false; 87 if( pClass->IsExternal() ) 88 { 89 // 外部参照の場合は取り込まない 90 continue; 91 } 92 93 pClass->ResetRelationalObjectModuleIndex( relationTable ); 77 94 pClass->Readed(); 78 95 this->GetClasses().Put( pClass ); … … 84 101 BOOST_FOREACH( Variable *pVar, meta.globalVars ) 85 102 { 103 if( pVar->IsExternal() ) 104 { 105 // 外部参照の場合は取り込まない 106 continue; 107 } 108 86 109 // 基底スコープレベルのグローバル変数の生存値をオンにする 87 110 if( pVar->GetScopeLevel() == 0 ) … … 99 122 } 100 123 101 pVar-> isTargetObjectModule = false;124 pVar->ResetRelationalObjectModuleIndex( relationTable ); 102 125 this->globalVars.Add( pVar, isResetOffsetAddress ); 103 126 } … … 113 136 { 114 137 CConst *pConst = meta.GetGlobalConsts().Iterator_GetNext(); 115 pConst->isTargetObjectModule = false; 138 if( pConst->IsExternal() ) 139 { 140 // 外部参照の場合は取り込まない 141 continue; 142 } 143 144 pConst->ResetRelationalObjectModuleIndex( relationTable ); 116 145 this->GetGlobalConsts().Put( pConst ); 117 146 } … … 123 152 { 124 153 ConstMacro *pConstMacro = meta.GetGlobalConstMacros().Iterator_GetNext(); 125 pConstMacro->isTargetObjectModule = false; 154 if( pConstMacro->IsExternal() ) 155 { 156 // 外部参照の場合は取り込まない 157 continue; 158 } 159 160 pConstMacro->ResetRelationalObjectModuleIndex( relationTable ); 126 161 this->GetGlobalConstMacros().Put( pConstMacro ); 127 162 } … … 131 166 BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes ) 132 167 { 133 blittableType.isTargetObjectModule = false;168 // TODO: coreモジュール以外でもBlittable型用のクラスモジュールを定義できるようにすべき 134 169 this->blittableTypes.push_back( blittableType ); 135 170 } … … 139 174 BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs ) 140 175 { 141 typeDef.isTargetObjectModule = false; 176 if( typeDef.IsExternal() ) 177 { 178 // 外部参照の場合は取り込まない 179 continue; 180 } 181 182 typeDef.ResetRelationalObjectModuleIndex( relationTable ); 142 183 this->typeDefs.push_back( typeDef ); 143 184 } … … 147 188 BOOST_FOREACH( ProcPointer *pProcPointer, meta.procPointers ) 148 189 { 149 pProcPointer->isTargetObjectModule = false; 190 if( pProcPointer->IsExternal() ) 191 { 192 // 外部参照の場合は取り込まない 193 continue; 194 } 195 196 pProcPointer->ResetRelationalObjectModuleIndex( relationTable ); 150 197 this->procPointers.push_back( pProcPointer ); 151 198 } … … 157 204 { 158 205 Delegate *pDelegate = meta.GetDelegates().Iterator_GetNext(); 159 pDelegate->isTargetObjectModule = false; 206 if( pDelegate->IsExternal() ) 207 { 208 // 外部参照の場合は取り込まない 209 continue; 210 } 211 212 pDelegate->ResetRelationalObjectModuleIndex( relationTable ); 160 213 this->GetDelegates().Put( pDelegate ); 161 214 } … … 199 252 return NULL; 200 253 } 254 255 void Meta::Resolve() 256 { 257 // 関数・メソッド 258 this->GetUserProcs().Iterator_Init(); 259 this->GetUserProcs().Iterator_Reset(); 260 while( this->GetUserProcs().Iterator_HasNext() ) 261 { 262 UserProc *pUserProc = this->GetUserProcs().Iterator_GetNext(); 263 pUserProc->Resolve(); 264 } 265 266 // DLL関数 267 this->GetDllProcs().Iterator_Init(); 268 this->GetDllProcs().Iterator_Reset(); 269 while( this->GetDllProcs().Iterator_HasNext() ) 270 { 271 DllProc *pDllProc = this->GetDllProcs().Iterator_GetNext(); 272 pDllProc->Resolve(); 273 } 274 275 // クラス 276 this->GetClasses().Iterator_Init(); 277 this->GetClasses().Iterator_Reset(); 278 while( this->GetClasses().Iterator_HasNext() ) 279 { 280 CClass *pClass = this->GetClasses().Iterator_GetNext(); 281 pClass->Resolve(); 282 } 283 284 // グローバル変数 285 BOOST_FOREACH( Variable *pVar, globalVars ) 286 { 287 pVar->Resolve(); 288 } 289 290 // グローバル定数 291 this->GetGlobalConsts().Iterator_Init(); 292 this->GetGlobalConsts().Iterator_Reset(); 293 while( this->GetGlobalConsts().Iterator_HasNext() ) 294 { 295 CConst *pConst = this->GetGlobalConsts().Iterator_GetNext(); 296 pConst->Resolve(); 297 } 298 299 // グローバル定数マクロ 300 this->GetGlobalConstMacros().Iterator_Init(); 301 this->GetGlobalConstMacros().Iterator_Reset(); 302 while( this->GetGlobalConstMacros().Iterator_HasNext() ) 303 { 304 ConstMacro *pConstMacro = this->GetGlobalConstMacros().Iterator_GetNext(); 305 pConstMacro->Resolve(); 306 } 307 308 // TypeDef 309 BOOST_FOREACH( TypeDef &typeDef, typeDefs ) 310 { 311 typeDef.Resolve(); 312 } 313 314 // 関数ポインタ 315 BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ) 316 { 317 pProcPointer->Resolve(); 318 } 319 320 // デリゲート 321 this->GetDelegates().Iterator_Init(); 322 this->GetDelegates().Iterator_Reset(); 323 while( this->GetDelegates().Iterator_HasNext() ) 324 { 325 Delegate *pDelegate = this->GetDelegates().Iterator_GetNext(); 326 pDelegate->Resolve(); 327 } 328 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/NativeCode.cpp
r636 r637 43 43 this->sourceLines.push_back( 44 44 SourceLine( 45 sourceLine.GetLineNum(),46 45 baseOffset + sourceLine.GetNativeCodePos(), 47 sourceLine.GetRelationalObjectModuleIndex(), // TODO: 複数libの取り込みを想定できていない(ソースコード行番号とネイティブコード位置の対応情報の追加は静的リンクが完了した後に行うべき) 48 sourceLine.GetSourceCodePos(), 49 sourceLine.GetCodeType() 46 sourceLine.GetCodeType(), 47 sourceLine.GetSourceCodePosition() 50 48 ) 51 49 ); … … 106 104 } 107 105 108 void NativeCode::NextSourceLine( int currentSourceIndex, int nowLine)106 void NativeCode::NextSourceLine( const SourceCodePosition &sourceCodePosition ) 109 107 { 110 108 if( sourceLines.size() ) … … 112 110 if( sourceLines.back().GetNativeCodePos() == GetSize() ) 113 111 { 114 sourceLines.back().SetSourceCodePos ( nowLine);112 sourceLines.back().SetSourceCodePosition( sourceCodePosition ); 115 113 return; 116 114 } … … 130 128 sourceLines.push_back( 131 129 SourceLine( 132 (long)sourceLines.size(),133 130 GetSize(), 134 currentSourceIndex, 135 nowLine, 136 sourceLineType 131 sourceLineType, 132 sourceCodePosition 137 133 ) 138 134 ); … … 152 148 } 153 149 } 154 void NativeCode::Reset SourceIndexes( const std::vector<int> &relationTable )150 void NativeCode::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable ) 155 151 { 156 152 BOOST_FOREACH( SourceLine &sourceLine, sourceLines ) 157 153 { 158 sourceLine.SetRelationalObjectModuleIndex( relationTable[sourceLine.GetRelationalObjectModuleIndex()] ); 154 sourceLine.GetSourceCodePosition().SetRelationalObjectModuleIndex( 155 relationTable[sourceLine.GetSourceCodePosition().GetRelationalObjectModuleIndex()] 156 ); 159 157 } 160 158 } 159 160 void NativeCode::Resolve() 161 { 162 // TODO: Resolve 163 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/ObjectModule.cpp
r636 r637 56 56 57 57 58 void ObjectModule::StaticLink( ObjectModule &objectModule )58 void ObjectModule::StaticLink( ObjectModule &objectModule, bool isSll ) 59 59 { 60 60 const std::vector<int> relationTable = this->GetRelationTable( objectModule.relationalObjectModuleNames ); … … 65 65 meta.StaticLink( objectModule.meta, dataSectionBaseOffset, relationTable ); 66 66 67 // グローバル ネイティブコードを結合 68 objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 69 objectModule.globalNativeCode.ResetSourceIndexes( relationTable ); 70 globalNativeCode.PutEx( objectModule.globalNativeCode ); 71 72 // データテーブルを結合 73 objectModule.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 74 dataTable.Add( objectModule.dataTable ); 67 if( !isSll ) 68 { 69 // グローバル ネイティブコードを結合 70 objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 71 objectModule.globalNativeCode.ResetRelationalObjectModuleIndex( relationTable ); 72 globalNativeCode.PutEx( objectModule.globalNativeCode ); 73 74 // データテーブルを結合 75 objectModule.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 76 dataTable.Add( objectModule.dataTable ); 77 } 78 79 // 依存関係を解決 80 this->Resolve(); 75 81 76 82 // TODO: basbufがいらなくなったら消す 77 83 extern char *basbuf; 78 84 basbuf = this->source.GetBuffer(); 85 } 86 87 void ObjectModule::Resolve() 88 { 89 this->meta.Resolve(); 90 91 // グローバルネイティブコードを解決(スケジュールを解決する) 92 this->globalNativeCode.Resolve(); 93 94 // データテーブルを解決(スケジュールを解決する) 95 this->dataTable.Resolve(); 79 96 } 80 97 -
trunk/ab5.0/abdev/ab_common/src/Lexical/Procedure.cpp
r632 r637 1 1 #include "stdafx.h" 2 2 3 4 void Procedure::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable ) 5 { 6 RelationalObjectModuleItem::ResetRelationalObjectModuleIndex( relationTable ); 7 8 if( !this->sourceCodePosition.IsNothing() ) 9 { 10 this->sourceCodePosition.SetRelationalObjectModuleIndex( relationTable[this->sourceCodePosition.GetRelationalObjectModuleIndex()] ); 11 } 12 } 13 14 void UserProc::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable ) 15 { 16 Procedure::ResetRelationalObjectModuleIndex( relationTable ); 17 18 this->GetNativeCode().ResetRelationalObjectModuleIndex( relationTable ); 19 } 20 3 21 int id_base = 0; 4 22 5 UserProc::UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport )6 : Procedure( namespaceScopes, name, kind, isCdecl )23 UserProc::UserProc( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces, Kind kind, bool isMacro, bool isCdecl, bool isExport ) 24 : Procedure( symbol, kind, isCdecl ) 7 25 , importedNamespaces( importedNamespaces ) 8 26 , pParentClass( NULL ) … … 139 157 } 140 158 159 bool UserProc::Resolve() 160 { 161 // TODO: Resolve 162 return true; 163 } 164 141 165 const UserProc *UserProc::pGlobalProc = NULL; 142 166 … … 161 185 } 162 186 187 bool DllProc::Resolve() 188 { 189 // TODO: Resolve 190 return true; 191 } 192 193 bool ProcPointer::Resolve() 194 { 195 // TODO: Resolve 196 return true; 197 } 198 163 199 void ProcPointers::Clear() 164 200 { -
trunk/ab5.0/abdev/ab_common/src/Lexical/Source.cpp
r635 r637 941 941 return 1; 942 942 } 943 944 int SourceCodePosition::GetRelationalObjectModuleIndex() const 945 { 946 if( this->IsNothing() ) 947 { 948 _ASSERTE( false ); 949 throw; 950 } 951 952 return relationalObjectModuleIndex; 953 } 954 bool SourceCodePosition::IsNothing() const 955 { 956 if( this->relationalObjectModuleIndex == -1 && this->pos == -1 ) 957 { 958 return true; 959 } 960 961 if( this->relationalObjectModuleIndex == -1 || this->pos == -1 ) 962 { 963 _ASSERTE( false ); 964 throw; 965 } 966 967 return false; 968 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/TypeDef.cpp
r632 r637 1 1 #include "stdafx.h" 2 2 3 TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, const Type &baseType )4 : Symbol( namespaceScopes, name)3 TypeDef::TypeDef( const Symbol &symbol, const std::string &baseName, const Type &baseType ) 4 : RelationalObjectModuleItem( symbol ) 5 5 , baseName( baseName ) 6 6 , baseType( baseType ) 7 7 { 8 } 9 10 bool TypeDef::Resolve() 11 { 12 // TODO: Resolve 13 return true; 8 14 } 9 15 … … 12 18 TypeDefCollection::~TypeDefCollection(){ 13 19 } 14 void TypeDefCollection::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, int nowLine ){15 TypeDef typeDef( namespaceScopes, name, baseName, nowLine );20 void TypeDefCollection::Add( const Symbol &symbol, const std::string &baseName, int nowLine ){ 21 TypeDef typeDef( symbol, baseName, nowLine ); 16 22 this->push_back( typeDef ); 17 23 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/Variable.cpp
r603 r637 2 2 3 3 Variable::Variable( const Symbol &symbol, const Type &type, bool isConst, bool isRef, const std::string ¶mStrForConstructor, bool hasInitData ) 4 : Symbol( symbol ) 5 , type( type ) 6 , isConst( isConst ) 7 , isRef( isRef ) 8 , isArray( false ) 9 , isParameter( false) 10 , paramStrForConstructor( paramStrForConstructor ) 11 , hasInitData( hasInitData ) 12 { 13 } 14 Variable::Variable( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &type, bool isConst, bool isRef, const std::string ¶mStrForConstructor, bool hasInitData ) 15 : Symbol( namespaceScopes, name ) 4 : RelationalObjectModuleItem( symbol ) 16 5 , type( type ) 17 6 , isConst( isConst ) … … 24 13 } 25 14 Variable::Variable( const Variable &var ) 26 : Symbol( var )15 : RelationalObjectModuleItem( var ) 27 16 , type( var.type ) 28 17 , isConst( var.isConst ) … … 37 26 Variable::Variable() 38 27 { 28 } 29 30 bool Variable::Resolve() 31 { 32 // TODO: Resolve 33 return true; 39 34 } 40 35
Note:
See TracChangeset
for help on using the changeset viewer.