aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-31 05:13:33 +0000
committerDavid Robillard <d@drobilla.net>2010-12-31 05:13:33 +0000
commitef8ec5f9d0a8def665cb31c6ee84e0afbc80c1bc (patch)
tree4893d604dbad2139ffcf30ab911b33e4a24a9b93 /src
parent587327df599069692dc8de6f4679bf09171b0e44 (diff)
downloadresp-ef8ec5f9d0a8def665cb31c6ee84e0afbc80c1bc.tar.gz
resp-ef8ec5f9d0a8def665cb31c6ee84e0afbc80c1bc.tar.bz2
resp-ef8ec5f9d0a8def665cb31c6ee84e0afbc80c1bc.zip
Print fn parameter type annotations correctly.
git-svn-id: http://svn.drobilla.net/resp/resp@390 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r--src/pprint.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/pprint.cpp b/src/pprint.cpp
index 65372d7..e83c089 100644
--- a/src/pprint.cpp
+++ b/src/pprint.cpp
@@ -41,21 +41,25 @@ print_annotation(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool
const AST* var = cenv->tenv.var(ast);
if (var) {
out << " :";
- print_to(out, cenv->tsubst.apply(var), indent + 2, cenv, print);
+ print_to(out, cenv->tsubst.apply(var), indent + 2, cenv, false);
}
}
}
ostream&
print_list_one_line(ostream& out, const ATuple* tup, ATuple::const_iterator i,
- unsigned indent, CEnv* cenv, bool types, bool elem_types)
+ unsigned indent, CEnv* cenv, bool types, const ATuple* elemsT)
{
+ ATuple::const_iterator ti = elemsT ? elemsT->begin() : tup->end();
for (; i != tup->end(); ) {
ATuple::const_iterator next = i;
++next;
print_to(out, *i, indent, cenv, types);
- print_annotation(out, *i, indent, cenv, elem_types);
+ if (elemsT) {
+ out << " :";
+ print_to(out, *ti++, indent, cenv, false);
+ }
if (next != tup->end())
out << " ";
@@ -142,8 +146,9 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
out << "(" << (*i++) << " ";
const ATuple* const fn = tup->frrst()->as_tuple();
const ATuple* const prot = fn->frst()->as_tuple();
- print_list_one_line(out, prot, prot->begin(), indent + 7, cenv, types, types);
- print_annotation(out, fn, indent + head_width + 1, cenv, types);
+ const ATuple* const fnT = cenv->type(fn)->as_tuple();
+ print_list_one_line(out, prot, prot->begin(), indent + 7, cenv, types, fnT->prot());
+ print_annotation(out, fn->list_last(), indent + head_width + 1, cenv, types);
newline(out, indent + 2);
print_list(out, fn, fn->iter_at(2), indent + 2, cenv, types, false);
@@ -168,11 +173,13 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
// Print prototype (possibly with parameter type annotations)
const ATuple* pat = (*i++)->as_tuple();
out << "(";
- print_list_one_line(out, pat, pat->begin(), indent + 2, cenv, types, types);
+ const ATuple* type = cenv->type(tup)->to_tuple();
+ const ATuple* protT = type ? type->prot() : NULL;
+ print_list_one_line(out, pat, pat->begin(), indent + 2, cenv, types, protT);
// Print body expression(s) indented on the following lines
newline(out, indent + 2);
- print_list(out, tup, i, indent + 2, cenv, types, false);
+ print_list(out, tup, i, indent + 2, cenv, false, false);
} else if (form == "if") {
print_list(out, tup, i, indent + 4, cenv, types, true);
@@ -192,9 +199,9 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types)
out << ")";
}
newline(out, indent + 2);
- print_list(out, tup, tup->iter_at(2), indent + 2, cenv, types, false);
+ print_list(out, tup, tup->iter_at(2), indent + 2, cenv, false, false);
out << ")";
- print_annotation(out, tup->list_last(), indent, cenv, types);
+ //print_annotation(out, tup->list_last(), indent, cenv, types);
} else if (form == "match") {
out << (*i++);