Polaris: Equivalence Class Reference

Equivalence Class Reference

FORTRAN Equivalence class. More...

#include <Equivalence.h>

Inheritance diagram for Equivalence:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Equivalence (const char *name)
 class Equivalence inlines
 Equivalence (const char *name, const BinRep &binstr, const Symtab &symtab)
 Constructor from binstr.
 Equivalence (const Equivalence &other)
Equivalenceoperator= (const Equivalence &other)
 ~Equivalence ()
const char * name_ref () const
BinRepoverflow_ref () const
int size () const
 Returns the size of the entire equivalence class.
int entries () const
 Returns the number of equivalence members in this object.
Iterator< EquivalenceMemberiterator () const
 Returns an iterator for the EquivalenceMember's of this equivalence class.
EquivalenceMemberfind_ref (const Symbol &sym)
 Returns a pointer to the EquivalenceMember (or 0 if none) which contains the Symbol 'sym'.
void del (Symbol &symbol)
 Delete a variable reference from the members list -- this change is also automatically reflected in symbol by making the variable's equivalence field point to NULL.
void clear ()
 Delete all variables from the members list, updating the symbols' equivalence field to NULL in the process.
void ins (Symbol &symbol, int byte_base)
 Insert a variable into the members list -- this change is also automatically reflected in symbol by making the variable's equivalence field point to this structure If the variable is already in another equivalence, then an error occurs, since this is likely a mistake.
virtual void print (ostream &o) const
 Write to stream in debug format (or use operator<< ).
virtual void write (ostream &o, int space_for_label, int max_line_len, const Symtab &symtab)
 Write to stream in Fortran format.
virtual Definitiondefinition_clone () const
virtual int structures_OK () const
 Check the structure of the data for errors or inconsistency Return 0 and print error message if problems found, otherwise return 1 without message.
virtual void relink_dptrs (ProgramUnit &p)
 Change the pointers found in an Equivalence element to be pointers into the given ProgramUnit.

Protected Member Functions

Expression_equiv_array_offset (const Symtab &symtab, EquivalenceMember &eq, int delta) const

Friends

class FunctionSymbol
class VariableSymbol
class EquivalenceDict

Detailed Description

FORTRAN Equivalence class.

Polaris C++ VDL

See also:
Equivalence.h

Equivalence.h

Description

Equivalence is a representation of a FORTRAN equivalence class, containing a set of members (with a byte-base indicating the byte in the equivalence class at which that variable starts) and a length or size.

A word of explanation is in order here. In FORTRAN, it is possible to have the same variable in more than one equivalence class. In this data structure, however, any particular symbol is allowed in no more than one equivalence class. The scanner automatically converts the multi format to the uni format, so the user need only be aware of this fact if he/she is trying to insert a symbol into an Equivalence.

Bugs

Perhaps the destructor for the Equivalence class should automatically call del() on each of its members so that the pointers in the Symtab are all set to null when this is deleted.

Definition at line 94 of file Equivalence.h.


Constructor & Destructor Documentation

Equivalence::Equivalence const char *  name  ) 
 

class Equivalence inlines

Definition at line 527 of file Equivalence.cc.

References register_instance().

Referenced by definition_clone().

Equivalence::Equivalence const char *  name,
const BinRep binstr,
const Symtab symtab
 

Constructor from binstr.

... Here we expect a set of tuples of [variable name, byte base]

... Unrecognized -- add to overflow

Definition at line 76 of file Equivalence.cc.

References BinRep::find_ref(), BinRep::ins(), List< T >::ins_first(), BinRep::is_set(), BinRep::put_set(), register_instance(), BinRep::to_integer(), BinRep::to_set(), BinRep::to_string(), and warn_overflow_map().

Equivalence::Equivalence const Equivalence other  ) 
 

Definition at line 33 of file Equivalence.cc.

References register_instance().

Equivalence::~Equivalence  ) 
 

Definition at line 569 of file Equivalence.cc.

References unregister_instance().


Member Function Documentation

Expression* Equivalence::_equiv_array_offset const Symtab symtab,
EquivalenceMember eq,
int  delta
const [protected]
 

Referenced by write().

Equivalence & Equivalence::operator= const Equivalence other  ) 
 

Definition at line 45 of file Equivalence.cc.

const char * Equivalence::name_ref  )  const
 

Definition at line 539 of file Equivalence.cc.

Referenced by ProgramUnit::create_program_unit(), PointerSymbol::print(), VariableSymbol::print(), FunctionSymbol::print(), PointerSymbol::relink_dptrs(), VariableSymbol::relink_dptrs(), and rename_equivalence_to_match().

BinRep * Equivalence::overflow_ref  )  const
 

Definition at line 545 of file Equivalence.cc.

