changed PascalIO.Get behaviour and used Allocate instead of ALLOCATE
This commit is contained in:
parent
9dccd59665
commit
021619910e
|
@ -13,7 +13,7 @@ IMPLEMENTATION MODULE CSP;
|
|||
|
||||
FROM random IMPORT Uniform;
|
||||
FROM SYSTEM IMPORT BYTE, ADDRESS, NEWPROCESS, TRANSFER;
|
||||
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
|
||||
FROM Storage IMPORT Allocate, Deallocate;
|
||||
IMPORT Traps;
|
||||
|
||||
CONST WorkSpaceSize = 1000;
|
||||
|
@ -163,8 +163,8 @@ IMPLEMENTATION MODULE CSP;
|
|||
BEGIN
|
||||
Pop(free, newprocess);
|
||||
IF newprocess = NIL THEN
|
||||
ALLOCATE(newprocess,SIZE(ProcessDescriptor));
|
||||
ALLOCATE(newprocess^.wsp, WorkSpaceSize)
|
||||
Allocate(newprocess,SIZE(ProcessDescriptor));
|
||||
Allocate(newprocess^.wsp, WorkSpaceSize)
|
||||
END;
|
||||
WITH newprocess^ DO
|
||||
father := cp;
|
||||
|
@ -198,7 +198,7 @@ IMPLEMENTATION MODULE CSP;
|
|||
PROCEDURE InitChannel(VAR ch: Channel);
|
||||
(* Initialize the channel ch *)
|
||||
BEGIN
|
||||
ALLOCATE(ch, SIZE(ChannelDescriptor));
|
||||
Allocate(ch, SIZE(ChannelDescriptor));
|
||||
WITH ch^ DO
|
||||
InitQueue(senders);
|
||||
owner := NIL;
|
||||
|
@ -227,7 +227,7 @@ IMPLEMENTATION MODULE CSP;
|
|||
BEGIN
|
||||
WITH ch^ DO
|
||||
Push(cp, senders);
|
||||
ALLOCATE(cp^.msgadr, SIZE(data));
|
||||
Allocate(cp^.msgadr, SIZE(data));
|
||||
m := cp^.msgadr;
|
||||
cp^.msglen := HIGH(data);
|
||||
FOR i := 0 TO HIGH(data) DO
|
||||
|
@ -276,7 +276,7 @@ IMPLEMENTATION MODULE CSP;
|
|||
Push(cp, ready);
|
||||
Push(aux, ready)
|
||||
END;
|
||||
DEALLOCATE(aux^.msgadr, aux^.msglen+1);
|
||||
Deallocate(aux^.msgadr, aux^.msglen+1);
|
||||
DoTransfer
|
||||
END
|
||||
END Receive;
|
||||
|
@ -338,7 +338,7 @@ IMPLEMENTATION MODULE CSP;
|
|||
BEGIN
|
||||
InitQueue(free);
|
||||
InitQueue(ready);
|
||||
ALLOCATE(cp,SIZE(ProcessDescriptor));
|
||||
Allocate(cp,SIZE(ProcessDescriptor));
|
||||
WITH cp^ DO
|
||||
sons := 0;
|
||||
father := NIL
|
||||
|
|
|
@ -17,7 +17,7 @@ IMPLEMENTATION MODULE PascalIO;
|
|||
FROM Streams IMPORT Stream, StreamKind, StreamMode, StreamResult,
|
||||
InputStream, OutputStream, OpenStream, CloseStream,
|
||||
EndOfStream, Read, Write, StreamBuffering;
|
||||
FROM Storage IMPORT ALLOCATE;
|
||||
FROM Storage IMPORT Allocate;
|
||||
FROM SYSTEM IMPORT ADR;
|
||||
|
||||
TYPE charset = SET OF CHAR;
|
||||
|
@ -98,7 +98,7 @@ IMPLEMENTATION MODULE PascalIO;
|
|||
Xtext := Xtext^.next;
|
||||
END;
|
||||
IF Xtext = NIL THEN
|
||||
ALLOCATE(Xtext,SIZE(IOstream));
|
||||
Allocate(Xtext,SIZE(IOstream));
|
||||
Xtext^.next := head;
|
||||
head := Xtext;
|
||||
END;
|
||||
|
@ -125,14 +125,20 @@ IMPLEMENTATION MODULE PascalIO;
|
|||
WITH InputText^ DO
|
||||
IF type # Preading THEN Error(Preading); END;
|
||||
IF NOT done THEN
|
||||
Get(InputText);
|
||||
done := TRUE;
|
||||
IF EndOfStream(stream, result) THEN
|
||||
eof := TRUE;
|
||||
ch := 0C;
|
||||
ELSE
|
||||
Read(stream, ch, result);
|
||||
done := TRUE;
|
||||
END;
|
||||
END;
|
||||
RETURN ch;
|
||||
END;
|
||||
END NextChar;
|
||||
|
||||
PROCEDURE Get(InputText: Text);
|
||||
VAR dummy: CHAR;
|
||||
BEGIN
|
||||
WITH InputText^ DO
|
||||
IF type # Preading THEN Error(Preading); END;
|
||||
|
@ -140,11 +146,8 @@ IMPLEMENTATION MODULE PascalIO;
|
|||
Traps.Message("unexpected EOF");
|
||||
HALT;
|
||||
END;
|
||||
IF EndOfStream(stream, result) THEN
|
||||
eof := TRUE;
|
||||
ch := 0C;
|
||||
ELSE
|
||||
Read(stream, ch, result);
|
||||
IF done THEN done := FALSE;
|
||||
ELSE dummy := NextChar(InputText);
|
||||
END;
|
||||
END;
|
||||
END Get;
|
||||
|
|
|
@ -8,7 +8,7 @@ IMPLEMENTATION MODULE Processes [1];
|
|||
|
||||
FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER;
|
||||
|
||||
FROM Storage IMPORT ALLOCATE;
|
||||
FROM Storage IMPORT Allocate;
|
||||
|
||||
FROM Traps IMPORT Message;
|
||||
|
||||
|
@ -28,8 +28,8 @@ IMPLEMENTATION MODULE Processes [1];
|
|||
wsp: ADDRESS;
|
||||
BEGIN
|
||||
s0 := cp;
|
||||
ALLOCATE(wsp, n);
|
||||
ALLOCATE(cp, TSIZE(ProcessDescriptor));
|
||||
Allocate(wsp, n);
|
||||
Allocate(cp, TSIZE(ProcessDescriptor));
|
||||
WITH cp^ DO
|
||||
next := s0^.next;
|
||||
s0^.next := cp;
|
||||
|
@ -94,7 +94,7 @@ IMPLEMENTATION MODULE Processes [1];
|
|||
END Init;
|
||||
|
||||
BEGIN
|
||||
ALLOCATE(cp, TSIZE(ProcessDescriptor));
|
||||
Allocate(cp, TSIZE(ProcessDescriptor));
|
||||
WITH cp^ DO
|
||||
next := cp;
|
||||
ready := TRUE;
|
||||
|
|
|
@ -14,7 +14,7 @@ IMPLEMENTATION MODULE Semaphores [1];
|
|||
*)
|
||||
|
||||
FROM SYSTEM IMPORT ADDRESS, NEWPROCESS, TRANSFER;
|
||||
FROM Storage IMPORT ALLOCATE;
|
||||
FROM Storage IMPORT Allocate;
|
||||
FROM random IMPORT Uniform;
|
||||
FROM Traps IMPORT Message;
|
||||
|
||||
|
@ -37,8 +37,8 @@ IMPLEMENTATION MODULE Semaphores [1];
|
|||
wsp: ADDRESS;
|
||||
BEGIN
|
||||
s0 := cp;
|
||||
ALLOCATE(wsp, n);
|
||||
ALLOCATE(cp, SIZE(Process));
|
||||
Allocate(wsp, n);
|
||||
Allocate(cp, SIZE(Process));
|
||||
WITH cp^ DO
|
||||
next := s0^.next;
|
||||
s0^.next := cp;
|
||||
|
@ -67,7 +67,7 @@ IMPLEMENTATION MODULE Semaphores [1];
|
|||
PROCEDURE NewSema(n: CARDINAL): Sema;
|
||||
VAR s: Sema;
|
||||
BEGIN
|
||||
ALLOCATE(s, SIZE(Semaphore));
|
||||
Allocate(s, SIZE(Semaphore));
|
||||
s^.level := n;
|
||||
RETURN s;
|
||||
END NewSema;
|
||||
|
@ -110,7 +110,7 @@ IMPLEMENTATION MODULE Semaphores [1];
|
|||
RETURN FALSE;
|
||||
END Runnable;
|
||||
BEGIN
|
||||
ALLOCATE(cp, SIZE(Process));
|
||||
Allocate(cp, SIZE(Process));
|
||||
WITH cp^ DO
|
||||
next := cp;
|
||||
waiting := NIL;
|
||||
|
|
|
@ -44,7 +44,7 @@ IMPLEMENTATION MODULE Streams;
|
|||
IF NOT Storage.Available(SIZE(IOB)) THEN
|
||||
RETURN;
|
||||
END;
|
||||
Storage.ALLOCATE(stream,SIZE(IOB));
|
||||
Storage.Allocate(stream,SIZE(IOB));
|
||||
stream^.next := head;
|
||||
head := stream;
|
||||
END;
|
||||
|
|
Loading…
Reference in a new issue