나는 다음과 같은 오류가 발생합니다 '매개 변수 목록은 다르다'. 여기 E2009 호환되지 않는 유형 : 나는 차이를 볼 수있는 정의를보고,</p> <blockquote> <p>E2009 Incompatible types: 'Parameter lists differ'</p> </blockquote> <p>그러나 나는 동의 :
type
TFastDiv = record
private
...
DivideFunction: function (const Buffer: TFastDiv; x: integer): integer;
그리고 여기 할당 할 MOD 함수입니다 :
class operator TFastDiv.Implicit(a: integer): TFastDiv;
begin
if (a = 0) then begin
raise EDivByZero.Create('Setting a zero divider is a division by zero error')
at ReturnAddress;
end;
Result.FSign:= Math.sign(a);
case Result.FSign of
-1: begin
SetDivisorI32(Result, a);
Result.DivideFunction:= dividefixedi32; <<-- error E2009
:
function dividefixedi32(const Buffer: TFastDiv; x: integer): integer;
asm
다음 할당 오류를 발행
내 코드가 잘못되었습니다.
SSCCE
unit SSCCE;
interface
uses Math;
type
TFastDiv = record
private
FBuffer: UInt64; // The reciprocal of the divider
FDivider: integer; // The divider itself (need with modulus etc).
FSign: TValueSign;
DivideFunction: function (const Buffer: TFastDiv; x: integer): integer;
ModFunction: function (const Buffer: TFastDiv; x: integer): integer;
public
class operator Implicit(a: integer): TFastDiv;
end;
implementation
uses SysUtils;
function dividefixedi32(const Buffer: TFastDiv; x: integer): integer; forward;
class operator TFastDiv.Implicit(a: integer): TFastDiv;
begin
if (a = 0) then begin raise EDivByZero.Create('Setting a zero divider is a division by zero error') at ReturnAddress; end;
Result.FSign:= Math.sign(a);
case Result.FSign of
-1: begin
//SetDivisorI32(Result, a);
Result.DivideFunction:= dividefixedi32;
end; {-1:}
1: begin
//SetDivisorU32(Result.FBuffer, a);
end; {1:}
end; {case}
Result.FDivider:= a;
end;
function dividefixedi32(const Buffer: TFastDiv; x: integer): integer;
asm
mov eax, edx
mov r8d, edx // x
mov r9, rcx // Buffer
imul dword [r9] // m
lea eax, [rdx+r8] // r8 = r8 or rsi
mov ecx, [r9+4] // shift count
sar eax, cl
sar r8d, 31 // sign(x)
sub eax, r8d
ret
end;
end.
시도해 보면 잘 작동합니다. [SSCCE] (http : // sscce.org), 내 생각 엔 아마도 서로 충돌하는 범위에 여러 개의 'TFastDiv' 유형이있을 것입니다. –
아니요 TFastDiv 레코드 정의에만 있습니다 (파일에서 찾기로 확인). – Johan
@RemyLebeau, SSCCE를 추가했습니다. – Johan