int Equivalence::size  )  const
 

Returns the size of the entire equivalence class.

Definition at line 551 of file Equivalence.cc.

Referenced by move_saved_vars().

int Equivalence::entries  )  const
 

Returns the number of equivalence members in this object.

Definition at line 557 of file Equivalence.cc.

References List< T >::entries().

Referenced by clear().

Iterator< EquivalenceMember > Equivalence::iterator  )  const
 

Returns an iterator for the EquivalenceMember's of this equivalence class.

Definition at line 563 of file Equivalence.cc.

EquivalenceMember * Equivalence::find_ref const Symbol sym  ) 
 

Returns a pointer to the EquivalenceMember (or 0 if none) which contains the Symbol 'sym'.

Definition at line 135 of file Equivalence.cc.

References List< T >::valid().

Referenced by VariableSymbol::clear_equivalence(), FunctionSymbol::clear_equivalence(), PointerSymbol::relink_dptrs(), VariableSymbol::relink_dptrs(), and rename_equivalence_to_match().

void Equivalence::del Symbol symbol  ) 
 

Delete a variable reference from the members list -- this change is also automatically reflected in symbol by making the variable's equivalence field point to NULL.

If the variable is not in this equivalence, an error occurs.

Definition at line 158 of file Equivalence.cc.

References Symbol::clear_equivalence(), Symbol::equivalence_ref(), and symbol().

Referenced by clear().

void Equivalence::clear  ) 
 

Delete all variables from the members list, updating the symbols' equivalence field to NULL in the process.

Definition at line 145 of file Equivalence.cc.

References del(), entries(), List< T >::entries(), List< T >::first_ref(), and EquivalenceMember::symbol().

Referenced by EquivalenceDict::del().

void Equivalence::ins Symbol symbol,
int  byte_base
 

Insert a variable into the members list -- this change is also automatically reflected in symbol by making the variable's equivalence field point to this structure If the variable is already in another equivalence, then an error occurs, since this is likely a mistake.

(In FORTRAN, this would be legal, but in Polaris, this is not allowed, since it is always possible to combine Equivalence's with overlapping members.

Definition at line 177 of file Equivalence.cc.

References Symbol::equivalence(), Symbol::equivalence_ref(), Symbol::size(), and symbol().

Referenced by move_saved_vars(), and rename_equivalence_to_match().

void Equivalence::print ostream &  o  )  const [virtual]
 

Write to stream in debug format (or use operator<< ).

... _size field

... _members field

... _overflow field

Implements Definition.

Definition at line 200 of file Equivalence.cc.

void Equivalence::write ostream &  o,
int  space_for_label,
int  max_line_len,
const Symtab symtab
[virtual]
 

Write to stream in Fortran format.

... Don't bother -- no members of this equivalence class exist

... Initially we need to process all of the members of the equivalence class.

... Make an equivalence statement covering all the members of ... this equivalence subclass.

... Form the union of all the EQUIVALENCE subclasses.

... Start with the minimum offset in the class.

... Join all of the subclasses into the existing region.

... Find a member we have not already used which overlaps with the ... existing region.

Definition at line 265 of file Equivalence.cc.

References _equiv_array_offset(), EquivalenceMember::byte_base(), convert_case(), Iterator< T >::current(), Iterator< T >::current_valid(), RefList< T >::entries(), False, ProtoDatabase< S, T >::find_ref(), TypedBaseMap< S, T >::first_ref(), RefList< T >::grab(), Database< S, T >::grab(), Database< S, T >::ins(), RefList< T >::ins_last(), Symbol::name_ref(), Iterator< T >::reset(), Symbol::size(), Declaration::str_ref(), EquivalenceMember::symbol(), True, RefList< T >::valid(), and Iterator< T >::valid().

Definition * Equivalence::definition_clone  )  const [virtual]
 

Implements Definition.

Definition at line 58 of file Equivalence.cc.

References Equivalence().

int Equivalence::structures_OK  )  const [virtual]
 

Check the structure of the data for errors or inconsistency Return 0 and print error message if problems found, otherwise return 1 without message.

Implements Definition.

Definition at line 435 of file Equivalence.cc.

void Equivalence::relink_dptrs ProgramUnit p  )  [virtual]
 

Change the pointers found in an Equivalence element to be pointers into the given ProgramUnit.

Implements RelinkableDef.

Definition at line 580 of file Equivalence.cc.

References relink_all_lptrs().


Friends And Related Function Documentation

friend class FunctionSymbol [friend]
 

Definition at line 95 of file Equivalence.h.

friend class VariableSymbol [friend]
 

Definition at line 96 of file Equivalence.h.

friend class EquivalenceDict [friend]
 

Definition at line 97 of file Equivalence.h.


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:18 2005