Browse Source

* Patch from Inoussa OUEDRAOGO to make it compilable with Delphi (WST has support for Delphi)

git-svn-id: trunk@8346 -
michael 18 years ago
parent
commit
2d8d8b1cac

+ 37 - 5
packages/fcl-passrc/src/pastree.pp

@@ -82,6 +82,8 @@ type
   public
   public
     SourceFilename: string;
     SourceFilename: string;
     SourceLinenumber: Integer;
     SourceLinenumber: Integer;
+    Visibility: TPasMemberVisibility;
+  public
     constructor Create(const AName: string; AParent: TPasElement); virtual;
     constructor Create(const AName: string; AParent: TPasElement); virtual;
     procedure AddRef;
     procedure AddRef;
     procedure Release;
     procedure Release;
@@ -90,7 +92,6 @@ type
     function GetModule: TPasModule;
     function GetModule: TPasModule;
     function ElementTypeName: string; virtual;
     function ElementTypeName: string; virtual;
     function GetDeclaration(full : Boolean) : string; virtual;
     function GetDeclaration(full : Boolean) : string; virtual;
-    Visibility: TPasMemberVisibility;
     property RefCount: LongWord read FRefCount;
     property RefCount: LongWord read FRefCount;
     property Name: string read FName write FName;
     property Name: string read FName write FName;
     property Parent: TPasElement read FParent;
     property Parent: TPasElement read FParent;
@@ -103,6 +104,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     procedure AddUnitToUsesList(const AUnitName: string);
     procedure AddUnitToUsesList(const AUnitName: string);
+  public
     UsesList: TList;            // TPasUnresolvedTypeRef or TPasModule elements
     UsesList: TList;            // TPasUnresolvedTypeRef or TPasModule elements
     Declarations, ResStrings, Types, Consts, Classes,
     Declarations, ResStrings, Types, Consts, Classes,
       Functions, Variables: TList;
       Functions, Variables: TList;
@@ -113,6 +115,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     InterfaceSection, ImplementationSection: TPasSection;
     InterfaceSection, ImplementationSection: TPasSection;
     PackageName: string;
     PackageName: string;
   end;
   end;
@@ -122,6 +125,7 @@ type
     constructor Create(const AName: string; AParent: TPasElement); override;
     constructor Create(const AName: string; AParent: TPasElement); override;
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
+  public
     Modules: TList;     // List of TPasModule objects
     Modules: TList;     // List of TPasModule objects
   end;
   end;
 
 
@@ -129,6 +133,7 @@ type
   public
   public
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : Boolean) : string; Override;
     function GetDeclaration(full : Boolean) : string; Override;
+  public
     Value: string;
     Value: string;
   end;
   end;
 
 
@@ -142,6 +147,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : Boolean): string; override;
     function GetDeclaration(full : Boolean): string; override;
+  public
     DestType: TPasType;
     DestType: TPasType;
   end;
   end;
 
 
@@ -150,6 +156,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : Boolean): string; override;
     function GetDeclaration(full : Boolean): string; override;
+  public
     DestType: TPasType;
     DestType: TPasType;
   end;
   end;
 
 
@@ -169,6 +176,7 @@ type
   public
   public
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     RangeStart, RangeEnd: string;
     RangeStart, RangeEnd: string;
   end;
   end;
 
 
@@ -177,6 +185,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     IndexRange : string;
     IndexRange : string;
     IsPacked : Boolean;          // 12/04/04 - Dave - Added
     IsPacked : Boolean;          // 12/04/04 - Dave - Added
     ElType: TPasType;
     ElType: TPasType;
@@ -187,12 +196,14 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     ElType: TPasType;
     ElType: TPasType;
   end;
   end;
 
 
   TPasEnumValue = class(TPasElement)
   TPasEnumValue = class(TPasElement)
   public
   public
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
+  public
     IsValueUsed: Boolean;
     IsValueUsed: Boolean;
     Value: Integer;
     Value: Integer;
     AssignedValue : string;
     AssignedValue : string;
@@ -205,6 +216,7 @@ type
      function ElementTypeName: string; override;
      function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
     Procedure GetEnumNames(Names : TStrings);
     Procedure GetEnumNames(Names : TStrings);
+  public
     Values: TList;      // List of TPasEnumValue objects
     Values: TList;      // List of TPasEnumValue objects
   end;
   end;
 
 
