summaryrefslogtreecommitdiff
path: root/src/MMgt/MMgt_StackManager.cdl
blob: 5ae1cb27aa7b7f59f4284b300feaeda971f39e54 (plain)
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
-- File:	MMgt_StackManager.cdl
-- Created:	Tue Oct 13 17:03:48 1992
-- Author:	Ramin BARRETO
--		<rba@sdsun4>
---Copyright:	 Matra Datavision 1992

class StackManager from MMgt
---Purpose:
--   The class <StackManager> provides primitive facilities for managing
--   stack-based storage.
--   

uses 
    Integer from Standard
   ,Address from Standard

raises
    OutOfMemory from Standard
   ,ProgramError from Standard

is
    Create returns StackManager;
    ---Purpose:
    --   Constructs a StackManager with an empty free stack.
    --
    ---Level: Advanced
    
    Allocate(me: in out; size: Integer) returns Address
    ---Purpose:
    --   Returns the address of a storage of the given size located on
    --   the top of the free stack.
    ---Level: Advanced
    raises OutOfMemory 
    	   -- If the allocation fails
    is static;
    
    Free(me: in out; aStack: in out Address; aSize: Integer)
    ---Purpose:
    --   Deallocates the storage of the given size from the free stack
    --   and nullify the address.
    ---Level: Advanced
    raises ProgramError  
    	   -- If the storage is not on the top of the stack.
    is static;
    
    ShallowCopy (me) returns StackManager;
    ---Purpose: 
    --   There is no way to have a "ShallowCopy" of a "StackManager"
    ---Level: Advanced
    ---Warning:
    --   A ProgramError will be raised with a message.
    --   
    ---C++:  function call

    Purge(me: in out)
    ---Purpose:
    --   Deallocates the storage associated to stack.
    ---Level: Advanced
    is static private;
    
    ShallowDump (me; S: in out OStream);
    ---Purpose: 
    --   Prints the contents of <me> on the stream <s>. 
    ---Level: Advanced
    ---C++:  function call

    Destructor(me: in out);
    ---Purpose:
    --    Deallocates the storage associated to stack.
    --    Delete <me>.
    ---Level: Advanced
    ---C++: alias ~
    
fields
    myFreeListSize: Integer;
    myFreeList:     Address;

end StackManager;