From 559a797100f054d9fcdb2468fb698552c5f00a1f Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 14 Mar 2018 20:24:47 +0530 Subject: [PATCH] rename locals to frame --- lib/parfait/typed_method.rb | 4 ++-- lib/parfait/vool_method.rb | 12 ++++++------ lib/vool/statements/method_statement.rb | 6 +++--- stash/rubyx/passes/method_collector.rb | 4 ++-- stash/test_rubyx/passes/test_method_collector.rb | 2 +- stash/test_rubyx/test_ruby_method.rb | 6 +++--- stash/vm/method_compiler/name_expression.rb | 2 +- test/parfait/test_typed_method.rb | 10 +++++----- test/vool/compilers/test_method_compiler.rb | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/parfait/typed_method.rb b/lib/parfait/typed_method.rb index 8cfa571c..b9078cf0 100644 --- a/lib/parfait/typed_method.rb +++ b/lib/parfait/typed_method.rb @@ -78,14 +78,14 @@ module Parfait end def frame_length - locals.instance_length - 1 + frame.instance_length - 1 end def locals_name( index ) frame.names.get(index + 1) end - def locals_type( index ) + def frame_type( index ) frame.types.get(index + 1) end diff --git a/lib/parfait/vool_method.rb b/lib/parfait/vool_method.rb index f11c4076..a03f9392 100644 --- a/lib/parfait/vool_method.rb +++ b/lib/parfait/vool_method.rb @@ -14,11 +14,11 @@ module Parfait attr_reader :name , :args_type , :frame_type , :source - def initialize(name , args_type , locals_type , source ) - @name , @args_type , @locals_type , @source = name , args_type, locals_type , source + def initialize(name , args_type , frame_type , source ) + @name , @args_type , @frame_type , @source = name , args_type, frame_type , source raise "Name must be symbol" unless name.is_a?(Symbol) raise "args_type must be type" unless args_type.is_a?(Parfait::Type) - raise "locals_type must be type" unless locals_type.is_a?(Parfait::Type) + raise "frame_type must be type" unless frame_type.is_a?(Parfait::Type) raise "source must be vool" unless source.is_a?(Vool::Statement) end @@ -28,12 +28,12 @@ module Parfait def create_parfait_method( type ) raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type - type.create_method( @name , @args_type )#FIXME, @locals_type) + type.create_method( @name , @args_type )#FIXME, @frame_type) end def create_tmp - tmp_name = "tmp_#{@locals_type.instance_length}".to_sym - @locals_type = @locals_type.add_instance_variable( tmp_name , :Object ) + tmp_name = "tmp_#{@frame_type.instance_length}".to_sym + @frame_type = @frame_type.add_instance_variable( tmp_name , :Object ) tmp_name end end diff --git a/lib/vool/statements/method_statement.rb b/lib/vool/statements/method_statement.rb index 43827c0f..366e8549 100644 --- a/lib/vool/statements/method_statement.rb +++ b/lib/vool/statements/method_statement.rb @@ -30,8 +30,8 @@ module Vool def create_objects args_type = make_type - locals_type = make_locals - method = Parfait::VoolMethod.new(name , args_type , locals_type , body ) + frame_type = make_frame + method = Parfait::VoolMethod.new(name , args_type , frame_type , body ) @clazz.add_method( method ) typed_method = method.create_parfait_method(clazz.instance_type) compiler = Risc::MethodCompiler.new( typed_method ).init_method @@ -47,7 +47,7 @@ module Vool Parfait::NamedList.type_for( type_hash ) end - def make_locals + def make_frame type_hash = {} vars = [] @body.collect([]).each { |node| node.add_local(vars) } diff --git a/stash/rubyx/passes/method_collector.rb b/stash/rubyx/passes/method_collector.rb index 1ade8292..5854925a 100644 --- a/stash/rubyx/passes/method_collector.rb +++ b/stash/rubyx/passes/method_collector.rb @@ -15,8 +15,8 @@ module Rubyx def on_def(statement) name , args , body = *statement args_type = make_type(args) - locals_type = make_locals(body) - @methods << Vool::VoolMethod.new(name , args_type , locals_type , body ) + frame_type = make_locals(body) + @methods << Vool::VoolMethod.new(name , args_type , frame_type , body ) end private diff --git a/stash/test_rubyx/passes/test_method_collector.rb b/stash/test_rubyx/passes/test_method_collector.rb index e145a139..d3d62f5e 100644 --- a/stash/test_rubyx/passes/test_method_collector.rb +++ b/stash/test_rubyx/passes/test_method_collector.rb @@ -31,7 +31,7 @@ module Rubyx def test_one_local method = parse_collect("def meth2(arg1); foo = 2 ;end").first - assert method.locals_type.variable_index(:foo) , method.locals_type.inspect + assert method.frame_type.variable_index(:foo) , method.frame_type.inspect end end diff --git a/stash/test_rubyx/test_ruby_method.rb b/stash/test_rubyx/test_ruby_method.rb index 6aff17d3..4c07e8a6 100644 --- a/stash/test_rubyx/test_ruby_method.rb +++ b/stash/test_rubyx/test_ruby_method.rb @@ -44,7 +44,7 @@ module Rubyx def test_method_has_no_locals method = create_method - assert_equal 1 , method.locals_type.instance_length + assert_equal 1 , method.frame_type.instance_length end def test_method_has_args @@ -54,7 +54,7 @@ module Rubyx def test_method_has_locals method = create_method_local - assert_equal 2 , method.locals_type.instance_length + assert_equal 2 , method.frame_type.instance_length end def test_method_create_tmp @@ -65,7 +65,7 @@ module Rubyx def test_method_add_tmp method = create_method_local method.create_tmp - assert_equal 3 , method.locals_type.instance_length + assert_equal 3 , method.frame_type.instance_length end end diff --git a/stash/vm/method_compiler/name_expression.rb b/stash/vm/method_compiler/name_expression.rb index 570e2a9a..4d58ce38 100644 --- a/stash/vm/method_compiler/name_expression.rb +++ b/stash/vm/method_compiler/name_expression.rb @@ -31,7 +31,7 @@ module Vm raise "must define local '#{name}' before using it" unless index named_list = use_reg :NamedList add_slot_to_reg("#{name} load locals" , :message , :frame , named_list ) - ret = use_reg @method.locals_type( index ) + ret = use_reg @method.frame_type( index ) add_slot_to_reg("#{name} load from locals" , named_list , index + 1, ret ) return ret end diff --git a/test/parfait/test_typed_method.rb b/test/parfait/test_typed_method.rb index 2d2ebad6..818ba35c 100644 --- a/test/parfait/test_typed_method.rb +++ b/test/parfait/test_typed_method.rb @@ -70,7 +70,7 @@ class TestMethod < MiniTest::Test @method.add_local(:foo2 , :Object) assert_equal 3 , @method.frame_length assert_equal :foo2 , @method.locals_name(3) - assert_equal :Object , @method.locals_type(3) + assert_equal :Object , @method.frame_type(3) end def test_get_locals_name1 @@ -78,18 +78,18 @@ class TestMethod < MiniTest::Test assert_equal 1 , index assert_equal :local_bar , @method.locals_name(index) end - def test_get_locals_type1 + def test_get_frame_type1 index = @method.has_local(:local_bar) - assert_equal :Integer , @method.locals_type(index) + assert_equal :Integer , @method.frame_type(index) end def test_get_locals_name2 index = @method.has_local(:local_foo) assert_equal 2 , index assert_equal :local_foo , @method.locals_name(index) end - def test_get_locals_type2 + def test_get_frame_type2 index = @method.has_local(:local_bar) - assert_equal :Integer , @method.locals_type(index) + assert_equal :Integer , @method.frame_type(index) end end diff --git a/test/vool/compilers/test_method_compiler.rb b/test/vool/compilers/test_method_compiler.rb index efed063b..ba173685 100644 --- a/test/vool/compilers/test_method_compiler.rb +++ b/test/vool/compilers/test_method_compiler.rb @@ -22,7 +22,7 @@ module Vool def test_method_has_no_locals method = create_method - assert_equal 1 , method.locals_type.instance_length + assert_equal 1 , method.frame_type.instance_length end def test_method_has_no_args @@ -60,7 +60,7 @@ module Vool VoolCompiler.ruby_to_vool in_Test("def meth; local = 5 ;end") test = Parfait.object_space.get_class_by_name(:Test) method = test.get_method(:meth) - assert_equal 2 , method.locals_type.instance_length + assert_equal 2 , method.frame_type.instance_length end end