Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Die Delphi-IDE (https://www.delphipraxis.net/62-die-delphi-ide/)
-   -   [Delphi 2010] Interner Fehler (https://www.delphipraxis.net/145848-%5Bdelphi-2010%5D-interner-fehler.html)

cookie22 9. Jan 2010 11:14


[Delphi 2010] Interner Fehler
 
Hallo,

ich habe eine funktion von c# nach delphi übersetzt und benutzte dazu
"TDictionary<TKey,TValue>", kompilieren lässt sich das ganze ohne probleme. beim linken kommt dann: [DCC Fataler Fehler] F2084 Interner Fehler: L1737. jemand ne idee woran das liegen kann? :gruebel:

auslöser scheinen die folgenden zeilen zu sein:
Delphi-Quellcode:
 
  dictionary := Generics.Collections.TDictionary<Char, Cardinal>.Create;
  dictionary2 := Generics.Collections.TDictionary<Integer, Cardinal>.Create;
P.S. Update 4 hab ich drauf.

gruß,
cookie

Daniel 9. Jan 2010 11:16

Re: [Delphi 2010] Interner Fehler
 
hm.

Versuche mal, die Namespaces wegzulassen:

Delphi-Quellcode:
dictionary := TDictionary<Char, Cardinal>.Create;
dictionary2 := TDictionary<Integer, Cardinal>.Create;
Das sollte funktionieren.

//edit:

Also folgender Code compiliert, linkt und startet bei mir wie erwartet:

Delphi-Quellcode:
procedure Tfrm_Main.Test;
var dictionary : TDictionary<Char, Cardinal>;
   dictionary2 : TDictionary<Integer, Cardinal>;
begin
  dictionary := Generics.Collections.TDictionary<Char, Cardinal>.Create;
  dictionary2 := Generics.Collections.TDictionary<Integer, Cardinal>.Create;
end;

cookie22 9. Jan 2010 11:35

Re: [Delphi 2010] Interner Fehler
 
namespaces weglassen bringt nix, habs gerade getestet.

bei mir startet das auch wenn ich die funktion nirgens benutze, wenn ich die funktion irgenwo benutze kommt der fehler.

mkinzler 9. Jan 2010 11:39

Re: [Delphi 2010] Interner Fehler
 
Dann zeig mal den Zugriff

Dezipaitor 9. Jan 2010 12:11

Re: [Delphi 2010] Interner Fehler
 
Versuch mal einen eigenen Typ für "TDictionary<Char, Cardinal>" zu machen und benutze diesen.

cookie22 9. Jan 2010 12:16

Re: [Delphi 2010] Interner Fehler
 
also ich mache das folgendermassen.

hier das original in c#:
Code:
public static uint EstimatePasswordBits(char[] vPasswordChars)
      {
         bool bChLower = false, bChUpper = false, bChNumber = false;
         bool bChSimpleSpecial = false, bChExtSpecial = false, bChHigh = false;
         bool bChEscape = false;
         Dictionary<char, uint> vCharCounts = new Dictionary<char, uint>();
         Dictionary<int, uint> vDifferences = new Dictionary<int, uint>();
         double dblEffectiveLength = 0.0;

         Debug.Assert(vPasswordChars != null); if(vPasswordChars == null) throw new ArgumentNullException("vPasswordChars");

         for(int i = 0; i < vPasswordChars.Length; i++) // Get character types
         {
            char tch = vPasswordChars[i];

            if(tch < ' ') bChEscape = true;
            if((tch >= 'A') && (tch <= 'Z')) bChUpper = true;
            if((tch >= 'a') && (tch <= 'z')) bChLower = true;
            if((tch >= '0') && (tch <= '9')) bChNumber = true;
            if((tch >= ' ') && (tch <= '/')) bChSimpleSpecial = true;
            if((tch >= ':') && (tch <= '@')) bChExtSpecial = true;
            if((tch >= '[') && (tch <= '`')) bChExtSpecial = true;
            if((tch >= '{') && (tch <= '~')) bChExtSpecial = true;
            if(tch > '~') bChHigh = true;

            double dblDiffFactor = 1.0;
            if(i >= 1)
            {
               int iDiff = (int)tch - (int)vPasswordChars[i - 1];

               if(vDifferences.ContainsKey(iDiff) == false)
                  vDifferences.Add(iDiff, 1);
               else
               {
                  vDifferences[iDiff] = vDifferences[iDiff] + 1;
                  dblDiffFactor /= (double)vDifferences[iDiff];
               }
            }

            if(vCharCounts.ContainsKey(tch) == false)
            {
               vCharCounts.Add(tch, 1);
               dblEffectiveLength += dblDiffFactor;
            }
            else
            {
               vCharCounts[tch] = vCharCounts[tch] + 1;
               dblEffectiveLength += dblDiffFactor * (1.0 / (double)vCharCounts[tch]);
            }
         }

         uint charSpace = 0;
         if(bChEscape) charSpace += (uint)CharSpaceBits.Escape;
         if(bChUpper) charSpace += (uint)CharSpaceBits.Alpha;
         if(bChLower) charSpace += (uint)CharSpaceBits.Alpha;
         if(bChNumber) charSpace += (uint)CharSpaceBits.Number;
         if(bChSimpleSpecial) charSpace += (uint)CharSpaceBits.SimpleSpecial;
         if(bChExtSpecial) charSpace += (uint)CharSpaceBits.ExtendedSpecial;
         if(bChHigh) charSpace += (uint)CharSpaceBits.High;

         if(charSpace == 0) return 0;

         double dblBitsPerChar = Math.Log((double)charSpace) / Math.Log(2.0);

         return (uint)Math.Ceiling(dblBitsPerChar * dblEffectiveLength);
      }
das hab ich mir mit hilfe von refector daraus zusammen gereimt. meine c# kenntnisse sind = 0, das muss ich dazu sagen.

Delphi-Quellcode:
function EstimatePasswordBits(vPasswordChars: string): Cardinal;
var
  flag, flag2, flag3, flag4, flag5, flag6, flag7: Boolean;
  dictionary: TDictionary<Char, Cardinal>;
  dictionary2: TDictionary<Integer, Cardinal>;
  i, num, num3, num4, num5 : Integer;
   num6 : Extended;
  key: Char;
begin
  flag := False;
  flag2 := False;
  flag3 := False;
  flag4 := False;
  flag5 := False;
  flag6 := False;
  flag7 := False;
  num := 0;

  dictionary := TDictionary<Char, Cardinal>.Create;
  dictionary2 := TDictionary<Integer, Cardinal>.Create;

  if (vPasswordChars = '') then
    raise ArgumentNullException.Create('vPasswordChars');
  i := 0;
  while i < Length(vPasswordChars) do
    begin
      key := vPasswordChars[i];
      if (key < ' ') then
        flag7 := True;
      if ((key >= 'A') and (key <= 'Z')) then
        flag2 := True;
      if ((key >= 'a') and (key <= 'z')) then
        flag := True;
      if ((key >= '0') and (key <= '9')) then
        flag3 := True;
      if ((key >= ' ') and (key <= '/')) then
        flag4 := True;
      if ((key >= ':') and (key <= '@')) then
        flag5 := True;
      if ((key >= '[') and (key <= '`')) then
        flag5 := True;
      if ((key >= '{') and (key <= '~')) then
        flag5 := True;
      if (key > '~') then
        flag6 := True;
      num3 := 1;
      if (i >= 1) then
        begin
          num4 := (Ord(key) - Ord(vPasswordChars[i - 1]));
          if (not dictionary2.ContainsKey(num4)) then
            dictionary2.Add(num4, 1)
          else
            begin
              dictionary2.Items[num4] := dictionary2.Items[num4] + 1;
              num3 := num3 div (dictionary2.Items[num4])
            end
        end;
      if (not dictionary.ContainsKey(key)) then
        begin
          dictionary.Add(key, 1);
          inc(num, num3)
        end
      else
        begin
         dictionary.Items[key] := dictionary.Items[key] +1;
          inc(num, (num3 * (1 div (dictionary.Items[key] ))))
        end;
      inc(i)
    end;
  num5 := 0;
  if (flag7) then
    inc(num5, 60);
  if (flag2) then
    inc(num5, $1A);
  if (flag) then
    inc(num5, $1A);
  if (flag3) then
    inc(num5, 10);
  if (flag4) then
    inc(num5, $10);
  if (flag5) then
    inc(num5, $11);
  if (flag6) then
    inc(num5, $70);
  if (num5 = 0) then
    begin
      Result := 0;
      exit
    end;
  num6 := round(Math.LogN(1, (num5))) / round(Math.LogN(1, 2));
  begin
    Result := Math.Ceil(num6 * num);
    exit
  end
end;
Delphi-Quellcode:
...
var
  s: string;
  bits: cardinal;
begin
...
  bits := EstimatePasswordBits(s);
...
end;

wie gesagt compilieren lässt sich das, nur nicht aufrufen.

mkinzler 9. Jan 2010 12:24

Re: [Delphi 2010] Interner Fehler
 
Und wo knallt es genau?

cookie22 9. Jan 2010 12:33

Re: [Delphi 2010] Interner Fehler
 
Zitat:

Zitat von mkinzler
Und wo knallt es genau?

sobald ich das irgendwo aufrufe, und auf compilieren drücke, kommt der fehler als letzte meldung.

mkinzler 9. Jan 2010 12:36

Re: [Delphi 2010] Interner Fehler
 
Hast du mal bei EM bei den Bug Reports geschaut, ob schon jemnad den Fehler gemeldet hat bzw. ihn gemeldet?

Dezipaitor 9. Jan 2010 13:00

Re: [Delphi 2010] Interner Fehler
 
Delphi-Quellcode:
var num6 : Extended;
-..
num6 := round(Math.LogN(1, (num5))) / round(Math.LogN(1, 2));
Divison durch 0.


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:12 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz