| 98 | } |
| 99 | |
| 100 | void 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 | |
| 143 | bool asCScriptCode::TokenEquals(size_t pos, size_t len, const char *str) |
| 144 | { |
no test coverage detected