aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm.cpp8
-rw-r--r--tuplr.hpp20
-rw-r--r--typing.cpp4
3 files changed, 16 insertions, 16 deletions
diff --git a/llvm.cpp b/llvm.cpp
index 4db9a2a..daaf4f9 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -293,7 +293,7 @@ CValue
ASTCall::compile(CEnv& cenv)
{
AST* c = maybeLookup(cenv, at(0));
- Function* f = dynamic_cast<Function*>(LLVal(cenv.compile(c)));
+ Function* f = dynamic_cast<Function*>(LLVal(c->compile(cenv)));
if (!f) throw Error("callee failed to compile", exp.loc);
vector<Value*> params(size() - 1);
@@ -408,9 +408,9 @@ ASTPrimitive::compile(CEnv& cenv)
AType*
ASTConsCall::functionType(CEnv& cenv)
{
- ASTTuple* protTypes = new ASTTuple(cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), NULL);
+ ASTTuple* protTypes = new ASTTuple(loc, cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), 0);
AType* cellType = new AType(loc,
- cenv.penv.sym("Pair"), cenv.tenv.type(at(1)), cenv.tenv.type(at(2)));
+ cenv.penv.sym("Pair"), cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), 0);
return new AType(at(0)->loc, cenv.penv.sym("Fn"), protTypes, cellType, 0);
}
@@ -423,7 +423,7 @@ ASTConsCall::lift(CEnv& cenv)
ASTCall::lift(cenv);
- ASTTuple* prot = new ASTTuple(at(1), at(2), NULL);
+ ASTTuple* prot = new ASTTuple(loc, at(1), at(2), 0);
vector<const Type*> types;
size_t sz = 0;
diff --git a/tuplr.hpp b/tuplr.hpp
index a906743..14be70d 100644
--- a/tuplr.hpp
+++ b/tuplr.hpp
@@ -135,11 +135,8 @@ private:
struct ASTTuple : public AST, public vector<AST*> {
ASTTuple(const vector<AST*>& t=vector<AST*>(), Cursor c=Cursor()) : AST(c), vector<AST*>(t) {}
ASTTuple(size_t size, Cursor c) : AST(c), vector<AST*>(size) {}
- ASTTuple(AST* ast, ...) {
+ ASTTuple(Cursor c, AST* ast, ...) : AST(c) {
va_list args; va_start(args, ast);
- init(ast, args);
- }
- void init(AST* ast, va_list args) {
push_back(ast);
for (AST* a = va_arg(args, AST*); a; a = va_arg(args, AST*))
push_back(a);
@@ -180,9 +177,12 @@ struct AType : public ASTTuple {
AType(unsigned i, Cursor c=Cursor()) : ASTTuple(0, c), kind(VAR), id(i) {}
AType(ASTSymbol* s) : ASTTuple(0, s->loc), kind(PRIM), id(0) { push_back(s); }
AType(const ASTTuple& t, Cursor c) : ASTTuple(t, c), kind(EXPR), id(0) {}
- AType(Cursor c, AST* ast, ...) : ASTTuple(0, c) {
+ AType(Cursor c, AST* ast, ...) : ASTTuple(0, c), kind(EXPR), id(0) {
va_list args; va_start(args, ast);
- init(ast, args);
+ push_back(ast);
+ for (AST* a = va_arg(args, AST*); a; a = va_arg(args, AST*))
+ push_back(a);
+ va_end(args);
}
string str() const {
switch (kind) {
@@ -236,8 +236,8 @@ struct Funcs : public list< pair<AType*, CFunction> > {
/// Closure (first-class function with captured lexical bindings)
struct ASTClosure : public ASTTuple {
- ASTClosure(ASTTuple* p, AST* b, const string& n="")
- : ASTTuple(0, p, b, NULL), name(n) {}
+ ASTClosure(Cursor c, ASTTuple* p, AST* b, const string& n="")
+ : ASTTuple(c, 0, p, b, NULL), name(n) {}
bool operator==(const AST& rhs) const { return this == &rhs; }
string str() const { return (format("%1%") % this).str(); }
void constrain(TEnv& tenv) const;
@@ -387,8 +387,8 @@ inline AST*
parseFn(PEnv& penv, const SExp& exp, void* arg)
{
SExp::List::const_iterator a = exp.list.begin(); ++a;
- return new ASTClosure(
- new ASTTuple(pmap(penv, *a), (*a++).loc),
+ return new ASTClosure(exp.loc,
+ new ASTTuple(pmap(penv, *a++)),
parseExpression(penv, *a++));
}
diff --git a/typing.cpp b/typing.cpp
index 872462a..b4a365a 100644
--- a/typing.cpp
+++ b/typing.cpp
@@ -24,7 +24,7 @@
void
ASTTuple::constrain(TEnv& tenv) const
{
- AType* t = new AType(loc, 0);
+ AType* t = new AType(ASTTuple(), loc);
FOREACH(const_iterator, p, *this) {
(*p)->constrain(tenv);
t->push_back(tenv.type(*p));
@@ -48,7 +48,7 @@ ASTCall::constrain(TEnv& tenv) const
FOREACH(const_iterator, p, *this)
(*p)->constrain(tenv);
AType* retT = tenv.type(this);
- AType* argsT = new AType(loc, 0);
+ AType* argsT = new AType(ASTTuple(), loc);
for (size_t i = 1; i < size(); ++i)
argsT->push_back(tenv.type(at(i)));
tenv.constrain(at(0), new AType(at(0)->loc, tenv.penv.sym("Fn"), argsT, retT, 0));