@@ -254,9 +254,10 @@ function ExtractName(IdentIndex: integer; const a: string): string;
254254var lab: string;
255255begin
256256
257- if { (Ident[IdentIndex].UnitIndex > 1) and} (pos(UnitName[Ident[IdentIndex].UnitIndex].Name + ' .' , a) = 1 ) then begin
257+ lab := Ident[IdentIndex].Name ;
258+
259+ if (lab <> a) and (pos(UnitName[Ident[IdentIndex].UnitIndex].Name + ' .' , a) = 1 ) then begin
258260
259- lab := Ident[IdentIndex].Name ;
260261 if lab.IndexOf(' .' ) > 0 then lab := copy(lab, 1 , lab.LastIndexOf(' .' ));
261262
262263 if (pos(UnitName[Ident[IdentIndex].UnitIndex].Name + ' .adr.' , a) = 1 ) then
@@ -715,37 +716,9 @@ procedure a65(code: code65; Value: Int64 = 0; Kind: Byte = CONSTANT; Size: Byte
715716
716717 __imulECX: asm65(#9 ' jsr imulECX' );
717718
718- // __notBOOLEAN: asm65(#9'jsr notBOOLEAN');
719- // __notaBX: asm65(#9'jsr notaBX');
720-
721- // __negaBX: asm65(#9'jsr negaBX');
722-
723- // __xorEAX_ECX: asm65(#9'jsr xorEAX_ECX');
724- // __xorAX_CX: asm65(#9'jsr xorAX_CX');
725- // __xorAL_CL: asm65(#9'jsr xorAL_CL');
726-
727- // __andEAX_ECX: asm65(#9'jsr andEAX_ECX');
728- // __andAX_CX: asm65(#9'jsr andAX_CX');
729- // __andAL_CL: asm65(#9'jsr andAL_CL');
730-
731- // __orEAX_ECX: asm65(#9'jsr orEAX_ECX');
732- // __orAX_CX: asm65(#9'jsr orAX_CX');
733- // __orAL_CL: asm65(#9'jsr orAL_CL');
734-
735- // __cmpEAX_ECX: asm65(#9'jsr cmpEAX_ECX');
736- // __cmpAX_CX: asm65(#9'jsr cmpEAX_ECX.AX_CX');
737- // __cmpSHORTINT: asm65(#9'jsr cmpSHORTINT');
738- // __cmpSMALLINT: asm65(#9'jsr cmpSMALLINT');
739- // __cmpINT: asm65(#9'jsr cmpINT');
740-
741- // __cmpSTRING: asm65(#9'jsr cmpSTRING');
742- // __cmpCHAR2STRING: asm65(#9'jsr cmpCHAR2STRING');
743- // __cmpSTRING2CHAR: asm65(#9'jsr cmpSTRING2CHAR');
744-
745719 __movaBX_Value: begin
746- // asm65(#9'ldx sp', '; mov dword ptr [bx], Value');
747720
748- if Kind= VARIABLE then begin // @label
721+ if Kind = VARIABLE then begin // @label
749722
750723 svar := GetLocalName(IdentIndex);
751724
@@ -2050,15 +2023,15 @@ procedure GenerateFileOpen(IdentIndex: Integer; Code: ioCode);
20502023 ioOpenRead,
20512024 ioOpenWrite:
20522025
2053- asm65(#9 ' @openfile ' + Ident[IdentIndex].Name + ' , #' +IntToStr(ord(Code)));
2026+ asm65(#9 ' @openfile ' + Ident[IdentIndex].Name + ' , #' +IntToStr(ord(Code)));
20542027
20552028 ioFileMode:
20562029
2057- asm65(#9 ' @openfile ' + Ident[IdentIndex].Name + ' , MAIN.SYSTEM.FileMode' );
2030+ asm65(#9 ' @openfile ' + Ident[IdentIndex].Name + ' , MAIN.SYSTEM.FileMode' );
20582031
20592032 ioClose:
20602033
2061- asm65(#9 ' @closefile ' + Ident[IdentIndex].Name );
2034+ asm65(#9 ' @closefile ' + Ident[IdentIndex].Name );
20622035
20632036 end ;
20642037
@@ -2093,9 +2066,9 @@ procedure GenerateFileRead(IdentIndex: Integer; Code: ioCode; NumParams: integer
20932066 ioWriteRecord:
20942067
20952068 if NumParams = 3 then
2096- asm65(#9 ' @readfile ' + Ident[IdentIndex].Name + ' , #' +IntToStr(ord(Code) or $80 ))
2069+ asm65(#9 ' @readfile ' + Ident[IdentIndex].Name + ' , #' +IntToStr(ord(Code) or $80 ))
20972070 else
2098- asm65(#9 ' @readfile ' + Ident[IdentIndex].Name + ' , #' +IntToStr(ord(Code)));
2071+ asm65(#9 ' @readfile ' + Ident[IdentIndex].Name + ' , #' +IntToStr(ord(Code)));
20992072
21002073 end ;
21012074
@@ -6411,24 +6384,23 @@ function CompileAddress(i: integer; out ValType, AllocElementType: Byte; VarPass
64116384 i := CompileArrayIndex(i, IdentIndex, AllocElementType);
64126385
64136386
6414- if Ident[IdentIndex].DataType = ENUMTYPE then begin
6415- // Size := DataSize[Ident[IdentIndex].AllocElementType];
6416- NumAllocElements := 0 ;
6417- end else
6418- NumAllocElements := Elements(IdentIndex); // Ident[IdentIndex].NumAllocElements;
6387+ if Ident[IdentIndex].DataType = ENUMTYPE then
6388+ NumAllocElements := 0
6389+ else
6390+ NumAllocElements := Elements(IdentIndex);
64196391
64206392 svar := GetLocalName(IdentIndex);
64216393
64226394 if (pos(' .' , svar) > 0 ) then begin
6423- // lab:=copy(svar,1,pos ('.', svar)-1 );
6395+ // lab:=copy(svar, 1, svar.IndexOf ('.') );
64246396 lab := ExtractName(IdentIndex, svar);
64256397
64266398 rec := (Ident[GetIdent(lab)].AllocElementType = RECORDTOK);
64276399 end ;
64286400
64296401 // AllocElementType := Ident[IdentIndex].AllocElementType;
64306402
6431- // writeln(Ident[IdentIndex].DataType,',',Ident[IdentIndex].AllocElementType,',',Ident[IdentIndex].NumAllocElements,',',Ident[IdentIndex].PassMethod,',',VarPass );
6403+ // writeln(Ident[IdentIndex].name,',',Ident[IdentIndex]. DataType,',',Ident[IdentIndex].AllocElementType,',',Ident[IdentIndex].NumAllocElements,',',Ident[IdentIndex].PassMethod,',',VarPass ,',',rec,',',Ident[IdentIndex].idType );
64326404
64336405 if rec then begin // record.array[]
64346406
@@ -7269,8 +7241,7 @@ procedure CompileActualParameters(var i: integer; IdentIndex: integer; ProcVarIn
72697241
72707242 end else begin
72717243
7272-
7273- if (Ident[IdentIndex].Param[NumActualParams].DataType = POINTERTOK) and (Ident[IdentIndex].Param[NumActualParams].NumAllocElements > 0 ) then
7244+ if (Ident[IdentIndex].Param[NumActualParams].DataType = POINTERTOK) and (Ident[IdentIndex].Param[NumActualParams].NumAllocElements > 0 ) and not (Ident[IdentIndex].Param[NumActualParams].AllocElementType in [RECORDTOK, OBJECTTOK]) then
72747245 i := CompileAddress(i + 1 , ActualParamType, AllocElementType)
72757246 else
72767247 i := CompileExpression(i + 2 , ActualParamType, Ident[IdentIndex].Param[NumActualParams].DataType); // Evaluate actual parameters and push them onto the stack
@@ -8909,10 +8880,12 @@ function CompileFactor(i: Integer; out isZero: Boolean; out ValType: Byte; VarTy
89098880
89108881 if (Ident[IdentIndex].DataType = POINTERTOK) and (Elements(IdentIndex) > 0 ) then begin
89118882
8912- // writeln(Ident[IdentIndex].name, ',', Ident[IdentIndex].PassMethod);
8913-
89148883 i := CompileAddress(i+1 , VarType, ValType);
89158884
8885+
8886+ // writeln(Ident[IdentIndex].name, ',', Ident[IdentIndex].PassMethod,',',VarType,',',ValType);
8887+
8888+
89168889 CheckTok(i + 1 , CPARTOK);
89178890 CheckTok(i + 2 , OBRACKETTOK);
89188891
@@ -9376,7 +9349,7 @@ // === record^.
93769349 else
93779350 begin
93789351
9379- // writeln('> ',Ident[IdentIndex].Name,',',ValType,',',Ident[GetIdent(Tok[i].Name^)].name,',',VarType);
9352+ // writeln('> ',Ident[IdentIndex].Name,',',ValType,',',Ident[GetIdent(Tok[i].Name^)].name,',',VarType);
93809353// perl
93819354 i := CompileArrayIndex(i, IdentIndex, ValType); // array[ ].field
93829355
@@ -14848,8 +14821,6 @@ procedure SaveData(compile: Boolean = true);
1484814821
1484914822begin
1485014823
14851- // yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
14852-
1485314824{
1485414825 if (Tok[i].Kind = STRINGLITERALTOK) and (ConstValType = CHARTOK) then begin // init char array by string -> array [0..15] of char = '0123456789ABCDEF';
1485514826
@@ -15038,7 +15009,6 @@ procedure SaveData(compile: Boolean = true);
1503815009
1503915010begin
1504015011
15041- // yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
1504215012{
1504315013 if (Tok[i].Kind = STRINGLITERALTOK) and (ConstValType = CHARTOK) then begin // init char array by string -> array [0..15] of char = '0123456789ABCDEF';
1504415014
@@ -15384,8 +15354,8 @@ procedure CheckForwardResolutions(typ: Boolean = true);
1538415354// ----------------------------------------------------------------------------
1538515355
1538615356
15387- procedure CompileRecordDeclaration (i: integer; var VarOfSameType: TVariableList; var tmpVarDataSize: integer; var ConstVal: Int64; VarOfSameTypeIndex: integer; VarType, AllocElementType: Byte; NumAllocElements: cardinal; isAbsolute: Boolean);
15388- var tmpVarDataSize_, ParamIndex{ , idx } : integer;
15357+ procedure CompileRecordDeclaration (i: integer; var VarOfSameType: TVariableList; var tmpVarDataSize: integer; var ConstVal: Int64; VarOfSameTypeIndex: integer; VarType, AllocElementType: Byte; NumAllocElements: cardinal; isAbsolute: Boolean; var idx: integer );
15358+ var tmpVarDataSize_, ParamIndex: integer;
1538915359begin
1539015360
1539115361// writeln(iDtype,',',VarOfSameType[VarOfSameTypeIndex].Name,' / ',NumAllocElements,' , ',VarType,',',Types[NumAllocElements].Block,' | ', AllocElementType);
@@ -15412,7 +15382,7 @@ procedure CompileRecordDeclaration(i: integer; var VarOfSameType: TVariableList;
1541215382 if Ident[NumIdent].isAbsolute = false then inc(tmpVarDataSize, DataSize[POINTERTOK]); // wskaznik dla ^record
1541315383
1541415384
15415- // idx := Ident[NumIdent].Value - DATAORIGIN;
15385+ idx := Ident[NumIdent].Value - DATAORIGIN;
1541615386
1541715387// writeln(NumAllocElements);
1541815388// !@!@
@@ -15457,7 +15427,7 @@ procedure CompileRecordDeclaration(i: integer; var VarOfSameType: TVariableList;
1545715427
1545815428 end ;
1545915429
15460- end ;
15430+ end ; // CompileRecordDeclaration
1546115431
1546215432
1546315433// ----------------------------------------------------------------------------
@@ -16868,7 +16838,7 @@ function CompileBlock(i: Integer; BlockIdentIndex: Integer; NumParams: Integer;
1686816838 end ;
1686916839
1687016840
16871- CompileRecordDeclaration(i, VarOfSameType, tmpVarDataSize, ConstVal, VarOfSameTypeIndex, VarType, AllocElementType, NumAllocElements, isAbsolute);
16841+ CompileRecordDeclaration(i, VarOfSameType, tmpVarDataSize, ConstVal, VarOfSameTypeIndex, VarType, AllocElementType, NumAllocElements, isAbsolute, idx); // !!! idx !!!
1687216842
1687316843
1687416844 end ;
@@ -16886,7 +16856,7 @@ function CompileBlock(i: Integer; BlockIdentIndex: Integer; NumParams: Integer;
1688616856
1688716857 if isAbsolute and (open_array = false) then
1688816858
16889- SetVarDataSize( i, tmpVarDataSize )
16859+ SetVarDataSize( i, tmpVarDataSize )
1689016860
1689116861 else
1689216862
0 commit comments