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]);
108 Bprint(bout, "%s variable", typenames[t]);
109 if(t == TINT || t == TFLOAT)
110 Bprint(bout, " format %c", l->v->fmt);
112 Bprint(bout, " complex %s", l->v->comt->base->name);
117 Bprint(bout, "complex %s {\n", l->name);
118 for(ti = l->lt; ti; ti = ti->next) {
121 Bprint(bout, "\t%s %d %s;\n",
122 ti->type->name, ti->offset,
126 Bprint(bout, "\t'%c' %s %d %s;\n",
127 ti->fmt, ti->type->name, ti->offset,
132 Bprint(bout, "\t'%c' %d %s;\n",
133 ti->fmt, ti->offset, ti->tag->name);
135 Bprint(bout, "};\n");
139 Bprint(bout, "defn %s(", l->name);
140 pexpr(l->proc->left);
141 Bprint(bout, ") {\n");
142 pcode(l->proc->right, 1);
147 Bprint(bout, "builtin function\n");
151 Bprint(bout, "%s is undefined\n", l->name);
155 slist(Node *n, int d)
160 Bprint(bout, "%.*s{\n", d-1, tabs);
163 Bprint(bout, "%.*s}\n", d-1, tabs);
167 pcode(Node *n, int d)
179 Bprint(bout, "%.*s", d, tabs);
188 Bprint(bout, "%.*slocal", d, tabs);
190 Bprint(bout, " %s", l->sym->name);
199 Bprint(bout, "%.*scomplex %s %s;\n", d, tabs, n->sym->name, l->sym->name);
202 Bprint(bout, "%.*sif ", d, tabs);
205 Bprint(bout, " then\n");
206 if(r && r->op == OELSE) {
208 Bprint(bout, "%.*selse\n", d-1, tabs);
215 Bprint(bout, "%.*swhile ", d, tabs);
218 Bprint(bout, " do\n");
222 Bprint(bout, "%.*sreturn ", d, tabs);
227 Bprint(bout, "%.*sloop ", d, tabs);
231 Bprint(bout, " do\n");
249 Bprint(bout, "%s", n->sym->name);
254 Bprint(bout, "%lld", n->ival);
257 Bprint(bout, "%g", n->fval);
286 Bprint(bout, binop[n->op]);
292 Bprint(bout, binop[n->op]);
338 Bprint(bout, "head ");
342 Bprint(bout, "tail ");
346 Bprint(bout, "append ");
352 Bprint(bout, "delete ");
358 Bprint(bout, "return ");
373 Bprint(bout, ".%s", n->sym->name);
376 Bprint(bout, "%s:%s", n->sym->name, l->sym->name);
379 Bprint(bout, "(%s)", n->sym->name);
384 Bprint(bout, "\\%c", (int)r->ival);
387 Bprint(bout, "eval ");
391 Bprint(bout, "whatis");
393 Bprint(bout, " %s", n->sym->name);
404 for(i = 0; i < s->len; i++) {