rubyx/lib/bosl/compiler/module_expression.rb

26 lines
872 B
Ruby
Raw Normal View History

module Bosl
Compiler.class_eval do
# module attr_reader :name ,:expressions
def on_module expression
return clazz
end
def on_class expression
2015-07-19 09:36:06 +02:00
clazz = Parfait::Space.object_space.get_class_by_name! expression.name
2015-07-30 18:18:41 +02:00
#puts "Compiling class #{clazz.name.inspect}"
expression_value = nil
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
raise "only functions for now #{expr.inspect}" unless expr.is_a? Ast::FunctionExpression
#puts "compiling expression #{expression}"
expression_value = process(expr )
2014-08-06 17:49:20 +02:00
#puts "compiled expression #{expression_value.inspect}"
end
return expression_value
2014-08-06 17:49:20 +02:00
end
end
end