22
33interface
44
5- uses FileIO;
6-
75{ $i define.inc}
8- { $i Types.inc}
96
107// ----------------------------------------------------------------------------
118
@@ -386,9 +383,8 @@ TParam = record
386383 PassMethod: Byte;
387384 i, i_: integer;
388385 end ;
389- // General number type. Union of 32-bit REAL in [0] and 32-bit INTEGER in [1]
390- // Depending on the token, either [0] or [1] is used.
391- TFloat = array [0 ..1 ] of Longword;
386+
387+ TFloat = array [0 ..1 ] of integer;
392388
393389 TParamList = array [1 ..MAXPARAMS] of TParam;
394390
@@ -413,16 +409,16 @@ TType = record
413409 TToken = record
414410 UnitIndex, Column: Smallint;
415411 Line: Integer;
416- Kind: Byte;
417- // For Kind= IDENTTOK:
418- Name : TString;
419- // For Kind= INTNUMBERTOK:
420- Value : Int64;
421- // For Kind= FRACNUMBERTOK:
422- FracValue: Single;
423- // For Kind= STRINGLITERALTOK:
424- StrAddress: Word;
425- StrLength: Word;
412+ case Kind: Byte of
413+ IDENTTOK:
414+ ( Name : ^ TString) ;
415+ INTNUMBERTOK:
416+ ( Value : Int64) ;
417+ FRACNUMBERTOK:
418+ ( FracValue: Single) ;
419+ STRINGLITERALTOK:
420+ ( StrAddress: Word;
421+ StrLength: Word) ;
426422 end ;
427423
428424 TIdentifier = record
@@ -452,33 +448,32 @@ TIdentifier = record
452448 isInitialized,
453449 Section: Boolean;
454450
455- Kind: Byte;
456-
457- // For kind=PROCEDURETOK, FUNCTIONTOK:
458- NumParams: Word;
459- Param: TParamList;
460- ProcAsBlock: Integer;
461- ObjectIndex: Integer;
462-
463- IsUnresolvedForward,
464- updateResolvedForward,
465- isOverload,
466- isRegister,
467- isInterrupt,
468- isRecursion,
469- isStdCall,
470- isPascal,
471- isInline,
472- isAsm,
473- isExternal,
474- isKeep,
475- isVolatile,
476- isStriped,
477- IsNotDead: Boolean;
478-
479- // For kind=VARIABLE, USERTYPE:
480- NumAllocElements, NumAllocElements_: Cardinal;
481- AllocElementType: Byte
451+ case Kind: Byte of
452+ PROCEDURETOK, FUNCTIONTOK:
453+ (NumParams: Word;
454+ Param: TParamList;
455+ ProcAsBlock: Integer;
456+ ObjectIndex: Integer;
457+
458+ IsUnresolvedForward,
459+ updateResolvedForward,
460+ isOverload,
461+ isRegister,
462+ isInterrupt,
463+ isRecursion,
464+ isStdCall,
465+ isPascal,
466+ isInline,
467+ isAsm,
468+ isExternal,
469+ isKeep,
470+ isVolatile,
471+ isStriped,
472+ IsNotDead: Boolean;);
473+
474+ VARIABLE, USERTYPE:
475+ (NumAllocElements, NumAllocElements_: Cardinal;
476+ AllocElementType: Byte);
482477 end ;
483478
484479
@@ -530,19 +525,15 @@ TIdentifier = record
530525
531526{ $i targets/var.inc}
532527
533- const MIN_MEMORY_ADDRESS=$0000 ;
534- const MAX_MEMORY_ADDRESS=$FFFF;
535-
536- type TWordMemory = array [MIN_MEMORY_ADDRESS..MAX_MEMORY_ADDRESS] of Word;
537-
528+
538529var
539530
540531 PROGRAM_NAME: string = ' Program' ;
541532 LIBRARY_NAME: string;
542533
543534 AsmBlock: array [0 ..4095 ] of string;
544535
545- Data, DataSegment, StaticStringData: TWordMemory ;
536+ Data, DataSegment, StaticStringData: array [ 0 ..$FFFF] of word ;
546537
547538 Types: array [1 ..MAXTYPES] of TType;
548539 Tok: array of TToken;
@@ -622,8 +613,6 @@ TIdentifier = record
622613
623614// ----------------------------------------------------------------------------
624615
625- procedure ClearWordMemory (anArray: TWordMemory);
626-
627616 procedure AddDefine (X: string);
628617
629618 procedure AddPath (s: string);
@@ -678,7 +667,7 @@ TIdentifier = record
678667
679668implementation
680669
681- uses SysUtils, Messages, Utilities ;
670+ uses SysUtils, Messages;
682671
683672// ----------------------------------------------------------------------------
684673
@@ -878,11 +867,9 @@ function GetEnumName(IdentIndex: integer): TString;
878867function StrToInt (const a: string): Int64;
879868(* ----------------------------------------------------------------------------*)
880869(* ----------------------------------------------------------------------------*)
881- var value : integer;
882870var i: integer;
883871begin
884- val(a,value , i);
885- Result := value ;
872+ val(a,Result, i);
886873end ;
887874
888875
@@ -918,8 +905,12 @@ function Min(a,b: integer): integer;
918905
919906
920907procedure FreeTokens ;
908+ var i: Integer;
921909begin
922910
911+ for i := 1 to NumTok do
912+ if (Tok[i].Kind = IDENTTOK) and (Tok[i].Name <> nil ) then Dispose(Tok[i].Name );
913+
923914 SetLength(Tok, 0 );
924915 SetLength(IFTmpPosStack, 0 );
925916 SetLength(UnitPath, 0 );
@@ -972,7 +963,7 @@ function ErrTokenFound(ErrTokenIndex: Integer): string;
972963procedure CheckOperator (ErrTokenIndex: Integer; op: Byte; DataType: Byte; RightType: Byte = 0 );
973964begin
974965
975- // writeln(tok[ErrTokenIndex].Name,',', op,',',DataType);
966+ // writeln(tok[ErrTokenIndex].Name^ ,',', op,',',DataType);
976967
977968 if { (not (DataType in (OrdinalTypes + [REALTOK, POINTERTOK]))) or}
978969 ((DataType in RealTypes) and
@@ -1346,10 +1337,7 @@ procedure DefineStaticString(StrTokenIndex: Integer; StrValue: String);
13461337else
13471338 Data[0 ] := len;
13481339
1349- if (NumStaticStrChars + len > $FFFF) then
1350- begin writeln(' DefineStaticString: ' + IntToStr(len));
1351- RaiseHaltException(2 );
1352- end ;
1340+ if (NumStaticStrChars + len > $FFFF) then begin writeln(' DefineStaticString: ' , len); halt end ;
13531341
13541342for i:=1 to len do Data[i] := ord(StrValue[i]);
13551343
@@ -1383,12 +1371,5 @@ procedure DefineStaticString(StrTokenIndex: Integer; StrValue: String);
13831371// ----------------------------------------------------------------------------
13841372// ----------------------------------------------------------------------------
13851373
1386- procedure ClearWordMemory (anArray: TWordMemory);
1387- begin
1388- for i := Low(Ident) to High(Ident) do
1389- begin
1390- anArray[i]:=0 ;
1391- end ;
1392- end ;
13931374
13941375end .
0 commit comments