Martin Frb via fpc-devel
2021-05-18 13:24:44 UTC
I was looking at TypeInfo (based on 3.2.2rc)
line 632 unit TypInfo
looked through other code:
fpc_3.2.2\source\tests\webtbs\tw12038.pp
line 194 procedure DisplayDetails(Informations : TPropInfo; const
expectedresult: ansistring);
appears to access the data (except for the ParamTypeRefs array)
The testcase does not seem to make any adjustments for alignment.
fpc_3.2.2\source\packages\rtl-objpas\src\inc\rtti.pp
line 3341 TRttiMethodType.GetParameters
also appears to access the same typeinfo.
It makes alignments in 3 different places
ptr := AlignTParamFlags(ptr); // foreach Flags :
TParamFlags; in the ParamList
ptr := AlignToPtr(PByte(ptr) + ptr^ + SizeOf(Byte)); // ResultTypeRef
paramtypes := PPPTypeInfo(AlignTypeData(ptr)); // ParamTypeRefs
Which is correct?
Or do they access different structures?
----------------------
A few other notes:
FPC_REQUIRES_PROPER_ALIGNMENT
does not seem to be listed on
https://www.freepascal.org/docs-html/prog/progap7.html
TypInfo line 1461
in Procedure GetPropInfos(TypeInfo : PTypeInfo;PropList : PPropList);
TP:=aligntoptr(PPropInfo(aligntoptr((Pointer(@TD^.UnitName)+Length(TD^.UnitName)+1))));
Why call aligntoptr twice?
The TypeCast in between does not change the alignment. (all the math is
done within the innermost call)
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-deve
line 632 unit TypInfo
(MethodKind : TMethodKind;
ParamCount : Byte;
ParamList : array[0..1023] of Char
record
Flags : TParamFlags;
ParamName : ShortString;
TypeName : ShortString;
end;
followed by
ResultType : ShortString // for mkFunction,
mkClassFunction only
ResultTypeRef : PPTypeInfo; // for mkFunction,
mkClassFunction only
CC : TCallConv;
ParamTypeRefs : array[1..ParamCount] of PPTypeInfo;}
);
To find out about alignment (for any target which needs alignment), IParamCount : Byte;
ParamList : array[0..1023] of Char
record
Flags : TParamFlags;
ParamName : ShortString;
TypeName : ShortString;
end;
followed by
ResultType : ShortString // for mkFunction,
mkClassFunction only
ResultTypeRef : PPTypeInfo; // for mkFunction,
mkClassFunction only
CC : TCallConv;
ParamTypeRefs : array[1..ParamCount] of PPTypeInfo;}
);
looked through other code:
fpc_3.2.2\source\tests\webtbs\tw12038.pp
line 194 procedure DisplayDetails(Informations : TPropInfo; const
expectedresult: ansistring);
appears to access the data (except for the ParamTypeRefs array)
The testcase does not seem to make any adjustments for alignment.
fpc_3.2.2\source\packages\rtl-objpas\src\inc\rtti.pp
line 3341 TRttiMethodType.GetParameters
also appears to access the same typeinfo.
It makes alignments in 3 different places
ptr := AlignTParamFlags(ptr); // foreach Flags :
TParamFlags; in the ParamList
ptr := AlignToPtr(PByte(ptr) + ptr^ + SizeOf(Byte)); // ResultTypeRef
paramtypes := PPPTypeInfo(AlignTypeData(ptr)); // ParamTypeRefs
Which is correct?
Or do they access different structures?
----------------------
A few other notes:
FPC_REQUIRES_PROPER_ALIGNMENT
does not seem to be listed on
https://www.freepascal.org/docs-html/prog/progap7.html
TypInfo line 1461
in Procedure GetPropInfos(TypeInfo : PTypeInfo;PropList : PPropList);
TP:=aligntoptr(PPropInfo(aligntoptr((Pointer(@TD^.UnitName)+Length(TD^.UnitName)+1))));
Why call aligntoptr twice?
The TypeCast in between does not change the alignment. (all the math is
done within the innermost call)
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-deve