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

Method SetStateRegisters

sdk/angelscript/source/as_context.cpp:548–602  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

546
547// interface
548int asCContext::SetStateRegisters(asUINT stackLevel, asIScriptFunction *callingSystemFunction, asIScriptFunction *initialFunction, asDWORD originalStackPointer, asDWORD argumentsSize, asQWORD valueRegister, void *objectRegister, asITypeInfo *objectType)
549{
550 if( m_status != asEXECUTION_DESERIALIZATION)
551 {
552 asCString str;
553 str.Format(TXT_FAILED_IN_FUNC_s_s_d, "SetStateRegisters", errorNames[-asCONTEXT_ACTIVE], asCONTEXT_ACTIVE);
554 m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
555 return asCONTEXT_ACTIVE;
556 }
557
558 if (stackLevel >= GetCallstackSize())
559 return asINVALID_ARG;
560
561 if( stackLevel == 0 )
562 {
563 m_callingSystemFunction = reinterpret_cast<asCScriptFunction*>(callingSystemFunction);
564 m_initialFunction = reinterpret_cast<asCScriptFunction*>(initialFunction);
565 m_originalStackPointer = DeserializeStackPointer(originalStackPointer);
566 m_originalStackIndex = DetermineStackIndex(m_originalStackPointer);
567 if (m_originalStackIndex >= m_stackBlocks.GetLength())
568 {
569 asCString str;
570 str.Format(TXT_FAILED_IN_FUNC_s_s_d, "SetStateRegisters", errorNames[-asCONTEXT_ACTIVE], asCONTEXT_ACTIVE);
571 m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
572 return asINVALID_ARG;
573 }
574 m_argumentsSize = argumentsSize; // TODO: Calculate this from the initialFunction so it doesn't need to be serialized
575
576 // Need to push the value of registers so they can be restored
577 m_regs.valueRegister = valueRegister;
578 m_regs.objectRegister = objectRegister;
579 m_regs.objectType = objectType;
580 }
581 else
582 {
583 asPWORD *tmp = &m_callStack[m_callStack.GetLength() - CALLSTACK_FRAME_SIZE*stackLevel];
584
585 if(tmp[0] != 0)
586 return asERROR; // TODO: This is not really an error. It just means that the stackLevel doesn't represent a pushed state
587
588 tmp[0] = 0;
589 tmp[1] = (asPWORD)callingSystemFunction;
590 tmp[2] = (asPWORD)initialFunction;
591 tmp[3] = (asPWORD)DeserializeStackPointer(originalStackPointer);
592 tmp[4] = (asPWORD)argumentsSize; // TODO: Calculate this from the initialFunction so it doesn't need to be serialized
593
594 // Need to push the value of registers so they can be restored
595 tmp[5] = (asPWORD)asDWORD(valueRegister);
596 tmp[6] = (asPWORD)asDWORD(valueRegister>>32);
597 tmp[7] = (asPWORD)objectRegister;
598 tmp[8] = (asPWORD)objectType;
599 }
600
601 return asSUCCESS;
602}
603
604// interface
605int asCContext::SetCallStateRegisters(asUINT stackLevel, asDWORD stackFramePointer, asIScriptFunction *_currentFunction, asDWORD _programPointer, asDWORD stackPointer, asDWORD stackIndex)

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