From a96d5030959dc084186339baa97e037d469eb851 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 5 Aug 2018 13:35:16 -0700 Subject: [PATCH] Properly throw away unused expressions in blocks. --- src/chalk/codegen.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chalk/codegen.cr b/src/chalk/codegen.cr index d8a3228..010724d 100644 --- a/src/chalk/codegen.cr +++ b/src/chalk/codegen.cr @@ -90,8 +90,10 @@ module Chalk generate! tree, entry.function, table, target, free when Trees::TreeBlock table = Table.new(table) + throwaway = free + free += 1 tree.children.each do |child| - free += generate! child, table, free, free + 1 + free += generate! child, table, throwaway, free end when Trees::TreeVar entry = table[tree.name]? @@ -143,7 +145,7 @@ module Chalk # Generates code for the function that was given to it. def generate! - generate!(@function.block, @table, -1, @registers) + generate!(@function.block, @table, 0, @registers) return @instructions end end