coming together, more and more each day

This commit is contained in:
Torsten Ruger
2014-05-13 21:06:12 +03:00
parent f6711ea49c
commit 04af367bc0
8 changed files with 45 additions and 28 deletions

View File

@@ -45,20 +45,21 @@ module Vm
def add_function function
raise "not a function #{function}" unless function.is_a? Function
raise "syserr " unless function.name.is_a? Symbol
@functions << function
end
def get_function name
name = name.to_sym
@functions.detect{ |f| (f.name == name) }
@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 = Core::Kernel.send(name)
raise "no such function '#{name}'" if fun == nil
@functions << fun
end
fun