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

Method SetProgramPointer

sdk/angelscript/source/as_context.cpp:1653–1702  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1651
1652// internal
1653void asCContext::SetProgramPointer()
1654{
1655 // This shouldn't be called if the program pointer is already set
1656 asASSERT(m_regs.programPointer == 0);
1657
1658 // Can't set up the program pointer if no function has been set yet
1659 asASSERT(m_currentFunction != 0);
1660
1661 // If the function is a delegate then get then set the function and object from the delegate
1662 if( m_currentFunction->funcType == asFUNC_DELEGATE )
1663 {
1664 // Push the object pointer onto the stack
1665 asASSERT( m_regs.stackPointer - AS_PTR_SIZE >= m_stackBlocks[m_stackIndex] );
1666 m_regs.stackPointer -= AS_PTR_SIZE;
1667 m_regs.stackFramePointer -= AS_PTR_SIZE;
1668 *(asPWORD*)m_regs.stackPointer = asPWORD(m_currentFunction->objForDelegate);
1669
1670 // Make the call to the delegated object method
1671 m_currentFunction = m_currentFunction->funcForDelegate;
1672 }
1673
1674 m_currentFunction = GetRealFunc(m_currentFunction, (void**)m_regs.stackFramePointer);
1675
1676 if( m_currentFunction->funcType == asFUNC_SCRIPT )
1677 {
1678 m_regs.programPointer = m_currentFunction->scriptData->byteCode.AddressOf();
1679
1680 // Set up the internal registers for executing the script function
1681 PrepareScriptFunction();
1682 }
1683 else if( m_currentFunction->funcType == asFUNC_SYSTEM )
1684 {
1685 asASSERT(m_status != asEXECUTION_DESERIALIZATION);
1686
1687 // The current function is an application registered function
1688
1689 // Call the function directly
1690 CallSystemFunction(m_currentFunction->id, this);
1691
1692 // Was the call successful?
1693 if( m_status == asEXECUTION_ACTIVE )
1694 m_status = asEXECUTION_FINISHED;
1695 }
1696 else
1697 {
1698 // This can happen, e.g. if attempting to call a template function
1699 if( m_status != asEXECUTION_EXCEPTION )
1700 SetInternalException(TXT_NULL_POINTER_ACCESS, false);
1701 }
1702}
1703
1704// interface
1705int asCContext::PushState()

Callers

nothing calls this directly

Calls 2

CallSystemFunctionFunction · 0.85
AddressOfMethod · 0.45

Tested by

no test coverage detected