diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
commit | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch) | |
tree | 4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/cmd/8l/list.c | |
parent | c8bf49ef8a92e2337b69c14b9b88396efe498600 (diff) | |
download | golang-upstream/1.3.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/cmd/8l/list.c')
-rw-r--r-- | src/cmd/8l/list.c | 313 |
1 files changed, 1 insertions, 312 deletions
diff --git a/src/cmd/8l/list.c b/src/cmd/8l/list.c index e2a2ec5ed..0a7534060 100644 --- a/src/cmd/8l/list.c +++ b/src/cmd/8l/list.c @@ -36,297 +36,10 @@ void listinit(void) { - - fmtinstall('R', Rconv); - fmtinstall('A', Aconv); - fmtinstall('D', Dconv); - fmtinstall('S', Sconv); - fmtinstall('P', Pconv); + listinit8(); fmtinstall('I', Iconv); } -static Prog *bigP; - -int -Pconv(Fmt *fp) -{ - Prog *p; - - p = va_arg(fp->args, Prog*); - bigP = p; - switch(p->as) { - case ATEXT: - if(p->from.scale) { - fmtprint(fp, "(%d) %A %D,%d,%D", - p->line, p->as, &p->from, p->from.scale, &p->to); - break; - } - default: - fmtprint(fp, "(%d) %A %D,%D", - p->line, p->as, &p->from, &p->to); - break; - case ADATA: - case AINIT_: - case ADYNT_: - fmtprint(fp, "(%d) %A %D/%d,%D", - p->line, p->as, &p->from, p->from.scale, &p->to); - break; - } - bigP = P; - return 0; -} - -int -Aconv(Fmt *fp) -{ - int i; - - i = va_arg(fp->args, int); - return fmtstrcpy(fp, anames[i]); -} - -char* -xsymname(Sym *s) -{ - if(s == nil) - return "!!noname!!"; - return s->name; -} - -int -Dconv(Fmt *fp) -{ - char str[STRINGSZ], s[STRINGSZ]; - Adr *a; - int i; - - a = va_arg(fp->args, Adr*); - i = a->type; - if(i >= D_INDIR && i < 2*D_INDIR) { - if(a->offset) - snprint(str, sizeof str, "%d(%R)", a->offset, i-D_INDIR); - else - snprint(str, sizeof str, "(%R)", i-D_INDIR); - goto brk; - } - switch(i) { - - default: - snprint(str, sizeof str, "%R", i); - break; - - case D_NONE: - str[0] = 0; - break; - - case D_BRANCH: - if(bigP != P && bigP->pcond != P) - if(a->sym != S) - snprint(str, sizeof str, "%ux+%s", bigP->pcond->pc, - a->sym->name); - else - snprint(str, sizeof str, "%ux", bigP->pcond->pc); - else - snprint(str, sizeof str, "%d(PC)", a->offset); - break; - - case D_EXTERN: - snprint(str, sizeof str, "%s+%d(SB)", xsymname(a->sym), a->offset); - break; - - case D_STATIC: - snprint(str, sizeof str, "%s<%d>+%d(SB)", xsymname(a->sym), - a->sym->version, a->offset); - break; - - case D_AUTO: - snprint(str, sizeof str, "%s+%d(SP)", xsymname(a->sym), a->offset); - break; - - case D_PARAM: - if(a->sym) - snprint(str, sizeof str, "%s+%d(FP)", a->sym->name, a->offset); - else - snprint(str, sizeof str, "%d(FP)", a->offset); - break; - - case D_CONST: - snprint(str, sizeof str, "$%d", a->offset); - break; - - case D_CONST2: - snprint(str, sizeof str, "$%d-%d", a->offset, a->offset2); - break; - - case D_FCONST: - snprint(str, sizeof str, "$(%.8ux,%.8ux)", a->ieee.h, a->ieee.l); - break; - - case D_SCONST: - snprint(str, sizeof str, "$\"%S\"", a->scon); - break; - - case D_ADDR: - a->type = a->index; - a->index = D_NONE; - snprint(str, sizeof str, "$%D", a); - a->index = a->type; - a->type = D_ADDR; - goto conv; - } -brk: - if(a->index != D_NONE) { - sprint(s, "(%R*%d)", (int)a->index, a->scale); - strcat(str, s); - } -conv: - fmtstrcpy(fp, str); -// if(a->gotype) -// fmtprint(fp, "«%s»", a->gotype->name); - return 0; -} - -char* regstr[] = -{ - "AL", /* [D_AL] */ - "CL", - "DL", - "BL", - "AH", - "CH", - "DH", - "BH", - - "AX", /* [D_AX] */ - "CX", - "DX", - "BX", - "SP", - "BP", - "SI", - "DI", - - "F0", /* [D_F0] */ - "F1", - "F2", - "F3", - "F4", - "F5", - "F6", - "F7", - - "CS", /* [D_CS] */ - "SS", - "DS", - "ES", - "FS", - "GS", - - "GDTR", /* [D_GDTR] */ - "IDTR", /* [D_IDTR] */ - "LDTR", /* [D_LDTR] */ - "MSW", /* [D_MSW] */ - "TASK", /* [D_TASK] */ - - "CR0", /* [D_CR] */ - "CR1", - "CR2", - "CR3", - "CR4", - "CR5", - "CR6", - "CR7", - - "DR0", /* [D_DR] */ - "DR1", - "DR2", - "DR3", - "DR4", - "DR5", - "DR6", - "DR7", - - "TR0", /* [D_TR] */ - "TR1", - "TR2", - "TR3", - "TR4", - "TR5", - "TR6", - "TR7", - - "X0", - "X1", - "X2", - "X3", - "X4", - "X5", - "X6", - "X7", - - "NONE", /* [D_NONE] */ -}; - -int -Rconv(Fmt *fp) -{ - char str[STRINGSZ]; - int r; - - r = va_arg(fp->args, int); - if(r >= D_AL && r <= D_NONE) - sprint(str, "%s", regstr[r-D_AL]); - else - sprint(str, "gok(%d)", r); - - return fmtstrcpy(fp, str); -} - -int -Sconv(Fmt *fp) -{ - int i, c; - char str[STRINGSZ], *p, *a; - - a = va_arg(fp->args, char*); - p = str; - for(i=0; i<sizeof(double); i++) { - c = a[i] & 0xff; - if(c >= 'a' && c <= 'z' || - c >= 'A' && c <= 'Z' || - c >= '0' && c <= '9') { - *p++ = c; - continue; - } - *p++ = '\\'; - switch(c) { - default: - if(c < 040 || c >= 0177) - break; /* not portable */ - p[-1] = c; - continue; - case 0: - *p++ = 'z'; - continue; - case '\\': - case '"': - *p++ = c; - continue; - case '\n': - *p++ = 'n'; - continue; - case '\t': - *p++ = 't'; - continue; - } - *p++ = (c>>6) + '0'; - *p++ = ((c>>3) & 7) + '0'; - *p++ = (c & 7) + '0'; - } - *p = 0; - return fmtstrcpy(fp, str); -} - int Iconv(Fmt *fp) { @@ -352,27 +65,3 @@ Iconv(Fmt *fp) free(s); return 0; } - -void -diag(char *fmt, ...) -{ - char buf[1024], *tn, *sep; - va_list arg; - - tn = ""; - sep = ""; - if(cursym != S) { - tn = cursym->name; - sep = ": "; - } - va_start(arg, fmt); - vseprint(buf, buf+sizeof(buf), fmt, arg); - va_end(arg); - print("%s%s%s\n", tn, sep, buf); - - nerrors++; - if(nerrors > 20) { - print("too many errors\n"); - errorexit(); - } -} |