update and fix class compilation

This commit is contained in:
Torsten Ruger
2015-09-20 16:30:39 +03:00
parent f2fc9c5f89
commit 77f0a08060
3 changed files with 8 additions and 15 deletions

View File

@ -4,8 +4,8 @@ module Bosl
# call_site - attr_reader :name, :args , :receiver
def on_call expession
name , arguments , receiver = *expession
def on_call expression
name , arguments , receiver = *expression
name = name.to_a.first
if receiver

View File

@ -1,23 +1,16 @@
module Bosl
Compiler.class_eval do
# module attr_reader :name ,:expressions
def on_module expression
def on_module expression
return clazz
end
def on_class expression
clazz = Parfait::Space.object_space.get_class_by_name! expression.name
puts expression.inspect
name , derives , expressions = *expression
clazz = Parfait::Space.object_space.get_class_by_name! name
#puts "Compiling class #{clazz.name.inspect}"
expression_value = nil
expression.expressions.each do |expr|
# 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}"
expression_value = process(expr )
#puts "compiled expression #{expression_value.inspect}"
end
expression_value = process_all(expressions).last
return expression_value
end