aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-03-07 03:56:20 +0000
committerDavid Robillard <d@drobilla.net>2009-03-07 03:56:20 +0000
commit6d9b8a06e9d9fece731d045db2f815f261db09c3 (patch)
treefb2bbf652b359670575906ce717b22523c6a2b04
parent311e3b43b68209648fe9561d1aaff93d9a4d4f0f (diff)
downloadresp-6d9b8a06e9d9fece731d045db2f815f261db09c3.tar.gz
resp-6d9b8a06e9d9fece731d045db2f815f261db09c3.tar.bz2
resp-6d9b8a06e9d9fece731d045db2f815f261db09c3.zip
Ensure only CEnv can call compile function directly (fix recursive functions).
git-svn-id: http://svn.drobilla.net/resp/tuplr@74 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r--llvm.cpp2
-rw-r--r--tuplr.hpp14
2 files changed, 9 insertions, 7 deletions
diff --git a/llvm.cpp b/llvm.cpp
index 8eeab42..c0c46c9 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -281,7 +281,7 @@ CValue
ASTCall::compile(CEnv& cenv)
{
AST* c = maybeLookup(cenv, at(0));
- Function* f = dynamic_cast<Function*>(LLVal(c->compile(cenv)));
+ Function* f = dynamic_cast<Function*>(LLVal(cenv.compile(c)));
if (!f) throw Error("callee failed to compile", exp.loc);
vector<Value*> params(size() - 1);
diff --git a/tuplr.hpp b/tuplr.hpp
index c86ff68..29b8463 100644
--- a/tuplr.hpp
+++ b/tuplr.hpp
@@ -99,13 +99,15 @@ struct CEnv; ///< Compile-Time Environment
struct AST {
AST(Cursor c=Cursor()) : loc(c) {}
virtual ~AST() {}
- virtual string str() const = 0;
- virtual bool operator==(const AST& o) const = 0;
- virtual bool contains(AST* child) const { return false; }
- virtual void constrain(TEnv& tenv) const {}
- virtual void lift(CEnv& cenv) {}
- virtual CValue compile(CEnv& cenv) = 0;
+ virtual string str() const = 0;
+ virtual bool operator==(const AST& o) const = 0;
+ virtual bool contains(const AST* child) const { return false; }
+ virtual void constrain(TEnv& tenv) const {}
+ virtual void lift(CEnv& cenv) {}
Cursor loc;
+private:
+ friend class CEnv;
+ virtual CValue compile(CEnv& cenv) = 0;
};
/// Literal value