mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 19:12: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(";
|
||||
GuardRecFunc = "__GUARDR(";
|
||||
TypeFunc = "__TYPEOF(";
|
||||
SetOfFunc = "__SETOF(";
|
||||
SetRangeFunc = "__SETRNG(";
|
||||
CopyFunc = "__COPY(";
|
||||
MoveFunc = "__MOVE(";
|
||||
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);
|
||||
VAR from, to: INTEGER;
|
||||
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
|
||||
IF (newtype.size < n.typ.size) & (OPM.ranchk IN OPM.opt) THEN
|
||||
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
|
||||
| OPT.Nconst: OPC.Constant(n^.conval, form)
|
||||
| OPT.Nupto: (* n^.typ = OPT.settyp *)
|
||||
OPM.WriteString(SetRangeFunc); expr(l, MinPrec); OPM.WriteString(Comma); expr (r, MinPrec);
|
||||
OPM.Write(CloseParen)
|
||||
OPM.WriteString("__SETRNG("); expr(l, MinPrec); OPM.WriteString(Comma); expr(r, MinPrec);
|
||||
OPM.WriteString(Comma); OPM.WriteInt(n.typ.size*8); OPM.Write(CloseParen)
|
||||
| OPT.Nmop:
|
||||
CASE subclass OF
|
||||
| OPS.not: OPM.Write("!"); expr(l, exprPrec)
|
||||
|
|
@ -865,8 +865,9 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
| OPT.incfn,
|
||||
OPT.decfn: expr(n^.left, MinPrec); OPC.Increment(n^.subcl = OPT.decfn); expr(n^.right, MinPrec)
|
||||
| OPT.inclfn,
|
||||
OPT.exclfn: expr(n^.left, MinPrec); OPC.SetInclude(n^.subcl = OPT.exclfn); OPM.WriteString(SetOfFunc); expr(n^.right, MinPrec);
|
||||
OPM.Write(CloseParen)
|
||||
OPT.exclfn: expr(n^.left, MinPrec); OPC.SetInclude(n^.subcl = OPT.exclfn);
|
||||
OPM.WriteString("__SETOF("); expr(n^.right, MinPrec);
|
||||
OPM.WriteString(","); OPM.WriteInt(n.left.typ.size*8); OPM.Write(CloseParen)
|
||||
| OPT.copyfn: OPM.WriteString(CopyFunc);
|
||||
expr(n^.right, MinPrec); OPM.WriteString(Comma); expr(n^.left, MinPrec); OPM.WriteString(Comma);
|
||||
Len(n^.left, 0); OPM.Write(CloseParen)
|
||||
|
|
|
|||
|
|
@ -228,11 +228,10 @@ static inline double SYSTEM_ABSD(double i) {return i >= 0.0 ? i : -i;}
|
|||
#define __CAP(ch) ((CHAR)((ch)&0x5f))
|
||||
#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) ((SET)1<<(x))
|
||||
#define __SETRNG(l, h) ((~(SET)0<<(l))&~(SET)0>>(8*sizeof(SET)-1-(h)))
|
||||
#define __SETOF(x, size) ((uint##size)1<<(x))
|
||||
#define __SETRNG(l, h, size) ((~(uint##size)0<<(l))&~(uint##size)0>>(size-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 */
|
||||
long x = 0;
|
||||
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 */
|
||||
{char a[10], b[10];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue