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

📄 uextidents.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
                               Messages: TStrings): Boolean;
begin
 Result := inherited CompareWith(Ident, MsgPrefix, Messages);

 if not (Ident is TVariable) then                 //check if correct type
  begin
   Messages.AddObject(MsgPrefix + 'Identifier is not a variable!', Self);
   Result := False;
  end;

 if Result then                                   //correct so far?
  begin
   if FIsThreadVar <> TVariable(Ident).IsThreadVar then
    begin
     Messages.AddObject(MsgPrefix + 'One is a thread-variable the other not!',
                        Self);
     Result := False;
    end;
   if (FVarInitIsAbsolute <> TVariable(Ident).VarInitIsAbsolute) or
      (CompareText(FInitialization,
                   TVariable(Ident).VarInitialization) <> 0) then
    begin
     Messages.AddObject(MsgPrefix + 'Initialization of variable is different!',
                        Self);
     Result := False;
    end;
   if (FVarInitIsAbsolute <> TVariable(Ident).VarInitIsAbsolute) or
      (CompareText(FInitialization,
                   TVariable(Ident).VarInitialization) <> 0) then
    begin
     Messages.AddObject(MsgPrefix + 'Initialization of variable is different!',
                        Self);
     Result := False;
    end;
   if not FVarType.CompareWith(TVariable(Ident).VarType,
                               '', IgnoreStringList) then
    begin
     Messages.AddObject(MsgPrefix + 'Type of variable doesn''t match!', Self);
     Result := False;
    end;
  end;
end;



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


{Copies all data of this identifier to the Clone.
~param Clone the identifier that should receive all data of this object }
procedure TResourceString.CloneTo(Clone: TIdentifier);
begin
 inherited CloneTo(Clone);                 //copy inherited values

 TResourceString(Clone).Value := FValue;   //copy the value-expression
end;

{Gets a description of the identifier, mostly like it has been declared in the
 pascal data.
~param TextFormat  an object as a set of call back-functions to format text
~param SourceIdent the ident for which the whole description should be
                   generated
~result the description of the identifier formatted by TextFormat }
function TResourceString.GetDescriptionString(TextFormat: TTextFormat;
                                       SourceIdent: TIdentifier = nil): String;
begin
 if not assigned(SourceIdent) then
  SourceIdent := Self;          //return name and value
 assert(assigned(SourceIdent.InFile));
 Result := TextFormat.IdentifierText(Name) + ' = ' +
           TextFormat.ExprText(FValue, SourceIdent);
end;

{Gets the declaration of the identifier in an internal representation.
~param Assembly an object with a set of call back-functions to save the
                 declaration }
procedure TResourceString.GetDeclaration(Assembly: TDeclarationAssembler);
begin
 Assembly.IdentifierText(Name);
 Assembly.Text(' = ');
 Assembly.ExprText(FValue);
end;

{Saves the identifier to the stream.
~param Stream the stream to save itself to }
procedure TResourceString.Save(Stream: TIdentStream);
begin
 inherited Save(Stream);                   //write inherited data

 Stream.WriteString(FValue);               //write data
end;

{Loads the identifier from the stream.
~param Stream  the stream to load the identifier from
~param Version the version the data of the identifier is in }
procedure TResourceString.Load(Stream: TIdentStream; Version: TIdentClassVersion);
begin
 inherited Load(Stream, Version);         //load inherited data

 FValue := Stream.ReadString;             //read data
end;


{Compares this identifier with the other one.
~param Ident     the identifier to compare this one with
~param MsgPrefix prefix for the messages to be generated
~param Messages  describing messages are added to this list, if the identifiers
                 are not equal
~result if the identifiers are equal }
function TResourceString.CompareWith(Ident: TIdentifier;
                                     const MsgPrefix: String;
                                     Messages: TStrings): Boolean;
begin
 Result := inherited CompareWith(Ident, MsgPrefix, Messages);

 if not (Ident is TResourceString) then                 //check if correct type
  begin
   Messages.AddObject(MsgPrefix + 'Identifier is not a resourcestring!', Self);
   Result := False;
  end;

 if Result and (CompareText(FValue, TResourceString(Ident).Value) <> 0) then
  begin
   Messages.AddObject(MsgPrefix + 'Value of resourcestring doesn''t match.',
                      Self);
   Result := False;
  end;
end;



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


{Frees the identifier and its type object. }
destructor TConstant.Destroy;
begin
 FConstType.Free;          //free the type

 inherited Destroy;        //free the object
end;

{Copies all data of this identifier to the Clone.
~param Clone the identifier that should receive all data of this object }
procedure TConstant.CloneTo(Clone: TIdentifier);
begin
 inherited CloneTo(Clone);                  //copy inherited values

 if assigned(FConstType) then               //if it has a type, clone it
  TConstant(Clone).ConstType := TType(FConstType.Clone);
 TConstant(Clone).Value := FValue;          //copy the value
end;

{Calls Proc with each instance of ~[linkClass TIdentType].
~param Proc   the call back-procedure to be called by each object of the class
              TIdentType
~param Parent the direct parent of this identifier, will be a parameter to the
              call back-procedure if this is an object of the class TIdentType
~param Data   data to pass on to the call back-procedure when calling }
procedure TConstant.ForEachIdentType(Proc: TForEachIdentTypeProc;
                                     Parent: TIdentifier;
                                     Data: TIdentifier = nil);
