-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiler_chardata.qdi
96 lines (67 loc) · 1.84 KB
/
compiler_chardata.qdi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
Таблица констант.
*/
/*****************************************************************************/
word _nChar;
char Char[_nCHAR];
/*****************************************************************************/
/* Сохраняет последовательность байт в массиве Char и возвращает индекс начала. */
word SaveString(char @Str; word Size)
uintptr u_Str = uintptr(@Str);
if (u_Str >= uintptr(@Char[0])) & (u_Str + Size < uintptr(@Char[_nChar])) then
return u_Str - uintptr(@Char[0]);
end:if
word i = 0;
word j = 0;
if chardata_merge_len < _nChar then
i = _nChar - chardata_merge_len;
end:if
word offset = i;
while j < Size do
if i >= _nChar then
exit;
end
if Str[j] != Char[i] then
inc i;
offset = i;
j = 0;
else
inc i;
inc j;
end:if
end:while
if j == Size then
return offset;
end
word R = _nChar;
word Tail = Size - j;
_nChar = _nChar + Tail;
if _nChar >= _nCHAR then
StopMemory();
end
memcpy(@Char[R], @Str[j], Tail);
return R;
end
/*****************************************************************************/
/* Сохраняет #0-строку, включая завершающий 0. */
word SaveString0(char @Str)
return SaveString(@Str, strlen(@Str) + 1);
end
/*****************************************************************************/
char @str_saved(word Value)
word Index = SaveString0(@str(Value));
return @Char[Index];
end
/*****************************************************************************/
void InitCharData()
Char[0] = #0;
_nChar = 1;
end
/*****************************************************************************/
word CharDataUsed()
return _nChar;
end
word CharDataTotal()
return _nCHAR;
end
/*****************************************************************************/