homing in on line length 100
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
module Register
|
||||
class LinkException < Exception
|
||||
end
|
||||
# Assmble the object space into a binary.
|
||||
# Assemble the object space into a binary.
|
||||
# Link first to get positions, then assemble
|
||||
# link and assemble functions for each class are close to each other, so to get them the same.
|
||||
# meaning: as the link function determines the length of an object and the assemble actually writes the bytes
|
||||
# they are pretty much dependant. In an earlier version they were functions on the objects, but now it
|
||||
# has gone to a visitor pattern.
|
||||
|
||||
# The link function determines the length of an object and the assemble actually
|
||||
# writes the bytes they are pretty much dependant. In an earlier version they were
|
||||
# functions on the objects, but now it has gone to a visitor pattern.
|
||||
|
||||
class Assembler
|
||||
TYPE_REF = 0
|
||||
TYPE_INT = 1
|
||||
@ -119,7 +120,9 @@ module Register
|
||||
# write type and layout of the instance, and the variables that are passed
|
||||
# variables ar values, ie int or refs. For refs the object needs to save the object first
|
||||
def assemble_self( object , variables )
|
||||
raise "Object(#{object.object_id}) not linked #{object.inspect}" unless @objects[object.object_id]
|
||||
unless @objects[object.object_id]
|
||||
raise "Object(#{object.object_id}) not linked #{object.inspect}"
|
||||
end
|
||||
type = type_word(variables)
|
||||
@stream.write_uint32( type )
|
||||
write_ref_for(object.layout[:names] )
|
||||
@ -207,9 +210,8 @@ module Register
|
||||
|
||||
private
|
||||
|
||||
# write means we write the resulting address straight into the assembler stream (ie don't return it)
|
||||
# write means we write the resulting address straight into the assembler stream
|
||||
# object means the object of which we write the address
|
||||
# and we write the address into the self, given as second parameter
|
||||
def write_ref_for object
|
||||
@stream.write_sint32 object.position
|
||||
end
|
||||
|
@ -2,7 +2,8 @@
|
||||
module Builtin
|
||||
module Integer
|
||||
module ClassMethods
|
||||
# The conversion to base10 is quite a bit more complicated than i thought. The bulk of it is in div10
|
||||
# The conversion to base10 is quite a bit more complicated than i thought.
|
||||
# The bulk of it is in div10
|
||||
# We set up variables, do the devision and write the result to the string
|
||||
# then check if were done and recurse if neccessary
|
||||
# As we write before we recurse (save a push) we write the number backwards
|
||||
|
@ -4,7 +4,8 @@ module Builtin
|
||||
|
||||
# return the index of the variable. Now "normal" code can't really do anything with that, but
|
||||
# set/get instance variable use it.
|
||||
# This is just a placeholder, as we code this in ruby, but the instance methods need the definition before.
|
||||
# This is just a placeholder, as we code this in ruby,
|
||||
# but the instance methods need the definition before.
|
||||
def index_of context , name = Virtual::Integer
|
||||
index_function = Virtual::CompiledMethodInfo.create_method("Object" , "index_of" , [Virtual::Reference] )
|
||||
index_function.info.return_type = Virtual::Integer
|
||||
@ -22,7 +23,8 @@ module Builtin
|
||||
# i = self.index_of(var)
|
||||
# return at_index(i)
|
||||
# end
|
||||
# The at_index is just "below" the api, something we need but don't want to expose, so we can't code the above in ruby
|
||||
# The at_index is just "below" the api, something we need but don't want to expose,
|
||||
# so we can't code the above in ruby
|
||||
def _get_instance_variable context , name = Virtual::Integer
|
||||
get_function = Virtual::CompiledMethodInfo.create_method("Object","_get_instance_variable" , [ Virtual::Reference ] )
|
||||
return get_function
|
||||
|
@ -2,7 +2,8 @@ module Register
|
||||
|
||||
# RegisterReference is not the name for a register, "only" for a certain use of it.
|
||||
# In a way it is like a variable name, a storage location. The location is a register off course,
|
||||
# but which register can be changed, and _all_ instructions sharing the RegisterReference then use that register
|
||||
# but which register can be changed, and _all_ instructions sharing the RegisterReference then
|
||||
# use that register
|
||||
# In other words a simple level of indirection, or change from value to reference sematics.
|
||||
|
||||
class RegisterReference
|
||||
|
Reference in New Issue
Block a user