t-edson / P65Pas

CPU 6502 Pascal Compiler/IDE/Debugger
GNU General Public License v3.0
123 stars 27 forks source link

unit using other units? #22

Closed mvdhoning closed 4 years ago

mvdhoning commented 4 years ago

after adding an uses in a unit it fails to compile at implementation

t-edson commented 4 years ago

Can you provide a sample code?

mvdhoning commented 4 years ago

The following unit compiles if not refering to unit libconst from unit libscreen:

libscreen.pas

unit libscreen;

interface

uses libconst;

var
 test: byte;

procedure getColor: byte;

implementation

procedure getColor: byte;
begin
  exit(0);
end; 

end.

libconst.pas

unit libconst;

interface

//Color Constants
const
  Black      = 0;
  White      = 1;
  Red        = 2;  
  Cyan       = 3; 
  Purple     = 4;
  Green      = 5;
  Blue       = 6;
  Yellow     = 7;
  Orange     = 8;
  Brown      = 9;
  LightRed   = 10;
  DarkGray   = 11;
  MediumGray = 12;
  LightGreen = 13;
  LightBlue  = 14;
  LightGray  = 15;

implementation

end.

both units are in the same folder

and finaly the main application: helloworld.pas

program helloworld;

uses Commodore64, libscreen;

var color: byte;

begin
  color := getColor;
end. 

p65pas version: 0.7.3

t-edson commented 4 years ago

OK. It's clearly a bug. It's solved now. Please update. Although, I must say the units nesting is not completely implemented in the compiler. There is some work to do in order to make it complies the Pascal standard.

mvdhoning commented 4 years ago

It works now for my use case. :-)

As you said implementation is not yet complete as specifying an uses in the implementation section of an unit makes the compiler loose access to procedures defined in that unit. But for now i can organize my code in a neat way again.

Keep up the good work with this compiler.