compiles.

This commit is contained in:
norayr 2017-04-13 16:41:08 +04:00
parent 4acd41201c
commit 4c64d37338
5 changed files with 79 additions and 36 deletions

View file

@ -6,33 +6,36 @@ TYPE
intarr64 = ARRAY 8 OF SYS.BYTE; (* to emulate int16 on x86_64; -- noch *)
intarr32 = ARRAY 4 OF SYS.BYTE;
intarr16 = ARRAY 2 OF SYS.BYTE;
Int16* = intarr16; (* INTEGER on 32 bit platform *)
Int32* = INTEGER;
Int64* = LONGINT;
Int16* = INTEGER; (* INTEGER on 32 bit platform *)
Int32* = LONGINT;
Int64* = HUGEINT;
String* = ARRAY 256 OF CHAR;
PROCEDURE LongintToInt16*(int: LONGINT; VAR int16: Int16);
VAR longintarr : intarr64;
PROCEDURE HugeintToInt16*(in: HUGEINT; VAR out: Int16);
VAR
int64 : intarr64;
int16 : intarr16;
BEGIN
(*RETURN SYS.VAL(Int16, int)*)
longintarr := SYS.VAL(intarr64, int);
int16[0] := longintarr[0];
int16[1] := longintarr[1]; (* this will work for little endian -- noch *)
END LongintToInt16;
int64 := SYS.VAL(intarr64, in);
int16[0] := int64[0];
int16[1] := int64[1];
out := SYS.VAL(Int16, int16)
END HugeintToInt16;
PROCEDURE IntegerToInt16*(int: INTEGER; VAR int16: Int16);
VAR intarr : intarr32;
PROCEDURE LongintToInt16*(int: LONGINT; VAR int16: Int16);
BEGIN
int16 := SYS.VAL(Int16, int)
(*intarr := SYS.VAL(intarr32, int);
int16[0] := intarr[0];
int16[1] := intarr[1];*) (* this will work for little endian -- noch *)
END IntegerToInt16;
END LongintToInt16;
PROCEDURE htons*(in: Int16; VAR out : Int16);
VAR
tmpin, tmpout : intarr16;
BEGIN
out[0] := in[1];
out[1] := in[0];
tmpin := SYS.VAL(intarr16, in);
tmpout := SYS.VAL(intarr16, out);
tmpout[0] := tmpin[1];
tmpout[1] := tmpin[0];
out := SYS.VAL(Int16, tmpout)
END htons;
END types.