⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logger.pm

📁 Verilog Parser in Perl
💻 PM
字号:
# Verilog - Verilog Perl Interface# See copyright, etc in below POD section.######################################################################package Verilog::Netlist::Logger;require Exporter;use vars qw($VERSION);use strict;$VERSION = '3.035';# We don't use Verilog::Netlist::Subclass, as this is called from it!########################################################################## Constructorssub new {    my $class = shift;    my $self = {	_warnings => 0,	_errors	=> 0,	_error_unlink_files => {},	@_    };    bless $self, $class;    return $self;}########################################################################## Accessorssub errors {    my $self = shift;    $self->{_errors} = shift if $#_>=0;    return $self->{_errors};}sub warnings {    my $self = shift;    $self->{_warnings} = shift if $#_>=0;    return $self->{_warnings};}########################################################################## Error Handlingsub info {    my $self = shift;    my $objref = shift;    CORE::warn "-Info: ".$objref->fileline.": ".join('',@_);}sub warn {    my $self = shift;    my $objref = shift;    CORE::warn "%Warning: ".$objref->fileline.": ".join('',@_);    $self->warnings($self->warnings+1);}sub error {    my $self = shift;    my $objref = shift;    CORE::warn "%Error: ".$objref->fileline.": ".join('',@_);    $self->errors($self->errors+1);}sub exit_if_error {    my $self = shift;    my $objref = shift;    my %opts = @_;    my $allow = $opts{allow} || "";    if ($self->errors || ($self->warnings && $allow !~ /warning/)) {	CORE::warn "Exiting due to errors\n";	exit(10);    }    return ($self->errors + $self->warnings);}sub unlink_if_error {    my $self = shift;    $self->{_error_unlink_files}{$_[0]} = 1;}sub error_unlink {    my $self = shift;    foreach my $file (keys %{$self->{_error_unlink_files}}) {	unlink $file;	delete $self->{_error_unlink_files}{$file};    }}sub DESTROY {    my $self = shift;    my $has_err = $? || $self->errors || $self->warnings;    if ($has_err) {	$self->error_unlink;    }}########################################################################## Package return1;__END__=pod=head1 NAMEVerilog::Netlist::Logger - Error collection and reporting=head1 SYNOPSIS  use Verilog::Netlist::Logger;  ...  my $self = Verilog::Netlist::Logger->new();  $self->info("We're here\n");  $self->warn("Things look bad\n");  $self->error("Things are even worse\n");  $self->exit_if_error();=head1 DESCRIPTIONThe Verilog::Netlist::Logger is used to report all errors detected byVerilog::Netlist::* structures.  By default, Verilog::Netlist creates a newLogger object, and passes it down to all contained objects.  Users maycreate their own logger objects to catch or otherwise handle errormessages.=head1 MEMBER FUNCTIONS=over 4=item $self->error (object, I<Text...>)Print an error about the object in a standard format.  The object must havea fileline method.=item $self->exit_if_error()Exits the program if any errors were detected.=item $self->info (I<Text...>)Print an informational about the object in a standard format.  The objectmust have a fileline method.=item $self->lineno()The line number the entity was created on.=item $self->unlink_if_error (I<filename>)Requests the given file be deleted if any errors are detected when theLogger object is destroyed.  Used for temporary files.=item $self->warn (I<Text...>)Print a warning about the object in a standard format.  The object musthave a fileline method.=back=head1 DISTRIBUTIONVerilog-Perl is part of the L<http://www.veripool.org/> free Verilog EDAsoftware tool suite.  The latest version is available from CPAN and fromL<http://www.veripool.org/verilog-perl>.Copyright 2000-2009 by Wilson Snyder.  This package is free software; youcan redistribute it and/or modify it under the terms of either the GNULesser General Public License or the Perl Artistic License.=head1 AUTHORSWilson Snyder <wsnyder@wsnyder.org>=head1 SEE ALSOL<Verilog-Perl>,L<Verilog::Netlist>,L<Verilog::Netlist::Subclass>=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -