From 77f0a08060deac1d610b14e9a8be139937a1aada Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 20 Sep 2015 16:30:39 +0300 Subject: [PATCH] update and fix class compilation --- Gemfile.lock | 2 +- lib/bosl/compiler/callsite_expression.rb | 4 ++-- lib/bosl/compiler/module_expression.rb | 17 +++++------------ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 75b9e14a..39efa2dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,7 +12,7 @@ GIT GIT remote: git://github.com/salama/salama-reader.git - revision: 8e07a7568f4b41d0f9b06c6c851b4fa785b88fc4 + revision: e8bc570d2530e501a08ed35eb5b6fac26dc78309 specs: salama-reader (0.2.0) ast (~> 2.1.0) diff --git a/lib/bosl/compiler/callsite_expression.rb b/lib/bosl/compiler/callsite_expression.rb index 1cef5b25..1e68510d 100644 --- a/lib/bosl/compiler/callsite_expression.rb +++ b/lib/bosl/compiler/callsite_expression.rb @@ -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 diff --git a/lib/bosl/compiler/module_expression.rb b/lib/bosl/compiler/module_expression.rb index f82501bd..c97ef8a2 100644 --- a/lib/bosl/compiler/module_expression.rb +++ b/lib/bosl/compiler/module_expression.rb @@ -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