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:
parent
6da1c69b87
commit
db17a9b696
@ -29,7 +29,7 @@ module Virtual
|
|||||||
raise return_type.inspect if return_type.is_a? Instruction
|
raise return_type.inspect if return_type.is_a? Instruction
|
||||||
end
|
end
|
||||||
new_method.source.return_type = return_type
|
new_method.source.return_type = return_type
|
||||||
new_method
|
Return.new(return_type)
|
||||||
end
|
end
|
||||||
def scratch
|
def scratch
|
||||||
args = []
|
args = []
|
||||||
|
@ -8,6 +8,7 @@ module Virtual
|
|||||||
def self.compile_class expression , method
|
def self.compile_class expression , method
|
||||||
clazz = Parfait::Space.object_space.get_class_by_name! expression.name
|
clazz = Parfait::Space.object_space.get_class_by_name! expression.name
|
||||||
puts "Created class #{clazz.name.inspect}"
|
puts "Created class #{clazz.name.inspect}"
|
||||||
|
expression_value = nil
|
||||||
expression.expressions.each do |expr|
|
expression.expressions.each do |expr|
|
||||||
# check if it's a function definition and add
|
# 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.
|
# 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
|
raise "only functions for now #{expr.inspect}" unless expr.is_a? Ast::FunctionExpression
|
||||||
#puts "compiling expression #{expression}"
|
#puts "compiling expression #{expression}"
|
||||||
expression_value = Compiler.compile(expr,method )
|
expression_value = Compiler.compile(expr,method )
|
||||||
clazz.add_instance_method(expression_value)
|
|
||||||
#puts "compiled expression #{expression_value.inspect}"
|
#puts "compiled expression #{expression_value.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
return clazz
|
return expression_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user