Fixed almost all but Interpreter
150 only failing, seems only 1 bug though and one in linker
This commit is contained in:
@ -22,6 +22,7 @@ module Mom
|
||||
attr_reader :method_source
|
||||
|
||||
def initialize(method_source)
|
||||
raise "no nil" unless method_source
|
||||
@method_source = method_source
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ module Mom
|
||||
# temporary, need to raise really.
|
||||
factory! << Parfait.object_space.get_factory_for(:Integer)
|
||||
integer_tmp! << factory[:reserve]
|
||||
Risc::Builtin::Object.emit_syscall( builder , :exit ) #uses integer_tmp
|
||||
Mom::Builtin.emit_syscall( builder , :exit ) #uses integer_tmp
|
||||
|
||||
add_code ok_label
|
||||
cache_entry[:cached_method] << callable_method
|
||||
|
@ -9,7 +9,7 @@ module Risc
|
||||
# space << Parfait.object_space # load constant
|
||||
# message[:receiver] << space #make current message's (r0) receiver the space
|
||||
# See http://ruby-x.org/rubyx/builder.html for details
|
||||
#
|
||||
#
|
||||
class Builder
|
||||
|
||||
attr_reader :built , :compiler
|
||||
|
@ -186,7 +186,7 @@ module Risc
|
||||
# populate the position caches (forward and revese) with the given position
|
||||
# forward caches object -> position
|
||||
# reverse caches position.at > position
|
||||
# Labels do not participatein reverse cache
|
||||
# Labels do not participate in reverse cache
|
||||
def self.set_cache( position , to)
|
||||
postest = Position.positions[position.object] unless to < 0
|
||||
raise "Mismatch #{position}" if postest and postest != position
|
||||
|
@ -1,5 +1,14 @@
|
||||
module RubyX
|
||||
# The RubyXCompiler provides the main interface to create binaries
|
||||
# The RubyXCompiler provides the main interface to create binaries, and also
|
||||
# give helper functions to create any intermediate layer.
|
||||
# Layers are:
|
||||
# - ruby , always needed as input, string
|
||||
# - vool - intermediate language layer
|
||||
# - mom - intermediate machine layer
|
||||
# - risc - "last" intermediate machine layer
|
||||
# - target - arm or interpreter binary code
|
||||
# - binary - "linked" code, everything need to create an elf binary
|
||||
#
|
||||
#
|
||||
# There are methods to go from ruby to any of the layers in the system
|
||||
# (mainly for testing). ruby_to_binary creates actual binary code
|
||||
@ -38,42 +47,59 @@ module RubyX
|
||||
to_binary(platform)
|
||||
end
|
||||
|
||||
# Process previously stored vool source to binary.
|
||||
# Binary code is generated byu calling to_risc, then positioning and calling
|
||||
# create_binary on the linker. The linker may then be used to creat a binary file.
|
||||
# The biary the method name refers to is binary code in memory, or in BinaryCode
|
||||
# objects to be precise.
|
||||
def to_binary(platform)
|
||||
linker = to_risc
|
||||
linker.position_all
|
||||
linker.create_binary(platform)
|
||||
linker
|
||||
# ruby_to_target creates Target instructions (but does not link)
|
||||
#
|
||||
# After creating vool, we call to_target
|
||||
# Return a Linker
|
||||
def ruby_to_target(ruby)
|
||||
ruby_to_vool(ruby)
|
||||
to_target()
|
||||
end
|
||||
|
||||
# ruby_to_risc creates Risc instructions (as the name implies), but also
|
||||
# translates those to the platform given
|
||||
# ruby_to_risc creates Risc instructions
|
||||
#
|
||||
# After creating vool, we call to_risc
|
||||
# Return a RiscCollection
|
||||
def ruby_to_risc(ruby)
|
||||
ruby_to_vool(ruby)
|
||||
to_risc()
|
||||
end
|
||||
|
||||
# Process previously stored vool source. First to mom, then to risc.
|
||||
def to_risc()
|
||||
mom = to_mom
|
||||
mom.to_risc()
|
||||
end
|
||||
|
||||
# ruby_to_mom does exactly that, it transform the incoming ruby source (string)
|
||||
# to mom
|
||||
# The vool is stored using ruby_to_vool, and if there was previous source,
|
||||
# this will also be momed
|
||||
# Transform the incoming ruby source (string) to mom
|
||||
#
|
||||
# The vool is stored using ruby_to_vool,the to_mom is called
|
||||
# Return Mom Statement
|
||||
def ruby_to_mom(ruby)
|
||||
ruby_to_vool(ruby)
|
||||
to_mom
|
||||
end
|
||||
|
||||
# Process previously stored vool source to binary.
|
||||
# Binary code is generated by calling to_risc, then positioning and calling
|
||||
# create_binary on the linker. The linker may then be used to creat a binary file.
|
||||
# The biary the method name refers to is binary code in memory, or in BinaryCode
|
||||
# objects to be precise.
|
||||
def to_binary(platform)
|
||||
linker = to_target(platform)
|
||||
linker.position_all
|
||||
linker.create_binary
|
||||
linker
|
||||
end
|
||||
|
||||
# transform stored vool to target code
|
||||
# return a linker
|
||||
def to_target(platform)
|
||||
collection = to_risc
|
||||
collection.translate(platform)
|
||||
end
|
||||
|
||||
# Process previously stored vool source to risc.
|
||||
# return a Risc::RiscCollection , a collection of MethodCompilers
|
||||
def to_risc()
|
||||
mom = to_mom
|
||||
mom.to_risc()
|
||||
end
|
||||
|
||||
# return mom for the previously stored vool source.
|
||||
def to_mom
|
||||
@vool.to_mom(nil)
|
||||
|
Reference in New Issue
Block a user