homing in on line length 100
This commit is contained in:
@ -79,7 +79,9 @@ module Virtual
|
||||
|
||||
#attr_reader :left, :right
|
||||
def self.compile_assignment expression , method
|
||||
raise "must assign to NameExpression , not #{expression.left}" unless expression.left.instance_of? Ast::NameExpression
|
||||
unless expression.left.instance_of? Ast::NameExpression
|
||||
raise "must assign to NameExpression , not #{expression.left}"
|
||||
end
|
||||
r = Compiler.compile(expression.right , method )
|
||||
raise "oh noo, nil from where #{expression.right.inspect}" unless r
|
||||
index = method.has_arg(Virtual.new_word name)
|
||||
|
@ -4,7 +4,8 @@ module Virtual
|
||||
|
||||
def self.compile_if expression , method
|
||||
# to execute the logic as the if states it, the blocks are the other way around
|
||||
# so we can the jump over the else if true ,and the else joins unconditionally after the true_block
|
||||
# so we can the jump over the else if true ,
|
||||
# and the else joins unconditionally after the true_block
|
||||
merge_block = method.info.new_block "if_merge" # last one, created first
|
||||
true_block = method.info.new_block "if_true" # second, linked in after current, before merge
|
||||
false_block = method.info.new_block "if_false" # directly next in order, ie if we don't jump we land here
|
||||
|
@ -10,7 +10,8 @@ module Virtual
|
||||
puts "Created class #{clazz.name.inspect}"
|
||||
expression.expressions.each do |expr|
|
||||
# check if it's a function definition and add
|
||||
# if not, execute it, but that does means we should be in salama (executable), not ruby. ie throw an error for now
|
||||
# if not, execute it, but that does means we should be in salama (executable), not ruby.
|
||||
# ie throw an error for now
|
||||
raise "only functions for now #{expr.inspect}" unless expr.is_a? Ast::FunctionExpression
|
||||
#puts "compiling expression #{expression}"
|
||||
expression_value = Compiler.compile(expr,method )
|
||||
|
@ -15,7 +15,9 @@ module Virtual
|
||||
if expression_value.is_a?(IntegerConstant) or expression_value.is_a?(ObjectConstant)
|
||||
return_reg.load into , expression_value
|
||||
else
|
||||
return_reg.move( into, expression_value ) if expression_value.register_symbol != return_reg.register_symbol
|
||||
if expression_value.register_symbol != return_reg.register_symbol
|
||||
return_reg.move( into, expression_value )
|
||||
end
|
||||
end
|
||||
#function.set_return return_reg
|
||||
return return_reg
|
||||
|
Reference in New Issue
Block a user