#include <linker.h>
Collaboration diagram for VM::VMLinker:

Public Types | |
| typedef TLBTree< LSymbol, TLDefaultOperators_CDT< LSymbol > > | SymbolQueue |
| SymbolQueue is used to queue symbols for linkage. | |
Public Member Functions | |
| VMLinker () | |
| Construct linker object. | |
| ~VMLinker () | |
| VM linker destructor. | |
| int | AddFile (AssemblerFile *afile) |
| Add a file to the linker. | |
| int | LinkAll (AssemblerFile *out) |
| Actually perform the linking. | |
Static Public Member Functions | |
| NamespaceInfo * | SPM_ORD (NamespaceInfo::SymbolEntryE *se) |
Private Member Functions | |
| void | _MergeNamespaceAndVTableInfo () |
| Merge namespace and class names. | |
| NamespaceInfo * | _MergeNamespaceInfo_Recursive (NamespaceInfo **head_list, uint nheads) |
| Merge namespace and class names; recursive. | |
| void | _CheckNamespaceInfo_Recursive (FileNode *fn, NamespaceInfo *ni) |
| Used by _MergeNamespaceAndVTableInfo(); see there. | |
| void | _LinkFunction (FileNode *fn, ProgramStorage::Function *psf, NamespaceInfo::SymbolEntryE *se_linked) |
| Process function for linkage. | |
| void | _LinkGlobalStorage (FileNode *fn, AssemblerFile::_GlobVars *gvar, AssemblerFile::_GlobVars *dest, char which) |
| Link/merge global vars section of passed file. | |
| void | _LinkerFileNeeded (FileNode *fn) |
| Perform linking of file. | |
| void | _LinkerNeedClassConstruct (ClassInfo *ci) |
| Class needed for construction. | |
| int | _CheckBaseRecursion (ClassInfo *cni) |
| Check if base classes are recursive. | |
| void | _CheckBaseRecursion_Recursive (FileNode *fn, NamespaceInfo *ni) |
| This is the recursive "driver" for _CheckBaseRecursion(). | |
| void | _PropagateUseFlags_Recursive (NamespaceInfo *ni) |
| Make sure the need_* flags (need_cast) are set on all bases. | |
| void | _DoPropagateUseFlags (ClassInfo *from, ClassInfo *cni) |
| Internally used by _PropagateUseFlags_Recursive(). | |
| void | _GenerateSymbolProvideMap () |
| Set up the big symbol provide map. | |
| void | _GenerateSymbolProvideMap_AddGlobal (FileNode *fn, AssemblerFile::_GlobVars *gvar) |
| Internally used by _GenerateSymbolProvideMap(). | |
| void | _CreateInitFunction () |
| Create the ".init" function for linked file at end of linking. | |
| FileNode * | _GetDefinitionFile (NamespaceInfo *from_here) |
| SymRef | _SQPush (NamespaceInfo::SymbolEntryE *, NamespaceInfo::SymbolEntryB **update_se=NULL, LSymbol::SFlag sflag=LSymbol::SNone) |
| Push entry into the symbol queue sq. Returns master symref. | |
| SymRef | _SQQuery (NamespaceInfo::SymbolEntryE *ni) |
| Like _SQPush() but just query a symref for passed *ni. | |
| void | _SQPop () |
| Pop entry from the symbol queue sq. | |
| bool | _SQPeek (LSymbol &ls) |
| Get smallest element without removal; Returns 0 if emtpy. | |
| VMLinker (const VMLinker &) | |
| Do not use:. | |
| void | operator= (const VMLinker &) |
| Do not use:. | |
Private Attributes | |
| Config | cfg |
| Configuration data stored here. | |
| LinkedList< FileNode > | flist |
| List of all files. | |
| int | n_errors |
| Count errors during linking:. | |
| SymbolQueue | sq |
| TypeID | master_TypeID_cnt |
| SymRef | master_SymRef_cnt |
| SymRef counter in linked output. | |
| SymbolProvideMap | symbol_provide_map |
| AssemblerFile * | out |
This class is NOT C++-safe.
Definition at line 43 of file linker.h.
|
|
SymbolQueue is used to queue symbols for linkage.
|
|
|
Do not use:.
|
|
|
Construct linker object.
|
|
|
VM linker destructor.
Definition at line 1595 of file linker.cc. References DELETE(), flist, LinkedList< FileNode >::IsEmpty(), out, and LinkedList< FileNode >::PopFirst(). |
|
|
Check if base classes are recursive.
For internal use only. E.g. you cannot make a class a base of itself. Things like that are normally not part of the linker but of the VM input validation but the linker would recurse infinitely while propagating class use informaition in case of recursive bases. Return value is number of errors. Definition at line 656 of file linker.cc. References Assert, VM::ClassInfo::base, VM::ClassInfoIE::ci(), VM::NonResizeableArray< BaseEntry, uint32 >::n(), VM::NamespaceInfo::nstype, VM::NamespaceInfo::recursion_flag, and uint32. Referenced by _CheckBaseRecursion_Recursive(). |
|
||||||||||||
|
This is the recursive "driver" for _CheckBaseRecursion().
Definition at line 681 of file linker.cc. References _CheckBaseRecursion(), VM::NamespaceInfo::asm_loc, VM::NamespaceInfo::CompleteName(), VM::NamespaceInfo::down, Error(), LinkedList< NamespaceInfo >::first(), n_errors, LinkedListBase< NamespaceInfo >::next, VM::NamespaceInfo::nstype, and TLString::str(). Referenced by _MergeNamespaceAndVTableInfo(). |
|
||||||||||||
|
|
Create the ".init" function for linked file at end of linking.
Definition at line 1197 of file linker.cc. References VM::ProgramStorage::AddFunction(), VM::InstructionStorage::append(), Assert, DELETE(), VM::NamespaceInfo::SymbolEntryE::extid, VM::VMLinker::FileNode::f, LinkedList< FileNode >::first(), flist, VM::NamespaceInfo::SymbolEntryE::ftype, VM::NamespaceInfo::SymbolEntryE::linked, VM::NamespaceInfo::SymbolEntryE::name, VM::VMLinker::FileNode::needed, LinkedListBase< FileNode >::next, VM::NamespaceInfo::SymbolEntryE::nspc, VM::AssemblerFile::nspc_root, out, VM::AssemblerFile::SLabelInfo::pfunc, VM::AssemblerFile::program, VM::ProgramStorage::Function::se, VM::AssemblerFile::SLabelInfo::se, VM::AssemblerFile::slabel_init, and VM::SymRef. Referenced by LinkAll(). |
|
||||||||||||
|
Internally used by _PropagateUseFlags_Recursive().
Definition at line 1160 of file linker.cc. References Assert, VM::ClassInfo::base, VM::ClassInfoIE::ci(), VM::NonResizeableArray< BaseEntry, uint32 >::n(), VM::ClassInfo::need_cast, VM::ClassInfo::need_construct, and uint32. Referenced by _PropagateUseFlags_Recursive(). |
|
|
||||||||||||
|
Internally used by _GenerateSymbolProvideMap().
For internal use only.
Definition at line 760 of file linker.cc. References VM::VMLinker::SymbolProvideMap::AddNode(), VM::NamespaceInfo::asm_loc, VM::NamespaceInfo::SymbolEntryB::CompleteName(), Error(), VM::VMLinker::FileNode::f, VM::AssemblerFile::filename, VM::AssemblerFile::_GlobVars::globvarq, n_errors, VM::NamespaceInfo::SymbolEntryE::nspc, TLString::str(), symbol_provide_map, and Warning(). Referenced by _GenerateSymbolProvideMap(). |
|
|
Get file in which passed symbol is defined. FIXME: Currently O(nfiles), should be O(1). Definition at line 119 of file linker.cc. References Assert, VM::VMLinker::FileNode::f, LinkedList< FileNode >::first(), flist, LinkedListBase< FileNode >::next, VM::AssemblerFile::nspc_root, and VM::NamespaceInfo::parent. Referenced by LinkAll(). |
|
|
Perform linking of file.
For internal use only. In case the file is not yet marked as needed, perform linking and mark it as needd. "Linking" is done by simply adding the required symbols to the queue. Definition at line 929 of file linker.cc. References _LinkGlobalStorage(), _SQPush(), VM::VMLinker::FileNode::f, VM::AssemblerFile::gvar_p, VM::AssemblerFile::gvar_v, VM::VMLinker::FileNode::needed, out, VM::AssemblerFile::SLabelInfo::pfunc, VM::AssemblerFile::SLabelInfo::se, and VM::AssemblerFile::slabel_init. Referenced by LinkAll(). |
|
|
Class needed for construction.
For internal use only. This will make sure all the required symbols for the vtable are queued. Definition at line 1105 of file linker.cc. References _SQPush(), Assert, VM::ClassInfo::CompleteName(), VM::AssemblerFile::internal_symbols, VM::NamespaceInfo::SymbolEntryE::linked, VM::NamespaceInfo::linked, VM::NonResizeableArray< VTableEntry, uint32 >::n(), VM::ClassInfo::need_construct, VM::NamespaceInfo::SymbolEntryE::nspc, out, VM::ClassInfo::VTableEntry::se, TLString::str(), uint, uint32, VM::ClassInfo::vtable, and Warning(). Referenced by _LinkFunction(). |
|
||||||||||||||||
|
||||||||||||||||||||
|
|
Merge namespace and class names.
For internal use only. This will build up the master namespace/class info tree in nspc_root but and then check if the class info is compatible. Definition at line 699 of file linker.cc. References _CheckBaseRecursion_Recursive(), _CheckNamespaceInfo_Recursive(), _MergeNamespaceInfo_Recursive(), Assert, VM::VMLinker::FileNode::f, LinkedList< FileNode >::first(), flist, FREE(), n_errors, LinkedListBase< FileNode >::next, VM::AssemblerFile::nspc_root, out, and uint. Referenced by LinkAll(). |
|
||||||||||||
|
|
Make sure the need_* flags (need_cast) are set on all bases.
Definition at line 1181 of file linker.cc. References _DoPropagateUseFlags(), VM::NamespaceInfo::down, LinkedList< NamespaceInfo >::first(), VM::ClassInfo::need_cast, VM::ClassInfo::need_construct, LinkedListBase< NamespaceInfo >::next, and VM::NamespaceInfo::nstype. Referenced by LinkAll(). |
|
|
Get smallest element without removal; Returns 0 if emtpy.
Definition at line 111 of file linker.cc. References TLBTree< T, _OP >::GetSmallest(), and sq. Referenced by LinkAll(). |
|
|
Pop entry from the symbol queue sq.
Definition at line 104 of file linker.cc. References TLBTree< T, _OP >::RemoveSmallest(), and sq. Referenced by LinkAll(). |
|
||||||||||||||||
|
Push entry into the symbol queue sq. Returns master symref.
Definition at line 56 of file linker.cc. References Assert, VM::NamespaceInfo::SymbolEntryB::CompleteName(), master_SymRef_cnt, VM::VMLinker::LSymbol::se, sq, TLBTree< T, _OP >::store(), TLString::str(), VM::VMLinker::LSymbol::symref, VM::NamespaceInfo::SymbolEntryB::symref, VM::SymRef, and Warning(). Referenced by _LinkerFileNeeded(), _LinkerNeedClassConstruct(), _LinkFunction(), and LinkAll(). |
|
|
Like _SQPush() but just query a symref for passed *ni.
Definition at line 92 of file linker.cc. References Assert, master_SymRef_cnt, TLBTree< T, _OP >::search(), sq, VM::VMLinker::LSymbol::symref, VM::NamespaceInfo::SymbolEntryB::symref, and VM::SymRef. Referenced by _LinkGlobalStorage(). |
|
|
Add a file to the linker. The passed file is added to the file list in the linker. + The file must have alredy been successfully read in (i.e. without error). The linker will take care of the file object and free it (all unneded info in it) when linking or upon destruction.
Definition at line 1571 of file linker.cc. References LinkedList< FileNode >::append(), and flist. Referenced by main(). |
|
|
|
Do not use:.
|
|
|
Access control issues are the reason for this wrapper. Only usable for non-internal symbols. Definition at line 73 of file linker.h. References VM::NamespaceInfo::linked, and VM::NamespaceInfo::SymbolEntryE::nspc. Referenced by VM::VMLinker::ProvideMapOP< T >::eq(), VM::VMLinker::ProvideMapOP< T >::le(), VM::VMLinker::ProvideMapOP< T >::lt(), and VM::VMLinker::ProvideMapOP< T >::ne(). |
|
|
Configuration data stored here.
Definition at line 205 of file linker.h. Referenced by _LinkFunction(), _LinkGlobalStorage(), _MergeNamespaceInfo_Recursive(), and LinkAll(). |
|
|
List of all files.
Definition at line 208 of file linker.h. Referenced by _CreateInitFunction(), _GenerateSymbolProvideMap(), _GetDefinitionFile(), _MergeNamespaceAndVTableInfo(), AddFile(), LinkAll(), and ~VMLinker(). |
|
|
SymRef counter in linked output.
Definition at line 233 of file linker.h. Referenced by _SQPush(), _SQQuery(), and LinkAll(). |
|
|
This is the TypeID counter which gets increased for each new ClassInfo in the master namespace tree. Starts with 1. Definition at line 230 of file linker.h. Referenced by _MergeNamespaceInfo_Recursive(), and LinkAll(). |
|
|
Count errors during linking:.
Definition at line 211 of file linker.h. Referenced by _CheckBaseRecursion_Recursive(), _CheckNamespaceInfo_Recursive(), _GenerateSymbolProvideMap(), _GenerateSymbolProvideMap_AddGlobal(), _LinkFunction(), _LinkGlobalStorage(), _MergeNamespaceAndVTableInfo(), _MergeNamespaceInfo_Recursive(), and LinkAll(). |
|
|
The linking will put the output into this file which will hold the master namespace tree, etc:
Definition at line 249 of file linker.h. Referenced by _CheckNamespaceInfo_Recursive(), _CreateInitFunction(), _LinkerFileNeeded(), _LinkerNeedClassConstruct(), _LinkFunction(), _LinkGlobalStorage(), _MergeNamespaceAndVTableInfo(), _MergeNamespaceInfo_Recursive(), LinkAll(), and ~VMLinker(). |
|
|
Symbol queue for to-be-resolved symbols while linking. The SymbolQueue is sorted like the symbol provide map by names and then linked namespaces. Definition at line 226 of file linker.h. Referenced by _SQPeek(), _SQPop(), _SQPush(), _SQQuery(), and LinkAll(). |
|
|
Map of all provided symbols in all files. Names may appear more than once in case their namespace differs. Definition at line 237 of file linker.h. Referenced by _GenerateSymbolProvideMap(), _GenerateSymbolProvideMap_AddGlobal(), and LinkAll(). |
1.3.5