mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 17:16:01 +02:00
codetools: parser: added class operator copy and clone
git-svn-id: trunk@53706 -
This commit is contained in:
parent
bc9a802ce1
commit
c9680cf88a
@ -137,6 +137,7 @@ type
|
|||||||
function GetExtraction(InUpperCase: boolean): string;
|
function GetExtraction(InUpperCase: boolean): string;
|
||||||
function ExtractStreamEndIsIdentChar: boolean;
|
function ExtractStreamEndIsIdentChar: boolean;
|
||||||
procedure ExtractNextAtom(AddAtom: boolean; Attr: TProcHeadAttributes);
|
procedure ExtractNextAtom(AddAtom: boolean; Attr: TProcHeadAttributes);
|
||||||
|
procedure CheckOperatorProc(IsOperator: boolean; var IsFunction: boolean); inline;
|
||||||
protected
|
protected
|
||||||
// parsing
|
// parsing
|
||||||
FLastCompilerMode: TCompilerMode;
|
FLastCompilerMode: TCompilerMode;
|
||||||
@ -324,6 +325,18 @@ end;
|
|||||||
|
|
||||||
{ TPascalParserTool }
|
{ TPascalParserTool }
|
||||||
|
|
||||||
|
// inline
|
||||||
|
procedure TPascalParserTool.CheckOperatorProc(IsOperator: boolean;
|
||||||
|
var IsFunction: boolean);
|
||||||
|
begin
|
||||||
|
if IsOperator then begin
|
||||||
|
AtomIsCustomOperator(true,true,true);
|
||||||
|
IsFunction:=not (UpAtomIs('INITIALIZE') or UpAtomIs('FINALIZE')
|
||||||
|
or UpAtomIs('COPY') or UpAtomIs('CLONE'));
|
||||||
|
end else
|
||||||
|
AtomIsIdentifierSaveE;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TPascalParserTool.Create;
|
constructor TPascalParserTool.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
@ -1239,11 +1252,7 @@ begin
|
|||||||
IsOperator:=(not IsFunction) and UpAtomIs('OPERATOR');
|
IsOperator:=(not IsFunction) and UpAtomIs('OPERATOR');
|
||||||
// read name
|
// read name
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if IsOperator then begin
|
CheckOperatorProc(IsOperator,IsFunction);
|
||||||
AtomIsCustomOperator(true,true,true);
|
|
||||||
IsFunction:=not (UpAtomIs('INITIALIZE') or UpAtomIs('FINALIZE'));
|
|
||||||
end else
|
|
||||||
AtomIsIdentifierSaveE;
|
|
||||||
// create node for procedure head
|
// create node for procedure head
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnProcedureHead;
|
CurNode.Desc:=ctnProcedureHead;
|
||||||
@ -2646,16 +2655,6 @@ var ChildCreated: boolean;
|
|||||||
IsFunction, HasForwardModifier, IsClassProc, IsOperator, IsMethod: boolean;
|
IsFunction, HasForwardModifier, IsClassProc, IsOperator, IsMethod: boolean;
|
||||||
ProcNode: TCodeTreeNode;
|
ProcNode: TCodeTreeNode;
|
||||||
ParseAttr: TParseProcHeadAttributes;
|
ParseAttr: TParseProcHeadAttributes;
|
||||||
|
|
||||||
procedure CheckProcName;
|
|
||||||
begin
|
|
||||||
if IsOperator then begin
|
|
||||||
AtomIsCustomOperator(true,true,true);
|
|
||||||
IsFunction:=not (UpAtomIs('INITIALIZE') or UpAtomIs('FINALIZE'));
|
|
||||||
end else
|
|
||||||
AtomIsIdentifierSaveE;
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if UpAtomIs('CLASS') then begin
|
if UpAtomIs('CLASS') then begin
|
||||||
if not (CurSection in [ctnImplementation]+AllSourceTypes) then
|
if not (CurSection in [ctnImplementation]+AllSourceTypes) then
|
||||||
@ -2683,7 +2682,7 @@ begin
|
|||||||
IsOperator:=(not IsFunction) and UpAtomIs('OPERATOR');
|
IsOperator:=(not IsFunction) and UpAtomIs('OPERATOR');
|
||||||
IsMethod:=False;
|
IsMethod:=False;
|
||||||
ReadNextAtom;// read first atom of head (= name/operator + parameterlist + resulttype;)
|
ReadNextAtom;// read first atom of head (= name/operator + parameterlist + resulttype;)
|
||||||
CheckProcName;
|
CheckOperatorProc(IsOperator,IsFunction);
|
||||||
if ChildCreated then begin
|
if ChildCreated then begin
|
||||||
// create node for procedure head
|
// create node for procedure head
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
@ -2709,7 +2708,7 @@ begin
|
|||||||
// read procedure name of a class method (the name after the . )
|
// read procedure name of a class method (the name after the . )
|
||||||
IsMethod:=True;
|
IsMethod:=True;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
CheckProcName;
|
CheckOperatorProc(IsOperator,IsFunction);
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5787,16 +5786,6 @@ var
|
|||||||
ParseAttr: TParseProcHeadAttributes;
|
ParseAttr: TParseProcHeadAttributes;
|
||||||
IsProcType: Boolean;
|
IsProcType: Boolean;
|
||||||
ProcHeadNode: TCodeTreeNode;
|
ProcHeadNode: TCodeTreeNode;
|
||||||
|
|
||||||
procedure CheckProcName;
|
|
||||||
begin
|
|
||||||
if IsOperator then begin
|
|
||||||
AtomIsCustomOperator(true,true,true);
|
|
||||||
IsFunction:=not (UpAtomIs('INITIALIZE') or UpAtomIs('FINALIZE'));
|
|
||||||
end else
|
|
||||||
AtomIsIdentifierSaveE;
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if ProcNode.Desc=ctnProcedureHead then ProcNode:=ProcNode.Parent;
|
if ProcNode.Desc=ctnProcedureHead then ProcNode:=ProcNode.Parent;
|
||||||
if ProcNode.Desc=ctnMethodMap then begin
|
if ProcNode.Desc=ctnMethodMap then begin
|
||||||
@ -5845,7 +5834,7 @@ begin
|
|||||||
if not IsProcType then begin
|
if not IsProcType then begin
|
||||||
// read procedure name of a class method (the name after the . )
|
// read procedure name of a class method (the name after the . )
|
||||||
repeat
|
repeat
|
||||||
CheckProcName;
|
CheckOperatorProc(IsOperator,IsFunction);
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if AtomIsChar('<') then
|
if AtomIsChar('<') then
|
||||||
ReadGenericParam;
|
ReadGenericParam;
|
||||||
|
@ -139,6 +139,8 @@ begin
|
|||||||
' // only IFDEF FPC_HAS_MANAGEMENT_OPERATORS',
|
' // only IFDEF FPC_HAS_MANAGEMENT_OPERATORS',
|
||||||
' class operator Initialize(var t: TMyRecord);',
|
' class operator Initialize(var t: TMyRecord);',
|
||||||
' class operator Finalize(var t: TMyRecord);',
|
' class operator Finalize(var t: TMyRecord);',
|
||||||
|
' class operator Copy(var t: TMyRecord);',
|
||||||
|
' class operator Clone(constref t1: TMyRecord ; var t2: TMyRecord);',
|
||||||
' end;',
|
' end;',
|
||||||
'',
|
'',
|
||||||
'class operator TMyRecord.Implicit(t: TMyRecord): TMyRecord;',
|
'class operator TMyRecord.Implicit(t: TMyRecord): TMyRecord;',
|
||||||
|
Loading…
Reference in New Issue
Block a user