adds a lot of to_ssss

This commit is contained in:
Torsten Ruger 2018-04-17 20:26:15 +03:00
parent 7c33f19bee
commit df08cb78e2
9 changed files with 52 additions and 1 deletions

View File

@ -28,6 +28,9 @@ module Mom
@arguments.each{|a| raise "args not SlotLoad #{a}" unless a.is_a?(SlotLoad)}
end
def to_s
"ArgumentTransfer " + ([@receiver] + @arguments).join(",")
end
def to_risc(compiler)
transfer = SlotLoad.new([:message , :next_message , :receiver] , @receiver, self).to_risc(compiler)
compiler.reset_regs

View File

@ -18,6 +18,12 @@ module Mom
@cache_entry = Parfait::CacheEntry.new(type, method)
end
def to_s
str = "DynamicCall "
str += cache_entry.cached_method&.name if cache_entry
str
end
# One could almost think that one can resolve this to a Risc::FunctionCall
# (which btw resolves to a simple jump), alas, the FunctionCall, like all other
# jumping, resolves the address at compile time.

View File

@ -14,6 +14,10 @@ module Mom
@name = name
end
def to_s
"Label: #{name}"
end
# A Mom::Label converts one2one to a Risc::Label. So in a way it could not be more
# simple.
# Alas, since almost by definition several roads lead to this label, all those

View File

@ -16,6 +16,10 @@ module Mom
@left , @right = left , right
end
def to_s
"NotSameCheck: #{left}:#{right}"
end
# basically move both left and right values into register
# subtract them and see if IsZero comparison
def to_risc(compiler)

View File

@ -31,6 +31,9 @@ module Mom
moves << Risc::FunctionReturn.new(self, return_address)
end
def to_s
"ReturnSequence"
end
end
end

View File

@ -14,6 +14,9 @@ module Mom
@method = method
end
def to_s
"SimpleCall #{@method.name}"
end
# To call the method, we determine the jumpable address (method.binary), move that
# into a register and issue a FunctionCall
#

View File

@ -34,6 +34,10 @@ module Mom
@original_source = original_source || self
end
def to_s
"SlotLoad #{right} -> #{left}"
end
def to_risc(compiler)
const = @right.to_register(compiler , original_source)
left_slots = @left.slots
@ -83,6 +87,23 @@ module Mom
raise "No slots #{object}" unless slots
end
def to_s
names = [known_name] + @slots
"[#{names.join(',')}]"
end
def known_name
case known_object
when Constant , Parfait::Object
known_object.class.short_name
when Risc::Label
known_object.to_s
when Symbol
known_object
else
"unknown"
end
end
def to_register(compiler, instruction)
type = known_object.respond_to?(:ct_type) ? known_object.ct_type : :Object
right = compiler.use_reg( type )

View File

@ -13,5 +13,8 @@ module Parfait
@cached_type = type
@cached_method = method
end
def to_s
"CacheEntry" + "#{cached_method&.name}"
end
end
end

View File

@ -6,7 +6,11 @@ class String
self[0].capitalize + self[1..-1]
end
end
class Class
def short_name
self.name.split("::").last
end
end
# The RiscMachine, is an abstract machine with registers. Think of it as an arm machine with
# normal instruction names. It is not however an abstraction of existing hardware, but only