rubyx/lib/compiler/module_expression.rb

23 lines
914 B
Ruby
Raw Normal View History

module Compiler
# module attr_reader :name ,:expressions
def self.compile_module expression , context
return clazz
end
def self.compile_class expression , method , message
2015-05-05 14:11:09 +02:00
clazz = ::Virtual::BootSpace.space.get_or_create_class expression.name
2014-08-06 17:49:20 +02:00
puts "Created class #{clazz.name.inspect}"
expression.expressions.each do |expr|
2014-08-06 17:49:20 +02:00
# 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 #{expr.inspect}" unless expr.is_a? Ast::FunctionExpression
#puts "compiling expression #{expression}"
2015-05-05 14:11:09 +02:00
expression_value = Compiler.compile(expr,method,message )
clazz.add_instance_method(expression_value)
2014-08-06 17:49:20 +02:00
#puts "compiled expression #{expression_value.inspect}"
end
2014-08-06 17:49:20 +02:00
return clazz
end
end