Run through clang-format.

This commit is contained in:
David Given 2016-08-21 19:38:02 +02:00
parent 3584ddb6e9
commit 1b66b63eae

View file

@ -8,7 +8,6 @@
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -25,13 +24,11 @@
#include "../share/get.h"
#include "ca_put.h"
/* This phase transforms the Intermediate Code of the global optimizer
* to 'standard' compact assembly language, which will be processed
* by the code generator.
*/
short dlength;
dblock_p* dmap;
@ -40,8 +37,6 @@ char **dnames, **pnames; /* Dynamically allocated arrays of strings.
* of the procedure with proc_id i.
*/
STATIC line_p get_ca_lines(lf, p_out)
FILE* lf;
proc_p* p_out;
@ -58,34 +53,45 @@ STATIC line_p get_ca_lines(lf,p_out)
pp = &head;
mp = &headm;
headm = (line_p)0;
while (TRUE) {
while (TRUE)
{
l = read_line(p_out);
if (feof(curinp)) break;
if (feof(curinp))
break;
assert(l != (line_p)0);
if (INSTR(l) == ps_end && INSTR(head) != ps_pro) {
if (INSTR(l) == ps_end && INSTR(head) != ps_pro)
{
/* Delete end pseudo after data-unit */
oldline(l);
break;
}
if (INSTR(l) == ps_mes && l->l_a.la_arg->a_a.a_offset == ms_reg) {
if (INSTR(l) == ps_mes && l->l_a.la_arg->a_a.a_offset == ms_reg)
{
/* l is a register message */
if (l->l_a.la_arg->a_next == (arg_p) 0) {
if (l->l_a.la_arg->a_next == (arg_p)0)
{
/* register message without arguments */
oldline(l);
} else {
}
else
{
*mp = l;
mp = &l->l_next;
}
} else {
}
else
{
*pp = l;
pp = &l->l_next;
}
if (INSTR(l) == ps_end) {
if (INSTR(l) == ps_end)
{
break;
}
}
*pp = (line_p)0;
if (head != (line_p) 0 && INSTR(head) == ps_pro) {
if (head != (line_p)0 && INSTR(head) == ps_pro)
{
/* append register message without arguments to list */
l = newline(OPLIST);
l->l_instr = ps_mes;
@ -94,7 +100,9 @@ STATIC line_p get_ca_lines(lf,p_out)
*mp = l;
l->l_next = head->l_next;
head->l_next = headm;
} else {
}
else
{
assert(headm == (line_p)0);
}
return head;
@ -111,17 +119,17 @@ STATIC int makedmap(dbl)
/* determine the length of the table */
cnt = 0;
for (d = dbl; d != (dblock_p) 0; d = d->d_next) cnt++;
for (d = dbl; d != (dblock_p)0; d = d->d_next)
cnt++;
dmap = (dblock_p*)newmap(cnt);
for (d = dbl; d != (dblock_p) 0; d = d->d_next) {
for (d = dbl; d != (dblock_p)0; d = d->d_next)
{
assert(d->d_id <= cnt);
dmap[d->d_id] = d;
}
return cnt;
}
STATIC getdnames(dumpd)
FILE* dumpd;
{
@ -133,8 +141,10 @@ STATIC getdnames(dumpd)
int id;
dnames = (char**)newmap(dlength);
for (;;) {
if (fscanf(dumpd,"%d %s",&id,str) == EOF) return;
for (;;)
{
if (fscanf(dumpd, "%d %s", &id, str) == EOF)
return;
assert(id <= dlength);
dnames[id] = (char*)newcore(strlen(str) + 1);
strcpy(dnames[id], str);
@ -152,18 +162,17 @@ STATIC getpnames(dumpp)
int id;
pnames = (char**)newmap(plength);
for (;;) {
if (fscanf(dumpp,"%d %s",&id,str) == EOF) return;
for (;;)
{
if (fscanf(dumpp, "%d %s", &id, str) == EOF)
return;
assert(id <= plength);
pnames[id] = (char*)newcore(strlen(str) + 1);
strcpy(pnames[id], str);
}
}
STATIC new_name(s)
char **s;
STATIC new_name(s) char** s;
{
static int nn = 0;
char buf[20];
@ -179,8 +188,6 @@ STATIC new_name(s)
strcpy(*s, buf);
}
STATIC uniq_names()
{
/* The names of all internal procedures and data blocks
@ -193,21 +200,23 @@ STATIC uniq_names()
proc_p p;
dblock_p d;
for (p = fproc; p != (proc_p) 0; p = p->p_next) {
if (!(p->p_flags1 & PF_EXTERNAL)) {
for (p = fproc; p != (proc_p)0; p = p->p_next)
{
if (!(p->p_flags1 & PF_EXTERNAL))
{
new_name(&(pnames[p->p_id]));
}
}
for (d = fdblock; d != (dblock_p) 0; d = d->d_next) {
if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id]) {
for (d = fdblock; d != (dblock_p)0; d = d->d_next)
{
if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id])
{
new_name(&(dnames[d->d_id]));
}
}
}
main(argc,argv)
int argc;
main(argc, argv) int argc;
char* argv[];
{
/* CA does not output proctable etc. files. Instead, its
@ -231,7 +240,8 @@ main(argc,argv)
f = openfile(lname, "r");
f2 = stdout;
cputmagic(f2); /* write magic number */
while ((lnp = get_ca_lines(f,&curproc)) != (line_p) 0) {
while ((lnp = get_ca_lines(f, &curproc)) != (line_p)0)
{
cputlines(lnp, f2);
}
fclose(f);