Hello All,
I'm currently playing with the Project Oberon compiler. Adding code from the Extended Oberon effort, I found a potential bug in the current compiler.
On Friday, March 20, 2020 at 11:12:15 AM UTC+10:30, Guy T. wrote:
Hello All,
I'm currently playing with the Project Oberon compiler. Adding code from the Extended Oberon effort, I found a potential bug in the current compiler.
Can you provide the source code of the *simplest* test example that convinces yourself that it is actually a bug?
Regards,
Chris Burrows
https://www.astrobe.com
On Friday, March 20, 2020 at 11:12:15 AM UTC+10:30, Guy T. wrote:
Hello All,
I'm currently playing with the Project Oberon compiler. Adding code from the Extended Oberon effort, I found a potential bug in the current compiler.
Can you provide the source code of the *simplest* test example that convinces yourself that it is actually a bug?
Regards,
Chris Burrows
https://www.astrobe.com
So compiling the following raised the error "not accessible", but it was expected to be ok:
MODULE Test;
CONST a = "HELLO!";
PROCEDURE P;
VAR aa : ARRAY 12 OF CHAR;
BEGIN aa := a; END P;
END Test.
On Friday, March 20, 2020 at 8:29:46 PM UTC+10:30, Guy T. wrote:There was an extensive debate as to whether or not that is a correct interpretation of the language report in the ETH Oberon Mailing list a couple of years ago:
So compiling the following raised the error "not accessible", but it was expected to be ok:
MODULE Test;
CONST a = "HELLO!";
PROCEDURE P;
VAR aa : ARRAY 12 OF CHAR;
BEGIN aa := a; END P;
END Test.
The new test you have added checks for access to constants that have been declared at an intermediate level i.e. they are not global or strictly local. The current implementation of the official Project Oberon 2013 compiler is not concerned about this.
[Oberon] Intermediate scopes in Oberon-07:
http://lists.inf.ethz.ch/pipermail/oberon/2018/011549.html
If you have copied code from Extended Oberon, keep in mind that there the meaning of obj.lev is different from the official Oberon-07 compiler. The Extended Oberon compiler strictly disallows access to all intermediate objects and it allows exporting/importing of string constants.
See
https://github.com/andreaspirklbauer/Oberon-no-access-to-intermediate-objects
https://github.com/andreaspirklbauer/Oberon-importing-string-constants
-ap
reasons, why exporting and importing string constants is, in fact, not implemented in Project Oberon 2013, i.e. it just does not work (unlike in Extended Oberon).My point is still valid but with no direct consequence (it seems to me) to the way> that the Project Oberon compiler is working. The obj.lev does not receive the
> level of the constant string but it's length. It maybe not a big deal as the current
> implementation doesn't care about it. Or there is some insight reason to have
> the string length put in the obj.lev that is not visible to me.
For the record, the meaning of the field obj.lev for string constants is as follows:
1. In Project Oberon 2013, the field obj.lev is "abused" to hold the length (len) of string constants. The reason is (probably) that there simply aren't any other fields available in obj to hold the string length. This choice may also be one of the
2. In Extended Oberon, the field obj.lev consistently holds the scope level for all (!) declared identifiers, i.e. also for constants, types and procedures, not just variables (see ORP.Declarations). This makes it trivial to disallow access to all (!)intermediate identifiers with a single ELSIF clause at the end of ORP.qualident (instead of ORG.MakeItem), and in all (!) cases when an item is used, not just when it is initially created.
3. In Extended Oberon, the length of a string constant (len) is encoded together with its string buffer position (strx) in the single object field obj.val. This was necessary because no other fields were available in obj (except exno perhaps, but thereare other reasons not to abuse that field). The encoding of obj.val (20bits for strx, 12 bits for len for globally declared strings) was chosen such that implementing exporting and importing string constants is made easy, i.e. such that the *same* code
x.a := y.val MOD 100000H; (*strx/exno*) x.b := y.val DIV 100000H (*len*)and ORG.MakeItem (which is used for imported strings), the assignment x.r := y.lev automatically sets x.r to the mno for imported strings (because ORB.Import sets y.lev to mno).
The field x.r is used to determine whether a string is global (x.r = 0) or imported (x.r = mno). This is why ORG.MakeStringItem (which is only ever called for global, but not for imported strings) has been adapted to include the assignment x.r := 0,
For the above reasons, one cannot simply mix and match code from Project Oberon 2013 and Extended Oberon. One has to take "all or nothing" from ORP.Declarations, ORP.qualident, ORP.loadStringAdr, ORG.MakeStringItem, ORG.MakeItem, ORB.Export and ORG.Close.
All this is explained in more detail at:
https://github.com/andreaspirklbauer/Oberon-importing-string-constants
I'm puzzle about what to implement or not in regard of extending the
Project Oberon Compiler. Up to now, I have limited these extensions
to the numerical CASE statement based on your own code in Extended
Oberon, and string <-> char constant assignments. I also added some `standard` functions to get access to specific instructions available
with the ESP32. That's part of the fun to create a new compiler I guess.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 422 |
Nodes: | 16 (2 / 14) |
Uptime: | 183:33:22 |
Calls: | 8,946 |
Calls today: | 13 |
Files: | 13,352 |
Messages: | 5,991,292 |