aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 4fed182..393084e 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -37,18 +37,23 @@ compile_symbol(CEnv& cenv, const ASymbol* sym) throw()
}
static CVal
-compile_type(CEnv& cenv, const AST* type) throw()
+compile_literal_symbol(CEnv& cenv, const ASymbol* sym) throw()
{
- const ASymbol* sym = type->as_tuple()->head()->as_symbol();
- CVal* existing = cenv.vals.ref(sym);
+ CVal* existing = cenv.vals.ref(sym);
if (existing) {
return *existing;
} else {
- CVal compiled = cenv.engine()->compileString(
- cenv, (string("__T_") + type->as_tuple()->head()->str()).c_str());
+ CVal compiled = cenv.engine()->compileString(cenv, (string("__T_") + sym->sym()).c_str());
cenv.vals.def(sym, compiled);
return compiled;
}
+
+}
+
+static CVal
+compile_type(CEnv& cenv, const AST* type) throw()
+{
+ return compile_literal_symbol(cenv, type->as_tuple()->head()->as_symbol());
}
static CVal
@@ -142,16 +147,6 @@ compile_if(CEnv& cenv, const ATuple* aif) throw()
}
static CVal
-compile_tag_is(CEnv& cenv, const ATuple* call) throw()
-{
- const AST* lhs = call->list_ref(1);
- const ASymbol* tag = call->list_ref(2)->as_symbol();
- const ATuple* patT = new ATuple(tag, 0, Cursor());
-
- return cenv.engine()->compileIsA(cenv, resp_compile(cenv, lhs), compile_type(cenv, patT));
-}
-
-static CVal
compile_call(CEnv& cenv, const ATuple* call) throw()
{
CFunc f = resp_compile(cenv, call->head());
@@ -181,6 +176,8 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
return cenv.engine()->compileString(cenv, ((AString*)ast)->cppstr.c_str());
case T_SYMBOL:
return compile_symbol(cenv, ast->as_symbol());
+ case T_LITSYM:
+ return compile_literal_symbol(cenv, (ASymbol*)ast);
case T_TUPLE:
{
const ATuple* const call = ast->as_tuple();
@@ -202,8 +199,6 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
return compile_fn(cenv, call);
else if (form == "if")
return compile_if(cenv, call);
- else if (form == "__tag_is")
- return compile_tag_is(cenv, call);
else
return compile_call(cenv, call);
}