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

Method ConvertPosToRowCol

sdk/angelscript/source/as_scriptcode.cpp:100–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void asCScriptCode::ConvertPosToRowCol(size_t pos, int *row, int *col)
101{
102 if( linePositions.GetLength() == 0 )
103 {
104 if( row ) *row = lineOffset;
105 if( col ) *col = 1;
106 return;
107 }
108
109 // Do a binary search in the buffer
110 int max = (int)linePositions.GetLength() - 1;
111 int min = 0;
112 int i = max/2;
113
114 for(;;)
115 {
116 if( linePositions[i] < pos )
117 {
118 // Have we found the largest number < programPosition?
119 if( min == i ) break;
120
121 min = i;
122 i = (max + min)/2;
123 }
124 else if( linePositions[i] > pos )
125 {
126 // Have we found the smallest number > programPoisition?
127 if( max == i ) break;
128
129 max = i;
130 i = (max + min)/2;
131 }
132 else
133 {
134 // We found the exact position
135 break;
136 }
137 }
138
139 if( row ) *row = i + 1 + lineOffset;
140 if( col ) *col = (int)(pos - linePositions[i]) + 1;
141}
142
143bool asCScriptCode::TokenEquals(size_t pos, size_t len, const char *str)
144{

Callers 15

LineInstrMethod · 0.80
CompileStatementBlockMethod · 0.80
MatchFunctionsMethod · 0.80
ErrorMethod · 0.80
WarningMethod · 0.80
InformationMethod · 0.80
PrintMatchingFuncsMethod · 0.80
CompileFunctionMethod · 0.80
CompileFunctionsMethod · 0.80
RegisterMixinClassMethod · 0.80
RegisterClassMethod · 0.80

Calls 1

GetLengthMethod · 0.45

Tested by

no test coverage detected