| 1 |
//---------------------------------------------------------------------------- |
| 2 |
// CompilerCode.h |
| 3 |
// Compile intermediate code into native C++ code |
| 4 |
// $Date: 2003/02/20 00:24:16 $ |
| 5 |
// $Revision: 1.3 $ |
| 6 |
//---------------------------------------------------------------------------- |
| 7 |
#ifndef QCOMPILERCODE_H |
| 8 |
#define QCOMPILERCODE_H |
| 9 |
|
| 10 |
#include <iostream> |
| 11 |
#include <string> |
| 12 |
#include <vector> |
| 13 |
#include "QCompiler.h" |
| 14 |
#include "QParseInfo.h" |
| 15 |
|
| 16 |
class QCompilerCode : public QCompiler { |
| 17 |
public: |
| 18 |
QCompilerCode(const char * const = "qcpp_result.qdt"); |
| 19 |
QCompilerCode(std::istream &is, const char * const = "qcpp_result.qdt"); |
| 20 |
virtual ~QCompilerCode(); |
| 21 |
void SaveToStream(std::ostream &os); |
| 22 |
void SaveToFile(const char * const filename); |
| 23 |
|
| 24 |
protected: |
| 25 |
virtual bool CompileOneLine(const QParseInfo &pinfo); |
| 26 |
virtual void CatchError(const QParseInfo &pinfo, const int at); |
| 27 |
|
| 28 |
// Utility functions |
| 29 |
void WriteHeader(std::ostream &os); |
| 30 |
void WriteQBits(std::ostream &os, const int &t1); |
| 31 |
void WriteFooter(std::ostream &os); |
| 32 |
void WriteCNot (std::ostream &os, const int &t1, const int &c1); |
| 33 |
void WriteCCNot (std::ostream &os, const int &t1, const int &c1, const int &c2); |
| 34 |
void WriteCRot (std::ostream &os, const int &t1, const int &c1, const double rad); |
| 35 |
void WriteHadam (std::ostream &os, const int &t1); |
| 36 |
//TODO: additional controls |
| 37 |
|
| 38 |
// Member valuables |
| 39 |
std::string mTargetName; |
| 40 |
std::vector<QParseInfo> mQParseInfo; |
| 41 |
}; |
| 42 |
|
| 43 |
#endif //QCOMPILERCODE_H |