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

Method FindNextLineWithCode

sdk/angelscript/source/as_scriptfunction.cpp:844–889  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

842
843// interface
844int asCScriptFunction::FindNextLineWithCode(int line) const
845{
846 if( scriptData == 0 ) return -1;
847 if( scriptData->lineNumbers.GetLength() == 0 ) return -1;
848
849 // The line numbers for constructors are not in order due to the way
850 // class members can be initialized directly in the declaration
851 if( objectType && objectType->name == name )
852 {
853 // Sort all line numbers before looking for the next
854 asCArray<int> lineNbrs;
855 for( asUINT n = 1; n < scriptData->lineNumbers.GetLength(); n += 2 )
856 lineNbrs.PushLast(scriptData->lineNumbers[n]&0xFFFFF);
857
858 struct C
859 {
860 static int cmp(const void *a, const void *b) { return *(int*)a - *(int*)b; }
861 };
862 std::qsort(&lineNbrs[0], lineNbrs.GetLength(), sizeof(int), C::cmp);
863
864 if( line < lineNbrs[0] && line < (scriptData->declaredAt&0xFFFFF)) return -1;
865 if( line > lineNbrs[lineNbrs.GetLength()-1] ) return -1;
866
867 // Find the line with code on or right after the input line
868 // TODO: optimize: Do binary search
869 for( asUINT n = 0; n < lineNbrs.GetLength(); n++ )
870 if( line <= lineNbrs[n] )
871 return lineNbrs[n];
872 }
873 else
874 {
875 // Check if given line is outside function
876 if( line < (scriptData->declaredAt&0xFFFFF) ) return -1;
877 if( line > (scriptData->lineNumbers[scriptData->lineNumbers.GetLength()-1]&0xFFFFF) ) return -1;
878
879 // Find the line with code on or right after the input line
880 // TODO: optimize: Do binary search instead
881 for( asUINT n = 1; n < scriptData->lineNumbers.GetLength(); n += 2 )
882 {
883 if( line <= (scriptData->lineNumbers[n]&0xFFFFF) )
884 return (scriptData->lineNumbers[n]&0xFFFFF);
885 }
886 }
887
888 return -1;
889}
890
891// interface
892int asCScriptFunction::GetDeclaredAt(const char** scriptSection, int* row, int* col) const

Callers 2

CheckBreakPointMethod · 0.80
test_debug.cppFile · 0.80

Calls 2

PushLastMethod · 0.80
GetLengthMethod · 0.45

Tested by

no test coverage detected