2015-09-19 15:28:41 +02:00
|
|
|
module Bosl
|
2015-09-19 17:56:18 +02:00
|
|
|
Compiler.class_eval do
|
2015-05-04 13:22:22 +02:00
|
|
|
# module attr_reader :name ,:expressions
|
2015-09-19 17:56:18 +02:00
|
|
|
def on_module expression
|
2014-06-25 01:47:59 +02:00
|
|
|
return clazz
|
|
|
|
end
|
|
|
|
|
2015-09-19 17:56:18 +02:00
|
|
|
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}"
|
2015-07-19 11:34:23 +02:00
|
|
|
expression_value = nil
|
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-09-19 17:56:18 +02:00
|
|
|
expression_value = process(expr )
|
2014-08-06 17:49:20 +02:00
|
|
|
#puts "compiled expression #{expression_value.inspect}"
|
|
|
|
end
|
2014-06-25 01:47:59 +02:00
|
|
|
|
2015-07-19 11:34:23 +02:00
|
|
|
return expression_value
|
2014-08-06 17:49:20 +02:00
|
|
|
end
|
2015-05-08 14:10:30 +02:00
|
|
|
end
|
2015-05-04 13:22:22 +02:00
|
|
|
end
|