sanyaade-g2g-repos / recursive-ascent

Automatically exported from code.google.com/p/recursive-ascent
0 stars 0 forks source link

Implement more compact structure for Source.Position #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Problem origin.
Often in reengineering we must know a position of cpecified token. Usually (the 
most convinient) it is a trinity (file name, line, column). But this structure 
is too memory-hungry, because:
1) file name is a pointer on string - 8 bytes on x64.
2) line and column are int - 8 bytes together;
3) trinity is .NET class, requesting 24 bytes on x64.
40 bytes together. Attached to each node, it can easily be a half of memory, 
taken by syntax tree.

There is a solution, reducing these requirements to 8 bytes. All information 
can be compressed in int64 number.
1) All file names are arrenged in array. We can assume, then there is not more, 
then 2^f different files.
2) Assume, there is not more then 2^c columns and 2^l lines in each file.
So, if set f=17,c=17,l=30, we can see, int64 is enough for storing entire 
position.

Problem statement itself.
Implement library, compressing and decompressing position between compact and 
human-sensitive form.
1) int64 <-> Described trinity (file id instead name)
2) Possibility to specify f,c,l (with other names, of course)
3) Implemet all in separate library in YC.
4) Example of usage.
5) If everything is ok, embed structure in YC.

Original issue reported on code.google.com by dimo...@gmail.com on 23 Oct 2012 at 3:35

GoogleCodeExporter commented 9 years ago
Теперь необходимо реализовать карту 
переносов (массив, где для каждой строки 
будет храниться ее offset от начала файла). 
Таким образом, можно будет быстро 
вычислять по строке и колонке AbsoluteOffset (за 
O(1)) и наоборот (за O(log LinesCount)).
Собственно, реализовать функции для 
описанных вычислений.
Тест для того, что это работает с готовой 
картой переносов.
Тест, в котором как-то будет разбираться 
файл, для него строиться карта, и снова 
проверка вычислений. Разбор файла сделать 
любым, чем проще - тем лучше.

Original comment by dimo...@gmail.com on 22 Nov 2012 at 9:14

GoogleCodeExporter commented 9 years ago
Ready Offset Map

Original comment by 2x2.4raymon on 8 Mar 2013 at 10:35

GoogleCodeExporter commented 9 years ago
Исправить замечания по коду.

Original comment by rsdpisuy@gmail.com on 9 Mar 2013 at 5:59

GoogleCodeExporter commented 9 years ago
Исправлены замечания
Добавлен тест для пустого файла

Original comment by 2x2.4raymon on 9 Mar 2013 at 8:29

GoogleCodeExporter commented 9 years ago

Original comment by 2x2.4raymon on 11 Mar 2013 at 2:24