diff options
Diffstat (limited to 'tuplr.hpp')
-rw-r--r-- | tuplr.hpp | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -26,17 +26,26 @@ #include <vector> #include <boost/format.hpp> -typedef void* CValue; ///< Compiled value (opaque) -typedef const void* CType; ///< Compiled type (opaque) -typedef void* CFunction; ///< Compiled function (opaque) - -struct CEngine; ///< Backend data (opaque) - #define FOREACH(IT, i, c) for (IT i = (c).begin(); i != (c).end(); ++i) using namespace std; using boost::format; + +/*************************************************************************** + * Backend * + ***************************************************************************/ + +typedef void* CValue; ///< Compiled value (opaque) +typedef void* CFunction; ///< Compiled function (opaque) + +struct CEngine; ///< Backend data (opaque) + + +/*************************************************************************** + * Basic Utility Classes * + ***************************************************************************/ + extern std::ostream& err; extern std::ostream& out; @@ -56,7 +65,7 @@ struct Error { }; template<typename Atom> -struct Exp { // ::= Atom | (Exp*) +struct Exp { Exp(Cursor c) : type(LIST), loc(c) {} Exp(Cursor c, const Atom& a) : type(ATOM), loc(c), atom(a) {} typedef std::vector< Exp<Atom> > List; @@ -164,9 +173,9 @@ struct ASTTuple : public AST, public vector<AST*> { /// Type Expression, e.g. "Int", "(Fn (Int Int) Float)" struct AType : public ASTTuple { - AType(const ASTTuple& t) : ASTTuple(t), kind(EXPR), _ctype(0) {} - AType(unsigned i) : kind(VAR), id(i), _ctype(0) {} - AType(ASTSymbol* n, CType t) : kind(PRIM), _ctype(t) { push_back(n); } + AType(unsigned i) : kind(VAR), id(i) {} + AType(ASTSymbol* s) : kind(PRIM), id(0) { push_back(s); } + AType(const ASTTuple& t) : ASTTuple(t), kind(EXPR), id(0) {} string str() const { switch (kind) { case VAR: return (format("?%1%") % id).str(); @@ -203,11 +212,8 @@ struct AType : public ASTTuple { } return false; // never reached } - CType ctype(); enum { VAR, PRIM, EXPR } kind; unsigned id; -private: - const CType _ctype; }; /// Lifted system functions (of various types) for a single Tuplr function |