mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 13:30:55 +02:00
* Copy & AddRef operators
This commit is contained in:
parent
41e32d0fba
commit
c44f82d11a
@ -1175,8 +1175,11 @@ type
|
||||
otLogicalAnd, otLogicalNot, otLogicalXor,
|
||||
otRightShift,
|
||||
otEnumerator, otIn,
|
||||
// Management operators
|
||||
otInitialize,
|
||||
otFinalize // Management operators
|
||||
otFinalize,
|
||||
otAddRef,
|
||||
otCopy
|
||||
);
|
||||
TOperatorTypes = set of TOperatorType;
|
||||
|
||||
@ -1765,13 +1768,13 @@ const
|
||||
'>',':=','<>','<=','>=','**',
|
||||
'><','Inc','Dec','mod','-','+','Or','div',
|
||||
'shl','or','and','xor','and','not','xor',
|
||||
'shr','enumerator','in','','');
|
||||
'shr','enumerator','in','','','','');
|
||||
OperatorNames : Array[TOperatorType] of string
|
||||
= ('','implicit','explicit','multiply','add','subtract','divide','lessthan','equal',
|
||||
'greaterthan','assign','notequal','lessthanorequal','greaterthanorequal','power',
|
||||
'symmetricaldifference','inc','dec','modulus','negative','positive','bitwiseor','intdivide',
|
||||
'leftshift','logicalor','bitwiseand','bitwisexor','logicaland','logicalnot','logicalxor',
|
||||
'rightshift','enumerator','in','initialize','finalize');
|
||||
'rightshift','enumerator','in','initialize','finalize','addref','copy');
|
||||
|
||||
AssignKindNames : Array[TAssignKind] of string = (':=','+=','-=','*=','/=' );
|
||||
|
||||
|
@ -5482,7 +5482,7 @@ begin
|
||||
ExpectToken(tkColon);
|
||||
ResultEl.ResultType := ParseType(ResultEl,CurSourcePos);
|
||||
end
|
||||
else if not ((Parent is TPasOperator) and (TPasOperator(Parent).OperatorType in [otInitialize,otFinalize])) then
|
||||
else if not ((Parent is TPasOperator) and (TPasOperator(Parent).OperatorType in [otInitialize,otFinalize,otAddRef,otCopy])) then
|
||||
// Initialize operator has no result
|
||||
begin
|
||||
if (CurToken=tkColon) then
|
||||
|
@ -1416,7 +1416,9 @@ begin
|
||||
// otInitialize has no result
|
||||
S:=GetEnumName(TypeInfo(TOperatorType),Ord(T));
|
||||
ResetParser;
|
||||
if t in [otInitialize,otFinalize] then
|
||||
if t in [otCopy] then
|
||||
AddDeclaration(Format('operator %s (constref Src: Integer; var Dest : Integer)',[OperatorNames[t]]))
|
||||
else if t in [otInitialize,otFinalize,otAddRef] then
|
||||
AddDeclaration(Format('operator %s (var a: Integer)',[OperatorNames[t]]))
|
||||
else if t in UnaryOperators then
|
||||
AddDeclaration(Format('operator %s (a: Integer) : te',[OperatorNames[t]]))
|
||||
@ -1425,7 +1427,9 @@ begin
|
||||
ParseOperator;
|
||||
AssertEquals(S+': Token based',t in [otIn],FOperator.TokenBased);
|
||||
AssertEquals(S+': Correct operator type',T,FOperator.OperatorType);
|
||||
if t in [otInitialize,otFinalize] then
|
||||
if t in [otCopy] then
|
||||
AssertEquals('Correct operator name',format('%s(Integer,Integer)',[OperatorNames[t]]),FOperator.Name)
|
||||
else if t in [otInitialize,otFinalize,otAddRef] then
|
||||
AssertEquals('Correct operator name',format('%s(Integer)',[OperatorNames[t]]),FOperator.Name)
|
||||
else if t in UnaryOperators then
|
||||
AssertEquals('Correct operator name',format('%s(Integer):te',[OperatorNames[t]]),FOperator.Name)
|
||||
|
@ -494,7 +494,9 @@ const
|
||||
'Enumerator',
|
||||
'In',
|
||||
'Initialize',
|
||||
'Finalize'
|
||||
'Finalize',
|
||||
'AddRef',
|
||||
'Copy'
|
||||
);
|
||||
|
||||
PCUProcedureModifierNames: array[TProcedureModifier] of string = (
|
||||
|
Loading…
Reference in New Issue
Block a user