Discussion:
A bug in the ORP.Mod compiler module (Project Oberon)
(too old to reply)
Guy T.
2020-03-19 22:54:51 UTC
Permalink
Hello all,

I don't know where I can give this information. Please advise.

I may have found a bug in the ORP.Mod module. In the Declarations procedure the following lines appear:

IF (x.type.form = ORB.String) & (x.b = 2) THEN ORG.StrToChar(x) END ;
ORB.NewObj(obj, id, ORB.Const); obj.expo := expo;
IF x.mode = ORB.Const THEN obj.val := x.a; obj.lev := x.b; obj.type := x.type

If a one-char string constant is migrated to a CHAR constant (1st line), it will receive a obj.lev := 2 (3rd line). The following modification may resolve the problem:

IF (x.type.form = ORB.String) & (x.b = 2) THEN ORG.StrToChar(x); x.b := level END ;
ORB.NewObj(obj, id, ORB.Const); obj.expo := expo;
IF x.mode = ORB.Const THEN obj.val := x.a; obj.lev := x.b; obj.type := x.type

At least, it seems to work for me.

Cheers!

Guy
Guy T.
2020-03-19 23:28:15 UTC
Permalink
Post by Guy T.
Hello all,
I don't know where I can give this information. Please advise.
IF (x.type.form = ORB.String) & (x.b = 2) THEN ORG.StrToChar(x) END ;
ORB.NewObj(obj, id, ORB.Const); obj.expo := expo;
IF x.mode = ORB.Const THEN obj.val := x.a; obj.lev := x.b; obj.type := x.type
IF (x.type.form = ORB.String) & (x.b = 2) THEN ORG.StrToChar(x); x.b := level END ;
ORB.NewObj(obj, id, ORB.Const); obj.expo := expo;
IF x.mode = ORB.Const THEN obj.val := x.a; obj.lev := x.b; obj.type := x.type
At least, it seems to work for me.
Cheers!
Guy
Well... I sent this message a bit too fast. The problem is related to the ORG.MakeItem that, in the case of a String constant, put the string length in x.b instead of the level. So I'm asking advise. Is the following a better alternative:

IF (x.type.form = ORB.String) & (x.b = 2) THEN ORG.StrToChar(x) END ;
ORB.NewObj(obj, id, ORB.Const); obj.expo := expo;
IF x.mode = ORB.Const THEN obj.val := x.a; obj.lev := level; obj.type := x.type

Guy

Loading...