2015-05-08 14:10:30 +02:00
|
|
|
module Virtual
|
|
|
|
module Compiler
|
2015-05-04 13:22:22 +02:00
|
|
|
# module attr_reader :name ,:expressions
|
2015-05-04 22:03:52 +02:00
|
|
|
def self.compile_module expression , context
|
2014-06-25 01:47:59 +02:00
|
|
|
return clazz
|
|
|
|
end
|
|
|
|
|
2015-05-08 14:10:30 +02:00
|
|
|
def self.compile_class expression , method
|
2015-07-19 09:36:06 +02:00
|
|
|
clazz = Parfait::Space.object_space.get_class_by_name! expression.name
|
2014-08-06 17:49:20 +02:00
|
|
|
puts "Created class #{clazz.name.inspect}"
|
2015-05-04 13:22:22 +02:00
|
|
|
expression.expressions.each do |expr|
|
2014-08-06 17:49:20 +02:00
|
|
|
# check if it's a function definition and add
|
2015-05-30 11:20:39 +02:00
|
|
|
# if not, execute it, but that does means we should be in salama (executable), not ruby.
|
|
|
|
# ie throw an error for now
|
2015-05-04 13:22:22 +02:00
|
|
|
raise "only functions for now #{expr.inspect}" unless expr.is_a? Ast::FunctionExpression
|
2014-08-07 14:37:32 +02:00
|
|
|
#puts "compiling expression #{expression}"
|
2015-05-06 14:14:47 +02:00
|
|
|
expression_value = Compiler.compile(expr,method )
|
2014-08-23 22:57:47 +02:00
|
|
|
clazz.add_instance_method(expression_value)
|
2014-08-06 17:49:20 +02:00
|
|
|
#puts "compiled expression #{expression_value.inspect}"
|
|
|
|
end
|
2014-06-25 01:47:59 +02:00
|
|
|
|
2014-08-06 17:49:20 +02:00
|
|
|
return clazz
|
|
|
|
end
|
2015-05-08 14:10:30 +02:00
|
|
|
end
|
2015-05-04 13:22:22 +02:00
|
|
|
end
|