aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-12-27 18:18:54 +0000
committerDavid Robillard <d@drobilla.net>2012-12-27 18:18:54 +0000
commit0c09f8394149afdd7cca5908e08e2bb69971b50b (patch)
tree72fc51e58ed8b84f0cecfebb1cc9d3092aac9355
parent01a458a33f3329a254206b6bbe858542d7634ca4 (diff)
downloadresp-0c09f8394149afdd7cca5908e08e2bb69971b50b.tar.gz
resp-0c09f8394149afdd7cca5908e08e2bb69971b50b.tar.bz2
resp-0c09f8394149afdd7cca5908e08e2bb69971b50b.zip
def-type => define-type
git-svn-id: http://svn.drobilla.net/resp/trunk@453 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r--src/compile.cpp2
-rw-r--r--src/constrain.cpp6
-rw-r--r--src/depoly.cpp4
-rw-r--r--src/flatten.cpp2
-rw-r--r--src/lift.cpp8
-rw-r--r--src/pprint.cpp4
-rw-r--r--src/repl.cpp2
-rw-r--r--test/match.scm2
-rw-r--r--test/quote.scm3
9 files changed, 16 insertions, 17 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 9921382..1131e73 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -232,7 +232,7 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
return compile_dot(cenv, call);
else if (form == "define")
return compile_def(cenv, call);
- else if (form == "def-type")
+ else if (form == "define-type")
return compile_def_type(cenv, call);
else if (form == "quote")
return compile_quote(cenv, call);
diff --git a/src/constrain.cpp b/src/constrain.cpp
index 069384a..9674a97 100644
--- a/src/constrain.cpp
+++ b/src/constrain.cpp
@@ -129,10 +129,10 @@ constrain_def(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error)
static void
constrain_def_type(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error)
{
- THROW_IF(call->list_len() < 3, call->loc, "`def-type' requires at least 2 arguments");
+ THROW_IF(call->list_len() < 3, call->loc, "`define-type' requires at least 2 arguments");
ATuple::const_iterator i = call->iter_at(1);
const ATuple* prot = (*i)->to_tuple();
- THROW_IF(!prot, (*i)->loc, "first argument of `def-type' is not a tuple");
+ THROW_IF(!prot, (*i)->loc, "first argument of `define-type' is not a tuple");
const ASymbol* sym = (*prot->begin())->as_symbol();
THROW_IF(!sym, (*prot->begin())->loc, "type name is not a symbol");
//THROW_IF(tenv.ref(sym), call->loc, "type redefinition");
@@ -408,7 +408,7 @@ constrain_list(TEnv& tenv, Constraints& c, const ATuple* tup) throw(Error)
constrain_dot(tenv, c, tup);
else if (form == "define")
constrain_def(tenv, c, tup);
- else if (form == "def-type")
+ else if (form == "define-type")
constrain_def_type(tenv, c, tup);
else if (form == "lambda")
constrain_fn(tenv, c, tup);
diff --git a/src/depoly.cpp b/src/depoly.cpp
index fa71ba0..20e7159 100644
--- a/src/depoly.cpp
+++ b/src/depoly.cpp
@@ -74,7 +74,7 @@ raise_type(CEnv& cenv, Code& code, const ATuple* type)
const ATuple* exp = (*cenv.tenv.ref(tag))->as_tuple();
const ATuple* prot = exp->frst()->as_tuple();
- List def(Cursor(), cenv.penv.sym("def-type"), type, NULL);
+ List def(Cursor(), cenv.penv.sym("define-type"), type, NULL);
// Build a substitution for each type parameter to its instantiation
Subst subst;
@@ -118,7 +118,7 @@ resp_depoly(CEnv& cenv, Code& code, const AST* ast) throw()
assert(form != "lambda");
if (form == "quote")
return ast;
- else if (form == "def-type")
+ else if (form == "define-type")
return depoly_def_type(cenv, code, call);
else
return depoly_args(cenv, code, call);
diff --git a/src/flatten.cpp b/src/flatten.cpp
index b190832..5cb7c67 100644
--- a/src/flatten.cpp
+++ b/src/flatten.cpp
@@ -180,7 +180,7 @@ resp_flatten(CEnv& cenv, Code& code, const AST* ast) throw()
return ast;
else if (form == "define")
return flatten_def(cenv, code, call);
- else if (form == "def-type")
+ else if (form == "define-type")
return flatten_def_type(cenv, code, call);
else if (form == "do")
return flatten_do(cenv, code, call);
diff --git a/src/lift.cpp b/src/lift.cpp
index 8cdf654..9341121 100644
--- a/src/lift.cpp
+++ b/src/lift.cpp
@@ -188,14 +188,14 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw()
cenv.setType(impl, realImplT);
// Create type definition for closure type
- List tdef(Cursor(), cenv.penv.sym("def-type"), tsym, 0);
+ List tdef(Cursor(), cenv.penv.sym("define-type"), tsym, 0);
tdef.push_back(closureT);
code.push_back(tdef);
cenv.tenv.def(tsym, closureT);
// Put forward declaration for type at start of code
- List tdecl(Cursor(), cenv.penv.sym("def-type"), tsym, 0);
+ List tdecl(Cursor(), cenv.penv.sym("define-type"), tsym, 0);
code.push_front(tdecl);
// Set type of closure to type symbol
@@ -218,7 +218,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw()
// Replace return type variable with actual return type in code
for (auto& i : code) {
- if (is_form(i, "def-type")) {
+ if (is_form(i, "define-type")) {
i = cenv.typedReplace(i->as_tuple(), retTVar, implRetT);
}
}
@@ -310,7 +310,7 @@ resp_lift(CEnv& cenv, Code& code, const AST* ast) throw()
return lift_dot(cenv, code, call);
else if (form == "define")
return lift_def(cenv, code, call);
- else if (form == "def-type")
+ else if (form == "define-type")
return call;
else if (form == "do")
return lift_args(cenv, code, call);
diff --git a/src/pprint.cpp b/src/pprint.cpp
index 463d91a..cc6d316 100644
--- a/src/pprint.cpp
+++ b/src/pprint.cpp
@@ -174,7 +174,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
}
out << ")";
- } else if (form == "def-type") {
+ } else if (form == "define-type") {
out << (*i++);
newline(out, indent + 2);
print_list(out, tup, i, indent + 2, cenv, types, false);
@@ -251,6 +251,6 @@ pprint(ostream& out, const AST* ast, CEnv* cenv, bool types)
out << endl;
if ((is_form(ast, "define") && is_form(ast->as_tuple()->frrst(), "lambda"))
|| is_form(ast, "fn-end")
- || is_form(ast, "def-type"))
+ || is_form(ast, "define-type"))
out << endl;
}
diff --git a/src/repl.cpp b/src/repl.cpp
index 16d766f..5e2741c 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -138,7 +138,7 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
Code exprs;
for (auto i : stages.back()) {
const ATuple* call = i->to_tuple();
- if (call && (is_form(i, "def-type")
+ if (call && (is_form(i, "define-type")
|| (is_form(i, "define") && is_form(call->frrst(), "lambda")))) {
resp_flatten(cenv, defs, call);
} else if (call && is_form(i, "prot")) {
diff --git a/test/match.scm b/test/match.scm
index db19be1..0cf0efc 100644
--- a/test/match.scm
+++ b/test/match.scm
@@ -1,5 +1,5 @@
; A Shape is either a Circle (w/ radius) or a Rectangle (w/ width/height)
-(def-type (Shape)
+(define-type (Shape)
(Circle Float)
(Rectangle Float Float))
diff --git a/test/quote.scm b/test/quote.scm
index 4895d2e..817f812 100644
--- a/test/quote.scm
+++ b/test/quote.scm
@@ -1,10 +1,9 @@
-(def-type (Expr)
+(define-type (Expr)
(Symbol Symbol)
(Int Int)
(List Expr Expr)
(Empty))
-
(define list (quote (2 a b c)))
(define (len l)