Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 18d204f

Browse files
committed
libscript: Spanify MCScriptBytecodeOp_InvokeIndirect::ExternalInvoke()
1 parent 7fe3ca9 commit 18d204f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

libscript/src/script-bytecode.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,7 @@ struct MCScriptBytecodeOp_InvokeIndirect
504504
ExternalInvoke(ctxt,
505505
(MCHandlerRef)t_handler,
506506
t_result_reg,
507-
t_argument_regs,
508-
t_argument_count);
507+
MCMakeSpan(t_argument_regs, t_argument_count));
509508
}
510509
}
511510

@@ -557,22 +556,22 @@ struct MCScriptBytecodeOp_InvokeIndirect
557556
static void ExternalInvoke(MCScriptExecuteContext& ctxt,
558557
MCHandlerRef p_handler,
559558
uindex_t p_result_reg,
560-
const uindex_t *p_argument_regs,
561-
uindex_t p_argument_count)
559+
MCSpan<const uindex_t> p_argument_regs)
562560
{
563561
// An 'external' handler-ref could be from anywhere and so we must use
564562
// the handler-ref API. Unfortunately, this does mean we have to pack
565563
// up the values into a list of valuerefs, then unpack them again after-
566564
// wards.
567565

568-
MCAutoValueRefArray t_linear_args;
569-
if (!t_linear_args.Resize(p_argument_count))
566+
MCAutoValueRefArray t_linear_args_array;
567+
if (!t_linear_args_array.Resize(p_argument_regs.size()))
570568
{
571569
ctxt.Rethrow();
572570
return;
573571
}
572+
MCSpan<MCValueRef> t_linear_args(t_linear_args_array.Span());
574573

575-
for(uindex_t t_arg_index = 0; t_arg_index < p_argument_count; t_arg_index++)
574+
for(uindex_t t_arg_index = 0; t_arg_index < p_argument_regs.size(); t_arg_index++)
576575
{
577576
t_linear_args[t_arg_index] = ctxt.CheckedFetchRegister(p_argument_regs[t_arg_index]);
578577
if (t_linear_args[t_arg_index] == nil)
@@ -581,8 +580,8 @@ struct MCScriptBytecodeOp_InvokeIndirect
581580

582581
MCAutoValueRef t_result;
583582
if (!MCHandlerInvoke(p_handler,
584-
t_linear_args.Ptr(),
585-
p_argument_count,
583+
t_linear_args.data(),
584+
t_linear_args.size(),
586585
&t_result))
587586
{
588587
ctxt.Rethrow();
@@ -592,7 +591,7 @@ struct MCScriptBytecodeOp_InvokeIndirect
592591
MCTypeInfoRef t_signature;
593592
t_signature = MCValueGetTypeInfo(p_handler);
594593

595-
for(uindex_t t_arg_index = 0; t_arg_index < p_argument_count; t_arg_index++)
594+
for(uindex_t t_arg_index = 0; t_arg_index < p_argument_regs.size(); t_arg_index++)
596595
{
597596
if (MCHandlerTypeInfoGetParameterMode(t_signature,
598597
t_arg_index) == kMCHandlerTypeFieldModeIn)

0 commit comments

Comments
 (0)