Skip to content

Commit a77dbbb

Browse files
Further tightened the frontend so we could support
waiting for multiple file scope identifiers with the same name at different points so I could add the function overloading in the backend
1 parent 1d53b26 commit a77dbbb

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

parse.pl

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,23 @@ sub findnearest {
567567
}
568568

569569
sub getidtostor {
570-
return pos();
570+
my $ident = $_[0];
571+
my $currpos = pos();
572+
my $lastid = -1;
573+
574+
{
575+
#return -1 if (not exists $identstoidmap->{$ident});
576+
lock @{$identstoidmap->{$ident}};
577+
578+
#CORE::print ("$ident " . Dumper2(\@{$identstoidmap->{$ident}}) . "\n");
579+
580+
foreach my $id (@{$identstoidmap->{$ident}}) {
581+
CORE::print ($id->[0] . " against " . $currpos . "\n");
582+
last if ($id->[0] > $currpos);
583+
$lastid++;
584+
}
585+
}
586+
return $lastid;
571587
}
572588

573589
sub broadcastid {
@@ -581,8 +597,7 @@ sub broadcastid {
581597

582598
CORE::print ("signalling over " . $idtosignal . "\n");
583599

584-
push @{$identstoidmap->{$ident}}, $idtosignal;
585-
600+
$identstoidmap->{$ident}->[$idtosignal]->[1] = 1;
586601

587602
cond_broadcast(@{$identstoidmap->{$ident}})
588603
}
@@ -601,6 +616,8 @@ sub waitforid {
601616

602617
while(1)
603618
{
619+
my $areallset = 1;
620+
my $nset = -1;
604621

605622
{
606623
#lock $identstoidmap->{$_[0]}->{$idtosignal};
@@ -613,16 +630,18 @@ sub waitforid {
613630
lock @{$identstoidmap->{$ident}};
614631

615632

616-
#CORE::print("$currpos waitin : " . Dumper2(\@{$locker}));
633+
#CORE::print("$currpos waitin : " . Dumper2(\@{$identstoidmap->{$ident}}));
617634

618635
foreach my $ind (@{$identstoidmap->{$ident}}) {
619-
CORE::print ("check map $ind \n");
620-
if ($ind <= $currpos) {
621-
CORE::print ("foind on " . $ident . " - $ind\n");
622-
return $ind;
623-
}
636+
#CORE::print ("check map $ind \n");
637+
last if(not ($ind->[0] <= $currpos));
638+
$areallset = $areallset && $ind->[1];
639+
last if (not $areallset);
640+
++$nset;
624641
}
625642

643+
return $nset if($areallset);
644+
626645
CORE::print ("waitin on " . $ident . "\n");
627646

628647
cond_wait(@{$identstoidmap->{$ident}});
@@ -1096,10 +1115,16 @@ sub waitforid {
10961115
if ($subject =~ m{$typeorqualifsreg$initseqlight\G(?&brackets)\s*+}sxx) {
10971116
pos($subject) = $+[0];
10981117
lock $identstoidmap;
1099-
$identstoidmap->{$possibleidentlocal} = shared_clone([]) if (not exists $identstoidmap->{$possibleidentlocal});
1118+
if (not exists $identstoidmap->{$possibleidentlocal}) {
1119+
$identstoidmap->{$possibleidentlocal} = shared_clone([[$lastposend, 0]])
1120+
}
1121+
else {
1122+
lock (@{$identstoidmap->{$possibleidentlocal}});
1123+
push @{$identstoidmap->{$possibleidentlocal}}, shared_clone([$lastposend, 0]);
1124+
}
11001125
#lock %{$identstoidmap->{$possibleidentlocal}};
11011126
#lock $identstoidmap->{$possibleident};
1102-
CORE::print("tag setting $possibleidentlocal @ $lastposend\n");
1127+
#CORE::print("tag setting $possibleidentlocal @ $lastposend\n");
11031128
#$identstoidmap->{$possibleidentlocal}->{(scalar($lastposend))} = 0;
11041129
}
11051130
$matches[-1]{strc} = 1
@@ -1137,10 +1162,16 @@ sub waitforid {
11371162
}
11381163
elsif($possibleident) {
11391164
lock $identstoidmap;
1140-
$identstoidmap->{$possibleident} = shared_clone([]) if (not exists $identstoidmap->{$possibleident});
1165+
if (not exists $identstoidmap->{$possibleident}) {
1166+
$identstoidmap->{$possibleident} = shared_clone([[$lastposend, 0]])
1167+
}
1168+
else {
1169+
lock (@{$identstoidmap->{$possibleident}});
1170+
push @{$identstoidmap->{$possibleident}}, shared_clone([$lastposend, 0]);
1171+
}
11411172
#lock %{$identstoidmap->{$possibleident}};
11421173
#lock $identstoidmap->{$possibleident};
1143-
CORE::print("setting $possibleident - $lastposend\n");
1174+
#CORE::print("setting $possibleident - $lastposend\n");
11441175
#$identstoidmap->{$possibleident}->{(scalar($lastposend))} = 0;
11451176
register_decl({'ident'=>$possibleident, 'typedefkey'=>($matches[-1]{typedefkey})}, 1);
11461177
}

0 commit comments

Comments
 (0)