forked from eugenechevski/CodeGeneratorSPL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_seq.h
More file actions
executable file
·53 lines (41 loc) · 1.6 KB
/
code_seq.h
File metadata and controls
executable file
·53 lines (41 loc) · 1.6 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
/* $Id: code_seq.h,v 1.3 2024/11/08 21:01:43 leavens Exp $ */
#ifndef _CODE_SEQ_H
#define _CODE_SEQ_H
#include <stdbool.h>
#include "code.h"
// code sequences are linked lists
// with an additional last pointer to the last node
typedef struct {
code *first;
code *last;
} code_seq;
// Return an empty code_seq
extern code_seq code_seq_empty();
// Return a code_seq containing just the given code
extern code_seq code_seq_singleton(code *c);
// Is seq empty?
extern bool code_seq_is_empty(code_seq seq);
// Requires: !code_seq_is_empty(seq)
// Return the first element of the given code sequence, seq
extern code *code_seq_first(code_seq seq);
// Requires: !code_seq_is_empty(seq)
// Return a new code_seq containing
// the rest of the given sequence, seq
// Note that seq is not modified
extern code_seq code_seq_rest(code_seq seq);
// Return the size (number of instructions/words) in seq
extern unsigned int code_seq_size(code_seq seq);
// Requires: !code_seq_is_empty(seq)
// Return the last element in the given sequence
extern code *code_seq_last_elem(code_seq seq);
// Requires: c != NULL && seq != NULL
// Modify seq to add the given code *c added to its end
extern void code_seq_add_to_end(code_seq *seq, code *c);
// Requires: s1 != NULL && s2 != NULL
// Modifies s1 to be the concatenation of s1 followed by s2
extern void code_seq_concat(code_seq *s1, code_seq s2);
// Requires: out is open for writing.
// Print the instructions in the code_seq to out
// in assembly language format
extern void code_seq_debug_print(FILE *out, code_seq seq);
#endif