add global variable space

could in the long run move spaces functionality to the class
and since the class is global anyway, wouldn’t need this
This commit is contained in:
Torsten Ruger 2015-11-07 12:19:04 +02:00
parent b1939e9828
commit 9ebe28450b
4 changed files with 16 additions and 2 deletions

View File

@ -136,6 +136,13 @@ module Soml
def reset_regs def reset_regs
@regs.clear @regs.clear
end end
# ensure the name given is not space and raise exception otherwise
# return the name for chaining
def no_space name
raise "space is a reserved name" if name == :space
name
end
end end
end end

View File

@ -5,7 +5,7 @@ module Soml
reset_regs # statements reset registers, ie have all at their disposal reset_regs # statements reset registers, ie have all at their disposal
#puts statement.inspect #puts statement.inspect
name , value = *statement name , value = *statement
name = name.to_a.first name = no_space name.to_a.first
v = process(value) v = process(value)
raise "Not register #{v}" unless v.is_a?(Register::RegisterValue) raise "Not register #{v}" unless v.is_a?(Register::RegisterValue)
code = nil code = nil

View File

@ -6,7 +6,8 @@ module Soml
reset_regs # field_def is a statement, no return and all regs reset_regs # field_def is a statement, no return and all regs
#puts statement.inspect #puts statement.inspect
type , name , value = *statement type , name , value = *statement
@method.ensure_local( name.first, type ) unless( @method.has_arg(name.first)) name_s = no_space( name.first )
@method.ensure_local( name_s, type ) unless( @method.has_arg(name_s))
# if there is a value assigned, process it as am assignemnt statement (kind of call on_assign) # if there is a value assigned, process it as am assignemnt statement (kind of call on_assign)
process( s(:assignment , name , value ) ) if value process( s(:assignment , name , value ) ) if value
return nil return nil

View File

@ -12,6 +12,12 @@ module Soml
add_code Register.get_slot(statement , :message , :receiver , ret ) add_code Register.get_slot(statement , :message , :receiver , ret )
return ret return ret
end end
if(name == :space)
space = Parfait::Space.object_space
reg = use_reg :Space , space
add_code Register::LoadConstant.new( statement, space , reg )
return reg
end
# either an argument, so it's stored in message # either an argument, so it's stored in message
if( index = @method.has_arg(name)) if( index = @method.has_arg(name))
ret = use_reg @method.arguments[index].type ret = use_reg @method.arguments[index].type