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

Method GetLineNumber

sdk/angelscript/source/as_context.cpp:1907–1959  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

1905
1906// interface
1907int asCContext::GetLineNumber(asUINT stackLevel, int *column, const char **sectionName)
1908{
1909 if( stackLevel >= GetCallstackSize() ) return asINVALID_ARG;
1910
1911 asCScriptFunction *func;
1912 asDWORD *bytePos;
1913 if( stackLevel == 0 )
1914 {
1915 func = m_currentFunction;
1916 if( func->scriptData == 0 ) return 0;
1917 bytePos = m_regs.programPointer;
1918 }
1919 else
1920 {
1921 asPWORD *s = m_callStack.AddressOf() + (GetCallstackSize()-stackLevel-1)*CALLSTACK_FRAME_SIZE;
1922 func = (asCScriptFunction*)s[1];
1923 if( func->scriptData == 0 ) return 0;
1924 bytePos = (asDWORD*)s[2];
1925
1926 // Subract 1 from the bytePos, because we want the line where
1927 // the call was made, and not the instruction after the call
1928 bytePos -= 1;
1929 }
1930
1931 // For nested calls it is possible that func is null
1932 if( func == 0 )
1933 {
1934 if( column ) *column = 0;
1935 if( sectionName ) *sectionName = 0;
1936 return 0;
1937 }
1938
1939 if (bytePos == 0)
1940 {
1941 // If the context has been Prepared but Execute hasn't been called yet the
1942 // programPointer will be zero. In this case simply use the address of the
1943 // bytecode as starting point
1944 bytePos = func->scriptData->byteCode.AddressOf();
1945 }
1946
1947 int sectionIdx;
1948 asDWORD line = func->GetLineNumber(int(bytePos - func->scriptData->byteCode.AddressOf()), &sectionIdx);
1949 if( column ) *column = (line >> 20);
1950 if( sectionName )
1951 {
1952 asASSERT( sectionIdx < int(m_engine->scriptSectionNames.GetLength()) );
1953 if( sectionIdx >= 0 && asUINT(sectionIdx) < m_engine->scriptSectionNames.GetLength() )
1954 *sectionName = m_engine->scriptSectionNames[sectionIdx]->AddressOf();
1955 else
1956 *sectionName = 0;
1957 }
1958 return (line & 0xFFFFF);
1959}
1960
1961// internal
1962bool asCContext::ReserveStackSpace(asUINT size)

Callers 12

SetInternalExceptionMethod · 0.45
LineCallbackFunction · 0.45
LineCallback2Function · 0.45
LineCallback3Function · 0.45
LineCallback4Function · 0.45
ExceptionCallbackFunction · 0.45
TestLineNumberMethod · 0.45
test_debug.cppFile · 0.45
TestFunction · 0.45
TestFunction · 0.45
AssertFunction · 0.45
ExecuteScriptFunction · 0.45

Calls 2

AddressOfMethod · 0.45
GetLengthMethod · 0.45

Tested by 10

LineCallbackFunction · 0.36
LineCallback2Function · 0.36
LineCallback3Function · 0.36
LineCallback4Function · 0.36
ExceptionCallbackFunction · 0.36
TestLineNumberMethod · 0.36
TestFunction · 0.36
TestFunction · 0.36
AssertFunction · 0.36
ExecuteScriptFunction · 0.36