aboutsummaryrefslogtreecommitdiff
path: root/tests/i/class-delete-designators/program.cps
blob: be552e7af1f4ee8cc4ab66c278ae24d8826f8f5e (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

CLASS Item
    Id : INTEGER
    PROCEDURE DELETE()
        OUTPUT "item:", Id
    ENDPROCEDURE
    PROCEDURE Explicit()
        this.DELETE()
    ENDPROCEDURE
    PROCEDURE Release()
        DELETE this
    ENDPROCEDURE
ENDCLASS
TYPE ItemPtr = ^Item
DECLARE Obj : Item
DECLARE Ptr : ItemPtr
Obj <- NEW Item()
Obj.Id <- 1
Ptr <- ^Obj
CALL Obj.Explicit()
DELETE Ptr^
Obj <- NEW Item()
Obj.Id <- 2
CALL Obj.Release()
DECLARE Arr : ARRAY[1:2] OF Item
Arr[2].Id <- 3
TRY
    DELETE Arr[2]
CATCH
    OUTPUT "array caught"
ENDTRY