home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
coders
/
jËzyki_programowania
/
oberon
/
system
/
types.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1977-12-31
|
2KB
|
65 lines
Syntax10.Scn.Fnt
ParcElems
Alloc
Syntax24b.Scn.Fnt
(* AMIGA *)
MODULE Types; (* RC 16.1.92 - AMIGA-Version 20.4.95 Ralf Degner *)
IMPORT Modules, Kernel, S := SYSTEM;
Type* = POINTER TO TypeDesc;
TypeDesc* = RECORD
size*: LONGINT;
extensionLevel: INTEGER;
methodCnt: INTEGER;
module*: Modules.Module;
reserved: LONGINT;
name*: Modules.ModuleName;
baseTypes: ARRAY 8 OF LONGINT;
pointerOffsets:ARRAY OF LONGINT;
END;
Entry = POINTER TO EntryDesc;
EntryDesc = RECORD l:LONGINT; END;
PROCEDURE This*(mod: Modules.Module; name: ARRAY OF CHAR): Type;
VAR
type: Type;
i: LONGINT;
entry: Entry;
BEGIN
IF name # "" THEN
FOR i:=0 TO mod.nofentries-1 DO
entry:=S.VAL(Entry, mod.entries+4*i);
IF entry.l<(-mod.dataSize) THEN
type:=S.VAL(Type, mod.code+entry.l);
IF type.name = name THEN RETURN type END;
END;
END;
END ;
RETURN NIL
END This;
PROCEDURE BaseOf*(t: Type; level: INTEGER): Type;
BEGIN
IF (level<=t.extensionLevel) & (level>=0) THEN
RETURN S.VAL(Type, t.baseTypes[level]);
ELSE
RETURN NIL
END;
END BaseOf;
PROCEDURE LevelOf*(t: Type): INTEGER;
BEGIN
RETURN t.extensionLevel
END LevelOf;
PROCEDURE TypeOf*(o: S.PTR): Type;
VAR type: Type;
BEGIN
S.GET(S.VAL(LONGINT, o)-4, type);
RETURN type
END TypeOf;
PROCEDURE NewObj*(VAR o: S.PTR; t: Type);
VAR
otype: Type;
BEGIN
otype:=S.VAL(Type, o);
IF BaseOf(t, LevelOf(otype)) # otype THEN o := NIL; RETURN END;
o := S.VAL(S.PTR, Kernel.New(S.VAL(LONGINT, t)));
END NewObj;
END Types.