Skip to content

Commit 929fa94

Browse files
committed
return to working version
1 parent dcef00d commit 929fa94

File tree

6 files changed

+58
-131
lines changed

6 files changed

+58
-131
lines changed

origin/Common.pas

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ TIdentifier = record
567567
NumDefines: integer = 1; // NumDefines = AddDefines
568568

569569
NumTok, NumIdent, NumTypes, NumPredefIdent, NumStaticStrChars, NumUnits, NumBlocks, NumProc,
570-
BlockStackTop, CodeSize, CodePosStackTop, BreakPosStackTop, _VarDataSize, Pass, ShrShlCnt,
570+
BlockStackTop, CodeSize, CodePosStackTop, BreakPosStackTop, VarDataSize, Pass, ShrShlCnt,
571571
NumStaticStrCharsTmp, AsmBlockIndex, IfCnt, CaseCnt, IfdefLevel, run_func: Integer;
572572

573573
iOut: integer = -1;
@@ -675,64 +675,12 @@ TIdentifier = record
675675

676676
function StrToInt(const a: string): Int64;
677677

678-
type TTokenIndex = Integer;
679-
procedure IncVarDataSize(const tokenIndex: TTokenIndex; const size: Integer);
680-
681-
function GetVarDataSize: Integer;
682-
procedure SetVarDataSize(const tokenIndex: TTokenIndex; const size: Integer);
683-
684-
var TraceFile: TextFile;
685-
procedure LogTrace(message: String);
686-
687678
// ----------------------------------------------------------------------------
688679

689680
implementation
690681

691682
uses SysUtils, Messages;
692683

693-
procedure LogTrace(message: String);
694-
begin
695-
{$IFDEF USETRACEFILE}
696-
Writeln(traceFile, message);
697-
{$ENDIF}
698-
end;
699-
700-
// ----------------------------------------------------------------------------
701-
// ----------------------------------------------------------------------------
702-
703-
function GetVarDataSize: Integer;
704-
begin
705-
Result := _VarDataSize;
706-
end;
707-
708-
709-
procedure SetVarDataSize(const tokenIndex: TTokenIndex; const size: Integer);
710-
var token: TToken;
711-
// var GetSourceFileLocationString: String;
712-
713-
begin
714-
_VarDataSize := size;
715-
token:= Tok[tokenIndex];
716-
717-
(*
718-
GetSourceFileLocationString := UnitName[ token.UnitIndex].Path;
719-
720-
if (token.line>0) then
721-
begin
722-
GetSourceFileLocationString:=GetSourceFileLocationString+ ' ( line ' + IntToStr(token.Line) + ', column ' + IntToStr(token.Column) + ')';
723-
end;
724-
725-
726-
// LogTrace(Format('SetVarDataSize: TokenIndex=%d: %s %s VarDataSize=%d', [tokenIndex, GetSourceFileLocationString,'TODO', _VarDataSize]));
727-
*)
728-
end;
729-
730-
731-
procedure IncVarDataSize(const tokenIndex: TTokenIndex; const size: Integer);
732-
begin
733-
SetVarDataSize(tokenIndex, _VarDataSize + size);
734-
end;
735-
736684
// ----------------------------------------------------------------------------
737685

738686

origin/Optimize.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,14 +1431,15 @@ procedure OptimizeEAX_OFF;
14311431

14321432

