⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uextidents.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{  JADD - Just Another DelphiDoc: Documentation from Delphi Source Code

Copyright (C) 2003-2008   Gerold Veith

This file is part of JADD - Just Another DelphiDoc.

DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.

DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
}


unit UExtIdents;

{Contains the classes for all identifiers besides the base classes defined in
 ~[linkUnit UBaseIdents].  }

interface

uses SysUtils, Classes,
     UPascalConsts,
     UBaseIdents;



type
   { * * *  ***  * * *  ***   TVariable   ***  * * *  ***  * * *  }

  //export directives of variables in the FreePascal-dialect.
  TVariableExport = (
                     veNone,     //no special attribute given
                     veExternal, //import of an external variable
                     veExport,   //export of the variable
                     vePublic,   //export of the variable
                     veCVar);      //export and name mangling like in C

  {The class for all variables. Besides a type the objects can have an
   initialization. Distinguished between normal variables and thread-variables
   is by a simple boolean value in each object. }
  TVariable = class(TIdentifier)
  private
    FVarType: TType;             //the type of the variable
    FInitialization: String;     //the initialization of the variable
    FVarInitIsAbsolute: Boolean; //is initialization with absolute?
    FIsThreadVar: Boolean;       //if it is a thread-variable
{//Free Pascal dialect:
    FExternal: TVariableExport;  //export directive of variables in FreePascal
    FExternalName: String;       //external name of the variable
    FExternalDLLName: String;    //name of the library containing the variable
}
  protected
    //Copies all data of this identifier to the Clone.
    procedure CloneTo(Clone: TIdentifier); override;
  public
    //Frees the type.
    destructor Destroy; override;

    //Calls Proc with each instance of TIdentType.
    procedure ForEachIdentType(Proc: TForEachIdentTypeProc; Parent: TIdentifier;
                               Data: TIdentifier = nil); override;
    //Adds the given set to its own and all contained identifiers.
    procedure AddPortabilityIssues(Portability: TIdentPortabilities); override;
    //Tests if it is or contains Ident.
    function RecursiveIsIn(Ident: TIdentifier): Boolean; override;

    //Gets a description of the identifier, mostly like it has been declared in
    //the pascal data.
    function GetDescriptionString(TextFormat: TTextFormat;
                                  SourceIdent: TIdentifier = nil): String;
                                                                      override;
    //Gets the declaration of the identifier in an internal representation.
    procedure GetDeclaration(Assembly: TDeclarationAssembler); override;

    //Adds itself and all owned identifiers to the list.
    procedure AddToList(List: TIdentifierList); override;

    //Saves the identifier to the stream.
    procedure Save(Stream: TIdentStream); override;
    //Loads the identifier from the stream.
    procedure Load(Stream: TIdentStream; Version: TIdentClassVersion);
                                                                      override;
    //Compares this identifier with the other one.
    function CompareWith(Ident: TIdentifier; const MsgPrefix: String;
                         Messages: TStrings): Boolean; override;


    property VarType: TType read FVarType write FVarType;
    property VarInitialization: String read FInitialization
                                       write FInitialization;
    property VarInitIsAbsolute: Boolean read FVarInitIsAbsolute
                                        write FVarInitIsAbsolute;
    property IsThreadVar: Boolean read FIsThreadVar write FIsThreadVar;
{
    property External: TVariableExport read FExternal write FExternal;
    property ExternalName: String read FExternalName write FExternalName;
    property ExternalDLLName: String read FExternalDLLName
                                     write FExternalDLLName;
}
  end;




   { * * *  ***  * * *  ***   TResourceString   ***  * * *  ***  * * *  }


  {The class for all resource strings. It only has to contain the value of the
   string. }
  TResourceString = class(TIdentifier)
  private
    FValue: String;        //the value (expression) of the resource string
  protected
    //Copies all data of this identifier to the Clone.
    procedure CloneTo(Clone: TIdentifier); override;
  public
    //Gets a description of the identifier, mostly like it has been declared in
    //the pascal data.
    function GetDescriptionString(TextFormat: TTextFormat;
                                  SourceIdent: TIdentifier = nil): String;
                                                                      override;
    //Gets the declaration of the identifier in an internal representation.
    procedure GetDeclaration(Assembly: TDeclarationAssembler); override;


    //Saves the identifier to the stream.
    procedure Save(Stream: TIdentStream); override;
    //Loads the identifier from the stream.
    procedure Load(Stream: TIdentStream; Version: TIdentClassVersion);
                                                                      override;
    //Compares this identifier with the other one.
    function CompareWith(Ident: TIdentifier; const MsgPrefix: String;
                         Messages: TStrings): Boolean; override;


    property Value: String read FValue write FValue;
  end;




   { * * *  ***  * * *  ***   TConstant   ***  * * *  ***  * * *  }


  {The class for all constants. It has to contain the value of the constant and
   the type that can be nil. }
  TConstant = class(TIdentifier)
  private
    FConstType: TType;          //the type of the constant or nil
    FValue: String;             //the value (expression) of the constant
  protected
    //Copies all data of this identifier to the Clone.
    procedure CloneTo(Clone: TIdentifier); override;
  public
    //Frees the type.
    destructor Destroy; override;

    //Calls Proc with each instance of TIdentType.
    procedure ForEachIdentType(Proc: TForEachIdentTypeProc; Parent: TIdentifier;
                               Data: TIdentifier = nil); override;
    //Adds the given set to its own and all contained identifiers.
    procedure AddPortabilityIssues(Portability: TIdentPortabilities); override;
    //Tests if it is or contains Ident.
    function RecursiveIsIn(Ident: TIdentifier): Boolean; override;

    //Gets a description of the identifier, mostly like it has been declared in
    //the pascal data.
    function GetDescriptionString(TextFormat: TTextFormat;
                                  SourceIdent: TIdentifier = nil): String;
                                                                      override;
    //Gets the declaration of the identifier in an internal representation.
    procedure GetDeclaration(Assembly: TDeclarationAssembler); override;

    //Adds itself and all owned identifiers to the list.
    procedure AddToList(List: TIdentifierList); override;

    //Saves the identifier to the stream.
    procedure Save(Stream: TIdentStream); override;
    //Loads the identifier from the stream.
    procedure Load(Stream: TIdentStream; Version: TIdentClassVersion);
                                                                      override;
    //Compares this identifier with the other one.
    function CompareWith(Ident: TIdentifier; const MsgPrefix: String;
                         Messages: TStrings): Boolean; override;


    property ConstType: TType read FConstType write FConstType;
    property Value: String read FValue write FValue;
  end;




   { * * *  ***  * * *  ***   TParameter   ***  * * *  ***  * * *  }


  {The class for all parameters. It has to contain the kind of the parameter,
   by value, by reference, constant-parameter and out-parameter, the type, that
   can be nil if not a by value-parameter, and a default value that can be ''.}
  TParameter = class(TIdentifier)
  private
    FKind: TParameterKind;        //the kind of the parameter
    FParamType: TType;            //the type of the parameter or nil
    FDefaultValue: String;        //the default value of the parameter or ''
  protected
    //Copies all data of this identifier to the Clone.
    procedure CloneTo(Clone: TIdentifier); override;
  public
    //Frees the type.
    destructor Destroy; override;

    //Calls Proc with each instance of TIdentType.
    procedure ForEachIdentType(Proc: TForEachIdentTypeProc; Parent: TIdentifier;
                               Data: TIdentifier = nil); override;
    //Adds the given set to its own and all contained identifiers.
    procedure AddPortabilityIssues(Portability: TIdentPortabilities); override;
    //Tests if it is or contains Ident.
    function RecursiveIsIn(Ident: TIdentifier): Boolean; override;

    //Gets a description of the identifier, mostly like it has been declared in
    //the pascal data.
    function GetDescriptionString(TextFormat: TTextFormat;
                                  SourceIdent: TIdentifier = nil): String;
                                                                       override;
    //Gets the declaration of the identifier in an internal representation.
    procedure GetDeclaration(Assembly: TDeclarationAssembler); override;

    //Tests if this identifier is equal to Other as regards content.
    function ParamEqualTo(Other: TParameter): Boolean;


    //Adds itself and all owned identifiers to the list.
    procedure AddToList(List: TIdentifierList); override;

    //Saves the identifier to the stream.
    procedure Save(Stream: TIdentStream); override;
    //Loads the identifier from the stream.
    procedure Load(Stream: TIdentStream; Version: TIdentClassVersion);
                                                                      override;
    //Compares this identifier with the other one.
    function CompareWith(Ident: TIdentifier; const MsgPrefix: String;
                         Messages: TStrings): Boolean; override;


    property Kind: TParameterKind read FKind write FKind;
    property ParamType: TType read FParamType write FParamType;
    property DefaultValue: String read FDefaultValue write FDefaultValue;
  end;





   { * * *  ***  * * *  ***   TFunction   ***  * * *  ***  * * *  }


  {The class for all functions, this means function, procedure, also methods,
   constructors and destructors. It has to contain what kind of this the
   function is, the list of parameters and if it is a function the return type
   (else nil). Additionally it has attributes, calling convention, if it is a
   referencing of a method, that should implement an interface method, the
   reference on the record-like type, from which it is a method, the list of
   all used identifiers in that function and the size of the body. }
  TFunction = class(TIdentifier)
  private
    FFuncKind: TFunctionKind;         //the kind of the function
    FParams: TIdentifierList;         //the list of the parameters
    FReturnType: TType;               //the return type

    FCallConvs: TStringList;          //the calling conventions
    FAttributes: TFunctionAttributes; //the attributes
    //the interface, for which it implements a method
    //~feature change to ~[link TIdentType]?
    FInterf: String;

    FUsedIdents: TIdentifierList;     //all used identifiers in that function
    FBodySize: TPosition;             //the size of the body of the function
  protected
    //Copies all data of this identifier to the Clone.
    procedure CloneTo(Clone: TIdentifier); override;
  public
    //Creates the object for the function and the list for the parameters.
    constructor Create; override;
    //Frees the object and all lists and the return type.
    destructor Destroy; override;

    //Calls Proc with each instance of TIdentType.
    procedure ForEachIdentType(Proc: TForEachIdentTypeProc; Parent: TIdentifier;
                               Data: TIdentifier = nil); override;
    //Adds the given set to its own and all contained identifiers.
    procedure AddPortabilityIssues(Portability: TIdentPortabilities); override;
    //Tests if it is or contains Ident.
    function RecursiveIsIn(Ident: TIdentifier): Boolean; override;

    //Gets a description of the identifier, mostly like it has been declared in
    //the pascal data.
    function GetDescriptionString(TextFormat: TTextFormat;
                                  SourceIdent: TIdentifier = nil): String;
                                                                      override;
    //Gets the declaration of the identifier in an internal representation.
    procedure GetDeclaration(Assembly: TDeclarationAssembler); override;

    //Generates a cross reference, by adding each identifier to each
    //identifier's ~[link UsedByIdents]-list it's using.
    function GenerateCrossReference: TIdentifier; override;

    //Sets the list of used global identifiers.
    procedure SetUsedIdentsList(UsedIdents: TIdentifierList);

    //Checks if the method is still abstract/not implemented in that class.
    function StillAbstractIn(CurrentClass: TRecordType): Boolean;


    //Adds itself and all owned identifiers to the list.
    procedure AddToList(List: TIdentifierList); override;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -