source_location.hh

Go to the documentation of this file.
00001 /*
00002    The lestes compiler suite
00003    Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy
00004    Copyright (C) 2002, 2003, 2004, 2005 Petr Zika
00005    Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala
00006    Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina
00007    Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda
00008    Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar
00009    Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; version 2 of the License.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    See the full text of the GNU General Public License version 2, and
00021    the limitations in the file doc/LICENSE.
00022 
00023    By accepting the license the licensee waives any and all claims
00024    against the copyright holder(s) related in whole or in part to the
00025    work, its use, and/or the inability to use it.
00026  
00027  */
00028 #ifndef lestes__std___source_location_hh___included
00029 #define lestes__std___source_location_hh___included
00030 
00031 /*! \file
00032   \brief Token location.
00033   
00034   Declaration of source_location class representing token location.
00035   \author pt
00036 */
00037 
00038 #include <lestes/std/object.hh>
00039 #include <lestes/std/file_info.hh>
00040 
00041 package(lestes);
00042 package(std);
00043 
00044 /*!
00045   Represents location of token in file inclusion chain and the file itself.
00046   The object is intentionally inmutable to simplify the processing.
00047 */
00048 class source_location: public object {
00049 public:
00050         //! Returns file information.
00051         ptr<file_info> file_get(void) const;
00052         //! Returns line in file.
00053         ulint line_get(void) const;
00054         //! Returns column on line.
00055         ulint column_get(void) const;
00056         //! Returns order.
00057         ulint order_get(void) const;
00058         //! Tests equality.
00059         bool equals(const ptr<source_location> &rhs) const;
00060         //! Clones location with new order.
00061         ptr<source_location> clone_order(ulint a_order) const;
00062         //! Clones location with new file information.
00063         ptr<source_location> clone_file(const ptr<file_info> &a_file) const;
00064         //! Returns new location, initializes with file information and position.
00065         static ptr<source_location> create(const ptr<file_info> &a_file, ulint a_line,
00066                         ulint a_column);
00067         //! Returns new location, initializes with file information, position and order.
00068         static ptr<source_location> create(const ptr<file_info> &a_file, ulint a_line,
00069                         ulint a_column, ulint a_order);
00070         //! Returns zero location.
00071         static ptr<source_location> zero(void);
00072         //! Returns list of reflection info.
00073         virtual ptr<reflection_list> reflection_get(void) const;
00074         //! Returns list of field values.
00075         virtual ptr<field_list_list> field_values_get(void) const;
00076 protected:
00077         //! Creates new object, initializes with file information, postion and order.
00078         source_location(const ptr<file_info> &a_file, ulint a_line,
00079                         ulint a_column, ulint a_order);
00080         //! Marking routine.
00081         void gc_mark();
00082 private:
00083         //! File information structure.
00084         srp<file_info> file;
00085         //! Line in file.
00086         ulint line;
00087         //! Column inside the line.
00088         ulint column;
00089         //! The order in the translation unit.
00090         ulint order;
00091         //! Zero location instance.
00092         static ptr<source_location> zero_instance;
00093         //! The reflection information.
00094         static ptr<reflection_list> reflection;
00095         //! Hides copy constructor.
00096         source_location(const source_location &);
00097         //! Hides assigment operator.
00098         source_location &operator=(const source_location &);
00099 };
00100 
00101 end_package(std);
00102 end_package(lestes);
00103 
00104 #endif
00105 /* vim: set ft=lestes : */

Generated on Mon Feb 12 18:27:11 2007 for lestes by doxygen 1.5.1-20070107