1999-09-23 15:14:20 +00:00
|
|
|
package winapi;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
my $self = {};
|
|
|
|
bless ($self, $class);
|
|
|
|
|
2000-04-06 20:11:04 +00:00
|
|
|
my $options = \${$self->{OPTIONS}};
|
1999-10-24 21:45:39 +00:00
|
|
|
my $output = \${$self->{OUTPUT}};
|
|
|
|
my $name = \${$self->{NAME}};
|
|
|
|
|
2000-04-06 20:11:04 +00:00
|
|
|
$$options = shift;
|
1999-10-24 21:45:39 +00:00
|
|
|
$$output = shift;
|
|
|
|
$$name = shift;
|
|
|
|
my $path = shift;
|
|
|
|
|
|
|
|
my @files = map {
|
|
|
|
s/^.\/(.*)$/$1/;
|
|
|
|
$_;
|
|
|
|
} split(/\n/, `find $path -name \\*.api`);
|
|
|
|
|
|
|
|
foreach my $file (@files) {
|
|
|
|
my $module = $file;
|
|
|
|
$module =~ s/.*?\/([^\/]*?)\.api$/$1/;
|
|
|
|
$self->parse_api_file($file,$module);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_api_file {
|
|
|
|
my $self = shift;
|
2000-04-15 20:39:55 +00:00
|
|
|
|
|
|
|
my $options = \${$self->{OPTIONS}};
|
1999-10-24 21:45:39 +00:00
|
|
|
my $output = \${$self->{OUTPUT}};
|
1999-09-23 15:14:20 +00:00
|
|
|
my $allowed_kind = \%{$self->{ALLOWED_KIND}};
|
|
|
|
my $allowed_modules = \%{$self->{ALLOWED_MODULES}};
|
|
|
|
my $allowed_modules_limited = \%{$self->{ALLOWED_MODULES_LIMITED}};
|
1999-10-24 21:45:39 +00:00
|
|
|
my $allowed_modules_unlimited = \%{$self->{ALLOWED_MODULES_UNLIMITED}};
|
1999-09-23 15:14:20 +00:00
|
|
|
my $translate_argument = \%{$self->{TRANSLATE_ARGUMENT}};
|
2000-05-11 21:46:17 +00:00
|
|
|
my $type_format = \%{$self->{TYPE_FORMAT}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $file = shift;
|
1999-10-24 21:45:39 +00:00
|
|
|
my $module = shift;
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $kind;
|
2000-05-11 21:46:17 +00:00
|
|
|
my $format;
|
2000-01-04 00:31:47 +00:00
|
|
|
my $extension = 0;
|
1999-09-23 15:14:20 +00:00
|
|
|
my $forbidden = 0;
|
|
|
|
|
2000-04-15 20:39:55 +00:00
|
|
|
if($$options->progress) {
|
|
|
|
$$output->progress("$file");
|
|
|
|
}
|
1999-10-24 21:45:39 +00:00
|
|
|
|
1999-09-23 15:14:20 +00:00
|
|
|
open(IN, "< $file") || die "$file: $!\n";
|
|
|
|
$/ = "\n";
|
|
|
|
while(<IN>) {
|
|
|
|
s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begin and end of line
|
|
|
|
s/^(.*?)\s*#.*$/$1/; # remove comments
|
|
|
|
/^$/ && next; # skip empty lines
|
|
|
|
|
|
|
|
if(s/^%(\S+)\s*//) {
|
|
|
|
$kind = $1;
|
2000-05-11 21:46:17 +00:00
|
|
|
$format = undef;
|
1999-09-23 15:14:20 +00:00
|
|
|
$forbidden = 0;
|
2000-01-04 00:31:47 +00:00
|
|
|
$extension = 0;
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
$$allowed_kind{$kind} = 1;
|
1999-10-24 21:45:39 +00:00
|
|
|
if(/^--forbidden/) {
|
1999-09-23 15:14:20 +00:00
|
|
|
$forbidden = 1;
|
2000-01-04 00:31:47 +00:00
|
|
|
} elsif(/^--extension/) {
|
|
|
|
$extension = 1;
|
2000-05-11 21:46:17 +00:00
|
|
|
} elsif(/^--format=(\".*?\"|\S*)/) {
|
|
|
|
$format = $1;
|
|
|
|
$format =~ s/^\"(.*?)\"$/$1/;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!defined($format)) {
|
|
|
|
if($kind eq "long") {
|
|
|
|
$format = "%d|%u|%x|%X|";
|
|
|
|
$format .= "%hd|%hu|%hx|%hX|";
|
|
|
|
$format .= "%ld|%lu|%lx|%lX|";
|
|
|
|
$format .= "%04x|%04X|0x%04x|0x%04X|";
|
|
|
|
$format .= "%08x|%08X|0x%08x|0x%08X|";
|
|
|
|
$format .= "%08lx|%08lX|0x%08lx|0x%08lX";
|
|
|
|
} elsif($kind eq "longlong") {
|
|
|
|
$format = "%lld";
|
|
|
|
} elsif($kind eq "ptr") {
|
|
|
|
$format = "%p";
|
|
|
|
} elsif($kind eq "segptr") {
|
|
|
|
$format = "%p";
|
|
|
|
} elsif($kind eq "str") {
|
|
|
|
$format = "%p|%s";
|
|
|
|
} elsif($kind eq "wstr") {
|
|
|
|
$format = "%p|%s";
|
|
|
|
} elsif($kind eq "word") {
|
|
|
|
$format = "%d|%u|%x|%X|";
|
|
|
|
$format .= "%hd|%hu|%hx|%hX|";
|
|
|
|
$format .= "%04x|%04X|0x%04x|0x%04X";
|
|
|
|
} else {
|
|
|
|
$format = "<unknown>";
|
|
|
|
}
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
} elsif(defined($kind)) {
|
|
|
|
my $type = $_;
|
|
|
|
if(!$forbidden) {
|
1999-10-24 21:45:39 +00:00
|
|
|
if(defined($module)) {
|
|
|
|
if($$allowed_modules_unlimited{$type}) {
|
1999-10-31 02:08:38 +00:00
|
|
|
$$output->write("$file: type ($type) already specificed as an unlimited type\n");
|
1999-10-24 21:45:39 +00:00
|
|
|
} elsif(!$$allowed_modules{$type}{$module}) {
|
|
|
|
$$allowed_modules{$type}{$module} = 1;
|
|
|
|
$$allowed_modules_limited{$type} = 1;
|
|
|
|
} else {
|
1999-10-31 02:08:38 +00:00
|
|
|
$$output->write("$file: type ($type) already specificed\n");
|
1999-10-24 21:45:39 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$$allowed_modules_unlimited{$type} = 1;
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$$allowed_modules_limited{$type} = 1;
|
|
|
|
}
|
1999-10-24 21:45:39 +00:00
|
|
|
if(defined($$translate_argument{$type}) && $$translate_argument{$type} ne $kind) {
|
1999-10-31 02:08:38 +00:00
|
|
|
$$output->write("$file: type ($type) respecified as different kind ($kind != $$translate_argument{$type})\n");
|
1999-10-24 21:45:39 +00:00
|
|
|
} else {
|
|
|
|
$$translate_argument{$type} = $kind;
|
|
|
|
}
|
2000-05-11 21:46:17 +00:00
|
|
|
|
|
|
|
$$type_format{$module}{$type} = $format;
|
1999-09-23 15:14:20 +00:00
|
|
|
} else {
|
1999-10-31 02:08:38 +00:00
|
|
|
$$output->write("$file: file must begin with %<type> statement\n");
|
1999-09-23 15:14:20 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_spec_file_type {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
|
|
|
|
my $file = shift;
|
|
|
|
|
2000-04-24 18:02:32 +00:00
|
|
|
my $module;
|
1999-09-23 15:14:20 +00:00
|
|
|
my $type;
|
|
|
|
|
|
|
|
open(IN, "< $file") || die "$file: $!\n";
|
2000-04-24 18:02:32 +00:00
|
|
|
local $/ = "\n";
|
1999-09-23 15:14:20 +00:00
|
|
|
while(<IN>) {
|
2000-04-24 18:02:32 +00:00
|
|
|
s/^\s*(.*?)\s*$/$1/;
|
|
|
|
s/^(.*?)\s*#.*$/$1/;
|
|
|
|
/^$/ && next;
|
|
|
|
|
|
|
|
if(/^name\s*(\S*)/) { $module = $1; }
|
|
|
|
if(/^type\s*(\w+)/) { $type = $1; }
|
|
|
|
|
|
|
|
if(defined($module) && defined($type)) { last; }
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
2000-04-24 18:02:32 +00:00
|
|
|
return ($type, $module);
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub read_spec_files {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
|
2000-04-24 18:02:32 +00:00
|
|
|
my $modules = shift;
|
|
|
|
my $wine_dir = shift;
|
|
|
|
my $current_dir = shift;
|
|
|
|
my $files = shift;
|
|
|
|
my $win16api = shift;
|
|
|
|
my $win32api = shift;
|
|
|
|
|
|
|
|
foreach my $file (@$files) {
|
|
|
|
(my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file");
|
|
|
|
$modules->spec_file_module($file, $module);
|
|
|
|
if($type eq "win16") {
|
|
|
|
$win16api->parse_spec_file("$wine_dir/$file");
|
|
|
|
} elsif($type eq "win32") {
|
|
|
|
$win32api->parse_spec_file("$wine_dir/$file");
|
|
|
|
}
|
|
|
|
}
|
2000-07-15 21:32:55 +00:00
|
|
|
|
|
|
|
foreach my $self ($win16api, $win32api) {
|
|
|
|
my $function_forward = \%{$self->{FUNCTION_FORWARD}};
|
|
|
|
my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
|
|
|
|
my $function_module = \%{$self->{FUNCTION_MODULE}};
|
|
|
|
|
|
|
|
foreach my $forward_name (sort(keys(%$function_forward))) {
|
|
|
|
$$function_forward{$forward_name} =~ /^(\S*):(\S*)\.(\S*)$/;
|
|
|
|
(my $from_module, my $to_module, my $external_name) = ($1, $2, $3);
|
|
|
|
my $internal_name = $$function_internal_name{$external_name};
|
|
|
|
if(defined($internal_name)) {
|
|
|
|
$$function_module{$internal_name} .= " & $from_module";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-04-24 18:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub read_all_spec_files {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
|
|
|
|
my $modules = shift;
|
|
|
|
my $wine_dir = shift;
|
|
|
|
my $current_dir = shift;
|
2000-04-15 20:39:55 +00:00
|
|
|
my $file_type = shift;
|
1999-09-23 15:14:20 +00:00
|
|
|
my $win16api = shift;
|
|
|
|
my $win32api = shift;
|
|
|
|
|
1999-10-24 21:45:39 +00:00
|
|
|
my @files = map {
|
2000-05-18 00:07:31 +00:00
|
|
|
s/^$wine_dir\/(.*)$/$1/;
|
2000-04-15 20:39:55 +00:00
|
|
|
if(&$file_type($_) eq "library") {
|
|
|
|
$_;
|
|
|
|
} else {
|
|
|
|
();
|
|
|
|
}
|
2000-04-24 18:02:32 +00:00
|
|
|
} split(/\n/, `find $wine_dir -name \\*.spec`);
|
|
|
|
|
|
|
|
'winapi'->read_spec_files($modules, $wine_dir, $current_dir, \@files, $win16api, $win32api);
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_spec_file {
|
|
|
|
my $self = shift;
|
1999-10-24 21:45:39 +00:00
|
|
|
|
2000-04-06 20:11:04 +00:00
|
|
|
my $options = \${$self->{OPTIONS}};
|
1999-10-24 21:45:39 +00:00
|
|
|
my $output = \${$self->{OUTPUT}};
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_arguments = \%{$self->{FUNCTION_INTERNAL_ARGUMENTS}};
|
|
|
|
my $function_external_arguments = \%{$self->{FUNCTION_EXTERNAL_ARGUMENTS}};
|
|
|
|
my $function_internal_ordinal = \%{$self->{FUNCTION_INTERNAL_ORDINAL}};
|
|
|
|
my $function_external_ordinal = \%{$self->{FUNCTION_EXTERNAL_ORDINAL}};
|
|
|
|
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
|
|
|
|
my $function_external_calling_convention = \%{$self->{FUNCTION_EXTERNAL_CALLING_CONVENTION}};
|
2000-07-15 21:32:55 +00:00
|
|
|
my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
|
2000-05-23 23:37:51 +00:00
|
|
|
my $function_external_name = \%{$self->{FUNCTION_EXTERNAL_NAME}};
|
1999-09-23 15:14:20 +00:00
|
|
|
my $function_stub = \%{$self->{FUNCTION_STUB}};
|
2000-07-15 21:32:55 +00:00
|
|
|
my $function_forward = \%{$self->{FUNCTION_FORWARD}};
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_module = \%{$self->{FUNCTION_INTERNAL_MODULE}};
|
|
|
|
my $function_external_module = \%{$self->{FUNCTION_EXTERNAL_MODULE}};
|
2000-04-15 20:39:55 +00:00
|
|
|
my $modules = \%{$self->{MODULES}};
|
2000-06-11 20:02:29 +00:00
|
|
|
my $module_files = \%{$self->{MODULE_FILES}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $file = shift;
|
1999-10-24 21:45:39 +00:00
|
|
|
|
|
|
|
my %ordinals;
|
1999-09-23 15:14:20 +00:00
|
|
|
my $type;
|
|
|
|
my $module;
|
2000-06-11 20:02:29 +00:00
|
|
|
my $module_file;
|
1999-09-23 15:14:20 +00:00
|
|
|
|
2000-04-15 20:39:55 +00:00
|
|
|
if($$options->progress) {
|
|
|
|
$$output->progress("$file");
|
|
|
|
}
|
1999-10-24 21:45:39 +00:00
|
|
|
|
1999-09-23 15:14:20 +00:00
|
|
|
open(IN, "< $file") || die "$file: $!\n";
|
|
|
|
$/ = "\n";
|
|
|
|
my $header = 1;
|
|
|
|
my $lookahead = 0;
|
|
|
|
while($lookahead || defined($_ = <IN>)) {
|
|
|
|
$lookahead = 0;
|
|
|
|
s/^\s*(.*?)\s*$/$1/;
|
|
|
|
s/^(.*?)\s*#.*$/$1/;
|
|
|
|
/^$/ && next;
|
|
|
|
|
|
|
|
if($header) {
|
|
|
|
if(/^name\s*(\S*)/) { $module = $1; }
|
2000-06-11 20:02:29 +00:00
|
|
|
if(/^file\s*(\S*)/) { $module_file = $1; }
|
1999-12-11 23:01:45 +00:00
|
|
|
if(/^type\s*(\w+)/) { $type = $1; }
|
2000-04-15 20:39:55 +00:00
|
|
|
if(/^\d+|@/) { $header = 0; $lookahead = 1; }
|
1999-09-23 15:14:20 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
1999-10-24 21:45:39 +00:00
|
|
|
my $ordinal;
|
2000-11-30 01:31:44 +00:00
|
|
|
if(/^(\d+|@)\s+
|
|
|
|
(pascal|pascal16|stdcall|cdecl|register|interrupt|varargs)
|
|
|
|
(?:\s+(?:-noimport|-norelay|-i386|-ret64))*\s+(\S+)\s*\(\s*(.*?)\s*\)\s*(\S+)$/x)
|
|
|
|
{
|
1999-10-24 21:45:39 +00:00
|
|
|
my $calling_convention = $2;
|
|
|
|
my $external_name = $3;
|
|
|
|
my $arguments = $4;
|
|
|
|
my $internal_name = $5;
|
|
|
|
|
|
|
|
$ordinal = $1;
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
# FIXME: Internal name existing more than once not handled properly
|
2000-07-15 21:32:55 +00:00
|
|
|
$$function_internal_name{$external_name} = $internal_name;
|
2000-05-23 23:37:51 +00:00
|
|
|
$$function_external_name{$internal_name} = $external_name;
|
2001-06-19 03:34:52 +00:00
|
|
|
$$function_internal_arguments{$internal_name} = $arguments;
|
|
|
|
$$function_external_arguments{$external_name} = $arguments;
|
|
|
|
$$function_internal_ordinal{$internal_name} = $ordinal;
|
|
|
|
$$function_external_ordinal{$external_name} = $ordinal;
|
|
|
|
$$function_internal_calling_convention{$internal_name} = $calling_convention;
|
|
|
|
$$function_external_calling_convention{$external_name} = $calling_convention;
|
|
|
|
if(!$$function_internal_module{$internal_name}) {
|
|
|
|
$$function_internal_module{$internal_name} = "$module";
|
|
|
|
} elsif($$function_internal_module{$internal_name} !~ /$module/) {
|
2000-07-15 21:32:55 +00:00
|
|
|
if(0) {
|
|
|
|
$$output->write("$file: $external_name: the internal function ($internal_name) " .
|
2001-06-19 03:34:52 +00:00
|
|
|
"already belongs to a module ($$function_internal_module{$internal_name})\n");
|
2000-07-15 21:32:55 +00:00
|
|
|
}
|
2001-06-19 03:34:52 +00:00
|
|
|
$$function_internal_module{$internal_name} .= " & $module";
|
|
|
|
}
|
|
|
|
if(!$$function_external_module{$external_name}) {
|
|
|
|
$$function_external_module{$external_name} = "$module";
|
|
|
|
} elsif($$function_external_module{$external_name} !~ /$module/) {
|
|
|
|
if(0) {
|
|
|
|
$$output->write("$file: $internal_name: the external function ($external_name) " .
|
|
|
|
"already belongs to a module ($$function_external_module{$external_name})\n");
|
|
|
|
}
|
|
|
|
$$function_external_module{$external_name} .= " & $module";
|
1999-12-11 23:01:45 +00:00
|
|
|
}
|
2000-04-06 20:11:04 +00:00
|
|
|
|
2000-05-18 00:07:31 +00:00
|
|
|
if(0 && $$options->spec_mismatch) {
|
2000-04-06 20:11:04 +00:00
|
|
|
if($external_name eq "@") {
|
|
|
|
if($internal_name !~ /^\U$module\E_$ordinal$/) {
|
|
|
|
$$output->write("$file: $external_name: the internal name ($internal_name) mismatch\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
my $name = $external_name;
|
|
|
|
|
|
|
|
my $name1 = $name;
|
|
|
|
$name1 =~ s/^Zw/Nt/;
|
|
|
|
|
|
|
|
my $name2 = $name;
|
|
|
|
$name2 =~ s/^(?:_|Rtl|k32|K32)//;
|
|
|
|
|
|
|
|
my $name3 = $name;
|
|
|
|
$name3 =~ s/^INT_Int[0-9a-f]{2}Handler$/BUILTIN_DefaultIntHandler/;
|
|
|
|
|
|
|
|
my $name4 = $name;
|
|
|
|
$name4 =~ s/^(VxDCall)\d$/$1/;
|
|
|
|
|
|
|
|
# FIXME: This special case is becuase of a very ugly kludge that should be fixed IMHO
|
|
|
|
my $name5 = $name;
|
|
|
|
$name5 =~ s/^(.*?16)_(.*?)$/$1_fn$2/;
|
|
|
|
|
|
|
|
if(uc($internal_name) ne uc($external_name) &&
|
|
|
|
$internal_name !~ /(\Q$name\E|\Q$name1\E|\Q$name2\E|\Q$name3\E|\Q$name4\E|\Q$name5\E)/)
|
|
|
|
{
|
|
|
|
$$output->write("$file: $external_name: internal name ($internal_name) mismatch\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-01-20 02:16:31 +00:00
|
|
|
} elsif(/^(\d+|@)\s+stub(?:\s+(?:-noimport|-norelay|-i386|-ret64))?\s+(\S+)$/) {
|
1999-10-24 21:45:39 +00:00
|
|
|
my $external_name = $2;
|
|
|
|
|
|
|
|
$ordinal = $1;
|
|
|
|
|
1999-12-11 23:01:45 +00:00
|
|
|
my $internal_name;
|
|
|
|
if($type eq "win16") {
|
2000-12-21 21:05:52 +00:00
|
|
|
if($external_name =~ /\d$/) {
|
|
|
|
$internal_name = $external_name . "_16";
|
|
|
|
} else {
|
|
|
|
$internal_name = $external_name . "16";
|
|
|
|
}
|
1999-12-11 23:01:45 +00:00
|
|
|
} else {
|
|
|
|
$internal_name = $external_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
# FIXME: Internal name existing more than once not handled properly
|
|
|
|
$$function_stub{$internal_name} = 1;
|
2001-06-19 03:34:52 +00:00
|
|
|
$$function_internal_ordinal{$internal_name} = $ordinal;
|
|
|
|
$$function_external_ordinal{$external_name} = $ordinal;
|
|
|
|
if(!$$function_internal_module{$internal_name}) {
|
|
|
|
$$function_internal_module{$internal_name} = "$module";
|
|
|
|
} elsif($$function_internal_module{$internal_name} !~ /$module/) {
|
|
|
|
$$function_internal_module{$internal_name} .= " & $module";
|
|
|
|
}
|
|
|
|
if(!$$function_external_module{$external_name}) {
|
|
|
|
$$function_external_module{$external_name} = "$module";
|
|
|
|
} elsif($$function_external_module{$external_name} !~ /$module/) {
|
|
|
|
$$function_external_module{$external_name} .= " & $module";
|
1999-12-11 23:01:45 +00:00
|
|
|
}
|
2001-01-25 22:22:37 +00:00
|
|
|
} elsif(/^(\d+|@)\s+forward(?:\s+(?:-noimport|-norelay|-i386|-ret64))?\s+(\S+)\s+(\S+)\.(\S+)$/) {
|
2000-07-15 21:32:55 +00:00
|
|
|
$ordinal = $1;
|
|
|
|
|
|
|
|
my $external_name = $2;
|
|
|
|
my $forward_module = lc($3);
|
|
|
|
my $forward_name = $4;
|
|
|
|
|
|
|
|
$$function_forward{$external_name} = "$module:$forward_module.$forward_name";
|
2000-11-30 01:31:44 +00:00
|
|
|
} elsif(/^(\d+|@)\s+(equate|extern|variable)/) {
|
1999-09-23 15:14:20 +00:00
|
|
|
# ignore
|
|
|
|
} else {
|
|
|
|
my $next_line = <IN>;
|
2000-04-15 20:39:55 +00:00
|
|
|
if(!defined($next_line) || $next_line =~ /^\s*\d|@/) {
|
1999-09-23 15:14:20 +00:00
|
|
|
die "$file: $.: syntax error: '$_'\n";
|
|
|
|
} else {
|
|
|
|
$_ .= $next_line;
|
|
|
|
$lookahead = 1;
|
|
|
|
}
|
|
|
|
}
|
1999-10-24 21:45:39 +00:00
|
|
|
|
|
|
|
if(defined($ordinal)) {
|
2000-01-08 22:20:32 +00:00
|
|
|
if($ordinal ne "@" && $ordinals{$ordinal}) {
|
1999-10-31 02:08:38 +00:00
|
|
|
$$output->write("$file: ordinal redefined: $_\n");
|
1999-10-24 21:45:39 +00:00
|
|
|
}
|
|
|
|
$ordinals{$ordinal}++;
|
|
|
|
}
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
close(IN);
|
2000-04-15 20:39:55 +00:00
|
|
|
|
|
|
|
$$modules{$module}++;
|
2001-06-19 03:34:52 +00:00
|
|
|
|
|
|
|
$$module_files{$module} = $file;
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub name {
|
|
|
|
my $self = shift;
|
1999-10-24 21:45:39 +00:00
|
|
|
my $name = \${$self->{NAME}};
|
|
|
|
|
|
|
|
return $$name;
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub is_allowed_kind {
|
|
|
|
my $self = shift;
|
|
|
|
my $allowed_kind = \%{$self->{ALLOWED_KIND}};
|
|
|
|
|
|
|
|
my $kind = shift;
|
|
|
|
if(defined($kind)) {
|
|
|
|
return $$allowed_kind{$kind};
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-24 21:45:39 +00:00
|
|
|
sub is_limited_type {
|
|
|
|
my $self = shift;
|
|
|
|
my $allowed_modules_limited = \%{$self->{ALLOWED_MODULES_LIMITED}};
|
|
|
|
|
|
|
|
my $type = shift;
|
|
|
|
|
|
|
|
return $$allowed_modules_limited{$type};
|
|
|
|
}
|
|
|
|
|
1999-09-23 15:14:20 +00:00
|
|
|
sub allowed_type_in_module {
|
|
|
|
my $self = shift;
|
|
|
|
my $allowed_modules = \%{$self->{ALLOWED_MODULES}};
|
|
|
|
my $allowed_modules_limited = \%{$self->{ALLOWED_MODULES_LIMITED}};
|
|
|
|
|
|
|
|
my $type = shift;
|
2000-01-29 21:01:47 +00:00
|
|
|
my @modules = split(/ \& /, shift);
|
|
|
|
|
|
|
|
if(!$$allowed_modules_limited{$type}) { return 1; }
|
1999-09-23 15:14:20 +00:00
|
|
|
|
2000-01-29 21:01:47 +00:00
|
|
|
foreach my $module (@modules) {
|
|
|
|
if($$allowed_modules{$type}{$module}) { return 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
1999-10-24 21:45:39 +00:00
|
|
|
sub type_used_in_module {
|
|
|
|
my $self = shift;
|
|
|
|
my $used_modules = \%{$self->{USED_MODULES}};
|
|
|
|
|
|
|
|
my $type = shift;
|
2000-01-29 21:01:47 +00:00
|
|
|
my @modules = split(/ \& /, shift);
|
|
|
|
|
|
|
|
foreach my $module (@modules) {
|
|
|
|
$$used_modules{$type}{$module} = 1;
|
|
|
|
}
|
1999-10-24 21:45:39 +00:00
|
|
|
|
|
|
|
return ();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub types_not_used {
|
|
|
|
my $self = shift;
|
|
|
|
my $used_modules = \%{$self->{USED_MODULES}};
|
|
|
|
my $allowed_modules = \%{$self->{ALLOWED_MODULES}};
|
|
|
|
|
|
|
|
my $not_used;
|
|
|
|
foreach my $type (sort(keys(%$allowed_modules))) {
|
|
|
|
foreach my $module (sort(keys(%{$$allowed_modules{$type}}))) {
|
|
|
|
if(!$$used_modules{$type}{$module}) {
|
|
|
|
$$not_used{$module}{$type} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $not_used;
|
|
|
|
}
|
|
|
|
|
2000-01-29 21:01:47 +00:00
|
|
|
sub types_unlimited_used_in_modules {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $output = \${$self->{OUTPUT}};
|
|
|
|
my $used_modules = \%{$self->{USED_MODULES}};
|
|
|
|
my $allowed_modules = \%{$self->{ALLOWED_MODULES}};
|
|
|
|
my $allowed_modules_unlimited = \%{$self->{ALLOWED_MODULES_UNLIMITED}};
|
|
|
|
|
|
|
|
my $used_types;
|
|
|
|
foreach my $type (sort(keys(%$allowed_modules_unlimited))) {
|
|
|
|
my $count = 0;
|
|
|
|
my @modules = ();
|
|
|
|
foreach my $module (sort(keys(%{$$used_modules{$type}}))) {
|
|
|
|
$count++;
|
|
|
|
push @modules, $module;
|
|
|
|
}
|
2000-02-29 21:59:09 +00:00
|
|
|
if($count) {
|
2000-01-29 21:01:47 +00:00
|
|
|
foreach my $module (@modules) {
|
|
|
|
$$used_types{$type}{$module} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $used_types;
|
|
|
|
}
|
|
|
|
|
1999-09-23 15:14:20 +00:00
|
|
|
sub translate_argument {
|
|
|
|
my $self = shift;
|
|
|
|
my $translate_argument = \%{$self->{TRANSLATE_ARGUMENT}};
|
|
|
|
|
|
|
|
my $argument = shift;
|
|
|
|
|
|
|
|
return $$translate_argument{$argument};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub all_declared_types {
|
|
|
|
my $self = shift;
|
|
|
|
my $translate_argument = \%{$self->{TRANSLATE_ARGUMENT}};
|
|
|
|
|
|
|
|
return sort(keys(%$translate_argument));
|
|
|
|
}
|
|
|
|
|
|
|
|
sub found_type {
|
|
|
|
my $self = shift;
|
|
|
|
my $type_found = \%{$self->{TYPE_FOUND}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
$$type_found{$name}++;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub type_found {
|
|
|
|
my $self = shift;
|
|
|
|
my $type_found= \%{$self->{TYPE_FOUND}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$type_found{$name};
|
|
|
|
}
|
|
|
|
|
2000-05-11 21:46:17 +00:00
|
|
|
sub is_allowed_type_format {
|
|
|
|
my $self = shift;
|
|
|
|
my $type_format = \%{$self->{TYPE_FORMAT}};
|
|
|
|
|
|
|
|
my $module = shift;
|
|
|
|
my $type = shift;
|
|
|
|
my $format = shift;
|
|
|
|
|
|
|
|
my $formats;
|
|
|
|
|
|
|
|
if(defined($module) && defined($type)) {
|
|
|
|
local $_;
|
|
|
|
foreach (split(/ & /, $module)) {
|
|
|
|
if(defined($formats)) {
|
|
|
|
$formats .= "|";
|
|
|
|
} else {
|
|
|
|
$formats = "";
|
|
|
|
}
|
|
|
|
if(defined($$type_format{$_}{$type})) {
|
|
|
|
$formats .= $$type_format{$_}{$type};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(defined($formats)) {
|
|
|
|
local $_;
|
|
|
|
foreach (split(/\|/, $formats)) {
|
|
|
|
if($_ eq $format) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-04-15 20:39:55 +00:00
|
|
|
sub all_modules {
|
|
|
|
my $self = shift;
|
|
|
|
my $modules = \%{$self->{MODULES}};
|
|
|
|
|
|
|
|
return sort(keys(%$modules));
|
|
|
|
}
|
|
|
|
|
2000-04-24 18:02:32 +00:00
|
|
|
sub is_module {
|
|
|
|
my $self = shift;
|
|
|
|
my $modules = \%{$self->{MODULES}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$modules{$name};
|
|
|
|
}
|
|
|
|
|
2000-06-11 20:02:29 +00:00
|
|
|
sub module_file {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $module = shift;
|
|
|
|
|
|
|
|
my $module_files = \%{$self->{MODULE_FILES}};
|
|
|
|
|
|
|
|
return $$module_files{$module};
|
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub all_internal_functions {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
return sort(keys(%$function_internal_calling_convention));
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub all_internal_functions_in_module {
|
2000-05-18 00:07:31 +00:00
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
|
|
|
|
my $function_internal_module = \%{$self->{FUNCTION_INTERNAL_MODULE}};
|
2000-05-18 00:07:31 +00:00
|
|
|
|
|
|
|
my $module = shift;
|
|
|
|
|
|
|
|
my @names;
|
2001-06-19 03:34:52 +00:00
|
|
|
foreach my $name (keys(%$function_internal_calling_convention)) {
|
|
|
|
if($$function_internal_module{$name} eq $module) {
|
2000-05-18 00:07:31 +00:00
|
|
|
push @names, $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sort(@names);
|
|
|
|
}
|
|
|
|
|
2000-04-06 20:11:04 +00:00
|
|
|
sub all_functions_stub {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_stub = \%{$self->{FUNCTION_STUB}};
|
|
|
|
|
|
|
|
return sort(keys(%$function_stub));
|
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub all_internal_functions_found {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
1999-10-24 21:45:39 +00:00
|
|
|
my $function_found = \%{$self->{FUNCTION_FOUND}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
return sort(keys(%$function_found));
|
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub function_internal_ordinal {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_internal_ordinal = \%{$self->{FUNCTION_INTERNAL_ORDINAL}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_internal_ordinal{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub function_external_ordinal {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_external_ordinal = \%{$self->{FUNCTION_EXTERNAL_ORDINAL}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_external_ordinal{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub function_internal_calling_convention {
|
2000-12-21 21:05:52 +00:00
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
|
2000-12-21 21:05:52 +00:00
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
return $$function_internal_calling_convention{$name};
|
2000-12-21 21:05:52 +00:00
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub function_external_calling_convention {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_external_calling_convention = \%{$self->{FUNCTION_EXTERNAL_CALLING_CONVENTION}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
return $$function_external_calling_convention{$name};
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
2000-05-23 23:37:51 +00:00
|
|
|
sub function_external_name {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_external_name = \%{$self->{FUNCTION_EXTERNAL_NAME}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_external_name{$name};
|
|
|
|
}
|
|
|
|
|
1999-09-23 15:14:20 +00:00
|
|
|
sub is_function {
|
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
return $$function_internal_calling_convention{$name};
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub is_shared_function {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_shared = \%{$self->{FUNCTION_SHARED}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_shared{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub found_shared_function {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_shared = \%{$self->{FUNCTION_SHARED}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
$$function_shared{$name} = 1;
|
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub function_internal_arguments {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_internal_arguments = \%{$self->{FUNCTION_INTERNAL_ARGUMENTS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_internal_arguments{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub function_external_arguments {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_external_arguments = \%{$self->{FUNCTION_EXTERNAL_ARGUMENTS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_external_arguments{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub function_internal_module {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_internal_module = \%{$self->{FUNCTION_INTERNAL_MODULE}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
return $$function_internal_module{$name};
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub function_external_module {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
2001-06-19 03:34:52 +00:00
|
|
|
my $function_external_module = \%{$self->{FUNCTION_EXTERNAL_MODULE}};
|
1999-09-23 15:14:20 +00:00
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
return $$function_external_module{$name};
|
1999-09-23 15:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub function_stub {
|
|
|
|
my $self = shift;
|
|
|
|
my $function_stub = \%{$self->{FUNCTION_STUB}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_stub{$name};
|
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub found_internal_function {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
|
|
|
my $function_found = \%{$self->{FUNCTION_FOUND}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
$$function_found{$name}++;
|
|
|
|
}
|
|
|
|
|
2001-06-19 03:34:52 +00:00
|
|
|
sub internal_function_found {
|
1999-09-23 15:14:20 +00:00
|
|
|
my $self = shift;
|
|
|
|
my $function_found = \%{$self->{FUNCTION_FOUND}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
return $$function_found{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|