Skip to content

Commit

Permalink
Enhance runtime error messages so they show the absolute line number
Browse files Browse the repository at this point in the history
in the macro definition file where the error occurs.  Developers
should be able to jump to that line in the file and reach the
offending code.
  • Loading branch information
rcaputo committed Jul 25, 2001
1 parent 5c79cd6 commit 135b97a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/POE/Preprocessor.pm
Expand Up @@ -9,7 +9,8 @@ use Filter::Util::Call;
sub MAC_PARAMETERS () { 0 }
sub MAC_CODE () { 1 }
sub MAC_NAME () { 2 } # only used in temporary %macro
sub MAC_LINE () { 3 } # only used in temporary %macro
sub MAC_FILE () { 3 }
sub MAC_LINE () { 4 } # only used in temporary %macro

sub STATE_PLAIN () { 0x0000 }
sub STATE_MACRO_DEF () { 0x0001 }
Expand Down Expand Up @@ -421,6 +422,7 @@ sub import {
[ \@macro_params, # MAC_PARAMETERS
'', # MAC_CODE
$macro_name, # MAC_NAME
$file_name, # MAC_FILE
$line_number, # MAC_LINE
];

Expand Down Expand Up @@ -459,6 +461,8 @@ sub import {

# Build a new bit of code here.
my $substitution = $macros{$package_name}->{$name}->[MAC_CODE];
my $macro_file = $macros{$package_name}->{$name}->[MAC_FILE];
my $macro_line = $macros{$package_name}->{$name}->[MAC_LINE];

foreach my $mac_param (@mac_params) {
my $use_param = shift @use_params;
Expand All @@ -471,7 +475,8 @@ sub import {
while ($sub_line--) {
splice( @sub_lines, $sub_line, 0,
"# line $line_number " .
"\"macro $name (line $sub_line) " .
"\"macro $name (defined in $macro_file at line " .
($macro_line + $sub_line + 1) . ") " .
"invoked from $file_name\""
);
}
Expand Down

0 comments on commit 135b97a

Please sign in to comment.