📄 accesstypes.ads
字号:
package AccessTypes is type Neigbor_Idx_Type is (N, S, E, W, NE, NW, SE, SW); type Ref_Count is access constant Integer range 0..1; type Ref_Count_Array is array (Neigbor_Idx_Type) of Ref_Count; type Game_Cell; type Game_Cell_Ptr is access Game_Cell; type Game_Cell is record Next: access Game_Cell; Life_Count: aliased Integer range 0..1; Total_Neighbor_Count : Integer range 1..8; Neighbor_Count: Ref_Count_Array; -- Access to the neighbors' Life Count end record; procedure Init; Abyss : aliased constant Game_Cell := Game_Cell'( Next => Null, Life_Count => 0, Total_Neighbor_Count => 1, Neighbor_Count=> (Others=>null)); NWCell : aliased Game_Cell := Game_Cell'( Next => Null, Life_Count => 0, Total_Neighbor_Count => 1, Neighbor_Count=> (Others=>null)); Live: aliased Game_Cell := Game_Cell'( Next => Null, Life_Count => 1, Total_Neighbor_Count => 1, Neighbor_Count => ( N => Abyss.Life_Count'Access, Others => null)); Live_Access : access Game_Cell := Live'Access; -- -- Access Game_Cell variable -- But cannot change it -- ACT: access constant Game_Cell := Live'Access; -- -- constant access to constant variable -- variable cannot be changed via CACT -- CACT can only access the variable it's initialized with. -- CACT: constant access constant Game_Cell := Abyss'Access; -- -- constant access to variable -- CAT can only access to variable it's initialized with -- CAT: constant access Game_Cell := Live'Access; -- -- Procedure with constant access type -- -- function MyProc(CATP: constant access not null Game_Cell, ACTP: access not null constant Game_Cell) -- return not null access Game_Cell ; function MyProc(CATP: access constant Game_Cell; ACTP: access constant Game_Cell) return not null Game_Cell_Ptr ; procedure AccessNotAllowed;---- function CannotAddToList(The_List: access Game_Cell;-- Obj_Ptr: access Game_Cell) return access Game_Cell;-- function AddToList(The_List: access Game_Cell; Obj_Ptr: access constant Game_Cell) return access Game_Cell; -- -- ERROR: functions can only have "in" parameters -- -- function InOutParameter(PIO: in out Game_Cell) return Game_Cell;privateend;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -