diff --git a/lib/typed/compiler.rb b/lib/typed/compiler.rb index ccb13535..46af3d84 100644 --- a/lib/typed/compiler.rb +++ b/lib/typed/compiler.rb @@ -4,7 +4,7 @@ module Typed CompilerModules = [ "assignment" , "basic_values" , "call_site", "class_statement" , "collections" , "field_access", - "function_statement" , "if_statement" , "name_expression" , + "if_statement" , "name_expression" , "operator_expression" , "return_statement", "statement_list", "while_statement"] diff --git a/lib/typed/compiler/function_statement.rb b/lib/typed/compiler/function_statement.rb deleted file mode 100644 index bb7d4520..00000000 --- a/lib/typed/compiler/function_statement.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Typed - module FunctionStatement - - def on_FunctionStatement statement - # return_type , name , parameters, kids , receiver = *statement - raise "Already in method #{@method}" if @method - - args = statement.parameters - - class_method = handle_receiver( statement ) #nil for instance method - - @method = @type.get_instance_method( statement.name ) - if(@method) - #puts "Warning, redefining method #{name}" unless name == :main - #TODO check args / type compatibility - init_method - else - create_method_for(@type, statement.name , args ).init_method - end - @method.source = statement - - process(statement.statements) - - @type = class_method if class_method - @method = nil - # function definition is a statement, does not return any value - return nil - end - - private - - def handle_receiver( statement ) - return nil unless statement.receiver - raise "Not covered #{statement.receiver}" unless ( statement.receiver.first == :self) - class_method = @type - @type = @type.object_class.meta.get_type - class_method - end - end -end diff --git a/lib/typed/tree.rb b/lib/typed/tree.rb index 993ee072..4140b184 100644 --- a/lib/typed/tree.rb +++ b/lib/typed/tree.rb @@ -9,7 +9,7 @@ end ["while_statement", "if_statement" , "return_statement" , "statements", "operator_expression" , "field_access" , "call_site" , "basic_values", - "assignment" , "class_statement" , "function_statement" , "to_code"].each do |code| + "assignment" , "class_statement" , "to_code"].each do |code| require_relative "tree/" + code end diff --git a/lib/typed/tree/function_statement.rb b/lib/typed/tree/function_statement.rb deleted file mode 100644 index 2f4ecbf3..00000000 --- a/lib/typed/tree/function_statement.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Typed - module Tree - class FunctionStatement < Statement - attr_accessor :return_type , :name , :parameters, :statements , :receiver - end - end -end diff --git a/lib/typed/tree/to_code.rb b/lib/typed/tree/to_code.rb index b94cae2a..ec14c634 100644 --- a/lib/typed/tree/to_code.rb +++ b/lib/typed/tree/to_code.rb @@ -20,17 +20,6 @@ module Typed w end - def on_function statement - return_type , name , parameters, statements , receiver = *statement - w = Tree::FunctionStatement.new() - w.return_type = return_type - w.name = name.children.first - w.parameters = process parameters - w.statements = process(statements) - w.receiver = receiver - w - end - def on_parameters statement params = {} statement.children.each do |param , type , name|