-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend_dict.qdi
150 lines (116 loc) · 3.77 KB
/
frontend_dict.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*****************************************************************************/
void Word(char @Name)
word p = DictMakeWord(@Name);
DictAddToNamespace(p, pKeywordsNamespace);
end
word BaseType(char @Name; byte TypeDomain; word Size)
word p = DictMakeBaseType(@Name, TypeDomain, Size);
DictAddToNamespace(p, pEnteredNamespace);
return p;
end
/*****************************************************************************/
word ResolveInNamespace(char @Buff; word pNamespace)
return FindInNamespace(@Buff, pNamespace);
end
word ResolveGlobal(char @Buff; word @_pNamespace)
/* Пробуем разрешить имя относительно текущего пространства имён */
word pNamespace = pEnteredNamespace;
word pName = ResolveInNamespace(@Buff, pNamespace);
if pName == nDICT & pNamespace != pGlobalNamespace then
/* Пробуем разрешить имя относительно глобального пространства имён */
pNamespace = pGlobalNamespace;
pName = ResolveInNamespace(@Buff, pNamespace);
end
if pName == nDICT then
when @_pNamespace != NULL:
_pNamespace = pEnteredNamespace;
return pName;
end
while true do
Scan(@Buff);
if !Dict_IsType(pName) | str_ne(@Buff,".") then
when @_pNamespace != NULL:
_pNamespace = pNamespace;
return pName;
end
Scan(@Buff);
pNamespace = pName;
pName = ResolveInNamespace(@Buff, pNamespace);
if pName == nDICT then
when @_pNamespace != NULL:
_pNamespace = pNamespace;
return pName;
end
end:while
end
void CheckDuplicateInNamespace(char @Buff; word pNamespace)
word pDuplicateName = ResolveInNamespace(@Buff, pNamespace);
if pDuplicateName != nDICT then
StopWithSubject(@eDUPLICATE, @Buff);
end
end
void CheckDuplicate(char @Buff)
CheckDuplicateInNamespace(@Buff, pEnteredNamespace);
end
/*****************************************************************************/
word DefineIntegerInNamespace(char @Name; word Type; word Value; word pNamespace)
CheckDuplicateInNamespace(@Name, pNamespace);
when !T_IsInteger(Type):
StopInternal(__FILE__, __LINE__);
word D = DictAlloc();
DictSetName(D, @Name);
DICT @d = @Dict[D];
d.Class = cLITERAL;
d.RO = 1;
d.pType = Type;
d.LiteralValue = Value;
DictAddToNamespace(D, pNamespace);
return D;
end
word DefineInteger(char @Name; word Type; word Value)
return DefineIntegerInNamespace(@Name, Type, Value, pEnteredNamespace);
end
/*****************************************************************************/
word DefineBoolInNamespace(char @Name; bool Value; word pNamespace)
CheckDuplicateInNamespace(@Name, pNamespace);
word D = DictAlloc();
DictSetName(D, @Name);
DICT @d = @Dict[D];
d.Class = cLITERAL;
d.RO = 1;
d.pType = st_bool;
if Value then
d.LiteralValue = 1;
else
d.LiteralValue = 0;
end:if
DictAddToNamespace(D, pNamespace);
return D;
end
word DefineBool(char @Name; bool Value)
return DefineBoolInNamespace(@Name, Value, pEnteredNamespace);
end
/*****************************************************************************/
word DefineStringInNamespace(char @Name; char @Value; word pNamespace)
CheckDuplicateInNamespace(@Name, pNamespace);
word i = strlen(@Value) + 1;
word D = DictAlloc();
DictSetName(D, @Name);
DICT @d = @Dict[D];
d.Class = cLITERAL;
d.RO = 1;
d.pType = T_PtrTo(st_char);
d.LiteralValue = SaveString(@Value, i);
d.nLiteralSize = i;
DictAddToNamespace(D, pNamespace);
return D;
end
word DefineString(char @Name; char @Value)
return DefineStringInNamespace(@Name, @Value, pEnteredNamespace);
end
/*****************************************************************************/
word DefineNamespace(char @Name; word pParentNamespace)
word pNamespace = DictMakeNamespace(@Name);
DictAddToNamespace(pNamespace, pParentNamespace);
return pNamespace;
end