瀏覽代碼

pas2js: -i showing modeswitches

git-svn-id: trunk@44134 -
Mattias Gaertner 5 年之前
父節點
當前提交
5a0ea9d884

+ 1 - 4
packages/fcl-passrc/src/pscanner.pp

@@ -1156,9 +1156,6 @@ const
     'DispatchStrField' // vsDispatchStrField
     'DispatchStrField' // vsDispatchStrField
     );
     );
 
 
-const
-  AllLanguageModes = [msFPC,msObjFPC,msDelphi,msTP7,msMac,msISO,msExtPas];
-
 const
 const
   MessageTypeNames : Array[TMessageType] of string = (
   MessageTypeNames : Array[TMessageType] of string = (
     'Fatal','Error','Warning','Note','Hint','Info','Debug'
     'Fatal','Error','Warning','Note','Hint','Info','Debug'
@@ -1167,7 +1164,7 @@ const
 const
 const
   // all mode switches supported by FPC
   // all mode switches supported by FPC
   msAllModeSwitches = [low(TModeSwitch)..High(TModeSwitch)];
   msAllModeSwitches = [low(TModeSwitch)..High(TModeSwitch)];
-  msAllModes = [msFpc..msGPC];
+  AllLanguageModes = [msFPC..msGPC];
 
 
   DelphiModeSwitches = [msDelphi,msClass,msObjpas,msResult,msStringPchar,
   DelphiModeSwitches = [msDelphi,msClass,msObjpas,msResult,msStringPchar,
      msPointer2Procedure,msAutoDeref,msTPProcVar,msInitFinal,msDefaultAnsistring,
      msPointer2Procedure,msAutoDeref,msTPProcVar,msInitFinal,msDefaultAnsistring,

+ 50 - 3
packages/pastojs/src/pas2jscompiler.pp

@@ -3725,7 +3725,7 @@ begin
     'm':
     'm':
       begin
       begin
       // write list of supported modeswitches
       // write list of supported modeswitches
-      for ms in (msAllPas2jsModeSwitches-msAllModes) do
+      for ms in (msAllPas2jsModeSwitches-AllLanguageModes) do
         Log.LogPlain(SModeSwitchNames[ms]);
         Log.LogPlain(SModeSwitchNames[ms]);
       end;
       end;
     'o':
     'o':
@@ -4882,6 +4882,33 @@ begin
 end;
 end;
 
 
 procedure TPas2jsCompiler.WriteInfo;
 procedure TPas2jsCompiler.WriteInfo;
+var
+  Flags: string;
+
+  procedure AppendFlag(const s: string);
+  begin
+    if s='' then exit;
+    if Flags='' then
+      Flags:=Space(Log.Indent)
+    else
+      Flags:=Flags+',';
+    if length(Flags)+length(s)>Log.LineLen then
+    begin
+      Log.LogPlain(Flags);
+      Flags:=Space(Log.Indent);
+    end;
+    Flags:=Flags+s;
+  end;
+
+  procedure FlushFlags;
+  begin
+    if Flags='' then exit;
+    Log.LogPlain(Flags);
+    Flags:='';
+  end;
+
+var
+  ms: TModeSwitch;
 begin
 begin
   WriteVersionLine;
   WriteVersionLine;
   Log.LogLn;
   Log.LogLn;
@@ -4895,10 +4922,30 @@ begin
   Log.LogPlain('Supported CPU instruction sets:');
   Log.LogPlain('Supported CPU instruction sets:');
   Log.LogPlain('  ECMAScript5, ECMAScript6');
   Log.LogPlain('  ECMAScript5, ECMAScript6');
   Log.LogLn;
   Log.LogLn;
+
   Log.LogPlain('Recognized compiler and RTL features:');
   Log.LogPlain('Recognized compiler and RTL features:');
-  Log.LogPlain('  RTTI,CLASSES,EXCEPTIONS,EXITCODE,RANDOM,DYNARRAYS,COMMANDARGS,');
-  Log.LogPlain('  UNICODESTRINGS');
+  Flags:='';
+  AppendFlag('INITFINAL');
+  AppendFlag('RTTI');
+  AppendFlag('CLASSES');
+  AppendFlag('EXCEPTIONS');
+  AppendFlag('EXITCODE');
+  AppendFlag('WIDESTRINGS');
+  AppendFlag('RANDOM');
+  AppendFlag('DYNARRAYS');
+  AppendFlag('COMMANDARGS');
+  AppendFlag('RESOURCES');
+  AppendFlag('UNICODESTRINGS');
+  FlushFlags;
+  Log.LogLn;
+
+  Log.LogPlain('Recognized modeswitches:');
+  Flags:='';
+  for ms in (msAllPas2jsModeSwitches-AllLanguageModes) do
+    AppendFlag(SModeSwitchNames[ms]);
+  FlushFlags;
   Log.LogLn;
   Log.LogLn;
+
   Log.LogPlain('Supported Optimizations:');
   Log.LogPlain('Supported Optimizations:');
   Log.LogPlain('  EnumNumbers');
   Log.LogPlain('  EnumNumbers');
   Log.LogPlain('  RemoveNotUsedPrivates');
   Log.LogPlain('  RemoveNotUsedPrivates');

+ 6 - 0
packages/pastojs/src/pas2jslogger.pp

@@ -119,12 +119,14 @@ type
   private
   private
     FDebugLog: TPas2JSStream;
     FDebugLog: TPas2JSStream;
     FEncoding: string;
     FEncoding: string;
+    FIndent: integer;
     FLastMsgCol: integer;
     FLastMsgCol: integer;
     FLastMsgFile: string;
     FLastMsgFile: string;
     FLastMsgLine: integer;
     FLastMsgLine: integer;
     FLastMsgNumber: integer;
     FLastMsgNumber: integer;
     FLastMsgTxt: string;
     FLastMsgTxt: string;
     FLastMsgType: TMessageType;
     FLastMsgType: TMessageType;
+    FLineLen: integer;
     FMsgNumberDisabled: TIntegerDynArray;// sorted ascending
     FMsgNumberDisabled: TIntegerDynArray;// sorted ascending
     FMsg: TFPList; // list of TPas2jsMessage
     FMsg: TFPList; // list of TPas2jsMessage
     FOnFormatPath: TPScannerFormatPathEvent;
     FOnFormatPath: TPScannerFormatPathEvent;
@@ -212,6 +214,8 @@ type
     property LastMsgTxt: string read FLastMsgTxt write FLastMsgTxt;
     property LastMsgTxt: string read FLastMsgTxt write FLastMsgTxt;
     property LastMsgNumber: integer read FLastMsgNumber write FLastMsgNumber;
     property LastMsgNumber: integer read FLastMsgNumber write FLastMsgNumber;
     property DebugLog: TPas2jsStream read FDebugLog write FDebugLog;
     property DebugLog: TPas2jsStream read FDebugLog write FDebugLog;
+    property LineLen: integer read FLineLen write FLineLen; // used by LogPlainText
+    property Indent: integer read FIndent write FIndent; // used by LogPlainText
   end;
   end;
 
 
 function CompareP2JMessage(Item1, Item2: {$IFDEF Pas2JS}JSValue{$ELSE}Pointer{$ENDIF}): Integer;
 function CompareP2JMessage(Item1, Item2: {$IFDEF Pas2JS}JSValue{$ELSE}Pointer{$ENDIF}): Integer;
@@ -723,6 +727,8 @@ constructor TPas2jsLogger.Create;
 begin
 begin
   FMsg:=TFPList.Create;
   FMsg:=TFPList.Create;
   FShowMsgTypes:=DefaultLogMsgTypes;
   FShowMsgTypes:=DefaultLogMsgTypes;
+  FLineLen:=78;
+  FIndent:=2;
 end;
 end;
 
 
 destructor TPas2jsLogger.Destroy;
 destructor TPas2jsLogger.Destroy;

+ 0 - 1
utils/pas2js/fpmake.pp

@@ -22,7 +22,6 @@ begin
     P.Description := 'Convert pascal sources to javascript.';
     P.Description := 'Convert pascal sources to javascript.';
     P.Email := '[email protected]';
     P.Email := '[email protected]';
     P.NeedLibC:= false;
     P.NeedLibC:= false;
-    P.ShortName:='p2js';
 
 
     P.Directory:=ADirectory;
     P.Directory:=ADirectory;
     P.Version:='3.3.1';
     P.Version:='3.3.1';