@@ -128,8 +128,18 @@ function GetIdent(S: TString): Integer;
128128
129129 if S = ' ' then exit(-1 );
130130
131+
132+ if High(WithName) > 0 then
133+ for TempIndex:=0 to High(WithName) do begin
134+ Result := Search(WithName[TempIndex] + ' .' + S, UnitNameIndex);
135+
136+ if Result > 0 then exit;
137+ end ;
138+
139+
131140 Result := Search(S, UnitNameIndex);
132141
142+
133143 if (Result = 0 ) and (pos(' .' , S) > 0 ) then begin // potencjalnie odwolanie do unitu / obiektu
134144
135145 TempIndex := Search(copy(S, 1 , pos(' .' , S)-1 ), UnitNameIndex);
@@ -194,7 +204,7 @@ function RecordSize(IdentIndex: integer; field: string =''): integer;
194204var i, j: integer;
195205 name , base: TName;
196206 FieldType, AllocElementType: Byte;
197- NumAllocElements: cardinal;
207+ NumAllocElements, NumAllocElements_ : cardinal;
198208 yes: Boolean;
199209begin
200210
@@ -214,20 +224,27 @@ function RecordSize(IdentIndex: integer; field: string =''): integer;
214224 for j := 1 to Types[i].NumFields do begin
215225
216226 FieldType := Types[i].Field[j].DataType;
217- NumAllocElements := Types[i].Field[j].NumAllocElements;
227+ NumAllocElements := Types[i].Field[j].NumAllocElements and $FFFF;
228+ NumAllocElements_ := Types[i].Field[j].NumAllocElements shr 16 ;
218229 AllocElementType := Types[i].Field[j].AllocElementType;
219230
220231 if AllocElementType in [FORWARDTYPE, PROCVARTOK] then begin
221232 AllocElementType := POINTERTOK;
222233 NumAllocElements := 0 ;
234+ NumAllocElements_ := 0 ;
223235 end ;
224236
225237 if Types[i].Field[j].Name = field then begin yes:=true; Break end ;
226238
227239 if FieldType <> RECORDTOK then
228- if (FieldType in Pointers) and (NumAllocElements > 0 ) then
229- inc(Result, NumAllocElements * DataSize[AllocElementType])
230- else
240+ if (FieldType in Pointers) and (NumAllocElements > 0 ) then begin
241+
242+ if NumAllocElements_ > 0 then
243+ inc(Result, NumAllocElements * NumAllocElements_ * DataSize[AllocElementType])
244+ else
245+ inc(Result, NumAllocElements * DataSize[AllocElementType]);
246+
247+ end else
231248 inc(Result, DataSize[FieldType]);
232249
233250 end ;
@@ -245,15 +262,21 @@ function RecordSize(IdentIndex: integer; field: string =''): integer;
245262 if Types[Ident[IdentIndex].NumAllocElements].Field[i].DataType <> RECORDTOK then begin
246263
247264 FieldType := Types[Ident[IdentIndex].NumAllocElements].Field[i].DataType;
248- NumAllocElements := Types[Ident[IdentIndex].NumAllocElements].Field[i].NumAllocElements;
265+ NumAllocElements := Types[Ident[IdentIndex].NumAllocElements].Field[i].NumAllocElements and $FFFF;
266+ NumAllocElements_ := Types[Ident[IdentIndex].NumAllocElements].Field[i].NumAllocElements shr 16 ;
249267 AllocElementType := Types[Ident[IdentIndex].NumAllocElements].Field[i].AllocElementType;
250268
251269 if Types[Ident[IdentIndex].NumAllocElements].Field[i].Name = field then begin yes:=true; Break end ;
252270
253271 if FieldType <> RECORDTOK then
254- if (FieldType in Pointers) and (NumAllocElements > 0 ) then
255- inc(Result, NumAllocElements * DataSize[AllocElementType])
256- else
272+ if (FieldType in Pointers) and (NumAllocElements > 0 ) then begin
273+
274+ if NumAllocElements_ > 0 then
275+ inc(Result, NumAllocElements * NumAllocElements_ * DataSize[AllocElementType])
276+ else
277+ inc(Result, NumAllocElements * DataSize[AllocElementType]);
278+
279+ end else
257280 inc(Result, DataSize[FieldType]);
258281
259282 end ;
@@ -562,7 +585,7 @@ function CompileConstFactor(i: Integer; out ConstVal: Int64; out ConstValType: B
562585 fl:=0 ;
563586 j:=0 ;
564587
565- // WRITELN(tok[i].line, ',', tok[i].kind);
588+ // WRITELN(tok[i].line, ',', tok[i].kind);
566589
567590case Tok[i].Kind of
568591
@@ -970,13 +993,15 @@ function CompileConstFactor(i: Integer; out ConstVal: Int64; out ConstValType: B
970993 iError(i, TypeMismatch);
971994
972995
973- if (Ident[GetIdent(Tok[i]. Name ^) ].DataType in RealTypes) and (ConstValType in RealTypes) then begin
996+ if (Ident[IdentIndex ].DataType in RealTypes) and (ConstValType in RealTypes) then begin
974997 // ok
975998 end else
976- if Ident[GetIdent(Tok[i]. Name ^) ].DataType in Pointers then
999+ if Ident[IdentIndex ].DataType in Pointers then
9771000 Error(j, ' Illegal type conversion: "' +InfoAboutToken(ConstValType)+' " to "' +Tok[i].Name ^+' "' );
9781001
979- ConstValType := Ident[GetIdent(Tok[i].Name ^)].DataType;
1002+ ConstValType := Ident[IdentIndex].DataType;
1003+
1004+ if ConstValType = ENUMTYPE then ConstValType := Ident[IdentIndex].AllocElementType;
9801005
9811006 CheckTok(j + 1 , CPARTOK);
9821007
@@ -1031,6 +1056,9 @@ function CompileConstFactor(i: Integer; out ConstVal: Int64; out ConstValType: B
10311056 ConstVal := Ident[IdentIndex].Value ;
10321057
10331058
1059+ // writeln(ident[identindex].name,',',ConstValType,',',ident[identindex].kind);
1060+
1061+
10341062 if ConstValType = ENUMTYPE then begin
10351063 CheckTok(i + 1 , OPARTOK);
10361064
@@ -1918,9 +1946,6 @@ function DeclareFunction(i: integer; out ProcVarIndex: cardinal): integer;
19181946
19191947 Ident[NumIdent].DataType := VarType; // Result
19201948
1921- if VarType = ENUMTOK then
1922- Ident[NumIdent].AllocElementType := AllocElementType;
1923-
19241949 Ident[NumIdent].NestedFunctionNumAllocElements := NumAllocElements;
19251950 Ident[NumIdent].NestedFunctionAllocElementType := AllocElementType;
19261951
@@ -2085,10 +2110,6 @@ function DefineFunction(i, ForwardIdentIndex: integer; out isForward, isInt, isI
20852110
20862111 Ident[NumIdent].DataType := NestedFunctionResultType; // Result
20872112
2088- if NestedFunctionResultType = ENUMTOK then
2089- Ident[NumIdent].AllocElementType := AllocElementType;
2090-
2091-
20922113 NestedFunctionNumAllocElements := NumAllocElements;
20932114 Ident[NumIdent].NestedFunctionNumAllocElements := NumAllocElements;
20942115
0 commit comments