<s> import abc <EOL> class Ref ( object ) : <EOL> __meta__ = abc . ABCMeta <EOL> @ abc . abstractmethod <EOL> def deref ( self ) : <EOL> pass <EOL> class GlobalValueRef ( Ref ) : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def deref ( self ) : <EOL> return self . value <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . value , ) <EOL> def __repr__ ( self ) : <EOL> return str ( self ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , GlobalValueRef ) and self . value is other . value <EOL> class GlobalNameRef ( Ref ) : <EOL> def __init__ ( self , globals_dict , name ) : <EOL> self . globals_dict = globals_dict <EOL> self . name = name <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . name <EOL> def __repr__ ( self ) : <EOL> return str ( self ) <EOL> def deref ( self ) : <EOL> return self . globals_dict [ self . name ] <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , GlobalNameRef ) and self . globals_dict is other . globals_dict and self . name == other . name <EOL> class ClosureCellRef ( Ref ) : <EOL> def __init__ ( self , cell , name ) : <EOL> self . cell = cell <EOL> self . name = name <EOL> def deref ( self ) : <EOL> return self . cell . cell_contents <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . name <EOL> def __repr__ ( self ) : <EOL> return str ( self ) <EOL> def __eq__ ( self , other ) : <EOL> if isinstance ( other , ClosureCellRef ) : <EOL> try : <EOL> return self . cell == other . cell <EOL> except : <EOL> return self . cell is other . cell <EOL> return False </s>
