fix function and class compile

also fix misconception: methods do not have to be added to class by
called
that is a side effect from compiling a method
This commit is contained in:
Torsten Ruger 2015-07-19 12:34:23 +03:00
parent 6da1c69b87
commit db17a9b696
2 changed files with 3 additions and 3 deletions

View File

@ -29,7 +29,7 @@ module Virtual
raise return_type.inspect if return_type.is_a? Instruction
end
new_method.source.return_type = return_type
new_method
Return.new(return_type)
end
def scratch
args = []

View File

@ -8,6 +8,7 @@ module Virtual
def self.compile_class expression , method
clazz = Parfait::Space.object_space.get_class_by_name! expression.name
puts "Created class #{clazz.name.inspect}"
expression_value = nil
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.
@ -15,11 +16,10 @@ module Virtual
raise "only functions for now #{expr.inspect}" unless expr.is_a? Ast::FunctionExpression
#puts "compiling expression #{expression}"
expression_value = Compiler.compile(expr,method )
clazz.add_instance_method(expression_value)
#puts "compiled expression #{expression_value.inspect}"
end
return clazz
return expression_value
end
end
end