-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListe.h
More file actions
105 lines (85 loc) · 2.8 KB
/
Liste.h
File metadata and controls
105 lines (85 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Liste.h
// Name: Eric Hübel, Mat.Nr: 54045, S-Nr: 86462, Gruppe: 041-62
#ifndef LISTE_H
#define LISTE_H
#ifndef VARSIZE
#define VARSIZE 2 // Standardwert für Variablengröße, kann mit gcc -DVARSIZE=2/4/8 angepasst werden
#endif
#if (VARSIZE == 2)
#define VAR_MSG "2-Byte Var\n"
typedef int16_t size_int;
#endif
#if (VARSIZE == 4)
#define VAR_MSG "4-Byte Var\n"
typedef int32_t size_int;
#endif
#if (VARSIZE == 8)
#define VAR_MSG "8-Byte Var\n"
typedef int64_t size_int;
#endif
typedef enum{BEZ, PRC, VAR, CST, LBL}tKz;
typedef struct{
tKz Kz; // Kennzeichen
struct tBezEntry* next; // next-Pointer auf nächsten Eintrag
short indexProc; // Prozedurindex
void* pObj; // Pointer auf Objektbeschreibung (VAR, CST, PRC)
//int len; // Länge
char* pName; // Pointer auf Name
}tBezEntry;
typedef struct tVAR{
tKz Kz; // Kennzeichen
int Dspl; // Relativadresse
}tVar;
typedef struct tCONST{
tKz Kz; // Kennzeichen
int32_t Val; // Wert
int Idx; // Index im ConstBlock
}tConst;
typedef struct tPROC{
tKz Kz; // Kennzeichen
short IndexProc; // Prodzedurnummer
struct tPROC* pParent; // Pointer auf Prozedurbeschr. der Elternprozedur
tBezEntry* pLocalBez; // Pointer auf lokale Namensliste der Prozedur
int SpzzVar; // Speicherzuordnungszähler für Variablen
}tProc;
typedef struct tLABL{
tKz Kz;
short iJmp;
char* pCodePos;
struct tLabl* next;
}tLabl;
// Namensliste
tBezEntry* append(tBezEntry* head, tKz Kz, short indexProc, void* pObj, char* pName);
tBezEntry* deleteFirst(tBezEntry* head);
tBezEntry* deleteLast(tBezEntry* head);
tBezEntry* getFirst();
tBezEntry* getNext(tBezEntry* current);
tBezEntry* getLast(void);
tBezEntry* ClearList(tBezEntry* head);
// Ausgabe
void PrintProc(tProc* pProc);
void PrintList(tBezEntry* head);
void PrintConstBlock();
tBezEntry* createBezEntry(char* pBez); // ohne PObj
tBezEntry* addVarPObj(tBezEntry* pBezEntry, tVar* pVar);
tBezEntry* addConstPObj(tBezEntry* pBezEntry, tConst* pConst);
tBezEntry* addProcPObj(tBezEntry* pBezEntry, tProc* pProc);
tProc* createMainProc();
tProc* createProc(tProc* pParent);
tConst* createConst(size_int Val);
tVar* createVar(void);
// Suche
tBezEntry* searchBez(tProc* pProc,char* pBez);
tBezEntry* searchBezGlobal(char* pBez);
// Konstantenblock Fkt.
void initConst();
void addConst(size_int val);
void deleteConstBlock();
int searchConst(size_int Val); // Suche im ConstBlock, damit nicht doppelt, gibt Index zurück, wo gefunden, kann auch Speicherbereich sein, vergrößern mit realloc()
// Labelliste
tLabl* pushLabl(tLabl* head, tKz Kz, short iJmp);
tLabl* getTopLabl(void);
tLabl* getNextLabl(tLabl* current);
tLabl* PopLabl(tLabl* head);
void PrintLablList(tLabl* head);
#endif