|
@@ -31,45 +31,46 @@
|
|
|
{$ENDIF}
|
|
|
{$ENDIF}
|
|
|
|
|
|
+
|
|
|
+{$ifdef NEWPPU}
|
|
|
+
|
|
|
{*****************************************************************************
|
|
|
PPU Writing
|
|
|
*****************************************************************************}
|
|
|
|
|
|
-{$ifdef NEWPPU}
|
|
|
-
|
|
|
procedure writebyte(b:byte);
|
|
|
begin
|
|
|
- ppufile^.putbyte(b);
|
|
|
+ current_ppu^.putbyte(b);
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure writeword(w:word);
|
|
|
begin
|
|
|
- ppufile^.putword(w);
|
|
|
+ current_ppu^.putword(w);
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure writelong(l:longint);
|
|
|
begin
|
|
|
- ppufile^.putlongint(l);
|
|
|
+ current_ppu^.putlongint(l);
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure writedouble(d:double);
|
|
|
begin
|
|
|
- ppufile^.putdata(d,sizeof(double));
|
|
|
+ current_ppu^.putdata(d,sizeof(double));
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure writestring(const s:string);
|
|
|
begin
|
|
|
- ppufile^.putstring(s);
|
|
|
+ current_ppu^.putstring(s);
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure writeset(var s); {You cannot pass an array[0..31] of byte!}
|
|
|
begin
|
|
|
- ppufile^.putdata(s,32);
|
|
|
+ current_ppu^.putdata(s,32);
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -83,11 +84,11 @@
|
|
|
while not p.empty do
|
|
|
begin
|
|
|
s:=p.get;
|
|
|
- ppufile^.putstring(s);
|
|
|
+ current_ppu^.putstring(s);
|
|
|
if hold then
|
|
|
hcontainer.insert(s);
|
|
|
end;
|
|
|
- ppufile^.writeentry(id);
|
|
|
+ current_ppu^.writeentry(id);
|
|
|
if hold then
|
|
|
p:=hcontainer;
|
|
|
end;
|
|
@@ -95,23 +96,23 @@
|
|
|
|
|
|
procedure writeposinfo(const p:tfileposinfo);
|
|
|
begin
|
|
|
- writeword(p.fileindex);
|
|
|
- writelong(p.line);
|
|
|
- writeword(p.column);
|
|
|
+ current_ppu^.putword(p.fileindex);
|
|
|
+ current_ppu^.putlongint(p.line);
|
|
|
+ current_ppu^.putword(p.column);
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure writedefref(p : pdef);
|
|
|
begin
|
|
|
if p=nil then
|
|
|
- ppufile^.putlongint($ffffffff)
|
|
|
+ current_ppu^.putlongint($ffffffff)
|
|
|
else
|
|
|
begin
|
|
|
if (p^.owner^.symtabletype in [recordsymtable,objectsymtable]) then
|
|
|
- ppufile^.putword($ffff)
|
|
|
+ current_ppu^.putword($ffff)
|
|
|
else
|
|
|
- ppufile^.putword(p^.owner^.unitid);
|
|
|
- ppufile^.putword(p^.indexnb);
|
|
|
+ current_ppu^.putword(p^.owner^.unitid);
|
|
|
+ current_ppu^.putword(p^.indexnb);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -119,159 +120,57 @@
|
|
|
procedure writesymref(p : psym);
|
|
|
begin
|
|
|
if p=nil then
|
|
|
- writelong($ffffffff)
|
|
|
+ current_ppu^.putlongint($ffffffff)
|
|
|
else
|
|
|
begin
|
|
|
if (p^.owner^.symtabletype in [recordsymtable,objectsymtable]) then
|
|
|
- writeword($ffff)
|
|
|
+ current_ppu^.putword($ffff)
|
|
|
else
|
|
|
- writeword(p^.owner^.unitid);
|
|
|
- writeword(p^.indexnb);
|
|
|
+ current_ppu^.putword(p^.owner^.unitid);
|
|
|
+ current_ppu^.putword(p^.indexnb);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
- procedure writeunitas(const s : string;unittable : punitsymtable);
|
|
|
- begin
|
|
|
- Message1(unit_u_ppu_write,s);
|
|
|
-
|
|
|
- { create unit flags }
|
|
|
- with Current_Module^ do
|
|
|
- begin
|
|
|
- if cs_smartlink in aktswitches then
|
|
|
- begin
|
|
|
- flags:=flags or uf_smartlink;
|
|
|
- if SplitName(ppufilename^)<>SplitName(libfilename^) then
|
|
|
- flags:=flags or uf_in_library;
|
|
|
- end;
|
|
|
- if use_dbx then
|
|
|
- flags:=flags or uf_has_dbx;
|
|
|
- if target_os.endian=en_big_endian then
|
|
|
- flags:=flags or uf_big_endian;
|
|
|
-{$ifdef UseBrowser}
|
|
|
- if cs_browser in aktswitches then
|
|
|
- flags:=flags or uf_has_browser;
|
|
|
-{$endif UseBrowser}
|
|
|
- end;
|
|
|
-
|
|
|
- { open ppufile }
|
|
|
- ppufile:=new(pppufile,init(s));
|
|
|
- ppufile^.change_endian:=source_os.endian<>target_os.endian;
|
|
|
- if not ppufile^.create then
|
|
|
- Message(unit_f_ppu_cannot_write);
|
|
|
-
|
|
|
- { write symbols and definitions }
|
|
|
- unittable^.writeasunit;
|
|
|
-
|
|
|
- { flush to be sure }
|
|
|
- ppufile^.flush;
|
|
|
- { create and write header }
|
|
|
- ppufile^.header.size:=ppufile^.size;
|
|
|
- ppufile^.header.checksum:=ppufile^.crc;
|
|
|
- ppufile^.header.compiler:=wordversion;
|
|
|
- ppufile^.header.target:=word(target_info.target);
|
|
|
- ppufile^.header.flags:=current_module^.flags;
|
|
|
- ppufile^.writeheader;
|
|
|
- { save crc in current_module also }
|
|
|
- current_module^.crc:=ppufile^.crc;
|
|
|
- { close }
|
|
|
- ppufile^.close;
|
|
|
- dispose(ppufile,done);
|
|
|
- end;
|
|
|
-
|
|
|
-
|
|
|
-{$else NEWPPU}
|
|
|
-
|
|
|
- procedure writebyte(b:byte);
|
|
|
- begin
|
|
|
- ppufile.write_data(b,1);
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writeword(w:word);
|
|
|
- begin
|
|
|
- ppufile.write_data(w,2);
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writelong(l:longint);
|
|
|
- begin
|
|
|
- ppufile.write_data(l,4);
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writedouble(d:double);
|
|
|
- begin
|
|
|
- ppufile.write_data(d,sizeof(double));
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writestring(s : string);
|
|
|
- begin
|
|
|
- ppufile.write_data(s,length(s)+1);
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writeset(var s); {You cannot pass an array[0..31] of byte!}
|
|
|
- begin
|
|
|
- ppufile.write_data(s,32);
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writecontainer(var p:tstringcontainer;id:byte;hold:boolean);
|
|
|
+ procedure writesourcefiles;
|
|
|
var
|
|
|
- hcontainer : tstringcontainer;
|
|
|
- s : string;
|
|
|
+ hp2 : pextfile;
|
|
|
+ index : longint;
|
|
|
begin
|
|
|
- if hold then
|
|
|
- hcontainer.init;
|
|
|
- while not p.empty do
|
|
|
+ { second write the used source files }
|
|
|
+ hp2:=current_module^.sourcefiles.files;
|
|
|
+ index:=current_module^.sourcefiles.last_ref_index;
|
|
|
+ while assigned(hp2) do
|
|
|
begin
|
|
|
- writebyte(id);
|
|
|
- s:=p.get;
|
|
|
- writestring(s);
|
|
|
- if hold then
|
|
|
- hcontainer.insert(s);
|
|
|
+ { only name and extension }
|
|
|
+ current_ppu^.putstring(hp2^.name^+hp2^.ext^);
|
|
|
+ { index in that order }
|
|
|
+ hp2^.ref_index:=index;
|
|
|
+ dec(index);
|
|
|
+ hp2:=hp2^._next;
|
|
|
end;
|
|
|
- if hold then
|
|
|
- p:=hcontainer;
|
|
|
+ current_ppu^.writeentry(ibsourcefiles);
|
|
|
end;
|
|
|
|
|
|
|
|
|
- procedure writeposinfo(const p:tfileposinfo);
|
|
|
- begin
|
|
|
- writeword(p.fileindex);
|
|
|
- writelong(p.line);
|
|
|
- writeword(p.column);
|
|
|
- end;
|
|
|
-
|
|
|
- procedure writedefref(p : pdef);
|
|
|
+ procedure writeusedunit;
|
|
|
+ var
|
|
|
+ hp : pused_unit;
|
|
|
begin
|
|
|
- if p=nil then
|
|
|
- writelong($ffffffff)
|
|
|
- else
|
|
|
+ numberunits;
|
|
|
+ hp:=pused_unit(current_module^.used_units.first);
|
|
|
+ while assigned(hp) do
|
|
|
begin
|
|
|
- if (p^.owner^.symtabletype in [recordsymtable,objectsymtable]) then
|
|
|
- writeword($ffff)
|
|
|
- else
|
|
|
- writeword(p^.owner^.unitid);
|
|
|
- writeword(p^.indexnb);
|
|
|
+ current_ppu^.putstring(hp^.name^);
|
|
|
+ current_ppu^.putlongint(hp^.checksum);
|
|
|
+ current_ppu^.putbyte(byte(hp^.in_interface));
|
|
|
+ hp:=pused_unit(hp^.next);
|
|
|
end;
|
|
|
+ current_ppu^.writeentry(ibloadunit_int);
|
|
|
end;
|
|
|
|
|
|
- procedure writesymref(p : psym);
|
|
|
- begin
|
|
|
- if p=nil then
|
|
|
- writelong($ffffffff)
|
|
|
- else
|
|
|
- begin
|
|
|
- if (p^.owner^.symtabletype in [recordsymtable,objectsymtable]) then
|
|
|
- writeword($ffff)
|
|
|
- else
|
|
|
- writeword(p^.owner^.unitid);
|
|
|
- writeword(p^.indexnb);
|
|
|
- end;
|
|
|
- end;
|
|
|
|
|
|
procedure writeunitas(const s : string;unittable : punitsymtable);
|
|
|
-{$ifdef UseBrowser}
|
|
|
- var
|
|
|
- pus : punitsymtable;
|
|
|
-{$endif UseBrowser}
|
|
|
begin
|
|
|
Message1(unit_u_ppu_write,s);
|
|
|
|
|
@@ -289,134 +188,258 @@
|
|
|
if target_os.endian=en_big_endian then
|
|
|
flags:=flags or uf_big_endian;
|
|
|
{$ifdef UseBrowser}
|
|
|
- if use_browser then
|
|
|
- flags:=flags or uf_uses_browser;
|
|
|
+ if cs_browser in aktswitches then
|
|
|
+ flags:=flags or uf_has_browser;
|
|
|
{$endif UseBrowser}
|
|
|
end;
|
|
|
|
|
|
- { open en init ppufile }
|
|
|
- ppufile.init(s,ppubufsize);
|
|
|
- ppufile.change_endian:=source_os.endian<>target_os.endian;
|
|
|
- ppufile.rewrite;
|
|
|
- if ioresult<>0 then
|
|
|
+ { open ppufile }
|
|
|
+ current_ppu:=new(pppufile,init(s));
|
|
|
+ current_ppu^.change_endian:=source_os.endian<>target_os.endian;
|
|
|
+ if not current_ppu^.create then
|
|
|
Message(unit_f_ppu_cannot_write);
|
|
|
- { create and write header }
|
|
|
- unitheader[8]:=char(byte(target_info.target));
|
|
|
- unitheader[9]:=char(current_module^.flags);
|
|
|
- ppufile.write_data(unitheader,sizeof(unitheader));
|
|
|
- ppufile.clear_crc;
|
|
|
- ppufile.do_crc:=true;
|
|
|
+
|
|
|
+ { write symbols and definitions }
|
|
|
unittable^.writeasunit;
|
|
|
- ppufile.flush;
|
|
|
- ppufile.do_crc:=false;
|
|
|
-{$ifdef UseBrowser}
|
|
|
- { write all new references to old unit elements }
|
|
|
- pus:=punitsymtable(unittable^.next);
|
|
|
- if use_browser then
|
|
|
- while assigned(pus) do
|
|
|
- begin
|
|
|
- if pus^.symtabletype = unitsymtable then
|
|
|
- pus^.write_external_references;
|
|
|
- pus:=punitsymtable(pus^.next);
|
|
|
- end;
|
|
|
-{$endif UseBrowser}
|
|
|
- { writes the checksum }
|
|
|
- ppufile.seek(10);
|
|
|
- current_module^.crc:=ppufile.getcrc;
|
|
|
- ppufile.write_data(current_module^.crc,4);
|
|
|
- ppufile.flush;
|
|
|
- ppufile.done;
|
|
|
+
|
|
|
+ { flush to be sure }
|
|
|
+ current_ppu^.flush;
|
|
|
+ { create and write header }
|
|
|
+ current_ppu^.header.size:=current_ppu^.size;
|
|
|
+ current_ppu^.header.checksum:=current_ppu^.crc;
|
|
|
+ current_ppu^.header.compiler:=wordversion;
|
|
|
+ current_ppu^.header.cpu:=word(target_cpu);
|
|
|
+ current_ppu^.header.target:=word(target_info.target);
|
|
|
+ current_ppu^.header.flags:=current_module^.flags;
|
|
|
+ current_ppu^.writeheader;
|
|
|
+ { save crc in current_module also }
|
|
|
+ current_module^.crc:=current_ppu^.crc;
|
|
|
+ { close }
|
|
|
+ current_ppu^.close;
|
|
|
+ dispose(current_ppu,done);
|
|
|
end;
|
|
|
|
|
|
-{$endif NEWPPU}
|
|
|
|
|
|
{*****************************************************************************
|
|
|
PPU Reading
|
|
|
*****************************************************************************}
|
|
|
|
|
|
-{$ifdef NEWPPU}
|
|
|
function readbyte:byte;
|
|
|
begin
|
|
|
- readbyte:=ppufile^.getbyte;
|
|
|
- if ppufile^.error then
|
|
|
+ readbyte:=current_ppu^.getbyte;
|
|
|
+ if current_ppu^.error then
|
|
|
Message(unit_f_ppu_read_error);
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
function readword:word;
|
|
|
begin
|
|
|
- readword:=ppufile^.getword;
|
|
|
- if ppufile^.error then
|
|
|
+ readword:=current_ppu^.getword;
|
|
|
+ if current_ppu^.error then
|
|
|
Message(unit_f_ppu_read_error);
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
function readlong:longint;
|
|
|
begin
|
|
|
- readlong:=ppufile^.getlongint;
|
|
|
- if ppufile^.error then
|
|
|
+ readlong:=current_ppu^.getlongint;
|
|
|
+ if current_ppu^.error then
|
|
|
Message(unit_f_ppu_read_error);
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
function readdouble : double;
|
|
|
var
|
|
|
d : double;
|
|
|
begin
|
|
|
- ppufile^.getdata(d,sizeof(double));
|
|
|
- if ppufile^.error then
|
|
|
+ current_ppu^.getdata(d,sizeof(double));
|
|
|
+ if current_ppu^.error then
|
|
|
Message(unit_f_ppu_read_error);
|
|
|
readdouble:=d;
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
function readstring : string;
|
|
|
begin
|
|
|
- readstring:=ppufile^.getstring;
|
|
|
- if ppufile^.error then
|
|
|
+ readstring:=current_ppu^.getstring;
|
|
|
+ if current_ppu^.error then
|
|
|
Message(unit_f_ppu_read_error);
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
procedure readset(var s); {You cannot pass an array [0..31] of byte.}
|
|
|
begin
|
|
|
- ppufile^.getdata(s,32);
|
|
|
- if ppufile^.error then
|
|
|
+ current_ppu^.getdata(s,32);
|
|
|
+ if current_ppu^.error then
|
|
|
Message(unit_f_ppu_read_error);
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
procedure readcontainer(var p:tstringcontainer);
|
|
|
begin
|
|
|
- while not current_module^.ppufile^.endofentry do
|
|
|
- p.insert(current_module^.ppufile^.getstring);
|
|
|
+ while not current_ppu^.endofentry do
|
|
|
+ p.insert(current_ppu^.getstring);
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
procedure readposinfo(var p:tfileposinfo);
|
|
|
begin
|
|
|
- p.fileindex:=readword;
|
|
|
- p.line:=readlong;
|
|
|
- p.column:=readword;
|
|
|
+ p.fileindex:=current_ppu^.getword;
|
|
|
+ p.line:=current_ppu^.getlongint;
|
|
|
+ p.column:=current_ppu^.getword;
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
function readdefref : pdef;
|
|
|
var
|
|
|
hd : pdef;
|
|
|
begin
|
|
|
- longint(hd):=readword;
|
|
|
- longint(hd):=longint(hd) or (longint(readword) shl 16);
|
|
|
+ longint(hd):=current_ppu^.getword;
|
|
|
+ longint(hd):=longint(hd) or (longint(current_ppu^.getword) shl 16);
|
|
|
readdefref:=hd;
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
{$ifdef UseBrowser}
|
|
|
function readsymref : psym;
|
|
|
var
|
|
|
hd : psym;
|
|
|
begin
|
|
|
- longint(hd):=readword;
|
|
|
- longint(hd):=longint(hd) or (longint(readword) shl 16);
|
|
|
+ longint(hd):=current_ppu^.getword;
|
|
|
+ longint(hd):=longint(hd) or (longint(current_ppu^.getword) shl 16);
|
|
|
readsymref:=hd;
|
|
|
end;
|
|
|
{$endif}
|
|
|
|
|
|
|
|
|
+ procedure readsourcefiles;
|
|
|
+ var
|
|
|
+ temp,hs : string;
|
|
|
+ incfile_found : boolean;
|
|
|
+ ppufiletime,
|
|
|
+ source_time : longint;
|
|
|
+{$ifdef UseBrowser}
|
|
|
+ hp : pextfile;
|
|
|
+ _d,_n,_e : string;
|
|
|
+{$endif UseBrowser}
|
|
|
+ begin
|
|
|
+ ppufiletime:=getnamedfiletime(current_module^.ppufilename^);
|
|
|
+ current_module^.sources_avail:=true;
|
|
|
+ while not current_ppu^.endofentry do
|
|
|
+ begin
|
|
|
+ hs:=current_ppu^.getstring;
|
|
|
+ temp:='';
|
|
|
+ if (current_module^.flags and uf_in_library)<>0 then
|
|
|
+ begin
|
|
|
+ current_module^.sources_avail:=false;
|
|
|
+ temp:=' library';
|
|
|
+ end
|
|
|
+ else if pos('Macro ',hs)=1 then
|
|
|
+ begin
|
|
|
+ { we don't want to find this file }
|
|
|
+ { but there is a problem with file indexing !! }
|
|
|
+ temp:='';
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ { check the date of the source files }
|
|
|
+ Source_Time:=GetNamedFileTime(current_module^.path^+hs);
|
|
|
+ if Source_Time=-1 then
|
|
|
+ begin
|
|
|
+ { search for include files in the includepathlist }
|
|
|
+ temp:=search(hs,includesearchpath,incfile_found);
|
|
|
+ if incfile_found then
|
|
|
+ begin
|
|
|
+ hs:=temp+hs;
|
|
|
+ Source_Time:=GetNamedFileTime(hs);
|
|
|
+ end;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ hs:=current_module^.path^+hs;
|
|
|
+ if Source_Time=-1 then
|
|
|
+ begin
|
|
|
+ current_module^.sources_avail:=false;
|
|
|
+ temp:=' not found';
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ temp:=' time '+filetimestring(source_time);
|
|
|
+ if (source_time>ppufiletime) then
|
|
|
+ begin
|
|
|
+ current_module^.do_compile:=true;
|
|
|
+ temp:=temp+' *'
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ Message1(unit_t_ppu_source,hs+temp);
|
|
|
+{$ifdef UseBrowser}
|
|
|
+ fsplit(hs,_d,_n,_e);
|
|
|
+ new(hp,init(_d,_n,_e));
|
|
|
+ { the indexing should match what is done in writeasunit }
|
|
|
+ current_module^.sourcefiles.register_file(hp);
|
|
|
+{$endif UseBrowser}
|
|
|
+ end;
|
|
|
+ { main source is always the last }
|
|
|
+ stringdispose(current_module^.mainsource);
|
|
|
+ current_module^.mainsource:=stringdup(hs);
|
|
|
+ { check if we want to rebuild every unit, only if the sources are
|
|
|
+ available }
|
|
|
+ if do_build and current_module^.sources_avail then
|
|
|
+ current_module^.do_compile:=true;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
+ procedure readloadunit;
|
|
|
+ var
|
|
|
+ hs : string;
|
|
|
+ checksum : longint;
|
|
|
+ in_interface : boolean;
|
|
|
+ begin
|
|
|
+ while not current_ppu^.endofentry do
|
|
|
+ begin
|
|
|
+ hs:=current_ppu^.getstring;
|
|
|
+ checksum:=current_ppu^.getlongint;
|
|
|
+ in_interface:=(current_ppu^.getbyte<>0);
|
|
|
+ current_module^.used_units.concat(new(pused_unit,init_to_load(hs,checksum,in_interface)));
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
+ procedure load_interface;
|
|
|
+ var
|
|
|
+ b : byte;
|
|
|
+ begin
|
|
|
+ { read interface part }
|
|
|
+ repeat
|
|
|
+ b:=current_ppu^.readentry;
|
|
|
+ case b of
|
|
|
+ { ibinitunit : usedunits^.insert(readstring); }
|
|
|
+ ibmodulename : begin
|
|
|
+ stringdispose(current_module^.modulename);
|
|
|
+ current_module^.modulename:=stringdup(current_ppu^.getstring);
|
|
|
+ end;
|
|
|
+ ibsourcefiles : readsourcefiles;
|
|
|
+ ibloadunit_int : readloadunit;
|
|
|
+ iblinksharedlibs : readcontainer(current_module^.LinkSharedLibs);
|
|
|
+ iblinkstaticlibs : readcontainer(current_module^.LinkStaticLibs);
|
|
|
+ iblinkofiles : readcontainer(current_module^.LinkOFiles);
|
|
|
+ ibendinterface : break;
|
|
|
+ else
|
|
|
+ Message1(unit_f_ppu_invalid_entry,tostr(b));
|
|
|
+ end;
|
|
|
+ until false;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{$else NEWPPU}
|
|
|
|
|
|
|
|
|
+{*****************************************************************************
|
|
|
+
|
|
|
+ Old PPU
|
|
|
+
|
|
|
+*****************************************************************************}
|
|
|
+
|
|
|
function readbyte : byte;
|
|
|
|
|
|
var
|
|
@@ -522,11 +545,163 @@
|
|
|
end;
|
|
|
{$endif UseBrowser}
|
|
|
|
|
|
+ procedure writebyte(b:byte);
|
|
|
+ begin
|
|
|
+ ppufile.write_data(b,1);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writeword(w:word);
|
|
|
+ begin
|
|
|
+ ppufile.write_data(w,2);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writelong(l:longint);
|
|
|
+ begin
|
|
|
+ ppufile.write_data(l,4);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writedouble(d:double);
|
|
|
+ begin
|
|
|
+ ppufile.write_data(d,sizeof(double));
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writestring(s : string);
|
|
|
+ begin
|
|
|
+ ppufile.write_data(s,length(s)+1);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writeset(var s); {You cannot pass an array[0..31] of byte!}
|
|
|
+ begin
|
|
|
+ ppufile.write_data(s,32);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writecontainer(var p:tstringcontainer;id:byte;hold:boolean);
|
|
|
+ var
|
|
|
+ hcontainer : tstringcontainer;
|
|
|
+ s : string;
|
|
|
+ begin
|
|
|
+ if hold then
|
|
|
+ hcontainer.init;
|
|
|
+ while not p.empty do
|
|
|
+ begin
|
|
|
+ writebyte(id);
|
|
|
+ s:=p.get;
|
|
|
+ writestring(s);
|
|
|
+ if hold then
|
|
|
+ hcontainer.insert(s);
|
|
|
+ end;
|
|
|
+ if hold then
|
|
|
+ p:=hcontainer;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
+ procedure writeposinfo(const p:tfileposinfo);
|
|
|
+ begin
|
|
|
+ writeword(p.fileindex);
|
|
|
+ writelong(p.line);
|
|
|
+ writeword(p.column);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writedefref(p : pdef);
|
|
|
+ begin
|
|
|
+ if p=nil then
|
|
|
+ writelong($ffffffff)
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ if (p^.owner^.symtabletype in [recordsymtable,objectsymtable]) then
|
|
|
+ writeword($ffff)
|
|
|
+ else
|
|
|
+ writeword(p^.owner^.unitid);
|
|
|
+ writeword(p^.indexnb);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writesymref(p : psym);
|
|
|
+ begin
|
|
|
+ if p=nil then
|
|
|
+ writelong($ffffffff)
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ if (p^.owner^.symtabletype in [recordsymtable,objectsymtable]) then
|
|
|
+ writeword($ffff)
|
|
|
+ else
|
|
|
+ writeword(p^.owner^.unitid);
|
|
|
+ writeword(p^.indexnb);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure writeunitas(const s : string;unittable : punitsymtable);
|
|
|
+{$ifdef UseBrowser}
|
|
|
+ var
|
|
|
+ pus : punitsymtable;
|
|
|
+{$endif UseBrowser}
|
|
|
+ begin
|
|
|
+ Message1(unit_u_ppu_write,s);
|
|
|
+
|
|
|
+ { create unit flags }
|
|
|
+ with Current_Module^ do
|
|
|
+ begin
|
|
|
+ if cs_smartlink in aktswitches then
|
|
|
+ begin
|
|
|
+ flags:=flags or uf_smartlink;
|
|
|
+ if SplitName(ppufilename^)<>SplitName(libfilename^) then
|
|
|
+ flags:=flags or uf_in_library;
|
|
|
+ end;
|
|
|
+ if use_dbx then
|
|
|
+ flags:=flags or uf_has_dbx;
|
|
|
+ if target_os.endian=en_big_endian then
|
|
|
+ flags:=flags or uf_big_endian;
|
|
|
+{$ifdef UseBrowser}
|
|
|
+ if use_browser then
|
|
|
+ flags:=flags or uf_uses_browser;
|
|
|
+{$endif UseBrowser}
|
|
|
+ end;
|
|
|
+
|
|
|
+ { open en init ppufile }
|
|
|
+ ppufile.init(s,ppubufsize);
|
|
|
+ ppufile.change_endian:=source_os.endian<>target_os.endian;
|
|
|
+ ppufile.rewrite;
|
|
|
+ if ioresult<>0 then
|
|
|
+ Message(unit_f_ppu_cannot_write);
|
|
|
+ { create and write header }
|
|
|
+ unitheader[8]:=char(byte(target_info.target));
|
|
|
+ unitheader[9]:=char(current_module^.flags);
|
|
|
+ ppufile.write_data(unitheader,sizeof(unitheader));
|
|
|
+ ppufile.clear_crc;
|
|
|
+ ppufile.do_crc:=true;
|
|
|
+ unittable^.writeasunit;
|
|
|
+ ppufile.flush;
|
|
|
+ ppufile.do_crc:=false;
|
|
|
+{$ifdef UseBrowser}
|
|
|
+ { write all new references to old unit elements }
|
|
|
+ pus:=punitsymtable(unittable^.next);
|
|
|
+ if use_browser then
|
|
|
+ while assigned(pus) do
|
|
|
+ begin
|
|
|
+ if pus^.symtabletype = unitsymtable then
|
|
|
+ pus^.write_external_references;
|
|
|
+ pus:=punitsymtable(pus^.next);
|
|
|
+ end;
|
|
|
+{$endif UseBrowser}
|
|
|
+ { writes the checksum }
|
|
|
+ ppufile.seek(10);
|
|
|
+ current_module^.crc:=ppufile.getcrc;
|
|
|
+ ppufile.write_data(current_module^.crc,4);
|
|
|
+ ppufile.flush;
|
|
|
+ ppufile.done;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
{$endif NEWPPU}
|
|
|
|
|
|
{
|
|
|
$Log$
|
|
|
- Revision 1.3 1998-06-13 00:10:17 peter
|
|
|
+ Revision 1.4 1998-06-16 08:56:32 peter
|
|
|
+ + targetcpu
|
|
|
+ * cleaner pmodules for newppu
|
|
|
+
|
|
|
+ Revision 1.3 1998/06/13 00:10:17 peter
|
|
|
* working browser and newppu
|
|
|
* some small fixes against crashes which occured in bp7 (but not in
|
|
|
fpc?!)
|