-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd_mem.sprut
125 lines (78 loc) · 3.53 KB
/
std_mem.sprut
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* This is file `std_mem.sprut'. This file contains macros and
functions for work with memory of program of a language whose
internal representation is stored as a single thing.
Copyright (C) 1997-2016 Vladimir Makarov.
Written by Vladimir Makarov <vmakarov@gcc.gnu.org>
This file is part of the tool SPRUT.
This is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
%import {
#include "objstack.h"
/* These macros for storage management of an internal representation: */
/* Start work with the storage manager -- see Sprut documentation. */
#define IR_BEGIN_ALLOC() OS_CREATE (irp, 0)
/* Finish work with the storage manager -- see Sprut documentation. */
#define IR_CLOSE_ALLOC() OS_DELETE (irp)
/* Allocate storage for internal representation of given size
-- see Sprut documentation. */
#define IR_ALLOC(ptr, size)\
do {\
OS_TOP_EXPAND (irp, size); ptr = OS_TOP_BEGIN (irp); OS_TOP_FINISH (irp);\
} while (0);
/* Free storage of internal representation of given size -- see Sprut
documentation. */
#define IR_FREE(ptr, size)
/* These macros are analogous to ones of package `object-stack'
worked with storage of Sprut internal representation: */
/* Start new internal representation object -- see also package
`object-stack'. */
#define IR_TOP_FINISH() OS_TOP_FINISH (irp)
/* Nullify current internal representation object -- see also package
`object-stack'. */
#define IR_TOP_NULLIFY() OS_TOP_NULLIFY (irp)
/* Shorten current internal representation object on given number bytes -- see
also package `object-stack'. */
#define IR_TOP_SHORTEN(length) OS_TOP_SHORTEN (irp, length)
/* Return start address of current internal representation object -- see also
package `object-stack'. */
#define IR_TOP_BEGIN() OS_TOP_BEGIN (irp)
/* Return length of current internal representation object in bytes -- see
also package `object-stack'. */
#define IR_TOP_LENGTH() OS_TOP_LENGTH (irp)
/* Expand current internal representation object -- see also package
`object-stack'. */
#define IR_TOP_EXPAND(length) OS_TOP_EXPAND (irp, length)
/* Add byte to the end of current internal representation object -- see also
package `object-stack'. */
#define IR_TOP_ADD_BYTE(b) OS_TOP_ADD_BYTE (irp, b)
/* Add string to the end of current internal representation object -- see also
package `object-stack'. */
#define IR_TOP_ADD_STRING(str) OS_TOP_ADD_STRING (irp, str)
/* Add memory of given length to the end of current internal representation
object -- see also package `object-stack'. */
#define IR_TOP_ADD_MEMORY(mem, length) OS_TOP_ADD_MEMORY (irp, mem, length)
extern os_t irp;
}
%%
%%
/* This page contains functions for initialization and finalization of
all internal representation of source file. */
/* All internal representation storage is implemented by object stack. See
package `object-stack'. */
os_t irp;
/*
Local Variables:
mode:c
End:
*/