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

Method GetCalledFunction

sdk/angelscript/source/as_scriptfunction.cpp:1881–1939  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1879
1880// internal
1881asCScriptFunction* asCScriptFunction::GetCalledFunction(asDWORD programPos)
1882{
1883 if (scriptData == 0)
1884 return 0;
1885
1886 asBYTE bc = *(asBYTE*)&scriptData->byteCode[programPos];
1887
1888 if (bc == asBC_CALL ||
1889 bc == asBC_CALLSYS ||
1890 bc == asBC_Thiscall1 ||
1891 bc == asBC_CALLINTF)
1892 {
1893 // Find the function from the function id in bytecode
1894 int funcId = asBC_INTARG(&scriptData->byteCode[programPos]);
1895 return engine->scriptFunctions[funcId];
1896 }
1897 else if (bc == asBC_ALLOC)
1898 {
1899 // Find the function from the function id in the bytecode
1900 int funcId = asBC_INTARG(&scriptData->byteCode[programPos + AS_PTR_SIZE]);
1901 return engine->scriptFunctions[funcId];
1902 }
1903 else if (bc == asBC_CALLBND)
1904 {
1905 // Find the function from the engine's bind array
1906 int funcId = asBC_INTARG(&scriptData->byteCode[programPos]);
1907 return engine->importedFunctions[funcId & ~FUNC_IMPORTED]->importedFunctionSignature;
1908 }
1909 else if (bc == asBC_CallPtr)
1910 {
1911 asUINT v;
1912 int var = asBC_SWORDARG0(&scriptData->byteCode[programPos]);
1913
1914 // Find the funcdef from the local variable
1915 for (v = 0; v < scriptData->variables.GetLength(); v++)
1916 if (scriptData->variables[v]->stackOffset == var)
1917 return CastToFuncdefType(scriptData->variables[v]->type.GetTypeInfo())->funcdef;
1918
1919 // Look in parameters
1920 int paramPos = 0;
1921 if (objectType)
1922 paramPos -= AS_PTR_SIZE;
1923 if (DoesReturnOnStack())
1924 paramPos -= AS_PTR_SIZE;
1925 for (v = 0; v < parameterTypes.GetLength(); v++)
1926 {
1927 if (var == paramPos)
1928 {
1929 if (parameterTypes[v].IsFuncdef())
1930 return CastToFuncdefType(parameterTypes[v].GetTypeInfo())->funcdef;
1931 else
1932 return 0;
1933 }
1934 paramPos -= parameterTypes[v].GetSizeOnStackDWords();
1935 }
1936 }
1937
1938 return 0;

Callers 2

CalculateStackNeededMethod · 0.80
AdjustGetOffsetMethod · 0.80

Calls 5

CastToFuncdefTypeFunction · 0.85
GetTypeInfoMethod · 0.80
IsFuncdefMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
GetLengthMethod · 0.45

Tested by

no test coverage detected