[Oberon] Static variable overflow (bug?)
Hans Klaver
hklaver at dds.nl
Mon Feb 24 01:15:13 CET 2020
Recently I tried to implement XYplane.Mod from the book of Reiser & Wirth 'Programming in Oberon' for Project Oberon. Within Peter de Wachter's RISC emulator I ran into an overflow problem (leading to the remaining empty of the menu line of a viewer) that appears to be dependent on which disk image is used.
Otherwise my port works fine (produces the IFS fractal fern as expected).
For those interested I will post it to my github repository.
A minimal module that can reproduce this menu problem can be found below.
When starting the emulator in macOS as follows this problem occurs:
$ ./risc --fullscreen DiskImage/Oberon-2019-01-21.dsk
But the problem does NOT occur when starting thus:
$ ./risc --fullscreen DiskImage/Oberon-2016-08-02.dsk
I do understand that there is a limit to the use of static variables within the PO version of Oberon, but I would not expect this limit to be reached this easily, and I would not expect it to appear in newer versions of the software and not in older.
Does anyone have a clue where to look for the cause of this happening?
Hans Klaver
---------------------
MODULE MyViewer;
(* Test of the menu line of a viewer *)
IMPORT Display, Viewers, Oberon, MenuViewers, TextFrames;
CONST
max = 16377; (* If max >= 16367 the frame name disappears; If max >= 16377 the whole menu line disappears! *)
menu = "System.Close System.Copy System.Grow";
TYPE
XYframe = POINTER TO XYframeDesc;
XYframeDesc = RECORD (Display.FrameDesc) END;
VAR bitmap: ARRAY max OF SET; (* with this variable present the menu may remain empty! *)
PROCEDURE Restore(F: XYframe);
BEGIN
Oberon.RemoveMarks(F.X, F.Y, F.W, F.H);
Display.ReplConst(Display.black, F.X, F.Y, F.W, F.H, Display.replace); (* clear *)
END Restore;
PROCEDURE Handle(F: Display.Frame; VAR M: Display.FrameMsg);
VAR F1: XYframe;
BEGIN
CASE F OF XYframe:
CASE M OF
Oberon.InputMsg:
IF M.id = Oberon.track THEN Oberon.DrawMouseArrow(M.X, M.Y) END |
Oberon.CopyMsg:
Oberon.RemoveMarks(F.X, F.Y, F.W, F.H); NEW(F1); F1^ := F^; M.F := F1 |
MenuViewers.ModifyMsg:
IF (M.Y # F.Y) OR (M.H # F.H) THEN F.Y := M.Y; F.H := M.H; Restore(F) END
END
END
END Handle;
PROCEDURE Open*;
VAR F: XYframe; V: Viewers.Viewer; x, y: INTEGER;
BEGIN
NEW(F); F.handle := Handle;
Oberon.AllocateUserViewer(Oberon.Par.vwr.X, x, y);
V := MenuViewers.New(TextFrames.NewMenu("MyViewer", menu), F, TextFrames.menuH, x, y)
END Open;
END MyViewer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200224/05c5573a/attachment.html>
More information about the Oberon
mailing list