Class: Ruby2CExtension::CFunction::ClassModuleScope

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby2cext/c_function.rb

Direct Known Subclasses

ToplevelScope

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

Instance Method Summary collapse

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(outer, scope_node, class_mod_var, is_class) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/ruby2cext/c_function.rb', line 234

def self.compile(outer, scope_node, class_mod_var, is_class)
	ensure_node_type(scope_node, :scope)
	vmode_methods = Scopes::Scope::VMODES.dup
	vmode_methods.delete :module_function if is_class
	cf = self.new(outer.compiler, Scopes::Scope.new(scope_node.last[:tbl], vmode_methods))
	cf.instance_eval {
		block = make_block(scope_node.last[:next])
		l "return #{comp(block)};"
	}
	body = "#{cf.init_c_code}\n#{cf.get_lines}"
	args = []
	args << "VALUE self" if cf.need_self
	args << "NODE *cref" if cf.need_cref
	sig = "static VALUE FUNNAME(#{args.join(", ")}) {"
	fname = cf.compiler.add_fun("#{sig}\n#{body}\n}", "class_module_scope")
	outer.instance_eval {
		args = []
		args << class_mod_var if cf.need_self
		args << "NEW_NODE(NODE_CREF, #{class_mod_var}, 0, #{get_cref})" if cf.need_cref
		assign_res("#{fname}(#{args.join(", ")})")
	}
	"res"
end

Instance Method Details

#get_cref_implObject



258
259
260
# File 'lib/ruby2cext/c_function.rb', line 258

def get_cref_impl
	"cref"
end