aboutsummaryrefslogtreecommitdiffstats
path: root/tuplr.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-03-06 22:12:36 +0000
committerDavid Robillard <d@drobilla.net>2009-03-06 22:12:36 +0000
commitecef8f697c66e15b85beb934d2b617b915a97aab (patch)
tree576af3f3063f07c08ecbbd1cfdb9d8034cc5bc2b /tuplr.hpp
parent382d3051052fd20ab55f40beb7664bfb3f0379a1 (diff)
downloadresp-ecef8f697c66e15b85beb934d2b617b915a97aab.tar.gz
resp-ecef8f697c66e15b85beb934d2b617b915a97aab.tar.bz2
resp-ecef8f697c66e15b85beb934d2b617b915a97aab.zip
Cleanup and de-llvm-ify primitive stuff.
Fix type inference (only treat actual type expressions as type expressions). git-svn-id: http://svn.drobilla.net/resp/tuplr@64 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'tuplr.hpp')
-rw-r--r--tuplr.hpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/tuplr.hpp b/tuplr.hpp
index 7c28112..0bfb5c1 100644
--- a/tuplr.hpp
+++ b/tuplr.hpp
@@ -31,7 +31,6 @@ typedef const void* CType; ///< Compiled type (opaque)
typedef void* CFunction; ///< Compiled function (opaque)
struct CEngine; ///< Backend data (opaque)
-struct CArg; ///< Parser function argument (opaque)
#define FOREACH(IT, i, c) for (IT i = (c).begin(); i != (c).end(); ++i)
@@ -247,7 +246,7 @@ struct ASTCall : public ASTTuple {
/// Definition special form, e.g. "(def x 2)"
struct ASTDefinition : public ASTCall {
- ASTDefinition(const SExp& e, const ASTTuple& t, CArg* ca=0) : ASTCall(e, t) {}
+ ASTDefinition(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {}
void constrain(TEnv& tenv) const;
void lift(CEnv& cenv);
CValue compile(CEnv& cenv);
@@ -255,22 +254,21 @@ struct ASTDefinition : public ASTCall {
/// Conditional special form, e.g. "(if cond thenexp elseexp)"
struct ASTIf : public ASTCall {
- ASTIf(const SExp& e, const ASTTuple& t, CArg* ca=0) : ASTCall(e, t) {}
+ ASTIf(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {}
void constrain(TEnv& tenv) const;
CValue compile(CEnv& cenv);
};
/// Primitive (builtin arithmetic function), e.g. "(+ 2 3)"
struct ASTPrimitive : public ASTCall {
- ASTPrimitive(const SExp& e, const ASTTuple& t, CArg* ca=0) : ASTCall(e, t), arg(ca) {}
+ ASTPrimitive(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {}
void constrain(TEnv& tenv) const;
CValue compile(CEnv& cenv);
- CArg* arg;
};
/// Cons special form, e.g. "(cons 1 2)"
struct ASTConsCall : public ASTCall {
- ASTConsCall(const SExp& e, const ASTTuple& t, CArg* ca=0) : ASTCall(e, t) {}
+ ASTConsCall(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {}
AType* functionType(CEnv& cenv);
void constrain(TEnv& tenv) const;
void lift(CEnv& cenv);
@@ -280,14 +278,14 @@ struct ASTConsCall : public ASTCall {
/// Car special form, e.g. "(car p)"
struct ASTCarCall : public ASTCall {
- ASTCarCall(const SExp& e, const ASTTuple& t, CArg* ca=0) : ASTCall(e, t) {}
+ ASTCarCall(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {}
void constrain(TEnv& tenv) const;
CValue compile(CEnv& cenv);
};
/// Cdr special form, e.g. "(cdr p)"
struct ASTCdrCall : public ASTCall {
- ASTCdrCall(const SExp& e, const ASTTuple& t, CArg* ca=0) : ASTCall(e, t) {}
+ ASTCdrCall(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {}
void constrain(TEnv& tenv) const;
CValue compile(CEnv& cenv);
};
@@ -299,8 +297,8 @@ struct ASTCdrCall : public ASTCall {
// Parse Time Environment (symbol table)
struct PEnv : private map<const string, ASTSymbol*> {
- typedef AST* (*PF)(PEnv&, const SExp&, CArg*); // Parse Function
- struct Handler { Handler(PF f, CArg* a=0) : func(f), arg(a) {} PF func; CArg* arg; };
+ typedef AST* (*PF)(PEnv&, const SExp&, void*); // Parse Function
+ struct Handler { Handler(PF f, void* a=0) : func(f), arg(a) {} PF func; void* arg; };
map<const string, Handler> aHandlers; ///< Atom parse functions
map<const string, Handler> lHandlers; ///< List parse functions
void reg(bool list, const string& s, const Handler& h) {
@@ -358,20 +356,20 @@ parseExpression(PEnv& penv, const SExp& exp)
template<typename C>
inline AST*
-parseCall(PEnv& penv, const SExp& exp, CArg* arg)
+parseCall(PEnv& penv, const SExp& exp, void* arg)
{
- return new C(exp, pmap(penv, exp.list), arg);
+ return new C(exp, pmap(penv, exp.list));
}
template<typename T>
inline AST*
-parseLiteral(PEnv& penv, const SExp& exp, CArg* arg)
+parseLiteral(PEnv& penv, const SExp& exp, void* arg)
{
return new ASTLiteral<T>(*reinterpret_cast<T*>(arg));
}
inline AST*
-parseFn(PEnv& penv, const SExp& exp, CArg* arg)
+parseFn(PEnv& penv, const SExp& exp, void* arg)
{
SExp::List::const_iterator a = exp.list.begin(); ++a;
return new ASTClosure(
@@ -479,6 +477,7 @@ private:
* EVAL/REPL/MAIN *
***************************************************************************/
+void initTypes(PEnv& penv, TEnv& tenv);
void initLang(PEnv& penv, TEnv& tenv);
CEnv* newCenv(PEnv& penv, TEnv& tenv);
int eval(CEnv& cenv, const string& name, istream& is);