-
Notifications
You must be signed in to change notification settings - Fork 2
/
Sample.cp
41 lines (34 loc) · 1008 Bytes
/
Sample.cp
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
MODULE ObxSample;
(**
project = "BlackBox"
organization = "www.oberon.ch"
contributors = "Oberon microsystems"
version = "System/Rsrc/About"
copyright = "System/Rsrc/About"
license = "Docu/BB-License"
changes = ""
issues = ""
**)
TYPE
File* = POINTER TO RECORD
len: INTEGER (* hidden instance variable *)
END;
Rider* = POINTER TO RECORD
(* there may be several riders on one file *)
file-: File; (* read-only instance variable *)
eof*: BOOLEAN; (* fully exported instance variable *)
pos: INTEGER (* hidden instance variable *)
(* Invariant: (pos >= 0) & (pos < file.len) *)
END;
PROCEDURE (f: File) GetLength* (OUT length: INTEGER), NEW;
BEGIN
length := f.len
END GetLength;
PROCEDURE (rd: Rider) SetPos* (pos: INTEGER), NEW;
BEGIN
(* assert invariants, so that errors may not be propagated across components *)
ASSERT(pos >= 0); ASSERT(pos < rd.file.len);
rd.pos := pos
END SetPos;
(* ... *)
END ObxSample.