2015-05-04 13:22:22 +02:00
|
|
|
module Compiler
|
|
|
|
|
2015-05-08 13:34:46 +02:00
|
|
|
def self.compile expression , method
|
2015-05-04 22:03:52 +02:00
|
|
|
exp_name = expression.class.name.split("::").last.sub("Expression","").downcase
|
2015-05-05 13:04:37 +02:00
|
|
|
#puts "Expression #{exp_name}"
|
|
|
|
begin
|
2015-05-08 13:34:46 +02:00
|
|
|
self.send "compile_#{exp_name}".to_sym , expression, method
|
2015-05-05 13:04:37 +02:00
|
|
|
rescue NoMethodError => e
|
2015-05-08 13:34:46 +02:00
|
|
|
puts "no compile method foudn for " + exp_name
|
2015-05-05 13:04:37 +02:00
|
|
|
raise e
|
|
|
|
end
|
2015-05-04 13:22:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
require_relative "compiler/basic_expressions"
|
2015-05-08 13:34:46 +02:00
|
|
|
require_relative "compiler/callsite_expression"
|
2015-05-04 13:22:22 +02:00
|
|
|
require_relative "compiler/compound_expressions"
|
|
|
|
require_relative "compiler/if_expression"
|
|
|
|
require_relative "compiler/function_expression"
|
|
|
|
require_relative "compiler/module_expression"
|
|
|
|
require_relative "compiler/operator_expressions"
|
|
|
|
require_relative "compiler/return_expression"
|
|
|
|
require_relative "compiler/while_expression"
|
|
|
|
require_relative "compiler/expression_list"
|