@@ -213,6 +225,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     EnumType: TPasType;
     EnumType: TPasType;
   end;
   end;
 
 
@@ -222,6 +235,7 @@ type
   public
   public
     constructor Create(const AName: string; AParent: TPasElement); override;
     constructor Create(const AName: string; AParent: TPasElement); override;
     destructor Destroy; override;
     destructor Destroy; override;
+  public
     Values: TStringList;
     Values: TStringList;
     Members: TPasRecordType;
     Members: TPasRecordType;
   end;
   end;
@@ -232,6 +246,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     IsPacked: Boolean;
     IsPacked: Boolean;
     Members: TList;     // array of TPasVariable elements
     Members: TList;     // array of TPasVariable elements
     VariantName: string;
     VariantName: string;
@@ -247,6 +262,7 @@ type
     constructor Create(const AName: string; AParent: TPasElement); override;
     constructor Create(const AName: string; AParent: TPasElement); override;
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
+  public
     ObjKind: TPasObjKind;
     ObjKind: TPasObjKind;
     AncestorType: TPasType;     // TPasClassType or TPasUnresolvedTypeRef
     AncestorType: TPasType;     // TPasClassType or TPasUnresolvedTypeRef
     IsPacked: Boolean;        // 12/04/04 - Dave - Added
     IsPacked: Boolean;        // 12/04/04 - Dave - Added
@@ -261,6 +277,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     Access: TArgumentAccess;
     Access: TArgumentAccess;
     ArgType: TPasType;
     ArgType: TPasType;
     Value: string;
     Value: string;
@@ -272,11 +289,11 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     class function TypeName: string; virtual;
     class function TypeName: string; virtual;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
-    IsOfObject: Boolean;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
     procedure GetArguments(List : TStrings);
     procedure GetArguments(List : TStrings);
-    function CreateArgument(const AName, AUnresolvedTypeName: string):
-      TPasArgument;
+    function CreateArgument(const AName, AUnresolvedTypeName: string):TPasArgument;
+  public
+    IsOfObject: Boolean;
     Args: TList;        // List of TPasArgument objects
     Args: TList;        // List of TPasArgument objects
   end;
   end;
 
 
@@ -284,6 +301,7 @@ type
   public
   public
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName : string; override;
     function ElementTypeName : string; override;
+  public
     ResultType: TPasType;
     ResultType: TPasType;
   end;
   end;
 
 
@@ -293,6 +311,7 @@ type
     class function TypeName: string; override;
     class function TypeName: string; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(Full : boolean) : string; override;
     function GetDeclaration(Full : boolean) : string; override;
+  public
     ResultEl: TPasResultElement;
     ResultEl: TPasResultElement;
   end;
   end;
 
 
@@ -314,6 +333,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     VarType: TPasType;
     VarType: TPasType;
     Value: string;
     Value: string;
     Modifiers : string;
     Modifiers : string;
@@ -331,6 +351,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function GetDeclaration(full : boolean) : string; override;
     function GetDeclaration(full : boolean) : string; override;
+  public
     Args: TList;        // List of TPasArgument objects
     Args: TList;        // List of TPasArgument objects
     IndexValue, ReadAccessorName, WriteAccessorName,
     IndexValue, ReadAccessorName, WriteAccessorName,
       StoredAccessorName, DefaultValue: string;
       StoredAccessorName, DefaultValue: string;
@@ -348,6 +369,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function TypeName: string; override;
     function TypeName: string; override;
+  public
     Overloads: TList;           // List of TPasProcedure nodes
     Overloads: TList;           // List of TPasProcedure nodes
   end;
   end;
 
 
@@ -356,9 +378,10 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function TypeName: string; override;
     function TypeName: string; override;
-    ProcType: TPasProcedureType;
     function GetDeclaration(full: Boolean): string; override;
     function GetDeclaration(full: Boolean): string; override;
     procedure GetModifiers(List: TStrings);
     procedure GetModifiers(List: TStrings);
+  public
+    ProcType: TPasProcedureType;
     IsVirtual, IsDynamic, IsAbstract, IsOverride,
     IsVirtual, IsDynamic, IsAbstract, IsOverride,
       IsOverload, IsMessage, isReintroduced, isStatic: Boolean;
       IsOverload, IsMessage, isReintroduced, isStatic: Boolean;
   end;
   end;
