5

Delphi 2009 で E2283 エラーが発生します: [DCC エラー] outputcode.pas(466): E2283 ローカル定数が多すぎます。より短い手順を使用する

Delphi 2007 は問題なくコンパイルされます。豊富なローカル定数が見つかりません。短い (500 行) 単位です。私が対処できる定数やリテラルがたくさんありますか?

procedure TOutputCodeForm.FormCreate(Sender: TObject);
var
   poParser : TStringStream;
begin

   if ( IsWindowsVista() )  then
   begin
      SetVistaFonts( self );
   end;

   poParser := TStringStream.Create( gstrSQLParser );

   SQLParser := TSyntaxMemoParser.Create( self );
   SQLParser.RegistryKey := '\Software\Advantage Data Architect\SQLSyntaxMemo';
   SQLParser.UseRegistry := True;
   SQLParser.CompileFromStream( poParser );

   FreeAndNil( poParser );
   poParser := TStringStream.Create( gstrCPPParser );



   cppParser := TSyntaxMemoParser.Create( self );
   cppParser.RegistryKey := '\Software\Advantage Data Architect\SQLSyntaxMemo';
   cppParser.UseRegistry := True;
   cppParser.CompileFromStream( poParser );

   FreeAndNil( poParser );
   poParser := TStringStream.Create( gstrPasParser );

   pasParser := TSyntaxMemoParser.Create( self );
   pasParser.RegistryKey := '\Software\Advantage Data Architect\SQLSyntaxMemo';
   pasParser.Script := ExtractFilePath( Application.ExeName ) + 'pasScript.txt';
   pasParser.CompileFromStream( poParser );

   {* Free the stream since we are finished with it. *}
   FreeAndNil( poParser );

   poCodeOutput := TSyntaxMemo.Create( self );
   poCodeOutput.Parent := Panel1;
   poCodeOutput.Left := 8;
   poCodeOutput.Top := 8;
   poCodeOutput.Width := Panel1.Width - 16;
   poCodeOutput.Height := Panel1.Height - 16;
   poCodeOutput.ClipCopyFormats := [smTEXT, smRTF];
   poCodeOutput.Font.Charset := ANSI_CHARSET;
   poCodeOutput.Font.Color := clWindowText;
   poCodeOutput.Font.Height := -11;
   poCodeOutput.Font.Name := 'Courier New';
   poCodeOutput.Font.Style := [];
   poCodeOutput.GutterFont.Charset := DEFAULT_CHARSET;
   poCodeOutput.GutterFont.Color := clWindowText;
   poCodeOutput.GutterFont.Height := -11;
   poCodeOutput.GutterFont.Name := 'MS Sans Serif';
   poCodeOutput.GutterFont.Style := [];
   poCodeOutput.HyperCursor := crDefault;
   poCodeOutput.IndentStep := 1;
   poCodeOutput.Margin := 2;
   poCodeOutput.Modified := False;
   poCodeOutput.MonoPrint := True;
   poCodeOutput.Options := [smoSyntaxHighlight, smoPrintWrap, smoPrintLineNos, smoPrintFilename, smoPrintDate, smoPrintPageNos, smoAutoIndent, smoTabToColumn, smoWordSelect, smoShowRMargin, smoShowGutter, smoShowWrapColumn, smoTitleAsFilename, smoProcessDroppedFiles, smoBlockOverwriteCursor, smoShowWrapGlyph, smoColumnTrack, smoUseTAB, smoSmartFill, smoOLEDragSource];
   poCodeOutput.ReadOnly := False;
   poCodeOutput.RightMargin := 80;
   poCodeOutput.SaveFormat := sfTEXT;
   poCodeOutput.ScrollBars := ssBoth;
   poCodeOutput.SelLineStyle := lsCRLF;
   poCodeOutput.SelStart := 3;
   poCodeOutput.SelLength := 0;
   poCodeOutput.SelTextColor := clWhite;
   poCodeOutput.SelTextBack := clBlack;
   poCodeOutput.TabDefault := 4;
   poCodeOutput.TabOrder := 0;
   poCodeOutput.VisiblePropEdPages := [ppOPTIONS, ppHIGHLIGHTING, ppKEYS, ppAUTOCORRECT, ppTEMPLATES];
   poCodeOutput.WrapAtColumn := 0;
   poCodeOutput.OnKeyDown := FormKeyDown;
   poCodeOutput.ActiveParser := 3;
   poCodeOutput.Anchors := [akLeft, akTop, akRight, akBottom];
   poCodeOutput.Parser1 := pasParser;
   poCodeOutput.Parser2 := cppParser;
   poCodeOutput.Parser3 := SQLParser;

   SQLParser.AttachEditor( poCodeOutput );
   cppParser.AttachEditor( poCodeOutput );
   pasParser.AttachEditor( poCodeOutput );

   poCodeOutput.Lines.AddStrings( poCode );

   if ( CodeType = ctCPP ) then
      poCodeOutput.ActiveParser := 2
   else if ( CodeType = ctPascal ) then
      poCodeOutput.ActiveParser := 1
   else
      poCodeOutput.ActiveParser := 3;

   MainForm.AdjustFormSize( self, 0.95, 0.75 );
