OpenCores
URL https://opencores.org/ocsvn/raptor64/raptor64/trunk

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [software/] [c64/] [source/] [List.c] - Blame information for rev 37

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 robfinch
#include        <stdio.h>
2
#include        "c.h"
3
#include        "expr.h"
4
#include        "gen.h"
5
#include        "cglbdec.h"
6
 
7
/*
8
 *      68000 C compiler
9
 *
10
 *      Copyright 1984, 1985, 1986 Matthew Brandt.
11
 *  all commercial rights reserved.
12
 *
13
 *      This compiler is intended as an instructive tool for personal use. Any
14
 *      use for profit without the written consent of the author is prohibited.
15
 *
16
 *      This compiler may be distributed freely for non-commercial use as long
17
 *      as this notice stays intact. Please forward any enhancements or questions
18
 *      to:
19
 *
20
 *              Matthew Brandt
21
 *              Box 920337
22
 *              Norcross, Ga 30092
23
 */
24
/*******************************************************
25
        Modified to support Raptor64 'C64' language
26
        by Robert Finch
27
        robfinch@opencores.org
28
*******************************************************/
29
 
30
void ListTable(TABLE *t, int i);
31
 
32
void put_typedef(int td)
33
{
34
        fprintf(list,td ? "   1   " : "   -    ");
35
}
36
 
37
void put_sc(int scl)
38
{       switch(scl) {
39
                case sc_static:
40
                        fprintf(list,"Static      ");
41
                        break;
42
                case sc_auto:
43
                        fprintf(list,"Auto        ");
44
                        break;
45
                case sc_global:
46
                        fprintf(list,"Global      ");
47
                        break;
48
                case sc_external:
49
                        fprintf(list,"External    ");
50
                        break;
51
                case sc_type:
52
                        fprintf(list,"Type        ");
53
                        break;
54
                case sc_const:
55
                        fprintf(list,"Constant    ");
56
                        break;
57
                case sc_member:
58
                        fprintf(list,"Member      ");
59
                        break;
60
                case sc_label:
61
                        fprintf(list,"Label");
62
                        break;
63
                case sc_ulabel:
64
                        fprintf(list,"Undefined label");
65
                        break;
66
                }
67
}
68
 
69
void put_ty(TYP *tp)
70
{       if(tp == 0)
71
                return;
72
        switch(tp->type) {
73
                                case bt_byte:
74
                        fprintf(list,"Byte");
75
                        break;
76
                case bt_char:
77
                        fprintf(list,"Char");
78
                        break;
79
                case bt_short:
80
                        fprintf(list,"Short");
81
                        break;
82
                case bt_enum:
83
                        fprintf(list,"enum ");
84
                        goto ucont;
85
                case bt_long:
86
                        fprintf(list,"Long");
87
                        break;
88
                case bt_unsigned:
89
                        fprintf(list,"unsigned long");
90
                        break;
91
                case bt_float:
92
                        fprintf(list,"Float");
93
                        break;
94
                case bt_double:
95
                        fprintf(list,"Double");
96
                        break;
97
                case bt_pointer:
98
                        if( tp->val_flag == 0)
99
                                fprintf(list,"Pointer to ");
100
                        else
101
                                fprintf(list,"Array of ");
102
                        put_ty(tp->btp);
103
                        break;
104
                case bt_union:
105
                        fprintf(list,"union ");
106
                        goto ucont;
107
                case bt_struct:
108
                        fprintf(list,"struct ");
109
ucont:                  if(tp->sname == 0)
110
                                fprintf(list,"<no name> ");
111
                        else
112
                                fprintf(list,"%s ",tp->sname);
113
                        break;
114
                case bt_ifunc:
115
                case bt_func:
116
                        fprintf(list,"Function returning ");
117
                        put_ty(tp->btp);
118
                        break;
119
                }
120
}
121
 
122
void list_var(SYM *sp, int i)
123
{       int     j;
124
        for(j = i; j; --j)
125
                fprintf(list,"    ");
126
                if (sp->name == NULL)
127
                        fprintf(list,"%-10s =%06x ","<unnamed>",sp->value.u);
128
                else
129
                        fprintf(list,"%-10s =%06x ",sp->name,sp->value.u);
130
        if( sp->storage_class == sc_external)
131
                fprintf(output,"\textern\t%s\n",sp->name);
132
        else if( sp->storage_class == sc_global )
133
                fprintf(output,";\tglobal\t%s\n",sp->name);
134
                put_typedef(sp->storage_class==sc_typedef);
135
        put_sc(sp->storage_class);
136
        put_ty(sp->tp);
137
        fprintf(list,"\n");
138
        if(sp->tp == 0)
139
                return;
140
        if((sp->tp->type == bt_struct || sp->tp->type == bt_union) &&
141
                sp->storage_class == sc_type)
142
                ListTable(&(sp->tp->lst),i+1);
143
}
144
 
145
void ListTable(TABLE *t, int i)
146
{
147
        SYM *sp;
148
        int nn;
149
 
150
        if (t==&gsyms[0]) {
151
                for (nn = 0; nn < 257; nn++) {
152
                        t = &gsyms[nn];
153
                        sp = t->head;
154
                        while(sp != NULL) {
155
                                list_var(sp,i);
156
                                sp = sp->next;
157
            }
158
                }
159
        }
160
        else {
161
                sp = t->head;
162
                while(sp != NULL) {
163
                        list_var(sp,i);
164
                        sp = sp->next;
165
        }
166
        }
167
}
168
 
169
 
170


powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.