Предмет:
Тип роботи:
Курсова робота
К-сть сторінок:
82
Мова:
Українська
if new_flags <> [] then
WriteError('unknown flags '+hexword(word(new_flags)));
writeln;
writeln;
writeln('Other: ');
{$IFDEF UNIT60}
dumpbytes(header^,$30,$50-$30)
{$ELSE}
dumpbytes(header^,ofs(header^.next_tpu)-ofs(header^),
sizeof(header^)-(ofs(header^.next_tpu)-ofs(header^)));
{$ENDIF}
end;
end;
end.
Loader.pas
unit loader;
{$I SWITCHES.INC}
interface
uses util,dump,globals,head,objects,dos;
type
hash_ptr = ^hash_rec;
hash_rec = record
byte_len : word;
table : word_array;
end;
list_ptr = ^list_rec;
list_rec = record
offset : word;
hash : word;
next : list_ptr;
end;
proc_list_ptr = ^proc_list_rec;
proc_list_rec = record
entry : word;
name : pstring;
next : proc_list_ptr;
end;
unit_ptr = ^unit_rec;
unit_rec = record
target:word;
checksum:word;
prev_unit,next_unit : word;
in_interface : boolean;
end;
unit_list_ptr = ^unit_list_rec;
unit_list_rec = record
name : string;
path : string;
obj_list : list_ptr;
proc_list : proc_list_ptr;
own_record : word;
checksum : word;
buffer : byte_array_ptr;
has_symbols : boolean;
end;
tpl_item_ptr = ^tpl_item_rec;
tpl_item_rec = record
buffer : byte_array_ptr;
size : word;
next : tpl_item_ptr;
end;
tpl_list_ptr = ^tpl_list_rec;
tpl_list_rec = record
path : string;
first : tpl_item_ptr;
end;
obj_ptr = ^obj_rec;
obj_rec = record
next_obj: word; { in case of a hash collision }
obj_type : byte;
name: string;
end;
var
hash_table : hash_ptr;
unit_list : array[1..255] of unit_list_ptr;
num_known : word;
tpl_buffer : tpl_list_rec;
procedure build_list(var obj_list:list_ptr;
buffer:byte_array_ptr;
hash_table:hash_ptr);
procedure destroy_list(obj_list:list_ptr);
procedure add_unit(const objname:string;info:unit_ptr);
function get_unit(unit_ofs:word):unit_list_ptr;
function get_unit_buffer(buffer:pointer;unit_ofs:word):unit_list_ptr;
function get_unit_name(unit_ofs:word):String;
function get_unit_by_name(const name:string):unit_list_ptr;
function get_unit_num(name:string):word;
procedure loadtpl;
procedure ReadPathFile(var path:string;var Header:header_ptr);
implementation
procedure build_list(var obj_list:list_ptr;
buffer:byte_array_ptr;
hash_table:hash_ptr);
var
i,j,t:word;
current,new_entry : list_ptr;
obj : obj_ptr;
begin
new(obj_list);
with obj_list^ do
begin
offset := $ffff; { set up a sentinel record }
next := nil;
end;
with hash_table^ do
for i := 0 to byte_len div 2 do
if table[i] <> 0 then
begin
t := table[i];
repeat
current := obj_list;
while t > current^.offset do
current := current^.next;
new(new_entry);
new_entry^ := current^;
current^.offset := t;
current^.hash := i;
current^.next := new_entry;
obj := add_only_offset(buffer,t);
{ get the next object... }
t := obj^.next_obj;
until t = 0;
end;
end;
procedure destroy_list(obj_list:list_ptr);
var aux:list_ptr;
begin
while obj_list<>nil do
begin