remove function statements

functions need to be defined a level up
This commit is contained in:
Torsten Ruger
2016-12-17 18:28:42 +02:00
parent 4875d3aea7
commit ffb69a2c55
5 changed files with 2 additions and 60 deletions

View File

@ -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