32 static char *tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
43 cmp(void *va, void *vb)
48 return strcmp(*a, *b);
56 int i, j, n, max, col, f, g, s;
61 vec = malloc(sizeof(char*)*g);
63 fatal("out of memory");
65 for(i = 0; i < Hashsize; i++) {
66 for(l = hash[i]; l; l = l->hash) {
67 if(l->proc == 0 && l->builtin == 0)
74 vec = realloc(vec, sizeof(char*)*g);
76 fatal("out of memory");
81 qsort(vec, f, sizeof(char*), cmp);
86 for(i = 0; i < s; i++) {
87 for(j = i; j < f; j += s)
88 Bprint(bout, "%-*s", max, vec[j]);
109 Bprint(bout, "%s variable", typenames[t]);
110 if(t == TINT || t == TFLOAT)
111 Bprint(bout, " format %c", l->v->fmt);
113 Bprint(bout, " complex %s", l->v->comt->base->name);
118 Bprint(bout, "complex %s {\n", l->name);
119 for(ti = l->lt; ti; ti = ti->next) {
122 Bprint(bout, "\t%s %d %s;\n",
123 ti->type->name, ti->offset,
127 Bprint(bout, "\t'%c' %s %d %s;\n",
128 ti->fmt, ti->type->name, ti->offset,
133 Bprint(bout, "\t'%c' %d %s;\n",
134 ti->fmt, ti->offset, ti->tag->name);
136 Bprint(bout, "};\n");
140 Bprint(bout, "defn %s(", l->name);
141 pexpr(l->proc->left);
142 Bprint(bout, ") {\n");
143 pcode(l->proc->right, 1);
148 Bprint(bout, "builtin function\n");
152 Bprint(bout, "%s is undefined\n", l->name);
156 slist(Node *n, int d)
161 Bprint(bout, "%.*s{\n", d-1, tabs);
164 Bprint(bout, "%.*s}\n", d-1, tabs);
168 pcode(Node *n, int d)
180 Bprint(bout, "%.*s", d, tabs);
189 Bprint(bout, "%.*slocal", d, tabs);
191 Bprint(bout, " %s", l->sym->name);
200 Bprint(bout, "%.*scomplex %s %s;\n", d, tabs, n->sym->name, l->sym->name);
203 Bprint(bout, "%.*sif ", d, tabs);
206 Bprint(bout, " then\n");
207 if(r && r->op == OELSE) {
209 Bprint(bout, "%.*selse\n", d-1, tabs);
216 Bprint(bout, "%.*swhile ", d, tabs);
219 Bprint(bout, " do\n");
223 Bprint(bout, "%.*sreturn ", d, tabs);
228 Bprint(bout, "%.*sloop ", d, tabs);
232 Bprint(bout, " do\n");
250 Bprint(bout, "%s", n->sym->name);
255 Bprint(bout, "%lld", n->ival);
258 Bprint(bout, "%g", n->fval);
287 Bprint(bout, binop[n->op]);
293 Bprint(bout, binop[n->op]);
339 Bprint(bout, "head ");
343 Bprint(bout, "tail ");
347 Bprint(bout, "append ");
353 Bprint(bout, "delete ");
359 Bprint(bout, "return ");
374 Bprint(bout, ".%s", n->sym->name);
377 Bprint(bout, "%s:%s", n->sym->name, l->sym->name);
380 Bprint(bout, "(%s)", n->sym->name);
385 Bprint(bout, "\\%c", (int)r->ival);
388 Bprint(bout, "eval ");
392 Bprint(bout, "whatis");
394 Bprint(bout, " %s", n->sym->name);
405 for(i = 0; i < s->len; i++) {