aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-26 20:07:18 +0000
committerDavid Robillard <d@drobilla.net>2010-12-26 20:07:18 +0000
commitaa6a0b6a6553e854be6731e8ebd4306605b00e6e (patch)
treeb1e4ebb8e3252df4aaf0eefd7f94e077cb8baaab /src
parentd9ced5e07ec20f47bd2743f93f84438ac3eb4c6a (diff)
downloadresp-aa6a0b6a6553e854be6731e8ebd4306605b00e6e.tar.gz
resp-aa6a0b6a6553e854be6731e8ebd4306605b00e6e.tar.bz2
resp-aa6a0b6a6553e854be6731e8ebd4306605b00e6e.zip
Remove AType::PRIM.
git-svn-id: http://svn.drobilla.net/resp/resp@357 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r--src/c.cpp6
-rw-r--r--src/expand.cpp2
-rw-r--r--src/llvm.cpp11
-rw-r--r--src/pprint.cpp1
-rw-r--r--src/resp.hpp7
5 files changed, 12 insertions, 15 deletions
diff --git a/src/c.cpp b/src/c.cpp
index 4d13ba6..65a939d 100644
--- a/src/c.cpp
+++ b/src/c.cpp
@@ -83,14 +83,13 @@ CEngine::llType(const AType* t)
{
if (t == NULL) {
return NULL;
- } else if (t->kind == AType::PRIM) {
+ } else if (t->kind == AType::NAME) {
if (t->head()->str() == "Nothing") return new string("void");
if (t->head()->str() == "Bool") return new string("bool");
if (t->head()->str() == "Int") return new string("int");
if (t->head()->str() == "Float") return new string("float");
if (t->head()->str() == "String") return new string("char*");
if (t->head()->str() == "Quote") return new string("char*");
- throw Error(t->loc, string("Unknown primitive type `") + t->str() + "'");
} else if (t->kind == AType::EXPR && t->head()->str() == "Fn") {
AType::const_iterator i = t->begin();
const ATuple* protT = (*++i)->to_tuple();
@@ -121,7 +120,8 @@ CEngine::llType(const AType* t)
ret->append("}*");
return ret;
}
- return new Type("void*");
+ throw Error(t->loc, string("Unknown compiled type `") + t->str() + "'");
+ return NULL;
}
CVal
diff --git a/src/expand.cpp b/src/expand.cpp
index 4c5b1ba..bd04e5f 100644
--- a/src/expand.cpp
+++ b/src/expand.cpp
@@ -116,7 +116,7 @@ initLang(PEnv& penv, TEnv& tenv)
"Bool", "Float", "Int", "Lexeme", "Nothing", "Quote", "String", 0 };
for (const char** t = types; *t; ++t) {
const ASymbol* sym = penv.sym(*t);
- tenv.def(sym, new AType(sym, AType::PRIM));
+ tenv.def(sym, new AType(sym, AType::NAME));
}
const char* primitives[] = {
diff --git a/src/llvm.cpp b/src/llvm.cpp
index 8dee633..939eeeb 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -131,14 +131,16 @@ LLVMEngine::llType(const AType* t)
{
if (t == NULL) {
return NULL;
- } else if (t->kind == AType::PRIM) {
+ } else if (t->kind == AType::VAR) {
+ // Kludge for _me closure parameter, will be casted
+ return PointerType::get(Type::getInt8Ty(context), NULL);
+ } else if (t->kind == AType::NAME) {
if (t->head()->str() == "Nothing") return Type::getVoidTy(context);
if (t->head()->str() == "Bool") return Type::getInt1Ty(context);
if (t->head()->str() == "Int") return Type::getInt32Ty(context);
if (t->head()->str() == "Float") return Type::getFloatTy(context);
if (t->head()->str() == "String") return PointerType::get(Type::getInt8Ty(context), NULL);
if (t->head()->str() == "Quote") return PointerType::get(Type::getInt8Ty(context), NULL);
- throw Error(t->loc, string("Unknown primitive type `") + t->str() + "'");
} else if (t->kind == AType::EXPR && t->head()->str() == "Fn") {
AType::const_iterator i = t->begin();
const ATuple* protT = (*++i)->to_tuple();
@@ -166,11 +168,8 @@ LLVMEngine::llType(const AType* t)
}
return PointerType::get(StructType::get(context, ctypes, false), 0);
- } else if (t->kind == AType::NAME) {
- assert(false);
}
- assert(false);
- return PointerType::get(Type::getInt8Ty(context), NULL);
+ return NULL;
}
/** Convert a size in bits to bytes, rounding up as necessary */
diff --git a/src/pprint.cpp b/src/pprint.cpp
index c8176d9..506d24e 100644
--- a/src/pprint.cpp
+++ b/src/pprint.cpp
@@ -102,7 +102,6 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
switch (type->kind) {
case AType::VAR: return out << "?" << type->id;
case AType::NAME: return out << type->head();
- case AType::PRIM: return out << type->head();
case AType::DOTS: return out << "...";
case AType::EXPR: break; // will catch Tuple case below
}
diff --git a/src/resp.hpp b/src/resp.hpp
index bde4bcf..8fa4b9b 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -353,7 +353,7 @@ list_contains(const ATuple* head, const AST* child) {
/// Type Expression, e.g. "Int", "(Fn (Int Int) Float)"
struct AType : public ATuple {
- enum Kind { VAR, NAME, PRIM, EXPR, DOTS };
+ enum Kind { VAR, NAME, EXPR, DOTS };
AType(const ASymbol* s, Kind k) : ATuple(s, NULL, s->loc), kind(k), id(0) { tag(T_TYPE); }
AType(Cursor c, unsigned i) : ATuple(c), kind(VAR), id(i) { tag(T_TYPE); }
AType(Cursor c, Kind k=EXPR) : ATuple(c), kind(k), id(0) { tag(T_TYPE); }
@@ -453,7 +453,6 @@ AST::operator==(const AST& rhs) const
switch (me->kind) {
case AType::VAR: return me->id == rt->id;
case AType::NAME: return me->head()->str() == rt->head()->str();
- case AType::PRIM: return me->head()->str() == rt->head()->str();
case AType::EXPR: return list_equals(me, rt);
case AType::DOTS: return true;
}
@@ -640,9 +639,9 @@ struct TEnv : public Env<const AType*> {
, varID(1)
, Closure(new AType(penv.sym("Closure"), AType::NAME))
, Dots(new AType(Cursor(), AType::DOTS))
- , Fn(new AType(penv.sym("Fn"), AType::PRIM))
+ , Fn(new AType(penv.sym("Fn"), AType::NAME))
, Tup(new AType(penv.sym("Tup"), AType::NAME))
- , U(new AType(penv.sym("U"), AType::PRIM))
+ , U(new AType(penv.sym("U"), AType::NAME))
{
Object::pool.addRoot(Fn);
}