Remove dead code

some copy paste in creating full mom layer left dome unused (untested) 
code
thanks to code climate stats
This commit is contained in:
Torsten Rüger 2019-08-18 10:19:52 +03:00
parent 5a43cbff15
commit 15d1c07a1c
6 changed files with 10 additions and 115 deletions

View File

@ -23,20 +23,6 @@ module Mom
risc_compiler
end
# resolve the type of the slot, by inferring from it's name, using the type
# scope related slots are resolved by the compiler by method/block
#
# This mainly calls super, and only for :caller adds extra info
# Using the info, means assuming that the block is not passed around (FIXME in 2020)
def slot_type( slot , type)
new_type = super
if slot == :caller
extra_info = { type_frame: @method.frame_type ,
type_arguments: @method.arguments_type ,
type_self: @method.self_type}
end
return new_type , extra_info
end
# determine how given name need to be accsessed.
# For blocks the options are args or frame
# or then the methods arg or frame

View File

@ -50,35 +50,6 @@ module Mom
self
end
# resolve the type of the slot, by inferring from it's name, using the type
# scope related slots are resolved by the compiler by method/block
def slot_type( slot , type)
case slot
when :frame
new_type = self.frame_type
when :arguments
new_type = self.arg_type
when :receiver
new_type = self.receiver_type
when Symbol
new_type = type.type_for(slot)
raise "Not found object #{slot}: in #{type}" unless new_type
else
raise "Not implemented object #{slot}:#{slot.class}"
end
#puts "RESOLVE in #{@type.class_name} #{slot}->#{type}"
return new_type
end
# return the frame type, ie the blocks frame type
def frame_type
@callable.frame_type
end
# return the frame type, ie the blocks arguments type
def arg_type
@callable.arguments_type
end
# return the frame type, ie the blocks self_type
def receiver_type
@callable.self_type

View File

@ -29,23 +29,6 @@ module Risc
end
return new_type , extra_info
end
# determine how given name need to be accsessed.
# For blocks the options are args or frame
# or then the methods arg or frame
def slot_type_for(name)
if @callable.arguments_type.variable_index(name)
slot_def = [:arguments]
elsif @callable.frame_type.variable_index(name)
slot_def = [:frame]
elsif @in_method.arguments_type.variable_index(name)
slot_def = [:caller , :caller ,:arguments ]
elsif @in_method.frame_type.variable_index(name)
slot_def = [:caller ,:caller , :frame ]
elsif
raise "no variable #{name} , need to resolve at runtime"
end
slot_def << name
end
end

View File

@ -20,68 +20,14 @@ module Risc
"#{@callable.self_type.name}.#{@callable.name}"
end
def get_method
@callable
end
# sometimes the method is used as source (tb reviewed)
def source
@callable
end
# helper method for builtin mainly
# the class_name is a symbol, which is resolved to the instance_type of that class
#
# return compiler_for_type with the resolved type
#
def self.compiler_for_clazz( class_name , method_name , args , frame )
raise "create_method #{class_name}.#{class_name.class}" unless class_name.is_a? Symbol
clazz = Parfait.object_space.get_class_by_name! class_name
compiler_for_type( clazz.instance_type , method_name , args , frame)
end
def add_method_to( target )
target.add_method( @callable )
end
def create_block(arg_type , frame_type)
@callable.create_block(arg_type ,frame_type)
end
# create a method for the given type ( Parfait type object)
# method_name is a Symbol
# args a hash that will be converted to a type
# the created method is set as the current and the given type too
# return the compiler
def self.compiler_for_typez( type , method_name , args , frame)
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
raise "Args must be Type #{args}" unless args.is_a?(Parfait::Type)
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
method = type.create_method( method_name , args , frame)
self.new(method)
end
# determine how given name need to be accsessed.
# For methods the options are args or frame
def slot_type_for(name)
if @callable.arguments_type.variable_index(name)
type = :arguments
else
type = :frame
end
[type , name]
end
def add_block_compiler(compiler)
@block_compilers << compiler
end
# return true or false if the given name is in scope (arg/local)
def in_scope?(name)
ret = true if @callable.arguments_type.variable_index(name)
ret = @callable.frame_type.variable_index(name) unless ret
ret
end
end
end

View File

@ -14,6 +14,12 @@ module Ruby
@lst = compile( input )
assert_equal Ruby::ClassMethodStatement , @lst.class
end
def test_tos
input = "def self.tryout(arg) ; arg = true ; return arg ; end "
@str = compile( input ).to_s
assert @str.include?("def self.tryou"), @str
assert @str.include?("arg = true"), @str
end
end
class TestClassMethodStatement2 < MiniTest::Test
include RubyTests

View File

@ -17,5 +17,8 @@ module RubyX
assert_output(/compiling/) {RubyXC.start(["compile" , "test/mains/source/add__4.rb"])}
File.delete "add__4.o"
end
def test_interpret
assert_output(/interpreting/) {RubyXC.start(["interpret" , "test/mains/source/add__4.rb"])}
end
end
end