Alien-SmokeQt

 view release on metacpan or  search on metacpan

generator/parser/rpp/pp-environment.h  view on Meta::CPAN


class CPPPARSER_EXPORT MacroBlock
{
public:
  MacroBlock(int _sourceLine);
  virtual ~MacroBlock();

  void setMacro(pp_macro* macro);

  QList<MacroBlock*> childBlocks;

  // The condition that opened this block(list of string indices)
  QVector<uint> condition;
  // The block to use if this block's condition was not met
  MacroBlock* elseBlock;

  // The source line where the block occurred
  int sourceLine;

  // This block is the owner of these macros
  QList<pp_macro*> macros;
};

class CPPPARSER_EXPORT Environment
{
public:
  typedef QHash<IndexedString, pp_macro*> EnvironmentMap;

  Environment(pp* preprocessor);
  virtual ~Environment();

  MacroBlock* firstBlock() const;
  MacroBlock* currentBlock() const;

  void enterBlock(MacroBlock* block);
  MacroBlock* enterBlock(int sourceLine, const QVector<uint>& condition = QVector<uint>());
  MacroBlock* elseBlock(int sourceLine, const QVector<uint>& condition = QVector<uint>());
  void leaveBlock();

  // Replay previously saved blocks on this environment
  void visitBlock(MacroBlock* block, int depth = 0);

  void clear();

  // For those not interested in the result, just in getting memory released etc.
  void cleanup();

  void clearMacro(const IndexedString& name);

  //Note: Undef-macros are allowed too
  virtual void setMacro(pp_macro* macro);

  virtual pp_macro* retrieveMacro(const IndexedString& name, bool isImportant) const;
  
  //Returns macros that are really stored locally(retrieveMacro may be overridden to perform more complex actions)
  pp_macro* retrieveStoredMacro(const IndexedString& name) const;
  
  QList<pp_macro*> allMacros() const;

  //Take the set of environment-macros from the given environment
  virtual void swapMacros( Environment* parentEnvironment );

  //Faster access then allMacros(..), because nothing is copied
  const EnvironmentMap& environment() const; //krazy:exclude=constref

  LocationTable* locationTable() const;
  LocationTable* takeLocationTable();

private:
  EnvironmentMap m_environment;

  QStack<MacroBlock*> m_blocks;
  bool m_replaying;
  pp* m_preprocessor;
  LocationTable* m_locationTable;
};

}

#endif // PP_ENVIRONMENT_H




( run in 1.131 second using v1.01-cache-2.11-cpan-13bb782fe5a )