From 66f5dcf15244cb31dec9434fd6182161a32847fa Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 1 Jun 2015 08:33:51 +0300 Subject: [PATCH] method stores constants --- lib/virtual/compiled_method_info.rb | 3 ++- lib/virtual/compiler/basic_expressions.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/virtual/compiled_method_info.rb b/lib/virtual/compiled_method_info.rb index 4b095de6..f59ea2d4 100644 --- a/lib/virtual/compiled_method_info.rb +++ b/lib/virtual/compiled_method_info.rb @@ -50,8 +50,9 @@ module Virtual @blocks = [enter] @current = enter new_block("return").add_code(MethodReturn.new) + @constants = [] end - attr_reader :blocks + attr_reader :blocks , :constants attr_accessor :return_type , :current , :receiver # add an instruction after the current (insertion point) diff --git a/lib/virtual/compiler/basic_expressions.rb b/lib/virtual/compiler/basic_expressions.rb index 27819f7e..90e3fb52 100644 --- a/lib/virtual/compiler/basic_expressions.rb +++ b/lib/virtual/compiler/basic_expressions.rb @@ -73,6 +73,7 @@ module Virtual def self.compile_string expression , method value = expression.string.to_sym to = Return.new(Reference , value) + method.info.constants << value method.info.add_code Set.new( to , value ) to end