[fpc-pascal] PascalScript / FPC: parameters problems (need internals gurus I think)

Alexandre Leclerc alexandre.leclerc at gmail.com
Tue Aug 8 21:40:26 CEST 2006


2006/8/8, Michael Van Canneyt <michael at freepascal.org>:
> The problem is more likely that all arguments are extended, which probably
> means that the stack is used differently. Are they pushed on the FPU stack ?

Ok, I found this procedure that is used to handle parameters... Maybe
this is the actual asm code who is not good... ???

procedure PutOnFPUStackExtended(ft: extended);
asm
  fstp tbyte ptr [ft]
end;

And here is a part of the monstruous function MyAllMethodsHandler2
that work with the arguments:
//...
  if (Res <> nil) then
  begin
    Params.DeleteLast;
    if (ResultAsRegister(Res.FType)) then
    begin
      if (res^.FType.BaseType = btSingle) or (res^.FType.BaseType = btDouble) or
      (res^.FType.BaseType = btCurrency) or (res^.Ftype.BaseType =
btExtended) then
      begin
        case Res^.FType.BaseType of
          btSingle: PutOnFPUStackExtended(PPSVariantSingle(res).Data);
          btDouble: PutOnFPUStackExtended(PPSVariantDouble(res).Data);
          btExtended: PutOnFPUStackExtended(PPSVariantExtended(res).Data);
          btCurrency: PutOnFPUStackExtended(PPSVariantCurrency(res).Data);
        end;
        DestroyHeapVariant(Res);
        Res := nil;
      end else
      begin
{$IFNDEF PS_NOINT64}
        if res^.FType.BaseType <> btS64 then
{$ENDIF}
          CopyArrayContents(Pointer(Longint(Stack)-8),
@PPSVariantData(res)^.Data, 1, Res^.FType);
      end;
    end;
    DestroyHeapVariant(res);
  end;
//...

-- 
Alexandre Leclerc



More information about the fpc-pascal mailing list