Class: CastOff::Compiler::SimpleIR::YieldIR
- Inherits:
-
CallIR
- Object
- IR
- CallIR
- CastOff::Compiler::SimpleIR::YieldIR
show all
- Defined in:
- lib/cast_off/compile/ir/call_ir.rb
Constant Summary
collapse
- SPLATCALL_TEMPLATE_YIELD =
ERB.new("%bug() unless param.size > 0\n {\n int argc = <%= @argc - 1 %>;\n VALUE buf[<%= SPLATCALL_LIMIT %>]; /* FIXME */\n VALUE *argv = buf;\n%splat_param = param.last()\n%normal_param = param.slice(0, param.size() - 1)\n VALUE ary = <%= splat_param %>;\n%if splat_param.is_just?(Array)\n% is_ary = true\n VALUE tmp = ary;\n%else\n% is_ary = false\n VALUE tmp = rb_check_convert_type(ary, T_ARRAY, \"Array\", \"to_a\");\n%end\n\n%normal_param.each_with_index do |p, i|\n argv[<%= i %>] = <%= p %>;\n%end\n%unless is_ary\n if (NIL_P(tmp)) {\n/* do nothing */\n } else {\n%else\n {\n%end\nVALUE *ptr;\nlong i, len = RARRAY_LEN(tmp);\nptr = RARRAY_PTR(tmp);\nargc += len;\nif (UNLIKELY(argc > <%= SPLATCALL_LIMIT %>)) {\n VALUE *newbuf = ALLOCA_N(VALUE, argc);\n%normal_param.size.times do |i|\n newbuf[i] = argv[i];\n%end\n argv = newbuf;\n}\nfor (i = 0; i < len; i++) {\n argv[<%= normal_param.size %> + i] = ptr[i];\n}\n }\n rb_yield_values2(argc, argv);\n }\n", 0, '%-', 'io')
Constants included
from Instruction
Instruction::BlockSeparator, Instruction::BranchInstruction, Instruction::IgnoreInstruction, Instruction::JumpOrReturnInstruction, Instruction::SupportInstruction, Instruction::TypeInfoUser, Instruction::VM_CALL_ARGS_BLOCKARG_BIT, Instruction::VM_CALL_ARGS_SPLAT_BIT, Instruction::VM_CALL_FCALL_BIT, Instruction::VM_CALL_OPT_SEND_BIT, Instruction::VM_CALL_SUPER_BIT, Instruction::VM_CALL_TAILCALL_BIT, Instruction::VM_CALL_TAILRECURSION_BIT, Instruction::VM_CALL_VCALL_BIT
Instance Attribute Summary
Attributes inherited from CallIR
#argc, #result_variable, #return_value, #values, #variables, #variables_without_result
Attributes inherited from IR
#alias, #insn
Instance Method Summary
collapse
Methods inherited from CallIR
#can_not_unbox, #mark, #param_irs, #param_variables, #propergate_boxed_value, #propergate_exact_class, #sampling_return_value, #sampling_return_value?, #unboxing_prelude
Methods included from Util
#bug, #dlog, #todo, #vlog
Methods inherited from IR
#add_sampling_variable, #alive, #alive?, #dispatch_method?, #generate_guard, #get_definition, #get_definition_str, #get_usage, #get_variable, #inlining_target?, #propergate_boxed_value, #reset, #sampling_variable, #set_info, #standard_guard_target, #unboxing_prelude, #vanish, #vanish?
Constructor Details
#initialize(flags, param, argc, return_value, insn, cfg) ⇒ YieldIR
Returns a new instance of YieldIR.
1386
1387
1388
1389
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1386
def initialize(flags, param, argc, return_value, insn, cfg)
super(param, argc, return_value, insn, cfg)
@flags = flags
end
|
Instance Method Details
#harmless?(recv_p) ⇒ Boolean
1468
1469
1470
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1468
def harmless?(recv_p)
false
end
|
#propergate_guard_usage ⇒ Object
1391
1392
1393
1394
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1391
def propergate_guard_usage()
params = param_irs()
params.each{|p| p.need_guard(splatyield?)}
end
|
#should_be_alive? ⇒ Boolean
1472
1473
1474
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1472
def should_be_alive?
true
end
|
#side_effect? ⇒ Boolean
1476
1477
1478
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1476
def side_effect?
true
end
|
#splatyield? ⇒ Boolean
1480
1481
1482
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1480
def splatyield?
(@flags & VM_CALL_ARGS_SPLAT_BIT) != 0
end
|
#to_c(params) ⇒ Object
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1442
def to_c(params)
ret = []
ret << super(params)
param = param_variables()
if splatyield?
ret << SPLATCALL_TEMPLATE_YIELD.trigger(binding)
else
if param.empty?
ret << " #{@return_value} = rb_yield(Qundef);"
else
ret << " #{@return_value} = rb_yield_values(#{param.size}, #{param.join(", ")});"
end
end
ret.join("\n")
end
|
#to_verbose_string ⇒ Object
1460
1461
1462
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1460
def to_verbose_string()
"yield"
end
|
#type_propergation(defs) ⇒ Object
1464
1465
1466
|
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1464
def type_propergation(defs)
@return_value.is_dynamic()
end
|