Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SCLocation Struct Reference

This class implements source a code location. More...

#include <location.h>

Collaboration diagram for SCLocation:

Collaboration graph
[legend]
List of all members.

Public Types

enum  _NullLoc { NullLoc }

Public Member Functions

 SCLocation (_NullLoc=NullLoc)
 Create a NULL location.

 SCLocation (const SourcePosition &p)
 Construct a position from a source position. Only used inside scanner.

 SCLocation (const SCLocation &loc)
 Copy constructor works as usual.

 SCLocation (const TLString &path, int line=-1, int lpos=-1)
 ~SCLocation ()
 Destructor is essentially a no-op.

SCLocationoperator= (const SCLocation &loc)
 Assignment operator works as usual.

SCLocationoperator= (_NullLoc)
 This can be used to assign a NULL location.

bool operator! () const
 Check for NULL location.

 operator bool () const
 Check for NULL location.

TLString path () const
 Get path (if any).

int line () const
 Get line number or -1.

int lpos () const
 Get line position or -1.

TLString LocString (int with_inc_hierarchy=0) const
 Return a string representation of this location.

TLString RelString (const SCLocation &rloc) const
 Return a relative string representation of the location.


Public Attributes

SourcePosition pos
 The actual (start) position is stored here.


Friends

class SCLocationRange

Detailed Description

This class implements source a code location.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
This class is intended to be leight-weight since it is attached to thousands of tree nodes to save location information. It has no virtual functions.

This class is "C++-safe", i.e. copy constructors and assignment are implemented properly.

Definition at line 47 of file location.h.


Member Enumeration Documentation

enum SCLocation::_NullLoc
 

Enumeration values:
NullLoc 

Definition at line 51 of file location.h.


Constructor & Destructor Documentation

SCLocation::SCLocation _NullLoc  = NullLoc  )  [inline]
 

Create a NULL location.

Definition at line 57 of file location.h.

References pos.

SCLocation::SCLocation const SourcePosition p  )  [inline]
 

Construct a position from a source position. Only used inside scanner.

Definition at line 59 of file location.h.

References pos, and SourcePosition.

SCLocation::SCLocation const SCLocation loc  )  [inline]
 

Copy constructor works as usual.

Definition at line 61 of file location.h.

References pos.

SCLocation::SCLocation const TLString path,
int  line = -1,
int  lpos = -1
 

Directly create a location with file and position.
NOTE: DO NOT USE THIS FUNCTION unless this a single location and you are not going to create more of them or of related ones. If you use this function to create lots of SCLocation objects, you waste TONS OF MEMORY!

Definition at line 71 of file location.cc.

References _InternalSourceFileNode::CreateSingleNode(), _InternalSourcePosition::CreateSinglePosition(), lpos(), pos, and SourceFileNode.

SCLocation::~SCLocation  )  [inline]
 

Destructor is essentially a no-op.

Definition at line 69 of file location.h.


Member Function Documentation

int SCLocation::line  )  const [inline]
 

Get line number or -1.

Definition at line 89 of file location.h.

References pos.

TLString SCLocation::LocString int  with_inc_hierarchy = 0  )  const
 

Return a string representation of this location.

Format the location into a string representation; include hierarchy dump is only included if with_inc_hierarchy is set.

Definition at line 55 of file location.cc.

References pos.

Referenced by MessageHandler_Console::HandleMessage().

int SCLocation::lpos  )  const [inline]
 

Get line position or -1.

Definition at line 92 of file location.h.

References pos.

Referenced by SCLocation().

SCLocation::operator bool  )  const [inline]
 

Check for NULL location.

Definition at line 82 of file location.h.

References pos.

bool SCLocation::operator!  )  const [inline]
 

Check for NULL location.

Definition at line 79 of file location.h.

References pos.

SCLocation& SCLocation::operator= _NullLoc   )  [inline]
 

This can be used to assign a NULL location.

Definition at line 75 of file location.h.

References pos, and SourcePosition.

SCLocation& SCLocation::operator= const SCLocation loc  )  [inline]
 

Assignment operator works as usual.

Definition at line 72 of file location.h.

References pos.

TLString SCLocation::path  )  const [inline]
 

Get path (if any).

Definition at line 86 of file location.h.

References pos.

Referenced by VM::VMLinker::LinkAll().

TLString SCLocation::RelString const SCLocation rloc  )  const
 

Return a relative string representation of the location.

Returns a relative string representation; i.e. the location stored in *this is reported, relative to the passed one. "Relative" means that the file is left away if it is the same file.

Definition at line 65 of file location.cc.

References pos.


Friends And Related Function Documentation

friend class SCLocationRange [friend]
 

Definition at line 49 of file location.h.


Member Data Documentation

SourcePosition SCLocation::pos
 

The actual (start) position is stored here.

Definition at line 54 of file location.h.

Referenced by line(), LocString(), lpos(), operator bool(), operator!(), operator=(), VM::AssemblerFile_Plaintext::ParseFile(), path(), SCLocationRange::RangeString(), RelString(), SCLocationRange::RelString(), and SCLocation().


The documentation for this struct was generated from the following files:
Generated on Sat Feb 19 22:35:36 2005 for Ray by doxygen 1.3.5