Browse Source

pas2js: option -Sj

git-svn-id: trunk@44077 -
Mattias Gaertner 5 years ago
parent
commit
b45a0dfbb8
1 changed files with 16 additions and 10 deletions
  1. 16 10
      packages/pastojs/src/pas2jscompiler.pp

+ 16 - 10
packages/pastojs/src/pas2jscompiler.pp

@@ -125,6 +125,7 @@ type
     // features
     // features
     coAllowCAssignments,
     coAllowCAssignments,
     coAllowMacros,
     coAllowMacros,
+    coWriteableConst,
     // output
     // output
     coLowerCase,
     coLowerCase,
     coUseStrict,
     coUseStrict,
@@ -153,7 +154,7 @@ type
   TResourceMode = (rmNone,rmHTML,rmJS);
   TResourceMode = (rmNone,rmHTML,rmJS);
 
 
 const
 const
-  DefaultP2jsCompilerOptions = [coShowErrors,coSourceMapXSSIHeader,coUseStrict];
+  DefaultP2jsCompilerOptions = [coShowErrors,coWriteableConst,coUseStrict,coSourceMapXSSIHeader];
   DefaultP2JSResourceStringFile = rsfProgram;
   DefaultP2JSResourceStringFile = rsfProgram;
   DefaultP2jsRTLVersionCheck = rvcNone;
   DefaultP2jsRTLVersionCheck = rvcNone;
   DefaultResourceMode = rmHTML;
   DefaultResourceMode = rmHTML;
@@ -185,6 +186,7 @@ const
     'Assertions',
     'Assertions',
     'Allow C assignments',
     'Allow C assignments',
     'Allow macros',
     'Allow macros',
+    'Allows typed constants to be writeable',
     'Lowercase identifiers',
     'Lowercase identifiers',
     'Use strict',
     'Use strict',
     'Write pas2jsdebug.log',
     'Write pas2jsdebug.log',
@@ -1008,8 +1010,12 @@ var
   bs: TBoolSwitches;
   bs: TBoolSwitches;
 begin
 begin
   bs:=[bsLongStrings,bsWriteableConst];
   bs:=[bsLongStrings,bsWriteableConst];
-  if coAllowMacros in Compiler.Options then
-    Include(bs,bsMacro);
+  if coShowHints in Compiler.Options then
+    Include(bs,bsHints);
+  if coShowNotes in Compiler.Options then
+    Include(bs,bsNotes);
+  if coShowWarnings in Compiler.Options then
+    Include(bs,bsWarnings);
   if coOverflowChecks in Compiler.Options then
   if coOverflowChecks in Compiler.Options then
     Include(bs,bsOverflowChecks);
     Include(bs,bsOverflowChecks);
   if coRangeChecks in Compiler.Options then
   if coRangeChecks in Compiler.Options then
@@ -1018,12 +1024,10 @@ begin
     Include(bs,bsObjectChecks);
     Include(bs,bsObjectChecks);
   if coAssertions in Compiler.Options then
   if coAssertions in Compiler.Options then
     Include(bs,bsAssertions);
     Include(bs,bsAssertions);
-  if coShowHints in Compiler.Options then
-    Include(bs,bsHints);
-  if coShowNotes in Compiler.Options then
-    Include(bs,bsNotes);
-  if coShowWarnings in Compiler.Options then
-    Include(bs,bsWarnings);
+  if coAllowMacros in Compiler.Options then
+    Include(bs,bsMacro);
+  if not (coWriteableConst in Compiler.Options) then
+    Exclude(bs,bsWriteableConst);
   Result:=bs;
   Result:=bs;
 end;
 end;
 
 
@@ -3990,7 +3994,7 @@ var
   Enabled, Disabled: string;
   Enabled, Disabled: string;
   i: Integer;
   i: Integer;
 begin
 begin
-  ReadSingleLetterOptions(Param,p,'2acdm',Enabled,Disabled);
+  ReadSingleLetterOptions(Param,p,'2acdmj',Enabled,Disabled);
   for i:=1 to length(Enabled) do begin
   for i:=1 to length(Enabled) do begin
     case Enabled[i] of
     case Enabled[i] of
     '2': Mode:=p2jmObjFPC;
     '2': Mode:=p2jmObjFPC;
@@ -3998,6 +4002,7 @@ begin
     'c': Options:=Options+[coAllowCAssignments];
     'c': Options:=Options+[coAllowCAssignments];
     'd': Mode:=p2jmDelphi;
     'd': Mode:=p2jmDelphi;
     'm': Options:=Options+[coAllowMacros];
     'm': Options:=Options+[coAllowMacros];
+    'j': Options:=Options+[coWriteableConst];
     end;
     end;
   end;
   end;
   for i:=1 to length(Disabled) do begin
   for i:=1 to length(Disabled) do begin
@@ -4007,6 +4012,7 @@ begin
     'c': Options:=Options-[coAllowCAssignments];
     'c': Options:=Options-[coAllowCAssignments];
     'd': ;
     'd': ;
     'm': Options:=Options-[coAllowMacros];
     'm': Options:=Options-[coAllowMacros];
+    'j': Options:=Options-[coWriteableConst];
     end;
     end;
   end;
   end;
 end;
 end;