#include <lib/sconfig.h>
#include <lib/tl/refnode.h>
#include <lib/sourcepos/sourcefile.h>
Include dependency graph for sourcepos.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Classes | |
class | _InternalSourcePosition |
Internally used source position class. More... | |
Defines | |
#define | _LIB_SOURCEPOS_SOURCEPOS_H_ 1 |
Typedefs | |
typedef RefNode< _InternalSourcePosition > | SourcePosition |
This is the source position "class" to be used by other code. | |
Functions | |
bool | operator== (const SourcePosition &a, const SourcePosition &b) |
operator==() returns true for same position in same file. | |
bool | operator!= (const SourcePosition &a, const SourcePosition &b) |
operator!=() returns false for same position in same file. |
For each toplevel input (source) file you read in with your parser, create a SourcePositionArchive. Use the SourcePositionArchive to get SourceFileNodes and SourcePosition indicators. When parsing is done, you may safely delete the SourcePositionArchive since the SourceFileNodes and SourcePositions which are still in use will not get deleted (they clean up themselves when no longer in use).
Note that SourcePositionArchive is not C++ - safe, create it once and only use pointers to it.
SourcePosition represents a source position (line and possibly lpos in a file); it is meant for mass usage and kept as small as possible: SourcePosition contains only one pointer, so it is 4 or 8 bytes (depending on the architecture and padding).
The pointer points to InternalSourcePosition.
SourcePosition does reference counting and is "C++-safe" (assignment and copy construction implemnented).
Note that InternalSourcePosition are normally shared among all tokens with the same position - thus you can save a lot of memory when not using lpos (always set it to -1 when creating the position information in your scanner/lexer).
(Internal) SourcePosition points to a SourceFileNode which represents a source file. SourceFileNodes are organized in a tree structure representing the include hierarchy. Note that if you include the same file twice, two SourceFileNodes will get allocated. SourceFileNode is C++ - safe (copy constructor and assignment).
The SourceFileNodes can also save the include statement position and size -- information which may be needed in case you want to concatenate all the included files into a single one. (Internally uses InternalSourceFileNode and reference counting.)
For more docu, check the comments around the public functions/methods in this file.
Definition in file sourcepos.h.
|
Definition at line 19 of file sourcepos.h. |
|
This is the source position "class" to be used by other code.
Definition at line 75 of file sourcepos.h. Referenced by _InternalSourcePosition::CreateSinglePosition(), SourcePositionCache::find(), SourcePositionArchive::GetPos(), main(), SCLocation::operator=(), _InternalSourcePosition::PosRangeString(), _InternalSourcePosition::PosStringRelative(), SCLocation::SCLocation(), and SourcePositionCache::store(). |
|
operator!=() returns false for same position in same file.
Definition at line 185 of file sourcepos.h. References operator==(). |
|
operator==() returns true for same position in same file.
Definition at line 178 of file sourcepos.h. |