Compile T and NIL correctly
[app-scheme79asm.git] / lib / App / Scheme79asm / Compiler.pm
index f4762623584a2e34e8a6adb5d63eed69d1642429..d9a420f1aaf03408e16c9dc9fa3ae6dc8e4c2a2e 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use parent qw/Exporter/;
 
 our @EXPORT_OK = qw/pretty_print/;
-our $VERSION = 0.004;
+our $VERSION = '0.005';
 
 use Carp qw/croak/;
 use Data::Dumper qw/Dumper/;
@@ -106,7 +106,7 @@ sub new {
        my %self = (
                symbols => ['', '', 'T'],
                nsymbols => 3,
-               symbol_map => {}
+               symbol_map => {T => 2},
        );
        bless \%self, $class;
 }
@@ -117,6 +117,9 @@ sub process_quoted {
                [LIST => 0]
        } elsif (scalarp $expr) {
                $expr = uc $expr;
+               if ($expr eq 'NIL') {
+                       return [LIST => 0]
+               }
                if (!exists $self->{symbol_map}{$expr}) {
                        $self->{symbol_map}{$expr} = $self->{nsymbols};
                        $self->{nsymbols}++;
@@ -187,12 +190,12 @@ sub process_toplevel {
                } 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)
This page took 0.011072 seconds and 4 git commands to generate.