interface
| 1905 | |
| 1906 | // interface |
| 1907 | int 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()), §ionIdx); |
| 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 |
| 1962 | bool asCContext::ReserveStackSpace(asUINT size) |