Changes
+lib/App/Scheme79asm.pm
+lib/App/Scheme79asm/Compiler.pm
Makefile.PL
MANIFEST
README
scheme79asm
t/App-Scheme79asm.t
t/Compiler.t
-lib/App/Scheme79asm.pm
-lib/App/Scheme79asm/Compiler.pm
+t/perlcritic.t
+t/perlcriticrc
use 5.014000;
use strict;
use warnings;
+use re '/s';
+use Carp qw/croak/;
use Data::Dumper qw/Dumper/;
use Data::SExpression qw/consp scalarp/;
}
$addr += (1 << $self->{addr_bits}) if $addr < 0;
- die "Type too large: $type\n" unless $type < (1 << $self->{type_bits});
- die "Addr too large: $addr\n" unless $addr < (1 << $self->{addr_bits});
+ die "Type too large: $type\n" if $type >= (1 << $self->{type_bits});
+ die "Addr too large: $addr\n" if $addr >= (1 << $self->{addr_bits});
my $result = ($type << $self->{addr_bits}) + $addr;
unless ($location) {
$self->{freeptr}++;
die "addr_bits + type_bits >= 16\n"if $self->{addr_bits} + $self->{type_bits} > 16;
my $length = @{$self->{memory}};
- print $fh pack('n', $length);
+ print $fh pack 'n', $length or croak "Failed to print memory size: $!";
for (@{$self->{memory}}) {
- print $fh pack('n', $_)
+ print $fh pack 'n', $_ or croak "Failed to print memory: $!"
}
}
my $spaces = ' ' x ($bits + 5 - (length $val));
$index = sprintf $index_format, $index;
- print $fh "mem[$index] <= $val;";
- print $fh "$spaces // $comment" if defined $comment;
- print $fh "\n";
+ my $string = "mem[$index] <= $val;";
+ $string .= "$spaces // $comment" if defined $comment;
+ say $fh $string or croak "Failed to print verilog: $!";
}
}
my %self = (
symbols => ['', '', 'T'],
nsymbols => 3,
- symbol_map => {}
+ symbol_map => {},
);
bless \%self, $class;
}
} elsif ($func eq 'LAMBDA') {
my $func_name = $expr->cdr->car;
my $func_args = $expr->cdr->cdr->car;
- my $func_body = $expr->cdr->cdr->cdr->car;
+ my $func_body = $expr->cdr->cdr->cdr->car; ## no critic (ProhibitLongChainsOfMethodCalls)
[PROC => $self->process_proc($func_name, $func_args, $func_body, $env)]
} elsif ($func eq 'IF') {
my ($if_cond, $if_then, $if_else) =
map { $self->process_toplevel($_, $env) }
- ($expr->cdr->car, $expr->cdr->cdr->car, $expr->cdr->cdr->cdr->car);
+ ($expr->cdr->car, $expr->cdr->cdr->car, $expr->cdr->cdr->cdr->car); ## no critic (ProhibitLongChainsOfMethodCalls)
[IF => [LIST => $if_else, $if_then], $if_cond]
} else {
$self->process_funcall($expr->car, $expr->cdr, $env)
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More;
+
+BEGIN { plan skip_all => '$ENV{RELEASE_TESTING} is false' unless $ENV{RELEASE_TESTING} }
+use Test::Perl::Critic -profile => 't/perlcriticrc';
+
+all_critic_ok 'lib'
--- /dev/null
+severity = 1
+
+[-BuiltinFunctions::ProhibitComplexMappings]
+[-CodeLayout::RequireTidyCode]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::PodSpelling]
+[-Documentation::RequirePodLinksIncludeText]
+[-InputOutput::RequireBracedFileHandleWithPrint]
+[-Modules::ProhibitAutomaticExportation]
+[-References::ProhibitDoubleSigils]
+[-RegularExpressions::ProhibitEnumeratedClasses]
+[-RegularExpressions::ProhibitUnusualDelimiters]
+[-RegularExpressions::RequireBracesForMultiline]
+[-RegularExpressions::RequireLineBoundaryMatching]
+[-Subroutines::ProhibitSubroutinePrototypes]
+[-Subroutines::RequireFinalReturn]
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitLeadingZeros]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+[-ValuesAndExpressions::ProhibitNoisyQuotes]
+[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitPackageVars]
+[-Variables::ProhibitPunctuationVars]
+
+[BuiltinFunctions::ProhibitStringyEval]
+allow_includes = 1
+
+[RegularExpressions::RequireExtendedFormatting]
+minimum_regex_length_to_complain_about = 20
+
+[Documentation::RequirePodSections]
+lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+script_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+
+[Subroutines::RequireArgUnpacking]
+short_subroutine_statements = 5
+allow_subscripts = 1
+
+[TestingAndDebugging::ProhibitNoWarnings]
+allow_with_category_restriction = 1