Re: [Oberon] IMPORT Modules: why does order matter?
A module M may be imported indirectly via more than a single import. There must be some merging of symbol file information of repeated parts of M for that case. If M is also imported directly I wonder what is the difference between merging the symbol file information of indirect imports versus merging the direct import. I have not studied the source code in detail but what I have seen is that it is simpler than previous versions. - Josef <oberon-request@lists.inf.ethz.ch> schrieb am So., 3. März 2019, 00:46:
Send Oberon mailing list submissions to oberon@lists.inf.ethz.ch
To subscribe or unsubscribe via the World Wide Web, visit https://lists.inf.ethz.ch/mailman/listinfo/oberon or, via email, send a message with subject or body 'help' to oberon-request@lists.inf.ethz.ch
You can reach the person managing the list at oberon-owner@lists.inf.ethz.ch
When replying, please edit your Subject line so it is more specific than "Re: Contents of Oberon digest..."
Today's Topics:
1. Re: Question on ORG.SaveRegs / ORG.RestoreRegs in the FPGA Oberon compiler (Tomas Kral) 2. Question on ORG.SaveRegs / ORG.RestoreRegs in the FPGA Oberon compiler (Andreas Pirklbauer) 3. Re: IMPORT Modules: why does order matter? (Richard Hable) 4. IMPORT Modules: why does order matter? (Andreas Pirklbauer) 5. Re: IMPORT Modules: why does order matter? (Skulski, Wojciech) 6. Re: IMPORT Modules: why does order matter? (Till Oliver Knoll) 7. IMPORT Modules: why does order matter? (Andreas Pirklbauer) 8. Re: IMPORT Modules: why does order matter? (Skulski, Wojciech) 9. IMPORT Modules: why does order matter? (Andreas Pirklbauer) 10. Re: IMPORT Modules: why does order matter? (Till Oliver Knoll) 11. Re: IMPORT Modules: why does order matter? (Michael Schierl) 12. Re: IMPORT Modules: why does order matter? (Chris Burrows) 13. IMPORT Modules: why does order matter? (Andreas Pirklbauer) 14. IMPORT Modules: why does order matter? (Andreas Pirklbauer) 15. IMPORT Modules: why does order matter? (Andreas Pirklbauer) 16. Re: IMPORT Modules: why does order matter? (oberon@x.colbyrussell.com) 17. Re: IMPORT Modules: why does order matter? (Michael Schierl)
----------------------------------------------------------------------
Message: 1 Date: Sat, 2 Mar 2019 12:04:03 +0100 From: Tomas Kral <thomas.kral@email.cz> To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] Question on ORG.SaveRegs / ORG.RestoreRegs in the FPGA Oberon compiler Message-ID: <20190302120403.7523c6c5@raspberrypi> Content-Type: text/plain; charset=US-ASCII
On Mon, 18 Feb 2019 06:38:47 +0100 Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> wrote:
As a purely pedagogical addendum: A possible student exercise would be to rewrite ORG assuming *no* procedure variables existed in the language:
Hi Andreas,
Rarely do I receive your posts from the list, seems on account of my email client.
Having read PO2013 Compiler Application, and Compiler construction books, still not feeling up to tinkering the compiler.
I rather toy with the system, seems easier task, you may see my endeavours, some better then others :)
Will delve into compiler books again and try to experiment a little.
-- Tomas Kral <thomas.kral@email.cz>
------------------------------
Message: 2 Date: Sat, 2 Mar 2019 13:45:19 +0100 From: Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Subject: [Oberon] Question on ORG.SaveRegs / ORG.RestoreRegs in the FPGA Oberon compiler Message-ID: <90217C43-2F23-4291-B039-08A8A07F2BF0@yahoo.com> Content-Type: text/plain; charset=utf-8
As a purely pedagogical addendum: A possible student exercise would be to rewrite ORG assuming *no* procedure variables existed in the language:
Having read PO2013 Compiler Application, and Compiler construction books, still not feeling up to tinkering the compiler.
Tomas, The question has been fully answered in the meantime. PS: In case you teach compiler construction, below is *one? possible sequencing of student exercises to gradually build up one's understanding. -ap
---------------------------------------------------------------------------------------
Step 0: Implement local/global procedure calls, assuming the language has *no* function procedures and *no* procedure variables
PROCEDURE Call*(VAR x: Item); BEGIN Put3(BL, 7, (x.a DIV 4)-pc-1); RH := 0 (*see book ?Compiler Construction"*) END Call;
Step 1: Add support for function procedures, but not procedure variables => result of a function procedure may be part of an expression (held in regs)
PROCEDURE PrepCall*(VAR x: Item; VAR r: LONGINT); BEGIN (*x.type.form = ORB.Proc*) r := RH; IF RH > 0 THEN SaveRegs(RH); RH := 0 END END PrepCall;
PROCEDURE Call*(VAR x: Item; r: LONGINT); BEGIN (*x.mode = ORB.Const & x.type.form = ORB.Proc*) Put3(BL, 7, (x.a DIV 4)-pc-1); IF x.type.base.form = ORB.NoTyp THEN (*procedure*) RH := 0 ELSE (*function*) IF r > 0 THEN Put0(Mov, r, 0, 0); RestoreRegs(r) END ; x.mode := Reg; x.r := r; RH := r+1 END END Call;
Step 2: Add support for *procedure variables* which are *not* de-referenced (as in ptr.handle) or selected (as in arr[3].handle, rec.fld.handle)
PROCEDURE Call*(VAR x: Item; r: LONGINT); BEGIN (*x.type.form = ORB.Proc*) IF x.mode = ORB.Const THEN (*regular procedure*) Put3(BL, 7, (x.a DIV 4)-pc-1) ELSE (*procedure variable*) load(x); DEC(RH); (*e.g. x.mode = ORB.Var or ORB.Par*) IF check THEN Trap(EQ, 5) END ; Put3(BLR, 7, RH) END ; IF x.type.base.form = ORB.NoTyp THEN (*procedure*) RH := 0 ELSE (*function*) IF r > 0 THEN Put0(Mov, r, 0, 0); RestoreRegs(r) END ; x.mode := Reg; x.r := r; RH := r+1 END END Call;
Step 3: Allow *de-referencing* (ptr.handle) and *selecting* (array[0].handle, record.field.handle) of procedure variables
PROCEDURE PrepCall*(VAR x: Item; VAR r: LONGINT); BEGIN (*x.type.form = ORB.Proc*) IF x.mode > ORB.Par THEN load(x) END ; (*if procedure variable has been dereferenced or selected => x.mode = RegI*) r := RH; IF RH > 0 THEN SaveRegs(RH); RH := 0 END END PrepCall;
PROCEDURE Call*(VAR x: Item; r: LONGINT); BEGIN (*x.type.form = ORB.Proc*) IF x.mode = ORB.Const THEN (*regular procedure*) Put3(BL, 7, (x.a DIV 4)-pc-1) ELSE (*procedure variable*) IF x.mode <= ORB.Par THEN load(x); DEC(RH) (*x.mode = ORB.Var or ORB.Par*) ELSE Put2(Ldr, RH, SP, 0); Put1(Add, SP, SP, 4); DEC(r); DEC(frame, 4) (*x.mode = RegI or Reg}*) END ; IF check THEN Trap(EQ, 5) END ; Put3(BLR, 7, RH) END ; IF x.type.base.form = ORB.NoTyp THEN (*procedure*) RH := 0 ELSE (*function*) IF r > 0 THEN Put0(Mov, r, 0, 0); RestoreRegs(r) END ; x.mode := Reg; x.r := r; RH := r+1 END END Call;
Step 4: Allow imported procedures
PROCEDURE Call*(VAR x: Item; r: LONGINT); BEGIN (*x.type.form = ORB.Proc*) IF x.mode = ORB.Const THEN (*regular procedure*) IF x.r >= 0 THEN Put3(BL, 7, (x.a DIV 4)-pc-1) ELSIF pc - fixorgP < 1000H THEN Put3(BL, 7, ((-x.r) (*mno*) * 100H + x.a (*exno*)) * 1000H + pc-fixorgP); fixorgP := pc-1 ELSE ORS.Mark("fixup impossible") END ELSE (*procedure variable*) IF x.mode <= ORB.Par THEN load(x); DEC(RH) ELSE Put2(Ldr, RH, SP, 0); Put1(Add, SP, SP, 4); DEC(r); DEC(frame, 4) END ; IF check THEN Trap(EQ, 5) END ; Put3(BLR, 7, RH) END ; IF x.type.base.form = ORB.NoTyp THEN (*procedure*) RH := 0 ELSE (*function*) IF r > 0 THEN Put0(Mov, r, 0, 0); RestoreRegs(r) END ; x.mode := Reg; x.r := r; RH := r+1 END END Call;
------------------------------
Message: 3 Date: Sat, 2 Mar 2019 14:20:57 +0100 From: Richard Hable <informujo@aon.at> To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] IMPORT Modules: why does order matter? Message-ID: <9e4286c1-303a-b72f-1cda-54a67006e2cb@aon.at> Content-Type: text/plain; charset=utf-8
On 02.03.19 05:22, Chris Burrows wrote:
M2 directly imports M0 but also indirectly imports M0 via M1.
This doesn't make sense. Short identifier names are easy to get wrong?
Do you mean, a module importing another module also has to explicitly import all modules referred by the imported module? That would be strange: as a user of a module I do not want to have to care about implementation details like its import list.
Richard
------------------------------
Message: 4 Date: Sat, 2 Mar 2019 14:49:30 +0100 From: Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> To: oberon@lists.inf.ethz.ch Subject: [Oberon] IMPORT Modules: why does order matter? Message-ID: <0AC2D396-4632-4CB3-BAC3-461D0A8B9213@yahoo.com> Content-Type: text/plain; charset="us-ascii"
Do you mean, a module importing another module also has to explicitly import all modules referred by the imported module? That would be strange.
No! In general, this is not necessary, as the compiler handles indirect imports. One only needs to import an intermediate module, if the importing module refers to its exported objects. But *if* it is imported, all modules must be imported in the right order.
participants (1)
-
Josef Templ