14331433
{
1434-
if (pos(#9'add #$00', listing[i]) > 0) then begin
1434+
if (pos(#9'sub #$', listing[i]) > 0) then begin
14351435
14361436
for p:=0 to l-1 do writeln(listing[p]);
14371437
writeln('-------');
14381438
14391439
end;
14401440
}
14411441

1442+
14421443
if opt_FORTMP(i) = false then begin Result := false; Break end;
14431444

14441445

origin/Parser.pas

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,6 @@ procedure SaveToDataSegment(ConstDataSize: integer; ConstVal: Int64; ConstValTyp
455455
var ftmp: TFloat;
456456
begin
457457

458-
// LogTrace(Format('SaveToDataSegment(index=%d, value=%d, valueDataType=%d', [ConstDataSize, ConstVal, ConstValType]));
459-
460-
461458
if (ConstDataSize < 0) or (ConstDataSize > $FFFF) then begin writeln('SaveToDataSegment: ', ConstDataSize); halt end;
462459

463460
ftmp:=Default(TFloat);
@@ -1750,10 +1747,10 @@ procedure DefineIdent(ErrTokenIndex: Integer; Name: TString; Kind: Byte; DataTyp
17501747
if Ident[NumIdent].isAbsolute then
17511748
Ident[NumIdent].Value := Data - 1
17521749
else
1753-
Ident[NumIdent].Value := DATAORIGIN + GetVarDataSize; // Variable address
1750+
Ident[NumIdent].Value := DATAORIGIN + VarDataSize; // Variable address
17541751

17551752
if not OutputDisabled then
1756-
IncVarDataSize( ErrTokenIndex,DataSize[DataType]);
1753+
VarDataSize := VarDataSize + DataSize[DataType];
17571754

17581755
Ident[NumIdent].NumAllocElements := NumAllocElements; // Number of array elements (0 for single variable)
17591756
Ident[NumIdent].NumAllocElements_ := NumAllocElements_;
@@ -1763,28 +1760,28 @@ procedure DefineIdent(ErrTokenIndex: Integer; Name: TString; Kind: Byte; DataTyp
17631760
if not OutputDisabled then begin
17641761

17651762
if (DataType = POINTERTOK) and (AllocElementType in [RECORDTOK, OBJECTTOK]) and (NumAllocElements_ = 0) then
1766-
IncVarDataSize( ErrTokenIndex, DataSize[POINTERTOK])
1763+
inc(VarDataSize, DataSize[POINTERTOK])
17671764
else
17681765

17691766
if DataType in [ENUMTYPE] then
1770-
IncVarDataSize( ErrTokenIndex,1)
1767+
inc(VarDataSize)
17711768
else
17721769
if (DataType in [RECORDTOK, OBJECTTOK]) and (NumAllocElements > 0) then
1773-
IncVarDataSize( ErrTokenIndex, 0)
1770+
VarDataSize := VarDataSize + 0
17741771
else
17751772
if (DataType in [FILETOK, TEXTFILETOK]) and (NumAllocElements > 0) then
1776-
IncVarDataSize( ErrTokenIndex, 12)
1773+
VarDataSize := VarDataSize + 12
17771774
else begin
17781775

17791776
if (Ident[NumIdent].idType = ARRAYTOK) and (Ident[NumIdent].isAbsolute = false) and (Elements(NumIdent) = 1) then // [0..0] ; [0..0, 0..0]
17801777

17811778
else
1782-
IncVarDataSize( ErrTokenIndex, integer(Elements(NumIdent) * DataSize[AllocElementType]));
1779+
VarDataSize := VarDataSize + integer(Elements(NumIdent) * DataSize[AllocElementType]);
17831780

17841781
end;
17851782

17861783

1787-
if NumAllocElements > 0 then IncVarDataSize( ErrTokenIndex,-DataSize[DataType]);
1784+
if NumAllocElements > 0 then dec(VarDataSize, DataSize[DataType]);
17881785

17891786
end;
17901787

origin/Scanner.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ procedure TokenizeProgramInitialization;
4747
SetLength(msgWarning, 1);
4848
SetLength(msgNote, 1);
4949

50-
NumBlocks := 0; BlockStackTop := 0; CodeSize := 0; CodePosStackTop := 0; SetVarDataSize(0,0);
50+
NumBlocks := 0; BlockStackTop := 0; CodeSize := 0; CodePosStackTop := 0; VarDataSize := 0;
5151
CaseCnt := 0; IfCnt := 0; ShrShlCnt := 0; NumTypes := 0; run_func := 0; NumProc := 0;
5252
NumTok := 0; NumIdent := 0;
5353

origin/define.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
//{$DEFINE WHILEDO}
22

33
//{$DEFINE USEOPTFILE}
4-
//{$DEFINE USETRACEFILE}
54

65
{$DEFINE OPTIMIZECODE}
76

8-
// The origin version still relies on accessing the element [0] of arrays starting at 1.
9-
{$RANGECHECKS OFF}
10-
117
{$I+}

0 commit comments

Comments
 (0)