trying to get function calls to work (but will have to rework regeister handling)

This commit is contained in:
Torsten Ruger
2014-05-10 15:24:56 +03:00
parent 7d69132d90
commit 79a28ac5fa
9 changed files with 25 additions and 7 deletions

View File

@@ -43,14 +43,21 @@ module Vm
@objects << o # TODO check type , no basic values allowed (must be wrapped)
end
def add_function function
raise "not a function #{function}" unless function.is_a? Function
@functions << function
end
def get_function name
@functions.detect{ |f| (f.name == name) && (f.class == Function) }
name = name.to_sym
@functions.detect{ |f| (f.name == name) }
end
# preferred way of creating new functions (also forward declarations, will flag unresolved later)
def get_or_create_function name
fun = get_function name
unless fun
puts @functions.inspect
fun = Function.new(name)
block = Core::Kernel.send(name)
fun.set_body block