[Tinyos8051wg-commit] SF.net SVN: tinyos8051wg:[1098] trunk/diku/mcs51/support/make/mcs51/ mangleAp
Status: Alpha
Brought to you by:
mleopold
From: <mle...@us...> - 2009-10-09 12:24:00
|
Revision: 1098 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1098&view=rev Author: mleopold Date: 2009-10-09 12:23:50 +0000 (Fri, 09 Oct 2009) Log Message: ----------- Brace counting robust to comments, added match for uncalled segment (as opposed uncalled function) Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl Modified: trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-10-06 06:02:33 UTC (rev 1097) +++ trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-10-09 12:23:50 UTC (rev 1098) @@ -116,14 +116,17 @@ close RFILE; } - my @mapInput = `grep -A1 \"MULTIPLE CALL TO FUNCTION\" $mapFile`; + my @mapInput = `grep -A2 \"MULTIPLE CALL TO FUNCTION\" $mapFile`; @mapInput = grep(/NAME/, @mapInput); map (s/^.*NAME:\s*_*(\w+)\/.*/$1/, @mapInput); chomp @mapInput; + push(@reentrantFunctions, @mapInput); - foreach my $fn (@mapInput) { - push(@reentrantFunctions, "$fn"); - } + @mapInput = `grep -A2 \"MULTIPLE CALL TO SEGMENT\" $mapFile`; + @mapInput = grep(/SEGMENT:/, @mapInput); + map (s/^.*SEGMENT:\s*(?:\?PR\?)?_?(\w+)\?.*/$1/, @mapInput); + chomp @mapInput; + push(@reentrantFunctions, @mapInput); } # First pass of source: find all functions marked as reentrant @@ -145,6 +148,13 @@ } @reentrantFunctions = @new_array; +print STDERR "Rentrant\n"; + foreach my $ln (@reentrantFunctions) { + print STDERR "$ln\n"; + } +print STDERR "Rentrant slut\n"; + + if (open (RFILE, ">$reentFile")) { foreach my $fn (@reentrantFunctions) {print RFILE "$fn\n";} close RFILE; @@ -365,11 +375,13 @@ foreach my $reentrantFunc (@reentrantFunctions) { my $funcName = quotemeta($reentrantFunc); if (m{$funcName\s*\(}gi) { - if (m{\(} != m{\)}) { + if (tr/\(// != tr/\)//) { # Paranthesis levels do not match. Wait for ")". $reentrantWait = 1; } else { - s{([^\;\{]+)}{$1 reentrant}; + if (!s{([^\;\{]+)}{$1 reentrant}) { + s{\)}{\) reentrant}; + } printf STDERR "Fixed reentrant function: '%s'\n",$funcName; } } @@ -377,25 +389,25 @@ } } - if ($reentrantWait && m{\);}) { - s{\)}{) reentrant}; - $reentrantWait = 0; + if ($reentrantWait && m{\)}) { + print STDERR "WAIT\n"; + s{\)}{\) reentrant}; + $reentrantWait = 0; } - # Make the TinyOS task poster function reentrant as well. - # NOTE: This will not work if the BasicScheduler is replaced. - s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; + # Make the TinyOS task poster function reentrant as well. + # NOTE: This will not work if the BasicScheduler is replaced. + s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; - if ($schedulerBasicReentrant) { - if (m{\;}) { - $schedulerBasicReentrant = 0; - s{\;}{ reentrant\;}; - } - } + if ($schedulerBasicReentrant) { + if (s{\;}{ reentrant\;}) { + $schedulerBasicReentrant = 0; + } + } - if (m{error_t\s*SchedulerBasicP__TaskBasic__postTask} && !m{reentrant}) { - $schedulerBasicReentrant = 1; - } + if (m{error_t\s*SchedulerBasicP__TaskBasic__postTask} && !m{reentrant}) { + $schedulerBasicReentrant = 1; + } } # @@ -695,7 +707,7 @@ # $typedef_struct_lines = 0; # $typedef_struct_empty = 0; # we are done - don't match any more! -# doneProcessing($_); +# doneProcessing($_,$comment_level); # next; # } else { # Output the whole structure at once! # $_ = ""; @@ -742,18 +754,28 @@ close(FILE); +# Arguments: +# 1: $line - line to process + sub doneProcessing { my $line = $_[0]; + # Remove all // and /**/ style commnets + my $line_nocomment = $line; + $line_nocomment =~ s/(.*)\/\//$1/; + # someting /*comment*/ something + while ($line_nocomment =~ s/(.*)\/\*.*\*\/(.*)/$1 $2/g) {}; + $line_nocomment =~ s/(.*)\/\*.*$/$1/g; # <something> /* + $line_nocomment =~ s/^.*\*\/(.*)/$1/; # comment */ <something> + # Update parentheses levels. - $braceLevel += ($line =~ m{\{}g); - $braceLevel -= ($line =~ m{\}}g); - $bracketLevel += $line =~ m{\[}g; - $bracketLevel -= $line =~ m{\]}g; - $parenthesesLevel += $line =~ m{\(}g; - $parenthesesLevel -= $line =~ m{\)}g; - + $braceLevel += $line_nocomment =~ tr/\{//; + $braceLevel -= $line_nocomment =~ tr/\}//; + $bracketLevel += $line_nocomment =~ tr/\[//; + $bracketLevel -= $line_nocomment =~ tr/\]//; + $parenthesesLevel += $line_nocomment =~ tr/\(//; + $parenthesesLevel -= $line_nocomment =~ tr/\)//; $output .= $line; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |