mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 15:42:25 +00:00
Add set size to __SETOF and __SETRNG.
This commit is contained in:
parent
b8496c3736
commit
f13130bbd3
3 changed files with 17 additions and 14 deletions
|
|
@ -27,8 +27,6 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
||||||
GuardPtrFunc = "__GUARDP(";
|
GuardPtrFunc = "__GUARDP(";
|
||||||
GuardRecFunc = "__GUARDR(";
|
GuardRecFunc = "__GUARDR(";
|
||||||
TypeFunc = "__TYPEOF(";
|
TypeFunc = "__TYPEOF(";
|
||||||
SetOfFunc = "__SETOF(";
|
|
||||||
SetRangeFunc = "__SETRNG(";
|
|
||||||
CopyFunc = "__COPY(";
|
CopyFunc = "__COPY(";
|
||||||
MoveFunc = "__MOVE(";
|
MoveFunc = "__MOVE(";
|
||||||
GetFunc = "__GET(";
|
GetFunc = "__GET(";
|
||||||
|
|
@ -293,7 +291,9 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
||||||
PROCEDURE Convert(n: OPT.Node; newtype: OPT.Struct; prec: INTEGER);
|
PROCEDURE Convert(n: OPT.Node; newtype: OPT.Struct; prec: INTEGER);
|
||||||
VAR from, to: INTEGER;
|
VAR from, to: INTEGER;
|
||||||
BEGIN from := n^.typ^.form; to := newtype.form;
|
BEGIN from := n^.typ^.form; to := newtype.form;
|
||||||
IF to = OPT.Set THEN OPM.WriteString(SetOfFunc); Entier(n, MinPrec); OPM.Write(CloseParen)
|
IF to = OPT.Set THEN
|
||||||
|
OPM.WriteString("__SETOF("); Entier(n, MinPrec);
|
||||||
|
OPM.WriteString(","); OPM.WriteInt(newtype.size*8); OPM.Write(CloseParen)
|
||||||
ELSIF to = OPT.Int THEN
|
ELSIF to = OPT.Int THEN
|
||||||
IF (newtype.size < n.typ.size) & (OPM.ranchk IN OPM.opt) THEN
|
IF (newtype.size < n.typ.size) & (OPM.ranchk IN OPM.opt) THEN
|
||||||
OPM.WriteString("__SHORT"); IF SideEffects(n) THEN OPM.Write("F") END;
|
OPM.WriteString("__SHORT"); IF SideEffects(n) THEN OPM.Write("F") END;
|
||||||
|
|
@ -527,8 +527,8 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
||||||
CASE class OF
|
CASE class OF
|
||||||
| OPT.Nconst: OPC.Constant(n^.conval, form)
|
| OPT.Nconst: OPC.Constant(n^.conval, form)
|
||||||
| OPT.Nupto: (* n^.typ = OPT.settyp *)
|
| OPT.Nupto: (* n^.typ = OPT.settyp *)
|
||||||
OPM.WriteString(SetRangeFunc); expr(l, MinPrec); OPM.WriteString(Comma); expr (r, MinPrec);
|
OPM.WriteString("__SETRNG("); expr(l, MinPrec); OPM.WriteString(Comma); expr(r, MinPrec);
|
||||||
OPM.Write(CloseParen)
|
OPM.WriteString(Comma); OPM.WriteInt(n.typ.size*8); OPM.Write(CloseParen)
|
||||||
| OPT.Nmop:
|
| OPT.Nmop:
|
||||||
CASE subclass OF
|
CASE subclass OF
|
||||||
| OPS.not: OPM.Write("!"); expr(l, exprPrec)
|
| OPS.not: OPM.Write("!"); expr(l, exprPrec)
|
||||||
|
|
@ -865,8 +865,9 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
||||||
| OPT.incfn,
|
| OPT.incfn,
|
||||||
OPT.decfn: expr(n^.left, MinPrec); OPC.Increment(n^.subcl = OPT.decfn); expr(n^.right, MinPrec)
|
OPT.decfn: expr(n^.left, MinPrec); OPC.Increment(n^.subcl = OPT.decfn); expr(n^.right, MinPrec)
|
||||||
| OPT.inclfn,
|
| OPT.inclfn,
|
||||||
OPT.exclfn: expr(n^.left, MinPrec); OPC.SetInclude(n^.subcl = OPT.exclfn); OPM.WriteString(SetOfFunc); expr(n^.right, MinPrec);
|
OPT.exclfn: expr(n^.left, MinPrec); OPC.SetInclude(n^.subcl = OPT.exclfn);
|
||||||
OPM.Write(CloseParen)
|
OPM.WriteString("__SETOF("); expr(n^.right, MinPrec);
|
||||||
|
OPM.WriteString(","); OPM.WriteInt(n.left.typ.size*8); OPM.Write(CloseParen)
|
||||||
| OPT.copyfn: OPM.WriteString(CopyFunc);
|
| OPT.copyfn: OPM.WriteString(CopyFunc);
|
||||||
expr(n^.right, MinPrec); OPM.WriteString(Comma); expr(n^.left, MinPrec); OPM.WriteString(Comma);
|
expr(n^.right, MinPrec); OPM.WriteString(Comma); expr(n^.left, MinPrec); OPM.WriteString(Comma);
|
||||||
Len(n^.left, 0); OPM.Write(CloseParen)
|
Len(n^.left, 0); OPM.Write(CloseParen)
|
||||||
|
|
|
||||||
|
|
@ -228,13 +228,12 @@ static inline double SYSTEM_ABSD(double i) {return i >= 0.0 ? i : -i;}
|
||||||
#define __CAP(ch) ((CHAR)((ch)&0x5f))
|
#define __CAP(ch) ((CHAR)((ch)&0x5f))
|
||||||
#define __ODD(x) ((x)&1)
|
#define __ODD(x) ((x)&1)
|
||||||
|
|
||||||
//#define __IN(x, s, size) ((x)>=0 && (x)<size && ((((uint##size)(s))>>(x))&1))
|
#define __IN(x, s, size) (((unsigned int)(x))<size && ((((uint##size)(s))>>(x))&1))
|
||||||
|
#define __SETOF(x, size) ((uint##size)1<<(x))
|
||||||
|
#define __SETRNG(l, h, size) ((~(uint##size)0<<(l))&~(uint##size)0>>(size-1-(h)))
|
||||||
|
|
||||||
#define __IN(x, s, size) (((unsigned int)(x))<size && ((((uint##size)(s))>>(x))&1))
|
#define __MASK(x, m) ((x)&~(m))
|
||||||
#define __SETOF(x) ((SET)1<<(x))
|
#define __BIT(x, n) (*(uint64*)(x)>>(n)&1)
|
||||||
#define __SETRNG(l, h) ((~(SET)0<<(l))&~(SET)0>>(8*sizeof(SET)-1-(h)))
|
|
||||||
#define __MASK(x, m) ((x)&~(m))
|
|
||||||
#define __BIT(x, n) (*(uint64*)(x)>>(n)&1)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,10 @@ void testSystemDotH() {
|
||||||
/* test the __SETRNG macro */
|
/* test the __SETRNG macro */
|
||||||
long x = 0;
|
long x = 0;
|
||||||
long y = sizeof(SET)*8 - 1;
|
long y = sizeof(SET)*8 - 1;
|
||||||
assert(__SETRNG(x, y) == -1, "SETRNG(0, MAX(SET)) != -1.");
|
if (sizeof(SET) == 4)
|
||||||
|
assert(__SETRNG(x, y, 32) == -1, "SETRNG(0, MAX(SET)) != -1.");
|
||||||
|
else
|
||||||
|
assert(__SETRNG(x, y, 64) == -1, "SETRNG(0, MAX(SET)) != -1.");
|
||||||
|
|
||||||
/* test string comparison for extended ascii */
|
/* test string comparison for extended ascii */
|
||||||
{char a[10], b[10];
|
{char a[10], b[10];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue