2014-06-25 01:47:59 +02:00
|
|
|
module Ast
|
|
|
|
class ModuleExpression < Expression
|
|
|
|
# attr_reader :name ,:expressions
|
|
|
|
def compile context
|
|
|
|
return clazz
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class ClassExpression < ModuleExpression
|
2014-08-06 17:49:20 +02:00
|
|
|
def compile method , message
|
2014-08-24 20:32:21 +02:00
|
|
|
clazz = ::Virtual::BootSpace.space.get_or_create_class name
|
2014-08-06 17:49:20 +02:00
|
|
|
puts "Created class #{clazz.name.inspect}"
|
|
|
|
expressions.each do |expression|
|
|
|
|
# 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
|
|
|
|
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
2014-08-07 14:37:32 +02:00
|
|
|
#puts "compiling expression #{expression}"
|
2014-08-06 17:49:20 +02:00
|
|
|
expression_value = expression.compile(method,message )
|
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
|
2014-06-25 01:47:59 +02:00
|
|
|
end
|
|
|
|
end
|