From 2aba73d532a55cd0cfa7a32b1e9270a15b0b53d7 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 28 Apr 2018 18:15:19 +0300 Subject: [PATCH] Compile T and NIL correctly --- lib/App/Scheme79asm.pm | 1 + lib/App/Scheme79asm/Compiler.pm | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/App/Scheme79asm.pm b/lib/App/Scheme79asm.pm index 1590d85..602afd1 100644 --- a/lib/App/Scheme79asm.pm +++ b/lib/App/Scheme79asm.pm @@ -71,6 +71,7 @@ sub process { 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}++; $location = $self->{freeptr} diff --git a/lib/App/Scheme79asm/Compiler.pm b/lib/App/Scheme79asm/Compiler.pm index 7bb9121..d9a420f 100644 --- a/lib/App/Scheme79asm/Compiler.pm +++ b/lib/App/Scheme79asm/Compiler.pm @@ -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}++; -- 2.30.2