Mercurial > hg > Members > menikon > CbC_xv6
changeset 237:2e71e7776062
fix generate_stub
author | anatofuz |
---|---|
date | Wed, 29 Jan 2020 21:40:55 +0900 |
parents | 9ceb72e05468 |
children | e825c247ab24 |
files | src/gearsTools/generate_stub.pl src/impl/fs_impl.cbc |
diffstat | 2 files changed, 34 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gearsTools/generate_stub.pl Wed Jan 29 17:01:37 2020 +0900 +++ b/src/gearsTools/generate_stub.pl Wed Jan 29 21:40:55 2020 +0900 @@ -17,6 +17,7 @@ our($opt_o,$opt_d,$opt_h); getopts('o:d:h'); + use Data::Dumper; my $dir = "."; if ($opt_d) { @@ -134,8 +135,12 @@ if (/^\s*(.*)\s+(\w+);$/ ) { my $ttype = $1; my $tname = $2; - if ($ttype =~ /^(union|struct)?\s*(\w+)/) { - $ttype = $2; + if ($ttype =~ /^(union|struct|const)?\s*(\w+)/) { + if ($1 ne 'const') { + $ttype = $2; + } else { + $ttype = "const $2"; + } } $var{$name}->{$tname} = $ttype; } @@ -170,12 +175,15 @@ my $next = $2; my @args = split(/,/,$3); push(@{$code{$name}->{$method}},"\_\_code $next"); - } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s+(\w+)//) { + } elsif ($args =~ s/^(struct|union|const)?\s*(\w+)(\**)\s+(\w+)//) { my $structType = $1; my $typeName = $2; my $ptrType = $3; my $varName = $4; my $typeField = lcfirst($typeName); + if ($structType =~ /const/) { + $typeName = "$structType $typeName"; + } push(@{$code{$name}->{$method}},"$typeName$ptrType $varName"); } elsif ($args =~ s/(.*,)//) { } else { @@ -197,16 +205,24 @@ $inputIncFlag = 0; my @outputs = split(/,/,$3); for my $output (@outputs) { - if ($output =~ /\s*(struct|union)?\s*(\w+)(\*)?+\s(\w+)/) { + if ($output =~ /\s*(struct|union|const)?\s*(\w+)(\*)?+\s(\w+)/) { + my $structType = $1; my $type = $2; my $varName = $4; + if ($structType =~ /const/) { + $type = "$structType $type"; + } $codeGear{$codeGearName}->{"var"}->{$varName} = "$type $outputCount"; $outputCount++; } } - } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)?+\s(\w+)// && $inputIncFlag) { + } elsif ($args =~ s/^(struct|union|const)?\s*(\w+)(\*)?+\s(\w+)// && $inputIncFlag) { + my $structType = $1; my $type = $2; my $varName = $4; + if ($structType =~ /const/) { + $type = "$structType $type"; + } $codeGear{$codeGearName}->{"var"}->{$varName} = "$type $inputCount"; $inputCount++; } elsif ($args =~ s/(.*,)//) { @@ -242,6 +258,7 @@ $dataGearName{$codeGearName} .= "\t$typeName* $varName = ($typeName*)GearImpl(cbc_context, $interface, $varName);\n"; } else { # interface var + print Dumper \%var; for my $ivar (keys %{$var{$interface}}) { # input data gear field if ($varName eq $ivar) { @@ -256,7 +273,7 @@ } } } - + # interface continuation for my $cName (keys %{$code{$interface}}) { if ($varName eq $cName) { @@ -265,7 +282,6 @@ return 1; } } - # par goto var for my $var (keys %{$codeGear{$codeGearName}->{"var"}}) { # input data gear field @@ -408,24 +424,30 @@ for my $arg (@args) { $arg =~ s/^\s*//; last if ($arg =~ /\.\.\./); - $arg =~ s/^(struct|union)?\s*(\w+)(\**)\s(\w+)//; + $arg =~ s/^(struct|union|const)?\s*(\w+)(\**)\s(\w+)//; my $structType = $1; my $typeName = $2; my $ptrType = $3; my $varName = $4; + if ($structType =~ /const/) { + $typeName = "$structType $typeName"; + } my $typeField = lcfirst($typeName); push(@{$outputArgs{$codeGearName}->{$next}}, $varName); if (&generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,1)) { $newArgs .= ",$structType $typeName **O_$varName"; } } - } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s(\w+)//) { + } elsif ($args =~ s/^(struct|union|const)?\s*(\w+)(\**)\s(\w+)//) { my $structType = $1; my $typeName = $2; my $ptrType = $3; my $varName = $4; + $newArgs .= $&; # assuming no duplicate + if ($structType =~ /const/) { + $typeName = "$structType $typeName"; + } my $typeField = lcfirst($typeName); - $newArgs .= $&; # assuming no duplicate &generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,0); } elsif ($args =~ s/(.*,)//) { $newArgs .= $1;
--- a/src/impl/fs_impl.cbc Wed Jan 29 17:01:37 2020 +0900 +++ b/src/impl/fs_impl.cbc Wed Jan 29 21:40:55 2020 +0900 @@ -35,6 +35,8 @@ fs->nameiparent = C_nameiparentfs_impl; return fs; } + + __code readsbfs_impl(struct fs_impl* fs, uint dev, struct superblock* sb, __code next(...)) { //:skip goto next(...);