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

Commit d5c710c

Browse files
committed
libscript: Spanify MCScriptExecuteContext::PushFrame()
1 parent 1e7327b commit d5c710c

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

libscript/src/script-bytecode.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ struct MCScriptBytecodeOp_Invoke
322322
ctxt.PushFrame(t_resolved_instance,
323323
static_cast<MCScriptHandlerDefinition *>(t_resolved_definition),
324324
t_result_reg,
325-
t_argument_regs,
326-
t_argument_count);
325+
MCMakeSpan(t_argument_regs, t_argument_count));
327326
}
328327
break;
329328

@@ -544,8 +543,7 @@ struct MCScriptBytecodeOp_InvokeIndirect
544543
ctxt.PushFrame(t_handler_instance,
545544
static_cast<MCScriptHandlerDefinition *>(t_handler_def),
546545
p_result_reg,
547-
p_argument_regs,
548-
p_argument_count);
546+
MCMakeSpan(p_argument_regs, p_argument_count));
549547
}
550548
break;
551549

libscript/src/script-execute.hpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ class MCScriptExecuteContext
133133
void PushFrame(MCScriptInstanceRef instance,
134134
MCScriptHandlerDefinition *handler,
135135
uindex_t result_reg,
136-
const uindex_t *argument_regs,
137-
uindex_t argument_count);
136+
MCSpan<const uindex_t> argument_regs);
138137

139138
// Pop the current activation frame and set the return value to the contents
140139
// of the given register. If result_reg is UINDEX_MAX, then it means there is
@@ -687,8 +686,7 @@ inline void
687686
MCScriptExecuteContext::PushFrame(MCScriptInstanceRef p_instance,
688687
MCScriptHandlerDefinition *p_handler_def,
689688
uindex_t p_result_reg,
690-
const uindex_t *p_argument_regs,
691-
uindex_t p_argument_count)
689+
MCSpan<const uindex_t> p_argument_regs)
692690
{
693691
if (m_error)
694692
{
@@ -726,11 +724,11 @@ MCScriptExecuteContext::PushFrame(MCScriptInstanceRef p_instance,
726724
p_handler_def);
727725

728726
// Check the parameter count.
729-
if (MCHandlerTypeInfoGetParameterCount(t_signature) != p_argument_count)
727+
if (MCHandlerTypeInfoGetParameterCount(t_signature) != p_argument_regs.size())
730728
{
731729
ThrowWrongNumberOfArguments(p_instance,
732730
p_handler_def,
733-
p_argument_count);
731+
p_argument_regs.size());
734732
return;
735733
}
736734

@@ -802,16 +800,16 @@ MCScriptExecuteContext::PushFrame(MCScriptInstanceRef p_instance,
802800
// caller registers that were passed so we can copy back at the end.
803801
if (t_needs_mapping)
804802
{
805-
if (!MCMemoryNewArray(p_argument_count,
803+
if (!MCMemoryNewArray(p_argument_regs.size(),
806804
t_new_frame->mapping))
807805
{
808806
Rethrow();
809807
return;
810808
}
811809

812810
MCMemoryCopy(t_new_frame->mapping,
813-
p_argument_regs,
814-
p_argument_count * sizeof(p_argument_regs[0]));
811+
p_argument_regs.data(),
812+
p_argument_regs.sizeBytes());
815813
}
816814

817815
// Finally, make the new frame the current frame and set the

0 commit comments

Comments
 (0)