begin
 if assigned(FConstType) then                   //if it has a type
  FConstType.ForEachIdentType(Proc, Self, Data);  //test with the type
end;

{Adds the given set of portability issues to its own and all contained
 identifiers.
~param Portability the portability issues to add }
procedure TConstant.AddPortabilityIssues(Portability: TIdentPortabilities);
begin
 inherited AddPortabilityIssues(Portability);        //add portability issues
 if assigned(FConstType) then                        //if it has a type
  FConstType.AddPortabilityIssues(SummarizedPortability); //add also to type
end;

{Tests if this object is or contains Ident.
~param Ident the identifier for which should be tested, if it is or is
             contained by this object
~result if the identifier is this object or is contained by it }
function TConstant.RecursiveIsIn(Ident: TIdentifier): Boolean;
begin                //identifier is this constant or the type?
 Result := inherited RecursiveIsIn(Ident) or
           (assigned(FConstType) and FConstType.RecursiveIsIn(Ident));
end;

{Gets a description of the identifier, mostly like it has been declared in the
 pascal data.
~param TextFormat  an object as a set of call back-functions to format text
~param SourceIdent the ident for which the whole description should be
                   generated
~result the description of the identifier formatted by TextFormat }
function TConstant.GetDescriptionString(TextFormat: TTextFormat;
                                       SourceIdent: TIdentifier = nil): String;
begin
 Result := TextFormat.IdentifierText(Name);    //return the name
 if not assigned(SourceIdent) then
  SourceIdent := Self;
 assert(assigned(SourceIdent.InFile) or not assigned(FConstType));
 if assigned(FConstType) then       //if it has a type, append that text
  Result := Result + ': ' +
            FConstType.GetDescriptionString(TextFormat, SourceIdent);
 //and append the value
 Result := Result + ' = ' + TextFormat.ExprText(FValue, SourceIdent);
end;

{Gets the declaration of the identifier in an internal representation.
~param Assembly an object with a set of call back-functions to save the
                 declaration }
procedure TConstant.GetDeclaration(Assembly: TDeclarationAssembler);
begin
 Assembly.IdentifierText(Name);         //return the name
 if assigned(FConstType) then            //if it has a type,
  begin
   Assembly.Text(': ');
   FConstType.GetDeclaration(Assembly);   //append its declaration
  end;
 Assembly.Text(' = ');
 Assembly.ExprText(FValue);             //and append the value
end;

{Adds itself and all owned identifiers to the list.
~param List the list to add the identifiers to }
procedure TConstant.AddToList(List: TIdentifierList);
begin
 inherited AddToList(List);                 //add itself

 if assigned(FConstType) then               //and its type
  FConstType.AddToList(List);
end;

{Saves the identifier to the stream.
~param Stream the stream to save itself to }
procedure TConstant.Save(Stream: TIdentStream);
begin
 inherited Save(Stream);                   //write inherited data

 Stream.WriteIdent(FConstType);            //write data
 Stream.WriteString(FValue);
end;

{Loads the identifier from the stream.
~param Stream  the stream to load the identifier from
~param Version the version the data of the identifier is in }
procedure TConstant.Load(Stream: TIdentStream; Version: TIdentClassVersion);
begin
 inherited Load(Stream, Version);                         //load inherited data

 //read data
 FConstType := TType(Stream.ReadIdentClass(TType, True));
 FValue := Stream.ReadString;
end;


{Compares this identifier with the other one.
~param Ident     the identifier to compare this one with
~param MsgPrefix prefix for the messages to be generated
~param Messages  describing messages are added to this list, if the identifiers
                 are not equal
~result if the identifiers are equal }
function TConstant.CompareWith(Ident: TIdentifier; const MsgPrefix: String;
                               Messages: TStrings): Boolean;
begin
 Result := inherited CompareWith(Ident, MsgPrefix, Messages);

 if not (Ident is TConstant) then                 //check if correct type
  begin
   Messages.AddObject(MsgPrefix + 'Identifier is not a constant!', Self);
   Result := False;
  end;

 if Result then
  begin
   if CompareText(FValue, TConstant(Ident).Value) <> 0 then
    begin
     Messages.AddObject(MsgPrefix + 'Value of constant doesn''t match.', Self);
     Result := False;
    end;
   if (assigned(FConstType) <> assigned(TConstant(Ident).ConstType)) or
      (assigned(FConstType) and
       not FConstType.CompareWith(TConstant(Ident).ConstType,
                                  '', IgnoreStringList)) then
    begin
     Messages.AddObject(MsgPrefix + 'Type of constant doesn''t match.', Self);
     Result := False;
    end;
  end;
end;


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


{Frees the identifier and its type object. }
destructor TParameter.Destroy;
begin
 FParamType.Free;            //free the type

 inherited Destroy;          //free the object
end;


{Copies all data of this identifier to the Clone.
~param Clone the identifier that should receive all data of this object }
procedure TParameter.CloneTo(Clone: TIdentifier);
begin
 inherited CloneTo(Clone);                 //copy inherited values

 if assigned(FParamType) then              //if it has a type, clone it
  TParameter(Clone).FParamType := TType(FParamType.Clone);
 TParameter(Clone).Kind := FKind;          //copy the other values
 TParameter(Clone).DefaultValue := FDefaultValue;
end;


{Calls Proc with each instance of ~[linkClass TIdentType].
~param Proc   the call back-procedure to be called by each object of the class
              TIdentType
~param Parent the direct parent of this identifier, will be a parameter to the

⌨️ 快捷键说明

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