MCPcopy Create free account
hub / github.com/anjo76/angelscript / SetCallStateRegisters

Method SetCallStateRegisters

sdk/angelscript/source/as_context.cpp:605–663  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

603
604// interface
605int asCContext::SetCallStateRegisters(asUINT stackLevel, asDWORD stackFramePointer, asIScriptFunction *_currentFunction, asDWORD _programPointer, asDWORD stackPointer, asDWORD stackIndex)
606{
607 if( m_status != asEXECUTION_DESERIALIZATION)
608 {
609 asCString str;
610 str.Format(TXT_FAILED_IN_FUNC_s_s_d, "SetCallStateRegisters", errorNames[-asCONTEXT_ACTIVE], asCONTEXT_ACTIVE);
611 m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
612 return asCONTEXT_ACTIVE;
613 }
614
615 if (stackLevel >= GetCallstackSize())
616 return asINVALID_ARG;
617
618 // TODO: The arg _currentFunction is just used in debug mode to validate that it is the same that is already given in m_currentFunction or on the call stack. Do we really need to take this argument?
619 asCScriptFunction *currentFunction = static_cast<asCScriptFunction*>(_currentFunction);
620
621 if( currentFunction->funcType == asFUNC_DELEGATE )
622 {
623 currentFunction = currentFunction->funcForDelegate;
624 }
625
626 if( stackLevel == 0 )
627 {
628 asASSERT(currentFunction->signatureId == m_currentFunction->signatureId);
629 currentFunction = m_currentFunction;
630
631 asDWORD *programPointer = currentFunction->scriptData->byteCode.AddressOf();
632 if(currentFunction->scriptData->byteCode.GetLength() > _programPointer)
633 {
634 programPointer += _programPointer;
635 }
636
637 m_regs.stackFramePointer = DeserializeStackPointer(stackFramePointer);
638 m_regs.programPointer = programPointer;
639 m_regs.stackPointer = DeserializeStackPointer(stackPointer);
640 m_stackIndex = stackIndex;
641 }
642 else
643 {
644 asPWORD *tmp = &m_callStack[m_callStack.GetLength() - CALLSTACK_FRAME_SIZE*stackLevel];
645
646 asASSERT(currentFunction->signatureId == ((asCScriptFunction*)tmp[1])->signatureId);
647 currentFunction = ((asCScriptFunction*)tmp[1]);
648
649 asDWORD *programPointer = currentFunction->scriptData->byteCode.AddressOf();
650 if(currentFunction->scriptData->byteCode.GetLength() > _programPointer)
651 {
652 programPointer += _programPointer;
653 }
654
655 tmp[0] = (asPWORD)DeserializeStackPointer(stackFramePointer);
656 // tmp[1] = (asPWORD)(currentFunction);
657 tmp[2] = (asPWORD)programPointer;
658 tmp[3] = (asPWORD)DeserializeStackPointer(stackPointer);
659 tmp[4] = (asPWORD)stackIndex;
660 }
661
662 return asSUCCESS;

Callers 1

DeserializeMethod · 0.80

Calls 4

WriteMessageMethod · 0.80
FormatMethod · 0.45
AddressOfMethod · 0.45
GetLengthMethod · 0.45

Tested by 1

DeserializeMethod · 0.64