InutitionTC  0.30
alloc.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2016 by University of Warsaw *
3  * *
4  * This file is part of IntuitionTC. *
5  * *
6  ****************************************************************************/
15 #ifndef _ALLOC_H
16 #define _ALLOC_H 1
17 #include "checker.h"
18 
19 
20 
21 
22 
23 /*@
24  @ behavior allocation:
25  @ assumes is_allocable{Pre}((size_t)sizeof(Term),(size_t)1);
26  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
27  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Term)),(size_t)1);
28  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Term)));
29  @ ensures \valid((char*)\result+(0..sizeof(Term)-1));
30  @ ensures \result!=\null;
31  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
32  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
33  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
34  @ ensures __allocated[__num_allocated-1] == (char*)\result;
35  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Term)-1));
36  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
37  @ \separated((char*)\result+(0..sizeof(Term)-1),a+(0..s-1));
38  @ behavior no_allocation:
39  @ assumes !is_allocable{Pre}((size_t)sizeof(Term),(size_t)1);
40  @ assigns \nothing;
41  @ ensures \result==\null;
42  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
43  @ complete behaviors;
44  @ disjoint behaviors;
45  @*/
46 Term* allocTerm();
47 
48 /*@
49  @ requires is_allocated{Pre}((char*)ptr);
50  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
51  @ frees ptr;
52  @ ensures !is_allocated{Post}((char*)ptr);
53  @ ensures old_allocated{Pre,Post}((char *)ptr);
54  @ ensures \forall size_t s; is_allocated_size{Pre}((char*)ptr,s) ==> \at(__size_allocated,Post) == \at(__size_allocated,Pre) - s;
55  @ ensures allocation_footprint{Post,Pre}((size_t)(\block_length{Pre}((char*)ptr)), (size_t)1);
56  @*/
57 void freeTerm(Term* ptr);
58 void freeTermZ(Term**);
59 
60 /*@
61  @ behavior allocation:
62  @ assumes is_allocable{Pre}((size_t)sizeof(Term),(size_t)1);
63  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
64  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Term)),(size_t)1);
65  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Term)));
66  @ ensures \valid((char*)\result+(0..sizeof(Term)-1));
67  @ ensures \result!=\null;
68  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
69  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
70  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
71  @ ensures __allocated[__num_allocated-1] == (char*)\result;
72  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Term)-1));
73  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
74  @ \separated((char*)\result+(0..sizeof(Term)-1),a+(0..s-1));
75  @ ensures \forall char* a, size_t s; is_allocated_size{Pre}(a, s) ==>
76  @ \separated((char*)\result+(0..sizeof(Term)-1),a+(0..s-1));
77  @ ensures isShallowCopyOfTerm{Post,Pre}(*\result,arg);
78  @ behavior no_allocation:
79  @ assumes !is_allocable{Pre}((size_t)sizeof(Term),(size_t)1);
80  @ assigns \nothing;
81  @ ensures \result==\null;
82  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
83  @ complete behaviors;
84  @ disjoint behaviors;
85  @*/
86 Term* makeTerm(const Term arg); /* shallow copy */
87 
88 /*@ requires valid_Term_ptr(arg);
89  @ behavior allocation:
90  @ assumes is_allocable{Pre}((size_t)sizeof(Term),(size_t)1);
91  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
92  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Term)),(size_t)1);
93  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Term)));
94  @ ensures \valid((char*)\result+(0..sizeof(Term)-1));
95  @ ensures \result!=\null;
96  @ ensures isShallowCopyOfTerm{Post,Pre}(*\result,*arg);
97  @ behavior no_allocation:
98  @ assumes !is_allocable{Pre}((size_t)sizeof(Term),(size_t)1);
99  @ assigns \nothing;
100  @ ensures \result==\null;
101  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
102  @ complete behaviors;
103  @ disjoint behaviors;
104  @*/
105 Term* copyTerm(const Term* arg); /* shallow copy */
106 Term* copyTermDeep(const Term*); /* deep copy */
107 
108 /*@
109  @ behavior allocation:
110  @ assumes is_allocable{Pre}((size_t)sizeof(Type),(size_t)1);
111  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
112  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Type)),(size_t)1);
113  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Type)));
114  @ ensures \valid((char*)\result+(0..sizeof(Type)-1));
115  @ ensures \result!=\null;
116  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
117  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
118  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
119  @ ensures __allocated[__num_allocated-1] == (char*)\result;
120  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Type)-1));
121  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
122  @ \separated((char*)\result+(0..sizeof(Type)-1),a+(0..s-1));
123  @ behavior no_allocation:
124  @ assumes !is_allocable{Pre}((size_t)sizeof(Type),(size_t)1);
125  @ assigns \nothing;
126  @ ensures \result==\null;
127  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
128  @ complete behaviors;
129  @ disjoint behaviors;
130  @*/
131 Type* allocType();
132 
133 /*@
134  @ requires is_allocated{Pre}((char*)ptr);
135  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
136  @ frees ptr;
137  @ ensures !is_allocated{Post}((char*)ptr);
138  @ ensures old_allocated{Pre,Post}((char *)ptr);
139  @ ensures \forall size_t s; is_allocated_size{Pre}((char*)ptr,s) ==> \at(__size_allocated,Post) == \at(__size_allocated,Pre) - s;
140  @ ensures allocation_footprint{Post,Pre}((size_t)(\block_length{Pre}((char*)ptr)), (size_t)1);
141  @*/
142 void freeType(Type* ptr);
143 void freeTypeZ(Type**);
144 
145 /*@
146  @ behavior allocation:
147  @ assumes is_allocable{Pre}((size_t)sizeof(Type),(size_t)1);
148  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
149  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Type)),(size_t)1);
150  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Type)));
151  @ ensures \valid((char*)\result+(0..sizeof(Type)-1));
152  @ ensures \result!=\null;
153  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
154  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
155  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
156  @ ensures __allocated[__num_allocated-1] == (char*)\result;
157  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Type)-1));
158  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
159  @ \separated((char*)\result+(0..sizeof(Type)-1),a+(0..s-1));
160  @ ensures \forall char* a, size_t s; is_allocated_size{Pre}(a, s) ==>
161  @ \separated((char*)\result+(0..sizeof(Type)-1),a+(0..s-1));
162  @ ensures isShallowCopyOfType{Post,Pre}(*\result,arg);
163  @ behavior no_allocation:
164  @ assumes !is_allocable{Pre}((size_t)sizeof(Type),(size_t)1);
165  @ assigns \nothing;
166  @ ensures \result==\null;
167  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
168  @ complete behaviors;
169  @ disjoint behaviors;
170  @*/
171 Type* makeType(const Type arg); /* shallow copy */
172 
173 /*@ requires valid_Type_ptr(arg);
174  @ behavior allocation:
175  @ assumes is_allocable{Pre}((size_t)sizeof(Type),(size_t)1);
176  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
177  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Type)),(size_t)1);
178  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Type)));
179  @ ensures \valid((char*)\result+(0..sizeof(Type)-1));
180  @ ensures \result!=\null;
181  @ ensures isShallowCopyOfType{Post,Pre}(*\result,*arg);
182  @ behavior no_allocation:
183  @ assumes !is_allocable{Pre}((size_t)sizeof(Type),(size_t)1);
184  @ assigns \nothing;
185  @ ensures \result==\null;
186  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
187  @ complete behaviors;
188  @ disjoint behaviors;
189  @*/
190 Type* copyType(const Type* arg); /* shallow copy */
191 Type* copyTypeDeep(const Type*); /* deep copy */
192 
193 /*@
194  @ behavior allocation:
195  @ assumes is_allocable{Pre}((size_t)sizeof(Kind),(size_t)1);
196  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
197  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Kind)),(size_t)1);
198  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Kind)));
199  @ ensures \valid((char*)\result+(0..sizeof(Kind)-1));
200  @ ensures \result!=\null;
201  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
202  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
203  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
204  @ ensures __allocated[__num_allocated-1] == (char*)\result;
205  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Kind)-1));
206  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
207  @ \separated((char*)\result+(0..sizeof(Kind)-1),a+(0..s-1));
208  @ behavior no_allocation:
209  @ assumes !is_allocable{Pre}((size_t)sizeof(Kind),(size_t)1);
210  @ assigns \nothing;
211  @ ensures \result==\null;
212  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
213  @ complete behaviors;
214  @ disjoint behaviors;
215  @*/
216 Kind* allocKind();
217 
218 /*@
219  @ requires is_allocated{Pre}((char*)ptr);
220  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
221  @ frees ptr;
222  @ ensures !is_allocated{Post}((char*)ptr);
223  @ ensures old_allocated{Pre,Post}((char *)ptr);
224  @ ensures \forall size_t s; is_allocated_size{Pre}((char*)ptr,s) ==> \at(__size_allocated,Post) == \at(__size_allocated,Pre) - s;
225  @ ensures allocation_footprint{Post,Pre}((size_t)(\block_length{Pre}((char*)ptr)), (size_t)1);
226  @*/
227 void freeKind(Kind* ptr);
228 void freeKindZ(Kind**);
229 
230 /*@
231  @ behavior allocation:
232  @ assumes is_allocable{Pre}((size_t)sizeof(Kind),(size_t)1);
233  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
234  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Kind)),(size_t)1);
235  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Kind)));
236  @ ensures \valid((char*)\result+(0..sizeof(Kind)-1));
237  @ ensures \result!=\null;
238  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
239  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
240  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
241  @ ensures __allocated[__num_allocated-1] == (char*)\result;
242  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Kind)-1));
243  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
244  @ \separated((char*)\result+(0..sizeof(Kind)-1),a+(0..s-1));
245  @ ensures \forall char* a, size_t s; is_allocated_size{Pre}(a, s) ==>
246  @ \separated((char*)\result+(0..sizeof(Kind)-1),a+(0..s-1));
247  @ ensures isShallowCopyOfKind{Post,Pre}(*\result,arg);
248  @ behavior no_allocation:
249  @ assumes !is_allocable{Pre}((size_t)sizeof(Kind),(size_t)1);
250  @ assigns \nothing;
251  @ ensures \result==\null;
252  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
253  @ complete behaviors;
254  @ disjoint behaviors;
255  @*/
256 Kind* makeKind(const Kind arg); /* shallow copy */
257 
258 /*@ requires valid_Kind_ptr(arg);
259  @ behavior allocation:
260  @ assumes is_allocable{Pre}((size_t)sizeof(Kind),(size_t)1);
261  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
262  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Kind)),(size_t)1);
263  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Kind)));
264  @ ensures \valid((char*)\result+(0..sizeof(Kind)-1));
265  @ ensures \result!=\null;
266  @ ensures isShallowCopyOfKind{Post,Pre}(*\result,*arg);
267  @ behavior no_allocation:
268  @ assumes !is_allocable{Pre}((size_t)sizeof(Kind),(size_t)1);
269  @ assigns \nothing;
270  @ ensures \result==\null;
271  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
272  @ complete behaviors;
273  @ disjoint behaviors;
274  @*/
275 Kind* copyKind(const Kind* arg); /* shallow copy */
276 Kind* copyKindDeep(const Kind*); /* deep copy */
277 
278 /*@
279  @ behavior allocation:
280  @ assumes is_allocable{Pre}((size_t)sizeof(Any),(size_t)1);
281  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
282  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Any)),(size_t)1);
283  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Any)));
284  @ ensures \valid((char*)\result+(0..sizeof(Any)-1));
285  @ ensures \result!=\null;
286  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
287  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
288  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
289  @ ensures __allocated[__num_allocated-1] == (char*)\result;
290  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Any)-1));
291  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
292  @ \separated((char*)\result+(0..sizeof(Any)-1),a+(0..s-1));
293  @ behavior no_allocation:
294  @ assumes !is_allocable{Pre}((size_t)sizeof(Any),(size_t)1);
295  @ assigns \nothing;
296  @ ensures \result==\null;
297  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
298  @ complete behaviors;
299  @ disjoint behaviors;
300  @*/
301 Any* allocAny();
302 
303 /*@
304  @ requires is_allocated{Pre}((char*)ptr);
305  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
306  @ frees ptr;
307  @ ensures !is_allocated{Post}((char*)ptr);
308  @ ensures old_allocated{Pre,Post}((char *)ptr);
309  @ ensures \forall size_t s; is_allocated_size{Pre}((char*)ptr,s) ==> \at(__size_allocated,Post) == \at(__size_allocated,Pre) - s;
310  @ ensures allocation_footprint{Post,Pre}((size_t)(\block_length{Pre}((char*)ptr)), (size_t)1);
311  @*/
312 void freeAny(Any* ptr);
313 void freeAnyZ(Any**);
314 
315 /*@
316  @ behavior allocation:
317  @ assumes is_allocable{Pre}((size_t)sizeof(Any),(size_t)1);
318  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
319  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Any)),(size_t)1);
320  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Any)));
321  @ ensures \valid((char*)\result+(0..sizeof(Any)-1));
322  @ ensures \result!=\null;
323  @ ensures \forall char* p; \result!=\null && (is_allocated{Pre}(p) ==> p != (char*)\result);
324  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
325  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
326  @ ensures __allocated[__num_allocated-1] == (char*)\result;
327  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..sizeof(Any)-1));
328  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
329  @ \separated((char*)\result+(0..sizeof(Any)-1),a+(0..s-1));
330  @ ensures \forall char* a, size_t s; is_allocated_size{Pre}(a, s) ==>
331  @ \separated((char*)\result+(0..sizeof(Any)-1),a+(0..s-1));
332  @ ensures isShallowCopyOfAny{Post,Pre}(*\result,arg);
333  @ behavior no_allocation:
334  @ assumes !is_allocable{Pre}((size_t)sizeof(Any),(size_t)1);
335  @ assigns \nothing;
336  @ ensures \result==\null;
337  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
338  @ complete behaviors;
339  @ disjoint behaviors;
340  @*/
341 Any* makeAny(const Any arg); /* shallow copy */
342 
343 /*@ requires valid_Any_ptr(arg);
344  @ behavior allocation:
345  @ assumes is_allocable{Pre}((size_t)sizeof(Any),(size_t)1);
346  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
347  @ ensures allocation_footprint{Pre,Post}((size_t)(sizeof(Any)),(size_t)1);
348  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(sizeof(Any)));
349  @ ensures \valid((char*)\result+(0..sizeof(Any)-1));
350  @ ensures \result!=\null;
351  @ ensures isShallowCopyOfAny{Post,Pre}(*\result,*arg);
352  @ behavior no_allocation:
353  @ assumes !is_allocable{Pre}((size_t)sizeof(Any),(size_t)1);
354  @ assigns \nothing;
355  @ ensures \result==\null;
356  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
357  @ complete behaviors;
358  @ disjoint behaviors;
359  @*/
360 Any* copyAny(const Any* arg); /* shallow copy */
361 Any* copyAnyDeep(const Any*); /* deep copy */
362 
363 
364 /*@ requires size+1 <= UINT32_MAX;
365  @ behavior allocation:
366  @ assumes is_allocable{Pre}((size_t)(size+1),(size_t)1);
367  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
368  @ ensures allocation_footprint{Pre,Post}((size_t)(size+1),(size_t)1);
369  @ ensures is_allocated_size{Post}((char*)\result,(size_t)(size+1));
370  @ ensures \forall char* p; (is_allocated{Pre}(p) ==> p != (char*)\result);
371  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
372  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post)-1 ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
373  @ ensures __allocated[__num_allocated-1] == (char*)\result;
374  @ ensures \valid((char*)\result+(0..size));
375  @ ensures \separated(__allocated+(0..MAX_ALLOCS-1),(char*)\result+(0..size));
376  @ ensures \forall char** a, size_t s; is_allocated_size{Pre}((char*)a, s) ==>
377  @ \separated((char*)\result+(0..(size_t)(size)),a+(0..s-1));
378  @ ensures \result!=\null;
379  @ behavior no_allocation:
380  @ assumes !is_allocable{Pre}((size_t)(size+1),(size_t)1);
381  @ assigns \nothing;
382  @ ensures \result==\null;
383  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
384  @ ensures \forall char* p, size_t n; is_allocated_size{Pre}(p,n) ==> is_allocated_size{Post}(p,n);
385  @ ensures \forall size_t i; 0 <= i <= \at(__num_allocated,Post) ==> \at(__allocated[i],Post) == \at(__allocated[i],Pre);
386  @ ensures !is_allocable{Pre}((size_t)(size+1),(size_t)1);
387  @ complete behaviors;
388  @ disjoint behaviors;
389  @*/
390 Name allocName(size_t size);
391 
392 /*@
393  @ requires is_allocated{Pre}((char*)ptr);
394  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
395  @ frees ptr;
396  @ ensures !is_allocated{Post}((char*)ptr);
397  @ ensures old_allocated{Pre,Post}((char *)ptr);
398  @ ensures \forall size_t s; is_allocated_size{Pre}((char*)ptr,s) ==> \at(__size_allocated,Post) == \at(__size_allocated,Pre) - s;
399  @ ensures allocation_footprint{Post,Pre}((size_t)(\block_length{Pre}((char*)ptr)), (size_t)1);
400  @*/
401 void freeName(Name ptr);
402 void freeNameZ(Name*);
403 
404 /*@ requires valid_string(arg);
405  @ requires strlen(arg)+1 <= UINT32_MAX;
406  @ behavior allocation:
407  @ assumes is_allocable{Pre}((size_t)(strlen(arg)+1),(size_t)1);
408  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
409  @ ensures allocation_footprint{Pre,Post}((size_t)(strlen(arg)+1),(size_t)1);
410  @ ensures is_allocated_size{Post}((char*)\result,(size_t)strlen(arg));
411  @ ensures \valid((char*)\result+(0..strlen(arg)));
412  @ ensures \result!=\null;
413  @ behavior no_allocation:
414  @ assumes !is_allocable{Pre}((size_t)(strlen(arg)+1),(size_t)1);
415  @ assigns \nothing;
416  @ ensures \result==\null;
417  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
418  @ complete behaviors;
419  @ disjoint behaviors;
420  @*/
421 Name makeName(const Name arg); /* shallow copy = deep copy*/
422 
423 
424 /*@ requires valid_string(arg);
425  @ requires strlen(arg)+1 <= UINT32_MAX;
426  @ behavior allocation:
427  @ assumes is_allocable{Pre}((size_t)(strlen(arg)+1),(size_t)1);
428  @ assigns __allocated[__num_allocated], __size_allocated, __num_allocated;
429  @ ensures allocation_footprint{Pre,Post}((size_t)(strlen(arg)+1),(size_t)1);
430  @ ensures is_allocated_size{Post}((char*)\result,(size_t)strlen(arg));
431  @ ensures \valid((char*)\result+(0..strlen(arg)));
432  @ ensures \result!=\null;
433  @ behavior no_allocation:
434  @ assumes !is_allocable{Pre}((size_t)(strlen(arg)+1),(size_t)1);
435  @ assigns \nothing;
436  @ ensures \result==\null;
437  @ ensures allocation_footprint{Pre,Post}((size_t)0,(size_t)0);
438  @ complete behaviors;
439  @ disjoint behaviors;
440  @*/
441 Name copyName(const Name arg); /* shallow copy = deep copy*/
442 Name copyNameDeep(const Name); /* shallow copy = deep copy*/
443 
444 void die(const char *reason);
445 void freeBindParts(Bind b);
446 
447 #endif
The representation of the kinds in the typesystem.
Definition: checker.h:68
Definitions of the base structures that represent the formulas and proofs.
The representation of the types in the typesystem.
Definition: checker.h:146
The wrapper that makes it possible to store in envmap different species of elements that occur in typ...
Definition: checker.h:329
The representation of the proof terms in the typesystem.
Definition: checker.h:298
char * Name
The type to structurally represent identifier names.
Definition: checker.h:46
The structure to represent binders. (For future use.)
Definition: checker.h:315