node/lib/metasm/samples/dynamic_ruby.rb
def compile(ast, klass, method, singleton=false)
		@compiled_func_cache ||= {}

		mname = super(ast, klass, method, singleton)
		return if not mname

		@compiled_func_cache[[klass, method.to_s, singleton]] = @cur_cfunc

		cls = rb_const(nil, klass)
		
		init.statements << fcall("rb_define#{'_singleton' if singleton}_method", cls, method.to_s, @cur_cfunc, method_arity)

		mname
	end
# add a new ruby function to the current @cp
add a new ruby function to the current @cp
add a new ruby function to the current @cp
def compile(ast, klass, method, singleton=false)
		@compiled_func_cache ||= {}
		mname = super(ast, klass, method, singleton)
		return if not mname
		@compiled_func_cache[[klass, method.to_s, singleton]] = @cur_cfunc
		cls = rb_const(nil, klass)
		init.statements << fcall("rb_define#{'_singleton' if singleton}_method", cls, method.to_s, @cur_cfunc, method_arity)
		mname
	end
def compile ( ast , klass , method , singleton = false ) @compiled_func_cache ||= { } mname = super ( ast , klass , method , singleton ) return if not mname @compiled_func_cache [ [ klass , method . to_s , singleton ] ] = @cur_cfunc cls = rb_const ( nil , klass ) init . statements << fcall ( "rb_define#{'_singleton' if singleton}_method" , cls , method . to_s , @cur_cfunc , method_arity ) mname end
add a new ruby function to the current @cp
add a new ruby function to the current @cp
ast
klass
method
singleton