mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 18:02:25 +00:00
Add OutSize and InTyp procedures for integer symbol handling.
This commit is contained in:
parent
7d7579a36d
commit
a33e38cf6c
1 changed files with 34 additions and 8 deletions
|
|
@ -229,7 +229,9 @@ BEGIN
|
||||||
(* Not sure if StPar0 (which calls this) always gets the baseiest type. This
|
(* Not sure if StPar0 (which calls this) always gets the baseiest type. This
|
||||||
ASSERT will tell me. *)
|
ASSERT will tell me. *)
|
||||||
ASSERT(x.BaseTyp = undftyp);
|
ASSERT(x.BaseTyp = undftyp);
|
||||||
|
(*
|
||||||
WHILE x.BaseTyp # undftyp DO ASSERT(x # x.BaseTyp); ASSERT(x.BaseTyp # NIL); x := x.BaseTyp END;
|
WHILE x.BaseTyp # undftyp DO ASSERT(x # x.BaseTyp); ASSERT(x.BaseTyp # NIL); x := x.BaseTyp END;
|
||||||
|
*)
|
||||||
i := 0; WHILE (NextSize[i] # x) & (i < LEN(NextSize)) DO INC(i) END;
|
i := 0; WHILE (NextSize[i] # x) & (i < LEN(NextSize)) DO INC(i) END;
|
||||||
ASSERT(i < LEN(NextSize)-1);
|
ASSERT(i < LEN(NextSize)-1);
|
||||||
RETURN NextSize[i+dir]
|
RETURN NextSize[i+dir]
|
||||||
|
|
@ -701,6 +703,26 @@ BEGIN
|
||||||
RETURN obj
|
RETURN obj
|
||||||
END InTProc;
|
END InTProc;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE InTyp(tag: LONGINT): Struct;
|
||||||
|
VAR size: LONGINT;
|
||||||
|
BEGIN
|
||||||
|
IF tag IN intSet THEN
|
||||||
|
size := OPM.SymRInt();
|
||||||
|
(*
|
||||||
|
IF size = 123456789 THEN (* Expected magic number while testing *)
|
||||||
|
size := OPM.SymRInt();
|
||||||
|
ELSE
|
||||||
|
OPM.LogWLn; OPM.LogWStr("Missing constant magic number. size = "); OPM.LogWNum(size,1);
|
||||||
|
END;
|
||||||
|
*)
|
||||||
|
RETURN IntType(size)
|
||||||
|
ELSE
|
||||||
|
RETURN impCtxt.ref[tag]
|
||||||
|
END
|
||||||
|
END InTyp;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE InStruct(VAR typ: Struct);
|
PROCEDURE InStruct(VAR typ: Struct);
|
||||||
VAR mno: SHORTINT; ref: INTEGER; tag: LONGINT; name: OPS.Name;
|
VAR mno: SHORTINT; ref: INTEGER; tag: LONGINT; name: OPS.Name;
|
||||||
t: Struct; obj, last, fld, old, dummy: Object;
|
t: Struct; obj, last, fld, old, dummy: Object;
|
||||||
|
|
@ -781,7 +803,7 @@ BEGIN
|
||||||
ELSE OPM.LogWStr("unhandled case at InStruct, tag = "); OPM.LogWNum(tag, 0); OPM.LogWLn;
|
ELSE OPM.LogWStr("unhandled case at InStruct, tag = "); OPM.LogWNum(tag, 0); OPM.LogWLn;
|
||||||
END;
|
END;
|
||||||
IF ref = impCtxt.minr THEN
|
IF ref = impCtxt.minr THEN
|
||||||
WHILE (ref < impCtxt.nofr) (*OR ((ref >= Int8) & (ref <= Int64))*) DO
|
WHILE (ref < impCtxt.nofr) DO
|
||||||
t := impCtxt.ref[ref]; FPrintStr(t);
|
t := impCtxt.ref[ref]; FPrintStr(t);
|
||||||
obj := t^.strobj; (* obj^.typ^.strobj = obj, else obj^.fprint differs (alias) *)
|
obj := t^.strobj; (* obj^.typ^.strobj = obj, else obj^.fprint differs (alias) *)
|
||||||
IF obj^.name # "" THEN FPrintObj(obj) END;
|
IF obj^.name # "" THEN FPrintObj(obj) END;
|
||||||
|
|
@ -840,11 +862,7 @@ BEGIN
|
||||||
obj := NewObj(); obj^.mnolev := -mno; obj^.vis := external;
|
obj := NewObj(); obj^.mnolev := -mno; obj^.vis := external;
|
||||||
IF tag <= Pointer THEN (* Constant *)
|
IF tag <= Pointer THEN (* Constant *)
|
||||||
obj^.mode := Con; obj^.conval := NewConst(); InConstant(tag, obj^.conval);
|
obj^.mode := Con; obj^.conval := NewConst(); InConstant(tag, obj^.conval);
|
||||||
IF tag IN intSet THEN
|
obj^.typ := InTyp(tag)
|
||||||
obj.typ := IntType(OPM.SymRInt())
|
|
||||||
ELSE
|
|
||||||
obj^.typ := impCtxt.ref[tag];
|
|
||||||
END
|
|
||||||
ELSIF tag >= Sxpro THEN
|
ELSIF tag >= Sxpro THEN
|
||||||
obj^.conval := NewConst();
|
obj^.conval := NewConst();
|
||||||
obj^.conval^.intval := -1;
|
obj^.conval^.intval := -1;
|
||||||
|
|
@ -1015,10 +1033,18 @@ END Import;
|
||||||
END
|
END
|
||||||
END OutTProcs;
|
END OutTProcs;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE OutSize(size: LONGINT);
|
||||||
|
BEGIN
|
||||||
|
(* OPM.SymWInt(123456789); *)
|
||||||
|
OPM.SymWInt(size)
|
||||||
|
END OutSize;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE OutStr(typ: Struct); (* OPV.TypeAlloc already applied *)
|
PROCEDURE OutStr(typ: Struct); (* OPV.TypeAlloc already applied *)
|
||||||
VAR strobj: Object;
|
VAR strobj: Object;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF (typ^.ref < expCtxt.ref) (*OR (typ^.ref >= Int8) & (typ^.ref <= Int64)*) THEN OPM.SymWInt(-typ^.ref)
|
IF (typ^.ref < expCtxt.ref) THEN OPM.SymWInt(-typ^.ref);
|
||||||
ELSE
|
ELSE
|
||||||
OPM.SymWInt(Sstruct);
|
OPM.SymWInt(Sstruct);
|
||||||
typ^.ref := expCtxt.ref; INC(expCtxt.ref);
|
typ^.ref := expCtxt.ref; INC(expCtxt.ref);
|
||||||
|
|
@ -1065,7 +1091,7 @@ END Import;
|
||||||
Char: OPM.SymWCh(CHR(obj^.conval^.intval))
|
Char: OPM.SymWCh(CHR(obj^.conval^.intval))
|
||||||
| SInt,
|
| SInt,
|
||||||
Int,
|
Int,
|
||||||
LInt: OPM.SymWInt(obj^.conval^.intval); OPM.SymWInt(obj.typ.size)
|
LInt: OPM.SymWInt(obj^.conval^.intval); OutSize(obj.typ.size)
|
||||||
| Set: OPM.SymWSet(obj^.conval^.setval)
|
| Set: OPM.SymWSet(obj^.conval^.setval)
|
||||||
| Real: rval := SHORT(obj^.conval^.realval); OPM.SymWReal(rval)
|
| Real: rval := SHORT(obj^.conval^.realval); OPM.SymWReal(rval)
|
||||||
| LReal: OPM.SymWLReal(obj^.conval^.realval)
|
| LReal: OPM.SymWLReal(obj^.conval^.realval)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue