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

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [software/] [c64/] [source/] [ParseStructDeclaration.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 <string.h>
3
#include        "c.h"
4
#include        "expr.h"
5
#include "Statement.h"
6
#include        "gen.h"
7
#include        "cglbdec.h"
8
 
9
/*
10
 *      68000 C compiler
11
 *
12
 *      Copyright 1984, 1985, 1986 Matthew Brandt.
13
 *  all commercial rights reserved.
14
 *
15
 *      This compiler is intended as an instructive tool for personal use. Any
16
 *      use for profit without the written consent of the author is prohibited.
17
 *
18
 *      This compiler may be distributed freely for non-commercial use as long
19
 *      as this notice stays intact. Please forward any enhancements or questions
20
 *      to:
21
 *
22
 *              Matthew Brandt
23
 *              Box 920337
24
 *              Norcross, Ga 30092
25
 */
26
/*******************************************************
27
        Copyright 2012  Robert Finch
28
        Modified to support Raptor64 'C64' language
29
        by Robert Finch
30
        robfinch@opencores.org
31
*******************************************************/
32
 
33
extern TABLE tagtable;
34
extern TYP *head;
35
extern TYP stdconst;
36
extern int bit_next;
37
extern int bit_offset;
38
extern int bit_width;
39
 
40
__int16 typeno = bt_last;
41
 
42
void ParseStructMembers(TYP *tp, int ztype);
43
 
44
void ParseStructDeclaration(int ztype)
45
{
46
    SYM     *sp;
47
    TYP     *tp;
48
        bit_offset = 0;
49
        bit_next = 0;
50
        bit_width = -1;
51
    if(lastst == id) {
52
        if((sp = search(lastid,&tagtable)) == NULL) {
53
            sp = allocSYM();
54
            sp->name = litlate(lastid);
55
            sp->tp = allocTYP();
56
            sp->tp->type = ztype;
57
                        sp->tp->typeno = typeno++;
58
            sp->tp->lst.head = 0;
59
            sp->storage_class = sc_type;
60
            sp->tp->sname = sp->name;
61
            NextToken();
62
            if(lastst != begin)
63
                error(ERR_INCOMPLETE);
64
            else    {
65
                insert(sp,&tagtable);
66
                NextToken();
67
                ParseStructMembers(sp->tp,ztype);
68
                }
69
        }
70
        else
71
            NextToken();
72
        head = sp->tp;
73
    }
74
    else {
75
        tp = allocTYP();
76
        tp->type = ztype;
77
        tp->sname = 0;
78
        tp->lst.head = 0;
79
        if( lastst != begin)
80
            error(ERR_INCOMPLETE);
81
        else {
82
                        NextToken();
83
                        ParseStructMembers(tp,ztype);
84
        }
85
        head = tp;
86
    }
87
}
88
 
89
void ParseStructMembers(TYP *tp, int ztype)
90
{
91
        int     slc;
92
    slc = 0;
93
    tp->val_flag = 1;
94
    while( lastst != end) {
95
        if(ztype == bt_struct)
96
            slc += declare(&(tp->lst),sc_member,slc,ztype);
97
        else
98
            slc = imax(slc,declare(&tp->lst,sc_member,0,ztype));
99
    }
100
        bit_offset = 0;
101
        bit_next = 0;
102
        bit_width = -1;
103
    tp->size = slc;
104
    NextToken();
105
}
106
 

powered by: WebSVN 2.1.0

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