From 1a60d0c2a8eeef3b39ef276f0f3552552a1519b1 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 26 May 2009 14:49:37 +0200 Subject: adding ue4 (copy from ue3) --- ue4/mycpu/cprogram.h | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 ue4/mycpu/cprogram.h (limited to 'ue4/mycpu/cprogram.h') diff --git a/ue4/mycpu/cprogram.h b/ue4/mycpu/cprogram.h new file mode 100644 index 0000000..27e7647 --- /dev/null +++ b/ue4/mycpu/cprogram.h @@ -0,0 +1,106 @@ +/** + * @module cprogram + * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) + * @brief CProgram extends std::vector and adds a method for parsing programfile + * @date 10.05.2009 + */ + +#ifndef CPROGRAM_H +#define CPROGRAM_H 1 + +#include +#include +#include +#include "cinstruction.h" + +/** + * @class CProgram + * + * CProgram extends std::vector and adds a method for parsing + * programfile. This adds instances of CInstruction to CProgram itself. + */ +class CProgram + : public std::vector +{ + public: + /** + * @method CProgram + * @brief Default ctor + * @param - + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + CProgram(); + + /** + * @method ~CProgram + * @brief Default dtor + * @param - + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + ~CProgram(); + + /** + * @method getLabels + * @brief get reference to labels map + * @param - + * @return reference to labels map + * @globalvars none + * @exception none + * @conditions none + */ + const std::map& getLabels() const + { + return m_labels; + } + + /** + * @method findLabel + * @brief search for label + * @param label name of label to search for + * @return index of found label in program + * @globalvars none + * @exception std::runtime_error + * @conditions none + */ + unsigned findLabel(const std::string& label) const; + + /** + * @method compile + * @brief create instructions from parsing stream + * @param in inputstream to read from + * @return void + * @globalvars none + * @exception std::runtime_error + * @conditions none + */ + void compile(std::istream& in); + +#if DEBUG + /** + * @method dump + * @brief dumps contents to outputstream + * @param out outputstream to write to + * @return void + * @globalvars none + * @exception none + * @conditions none + */ + void dump(std::ostream& out); +#endif + + private: + /* members */ + /** set of known instructions */ + std::set m_instrset; + std::map m_labels; +}; + +#endif + +/* vim: set et sw=2 ts=2: */ -- cgit v1.2.3