@@ -396,6 +419,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function ElementTypeName: string; override;
     function ElementTypeName: string; override;
     function TypeName: string; virtual;
     function TypeName: string; virtual;
+  public
     ProcType: TPasProcedureType;
     ProcType: TPasProcedureType;
     Locals: TList;
     Locals: TList;
     Body: TPasImplBlock;
     Body: TPasImplBlock;
@@ -425,12 +449,14 @@ type
   public
   public
     constructor Create(const AName: string; AParent: TPasElement); override;
     constructor Create(const AName: string; AParent: TPasElement); override;
     destructor Destroy; override;
     destructor Destroy; override;
+  public
     Commands: TStrings;
     Commands: TStrings;
   end;
   end;
 
 
   TPasImplIfElse = class(TPasImplElement)
   TPasImplIfElse = class(TPasImplElement)
   public
   public
     destructor Destroy; override;
     destructor Destroy; override;
+  public
     Condition: string;
     Condition: string;
     IfBranch, ElseBranch: TPasImplElement;
     IfBranch, ElseBranch: TPasImplElement;
   end;
   end;
@@ -438,6 +464,7 @@ type
   TPasImplForLoop = class(TPasImplElement)
   TPasImplForLoop = class(TPasImplElement)
   public
   public
     destructor Destroy; override;
     destructor Destroy; override;
+  public
     Variable: TPasVariable;
     Variable: TPasVariable;
     StartValue, EndValue: string;
     StartValue, EndValue: string;
     Body: TPasImplElement;
     Body: TPasImplElement;
@@ -452,6 +479,7 @@ type
     function AddIfElse(const ACondition: string): TPasImplIfElse;
     function AddIfElse(const ACondition: string): TPasImplIfElse;
     function AddForLoop(AVar: TPasVariable;
     function AddForLoop(AVar: TPasVariable;
       const AStartValue, AEndValue: string): TPasImplForLoop;
       const AStartValue, AEndValue: string): TPasImplForLoop;
+  public
     Elements: TList;    // TPasImplElement objects
     Elements: TList;    // TPasImplElement objects
   end;
   end;
 
 
@@ -473,6 +501,10 @@ implementation
 
 
 uses SysUtils;
 uses SysUtils;
 
 
+{$IFNDEF FPC}
+  const
+    LineEnding = sLineBreak;
+{$ENDIF}
 
 
 { Parse tree element type name functions }
 { Parse tree element type name functions }
 
 

+ 4 - 4
packages/fcl-passrc/src/paswrite.pp

@@ -37,8 +37,8 @@ type
     constructor Create(AStream: TStream);
     constructor Create(AStream: TStream);
     destructor Destroy; override;
     destructor Destroy; override;
     procedure wrt(const s: string);
     procedure wrt(const s: string);
-    procedure wrtln(const s: string);
-    procedure wrtln;
+    procedure wrtln(const s: string);overload;
+    procedure wrtln;overload;
 
 
     procedure WriteElement(AElement: TPasElement);
     procedure WriteElement(AElement: TPasElement);
     procedure WriteType(AType: TPasType);
     procedure WriteType(AType: TPasType);
@@ -60,8 +60,8 @@ type
   end;
   end;
 
 
 
 
-procedure WritePasFile(AElement: TPasElement; const AFilename: string);
-procedure WritePasFile(AElement: TPasElement; AStream: TStream);
+procedure WritePasFile(AElement: TPasElement; const AFilename: string);overload;
+procedure WritePasFile(AElement: TPasElement; AStream: TStream);overload;
 
 
 
 
 
 

+ 8 - 8
packages/fcl-passrc/src/pparser.pp

