diff options
-rw-r--r-- | tuplr.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -59,11 +59,11 @@ struct Error { template<typename A> struct Exp { // ::= Atom | (Exp*) - Exp(Cursor c) : loc(c), type(LIST) {} - Exp(Cursor c, const A& a) : loc(c), type(ATOM), atom(a) {} - Cursor loc; - enum { ATOM, LIST } type; + Exp(Cursor c) : type(LIST), loc(c) {} + Exp(Cursor c, const A& a) : type(ATOM), loc(c), atom(a) {} typedef std::vector< Exp<A> > List; + enum { ATOM, LIST } type; + Cursor loc; A atom; List list; }; @@ -153,7 +153,7 @@ struct ASTLiteral : public AST { ASTLiteral(VT v) : val(v) {} bool operator==(const AST& rhs) const { const ASTLiteral<VT>* r = dynamic_cast<const ASTLiteral<VT>*>(&rhs); - return r && val == r->val; + return (r && (val == r->val)); } string str() const { return (format("%1%") % val).str(); } void constrain(TEnv& tenv) const; @@ -219,13 +219,7 @@ struct AType : public ASTTuple { AType(ASTSymbol* n, const Type* t) : var(false), ctype(t) { push_back(n); } - string str() const { - if (var) { - return (format("?%1%") % id).str(); - } else { - return ASTTuple::str(); - } - } + string str() const { return var ? (format("?%1%") % id).str() : ASTTuple::str(); } void constrain(TEnv& tenv) const {} Value* compile(CEnv& cenv) { return NULL; } bool concrete() const { @@ -258,7 +252,7 @@ struct AType : public ASTTuple { } else { return ctype; } - }; + } bool var; unsigned id; private: @@ -768,9 +762,9 @@ template<> void \ ASTLiteral<CT>::constrain(TEnv& tenv) const { tenv.constrain(this, tenv.named(NAME)); } /// Literal template instantiations -LITERAL(int32_t, "Int", ConstantInt::get(Type::Int32Ty, val, true)); -LITERAL(float, "Float", ConstantFP::get(Type::FloatTy, val)); -LITERAL(bool, "Bool", ConstantInt::get(Type::Int1Ty, val, false)); +LITERAL(int32_t, "Int", ConstantInt::get(Type::Int32Ty, val, true)) +LITERAL(float, "Float", ConstantFP::get(Type::FloatTy, val)) +LITERAL(bool, "Bool", ConstantInt::get(Type::Int1Ty, val, false)) static Function* compileFunction(CEnv& cenv, const std::string& name, const Type* retT, ASTTuple& prot, |