aboutsummaryrefslogtreecommitdiffstats
path: root/src/c.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/c.cpp')
-rw-r--r--src/c.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/c.cpp b/src/c.cpp
index 7df33b0..6493ff3 100644
--- a/src/c.cpp
+++ b/src/c.cpp
@@ -55,14 +55,14 @@ llType(const AType* t)
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<const ATuple*>();
- const AType* retT = (*i)->as<const AType*>();
+ const ATuple* protT = (*++i)->to_tuple();
+ const AType* retT = (*i)->as_type();
if (!llType(retT))
return NULL;
Type* ret = new Type(*llType(retT) + " (*)(");
FOREACHP(ATuple::const_iterator, i, protT) {
- const AType* at = (*i)->to<const AType*>();
+ const AType* at = (*i)->to_type();
const Type* lt = llType(at);
if (!lt)
return NULL;
@@ -74,7 +74,7 @@ llType(const AType* t)
} else if (t->kind == AType::EXPR && t->head()->str() == "Tup") {
Type* ret = new Type("struct { void* me; ");
for (AType::const_iterator i = t->iter_at(1); i != t->end(); ++i) {
- const Type* lt = llType((*i)->to<const AType*>());
+ const Type* lt = llType((*i)->to_type());
if (!lt)
return NULL;
ret->append("; ");
@@ -103,12 +103,12 @@ struct CEngine : public Engine {
CFunc startFunction(CEnv& cenv,
const std::string& name, const ATuple* args, const AType* type)
{
- const AType* argsT = type->prot()->as<const AType*>();
- const AType* retT = type->list_ref(2)->as<const AType*>();
+ const AType* argsT = type->prot()->as_type();
+ const AType* retT = type->list_ref(2)->as_type();
vector<const Type*> cprot;
FOREACHP(ATuple::const_iterator, i, argsT) {
- const AType* at = (*i)->as<const AType*>();
+ const AType* at = (*i)->as_type();
THROW_IF(!llType(at), Cursor(), string("non-concrete parameter :: ")
+ at->str())
cprot.push_back(llType(at));
@@ -126,7 +126,7 @@ struct CEngine : public Engine {
for (; ai != argsT->end(); ++ai, ++ni) {
if (ai != argsT->begin())
f->text += ", ";
- f->text += *llType((*ai)->as<const AType*>()) + " " + (*ni)->as<const ASymbol*>()->cppstr;
+ f->text += *llType((*ai)->as_type()) + " " + (*ni)->as_symbol()->cppstr;
}
f->text += ")\n{\n";
@@ -215,17 +215,17 @@ CEngine::pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc
{
cenv.push();
- const AType* argsT = type->prot()->as<const AType*>();
+ const AType* argsT = type->prot()->as_type();
// Bind argument values in CEnv
vector<Value*> args;
ATuple::const_iterator p = fn->prot()->begin();
ATuple::const_iterator pT = argsT->begin();
for (; p != fn->prot()->end(); ++p, ++pT) {
- const AType* t = (*pT)->as<const AType*>();
+ const AType* t = (*pT)->as_type();
const Type* lt = llType(t);
THROW_IF(!lt, fn->loc, "untyped parameter\n");
- cenv.def((*p)->as<const ASymbol*>(), *p, t, new string((*p)->str()));
+ cenv.def((*p)->as_symbol(), *p, t, new string((*p)->str()));
}
}
@@ -275,7 +275,7 @@ CEngine::compilePrimitive(CEnv& cenv, const ATuple* prim)
Value* a = llVal(resp_compile(cenv, *i++));
Value* b = llVal(resp_compile(cenv, *i++));
- const string n = prim->head()->to<const ASymbol*>()->str();
+ const string n = prim->head()->to_symbol()->str();
string op = n;
// Convert operator to C operator if they don't match