method stores constants

This commit is contained in:
Torsten Ruger 2015-06-01 08:33:51 +03:00
parent f08d9659fc
commit 66f5dcf152
2 changed files with 3 additions and 1 deletions

View File

@ -50,8 +50,9 @@ module Virtual
@blocks = [enter] @blocks = [enter]
@current = enter @current = enter
new_block("return").add_code(MethodReturn.new) new_block("return").add_code(MethodReturn.new)
@constants = []
end end
attr_reader :blocks attr_reader :blocks , :constants
attr_accessor :return_type , :current , :receiver attr_accessor :return_type , :current , :receiver
# add an instruction after the current (insertion point) # add an instruction after the current (insertion point)

View File

@ -73,6 +73,7 @@ module Virtual
def self.compile_string expression , method def self.compile_string expression , method
value = expression.string.to_sym value = expression.string.to_sym
to = Return.new(Reference , value) to = Return.new(Reference , value)
method.info.constants << value
method.info.add_code Set.new( to , value ) method.info.add_code Set.new( to , value )
to to
end end