Class: Ruby2CExtension::CFunction::ToplevelScope

Inherits:
ClassModuleScope show all
Defined in:
lib/ruby2cext/c_function.rb

Constant Summary

Constants included from Ruby2CExtension::CommonNodeComp

Ruby2CExtension::CommonNodeComp::NON_ITER_PROC

Instance Attribute Summary

Attributes inherited from Base

#closure_tbl, #compiler, #need_class, #need_cref, #need_res, #need_self, #need_wrap, #scope

Class Method Summary collapse

Methods inherited from ClassModuleScope

#get_cref_impl

Methods inherited from Base

#add_closure_need, #add_helper, #assign_res, #break_allowed?, #closure_buid_c_code, #comp_break, #comp_next, #comp_redo, #comp_retry, #comp_return, #get_cbase, #get_class, #get_closure_ary_var, #get_cref, #get_cvar_cbase, #get_lines, #get_self, #get_wrap_ptr, #global_const, #global_var, #in_while?, #init_c_code, #initialize, #l, #need_closure_ptr, #next_allowed?, #pop_while, #push_while, #redo_allowed?, #return_allowed?, #sym, #un, #wrap_buid_c_code

Methods included from Tools::EnsureNodeTypeMixin

#ensure_node_type

Methods included from Ruby2CExtension::CommonNodeComp

#build_args, #build_c_arr, #c_else, #c_for, #c_if, #c_scope, #c_scope_res, #c_static_once, #comp, #comp_alias, #comp_and, #comp_argscat, #comp_argspush, #comp_array, #comp_attrasgn, #comp_back_ref, #comp_begin, #comp_block, #comp_block_pass, #comp_break, #comp_call, #comp_case, #comp_cdecl, #comp_class, #comp_colon2, #comp_colon3, #comp_const, #comp_cvar, #comp_cvasgn, #comp_cvdecl, #comp_dasgn, #comp_dasgn_curr, #comp_defined, #comp_defn, #comp_defs, #comp_dot2, #comp_dot3, #comp_dregx, #comp_dregx_once, #comp_dstr, #comp_dsym, #comp_dvar, #comp_dxstr, #comp_ensure, #comp_evstr, #comp_false, #comp_fcall, #comp_flip2, #comp_flip3, #comp_for, #comp_gasgn, #comp_gvar, #comp_hash, #comp_iasgn, #comp_if, #comp_iter, #comp_ivar, #comp_lasgn, #comp_lit, #comp_lvar, #comp_masgn, #comp_match, #comp_match2, #comp_match3, #comp_module, #comp_next, #comp_nil, #comp_not, #comp_nth_ref, #comp_op_asgn1, #comp_op_asgn2, #comp_op_asgn_and, #comp_op_asgn_or, #comp_or, #comp_postexe, #comp_redo, #comp_rescue, #comp_retry, #comp_return, #comp_sclass, #comp_self, #comp_splat, #comp_str, #comp_super, #comp_svalue, #comp_to_ary, #comp_true, #comp_undef, #comp_until, #comp_valias, #comp_vcall, #comp_when, #comp_while, #comp_xstr, #comp_yield, #comp_zarray, #comp_zsuper, #do_funcall, #get_global_entry, #handle_assign, #handle_dot, #handle_dyn_str, #handle_flip, #handle_iter, #handle_method_args, #handle_when, #helper_class_module_check, #helper_super_allowed_check, #make_block, #make_class_prefix

Constructor Details

This class inherits a constructor from Ruby2CExtension::CFunction::Base

Class Method Details

.compile(compiler, scope_node, private_vmode = true) ⇒ Object



265
266
267
268
269
270
271
272
273
274
275
# File 'lib/ruby2cext/c_function.rb', line 265

def self.compile(compiler, scope_node, private_vmode = true)
	ensure_node_type(scope_node, :scope)
	cf = self.new(compiler, Scopes::Scope.new(scope_node.last[:tbl], [:public, :private], private_vmode))
	cf.instance_eval {
		block = make_block(scope_node.last[:next])
		l "#{comp(block)};"
	}
	body = "#{cf.init_c_code}\n#{cf.get_lines}"
	sig = "static void FUNNAME(VALUE self, NODE *cref) {"
	cf.compiler.add_fun("#{sig}\n#{body}\n}", "toplevel_scope") # and return the function name
end