@@ -50,10 +50,10 @@ type
   public
   public
     function CreateElement(AClass: TPTreeElement; const AName: String;
     function CreateElement(AClass: TPTreeElement; const AName: String;
       AParent: TPasElement; const ASourceFilename: String;
       AParent: TPasElement; const ASourceFilename: String;
-      ASourceLinenumber: Integer): TPasElement;
+      ASourceLinenumber: Integer): TPasElement;overload;
     function CreateElement(AClass: TPTreeElement; const AName: String;
     function CreateElement(AClass: TPTreeElement; const AName: String;
       AParent: TPasElement; AVisibility: TPasMemberVisibility;
       AParent: TPasElement; AVisibility: TPasMemberVisibility;
-      const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
+      const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;overload;
       virtual; abstract;
       virtual; abstract;
     function CreateFunctionType(const AName, AResultName: String; AParent: TPasElement;
     function CreateFunctionType(const AName, AResultName: String; AParent: TPasElement;
       UseParentAsResultParent: Boolean; const ASourceFilename: String;
       UseParentAsResultParent: Boolean; const ASourceFilename: String;
@@ -105,9 +105,9 @@ type
     procedure ParseExc(const Msg: String);
     procedure ParseExc(const Msg: String);
   protected
   protected
     function CreateElement(AClass: TPTreeElement; const AName: String;
     function CreateElement(AClass: TPTreeElement; const AName: String;
-      AParent: TPasElement): TPasElement;
+      AParent: TPasElement): TPasElement;overload;
     function CreateElement(AClass: TPTreeElement; const AName: String;
     function CreateElement(AClass: TPTreeElement; const AName: String;
-      AParent: TPasElement; AVisibility: TPasMemberVisibility): TPasElement;
+      AParent: TPasElement; AVisibility: TPasMemberVisibility): TPasElement;overload;
     Function CheckHint(Element : TPasElement; ExpectSemiColon : Boolean) : TPasMemberHints;
     Function CheckHint(Element : TPasElement; ExpectSemiColon : Boolean) : TPasMemberHints;
   public
   public
     Options : set of TPOptions;
     Options : set of TPOptions;
@@ -120,8 +120,8 @@ type
     procedure ExpectToken(tk: TToken);
     procedure ExpectToken(tk: TToken);
     function ExpectIdentifier: String;
     function ExpectIdentifier: String;
 
 
-    function ParseType(Parent: TPasElement; Prefix : String): TPasType;
-    function ParseType(Parent: TPasElement): TPasType;
+    function ParseType(Parent: TPasElement; Prefix : String): TPasType;overload;
+    function ParseType(Parent: TPasElement): TPasType;overload;
     function ParseComplexType: TPasType;
     function ParseComplexType: TPasType;
     procedure ParseArrayType(Element: TPasArrayType);
     procedure ParseArrayType(Element: TPasArrayType);
     procedure ParseFileType(Element: TPasFileType);
     procedure ParseFileType(Element: TPasFileType);
@@ -136,9 +136,9 @@ type
     function ParseConstDecl(Parent: TPasElement): TPasConst;
     function ParseConstDecl(Parent: TPasElement): TPasConst;
     function ParseResourcestringDecl(Parent: TPasElement): TPasResString;
     function ParseResourcestringDecl(Parent: TPasElement): TPasResString;
     function ParseTypeDecl(Parent: TPasElement): TPasType;
     function ParseTypeDecl(Parent: TPasElement): TPasType;
-    procedure ParseInlineVarDecl(Parent: TPasElement; VarList: TList);
+    procedure ParseInlineVarDecl(Parent: TPasElement; VarList: TList);overload;
     procedure ParseInlineVarDecl(Parent: TPasElement; VarList: TList;
     procedure ParseInlineVarDecl(Parent: TPasElement; VarList: TList;
-      AVisibility : TPasMemberVisibility; ClosingBrace: Boolean);
+      AVisibility : TPasMemberVisibility; ClosingBrace: Boolean);overload;
     procedure ParseVarDecl(Parent: TPasElement; List: TList);
     procedure ParseVarDecl(Parent: TPasElement; List: TList);
     procedure ParseArgList(Parent: TPasElement; Args: TList; EndToken: TToken);
     procedure ParseArgList(Parent: TPasElement; Args: TList; EndToken: TToken);
     procedure ParseProcedureOrFunctionHeader(Parent: TPasElement;
     procedure ParseProcedureOrFunctionHeader(Parent: TPasElement;

+ 2 - 2
packages/fcl-passrc/src/pscanner.pp

@@ -194,8 +194,8 @@ type
 
 
     function GetCurColumn: Integer;
     function GetCurColumn: Integer;
   protected
   protected
-    procedure Error(const Msg: string);
-    procedure Error(const Msg: string; Args: array of Const);
+    procedure Error(const Msg: string);overload;
+    procedure Error(const Msg: string; Args: array of Const);overload;
     function DoFetchToken: TToken;
     function DoFetchToken: TToken;
   public
   public
     Options : set of TPOptions;
     Options : set of TPOptions;