end;
4

6 に答える 6

3

コンパイラのバグだと主張したり、助けを求めたりする前に、私はコードを整理してクリーンアップしようと真剣に取り組んでいました。

この巨大なバッグの代わりに、FormCreateの各パーツに対して呼び出される専用のルーチンを作成します。--SQLParseInit --cppParseInit --pasParseInit
-- CodeOutPutInit<-+++++多くの定数があります

そして、特に1が問題を引き起こしているかどうかを確認します。

そして、サードパーティの依存関係をできるだけ少なくして、他の人がそれを再現できるようにするための最小限のケースを作成し、それが本当にバグなのか、それとも単に悪いコードなのかを確認するのは悪くありません。
また、これらの$ IFDEFを削除します...すべての混乱なしに、この動作を引き起こす実際のコードを提供するだけです。

追加:D2007では機能しますが、D2009では機能しないため、コードに含めるすべてのライブラリ/サードパーティコンポーネントがD2009に正しく移行されていることも再確認します。(そのcppParserをドリルダウンします)

于 2008-10-28T20:19:07.023 に答える
3

Win32 で定義されていますか?定数は含まれているすべてのユニットからのものである可能性があります。

私はバイナリ検索を行います。コンパイルされるまでユニットの半分を引き裂き続けてから、何かを追加します。

はい、それはひどいですが、それは BorlandCodeGaembarcadero の内部コンパイラ エラーをデバッグしようとする機能の 1 つです。

于 2008-10-28T17:13:59.050 に答える
0

問題であるメソッド (FormCreate) を見つけてリファクタリングしましたが、チャンクをどれだけ小さくしても、コードの一部を削除しない限り、コンパイラにはまだ問題があります。

François に感謝しますが、コードをリファクタリングしてもエラーが発生します。D2007 でビルドされ、D2009 ではビルドされない場合、それは怪しいように思えます。

procedure TOutputCodeForm.FormCreate(Sender: TObject);
begin

   if ( IsWindowsVista() )  then
   begin
      SetVistaFonts( self );
   end;

   SetupParser( SQLParser, gstrSQLParser, '' );
   // unresolved jmu - have to comment this out for now or delphi will complain
   // that there are too many literals in this file. Seems like a delphi bug
   // since this builds in older versions, and I've already refactored it.
   //SetupParser( cppParser, gstrCPPParser, '' );
   SetupParser( pasParser, gstrPasParser, ExtractFilePath( Application.ExeName ) + 'pasScript.txt' );
   SetupCodeOutput( poCodeOutput );

   SQLParser.AttachEditor( poCodeOutput );
   cppParser.AttachEditor( poCodeOutput );
   pasParser.AttachEditor( poCodeOutput );

   poCodeOutput.Lines.AddStrings( poCode );

   if ( CodeType = ctCPP ) then
      poCodeOutput.ActiveParser := 2
   else if ( CodeType = ctPascal ) then
      poCodeOutput.ActiveParser := 1
   else
      poCodeOutput.ActiveParser := 3;

   MainForm.AdjustFormSize( self, 0.95, 0.75 );
end;
于 2008-10-28T19:20:20.920 に答える
0

問題が Delphi コンパイラ/セットアップの 1 つでのみ発生していることを考えると、コンポーネントのインストールの問題に関連しているのではないかと考えています。動的に作成しているすべてのコンポーネントの静的バージョンを使用する基本的なフォームを作成しようとしましたか? (TSyntaxMemoParser など)。

(これらの Delphi バージョンを別々のマシン/VM で実行していますか?多くのサードパーティ コンポーネントと複数のバージョンの Delphi を使用すると、多くの手間を省くことができます)

于 2008-10-29T09:21:42.250 に答える
0

ヘルプから:

1 つ以上のプロシージャに含まれる文字列定数式が多すぎて、コンパイラの内部ストレージ制限を超えています。これは、自動的に生成されるコードで発生する可能性があります。これを修正するには、コードで非常に多くのリテラルを使用する代わりに、プロシージャを短縮するか、定数識別子を宣言します。

したがって、これらの文字列の一部を const または他の変数 (非ローカル) に入れてみてください。

于 2008-10-31T22:35:27.370 に答える
0

「poCodeOutput.Options := [xx....]」の行を見てみましょう。コードの 1 行でセット内のオプションが多すぎるように見えます。

その1行を取り出して、エラーが発生するかどうかを確認してください。

于 2008-11-08T04:13:24.033 に答える