* Convert array of jsvalue to array of const where appropriate

git-svn-id: trunk@49345 -
This commit is contained in:
michael 2021-05-08 15:36:50 +00:00
parent 5e1e6c24a4
commit ac9d2b3cc5
10 changed files with 80 additions and 85 deletions

View File

@ -63,10 +63,10 @@ Type
{$endif} {$endif}
Function Write(Const S : TJSWriterString) : Integer; Function Write(Const S : TJSWriterString) : Integer;
Function WriteLn(Const S : TJSWriterString) : Integer; Function WriteLn(Const S : TJSWriterString) : Integer;
Function Write(Const Fmt : TJSWriterString; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}) : Integer; Function Write(Const Fmt : TJSWriterString; Args : Array of const) : Integer;
Function WriteLn(Const Fmt : TJSWriterString; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}) : Integer; Function WriteLn(Const Fmt : TJSWriterString; Args : Array of const) : Integer;
Function Write(Const Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}) : Integer; Function Write(Const Args : Array of const) : Integer;
Function WriteLn(Const Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}) : Integer; Function WriteLn(Const Args : Array of const) : Integer;
Property CurLine: integer read FCurLine write FCurLine; Property CurLine: integer read FCurLine write FCurLine;
Property CurColumn: integer read FCurColumn write FCurColumn;// char index, not codepoint Property CurColumn: integer read FCurColumn write FCurColumn;// char index, not codepoint
Property CurElement: TJSElement read FCurElement write SetCurElement; Property CurElement: TJSElement read FCurElement write SetCurElement;
@ -179,7 +179,7 @@ Type
Protected Protected
// Helper routines // Helper routines
Procedure Error(Const Msg : TJSWriterString); Procedure Error(Const Msg : TJSWriterString);
Procedure Error(Const Fmt : TJSWriterString; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Procedure Error(Const Fmt : TJSWriterString; Args : Array of const);
Procedure WriteIndent; // inline; Procedure WriteIndent; // inline;
{$ifdef FPC_HAS_CPSTRING} {$ifdef FPC_HAS_CPSTRING}
Procedure Write(Const U : UnicodeString); Procedure Write(Const U : UnicodeString);
@ -466,7 +466,7 @@ begin
end; end;
procedure TJSWriter.Error(const Fmt: TJSWriterString; procedure TJSWriter.Error(const Fmt: TJSWriterString;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Args: array of const);
begin begin
Raise EJSWriter.CreateFmt(Fmt,Args); Raise EJSWriter.CreateFmt(Fmt,Args);
end; end;
@ -2137,19 +2137,19 @@ begin
end; end;
function TTextWriter.Write(const Fmt: TJSWriterString; function TTextWriter.Write(const Fmt: TJSWriterString;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): Integer; Args: array of const): Integer;
begin begin
Result:=Write(Format(Fmt,Args)); Result:=Write(Format(Fmt,Args));
end; end;
function TTextWriter.WriteLn(const Fmt: TJSWriterString; function TTextWriter.WriteLn(const Fmt: TJSWriterString;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): Integer; Args: array of const): Integer;
begin begin
Result:=WriteLn(Format(Fmt,Args)); Result:=WriteLn(Format(Fmt,Args));
end; end;
function TTextWriter.Write(const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): Integer; function TTextWriter.Write(const Args: array of const): Integer;
Var Var
I : Integer; I : Integer;
@ -2209,8 +2209,7 @@ begin
end; end;
end; end;
function TTextWriter.WriteLn( function TTextWriter.WriteLn(const Args: array of const): Integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): Integer;
begin begin
Result:=Write(Args)+Writeln(''); Result:=Write(Args)+Writeln('');
end; end;

View File

@ -695,7 +695,7 @@ type
TPasResEvalLogHandler = procedure(Sender: TResExprEvaluator; const id: TMaxPrecInt; TPasResEvalLogHandler = procedure(Sender: TResExprEvaluator; const id: TMaxPrecInt;
MsgType: TMessageType; MsgNumber: integer; MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: Array of {$ifdef pas2js}jsvalue{$else}const{$endif}; PosEl: TPasElement) of object; const Fmt: String; Args: Array of const; PosEl: TPasElement) of object;
TPasResEvalIdentHandler = function(Sender: TResExprEvaluator; TPasResEvalIdentHandler = function(Sender: TResExprEvaluator;
Expr: TPrimitiveExpr; Flags: TResEvalFlags): TResEvalValue of object; Expr: TPrimitiveExpr; Flags: TResEvalFlags): TResEvalValue of object;
TPasResEvalParamsHandler = function(Sender: TResExprEvaluator; TPasResEvalParamsHandler = function(Sender: TResExprEvaluator;
@ -718,9 +718,9 @@ type
FOnRangeCheckEl: TPasResEvalRangeCheckElHandler; FOnRangeCheckEl: TPasResEvalRangeCheckElHandler;
protected protected
procedure LogMsg(const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer; procedure LogMsg(const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: Array of {$ifdef pas2js}jsvalue{$else}const{$endif}; PosEl: TPasElement); overload; const Fmt: String; Args: Array of const; PosEl: TPasElement); overload;
procedure RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; const Fmt: String; procedure RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; const Fmt: String;
Args: Array of {$ifdef pas2js}jsvalue{$else}const{$endif}; ErrorPosEl: TPasElement); Args: Array of const; ErrorPosEl: TPasElement);
procedure RaiseNotYetImplemented(id: TMaxPrecInt; El: TPasElement; Msg: string = ''); virtual; procedure RaiseNotYetImplemented(id: TMaxPrecInt; El: TPasElement; Msg: string = ''); virtual;
procedure RaiseInternalError(id: TMaxPrecInt; const Msg: string = ''); procedure RaiseInternalError(id: TMaxPrecInt; const Msg: string = '');
procedure RaiseConstantExprExp(id: TMaxPrecInt; ErrorEl: TPasElement); procedure RaiseConstantExprExp(id: TMaxPrecInt; ErrorEl: TPasElement);
@ -1327,14 +1327,14 @@ end;
procedure TResExprEvaluator.LogMsg(const id: TMaxPrecInt; MsgType: TMessageType; procedure TResExprEvaluator.LogMsg(const id: TMaxPrecInt; MsgType: TMessageType;
MsgNumber: integer; const Fmt: String; MsgNumber: integer; const Fmt: String;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; Args: array of const;
PosEl: TPasElement); PosEl: TPasElement);
begin begin
OnLog(Self,id,MsgType,MsgNumber,Fmt,Args,PosEl); OnLog(Self,id,MsgType,MsgNumber,Fmt,Args,PosEl);
end; end;
procedure TResExprEvaluator.RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; procedure TResExprEvaluator.RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Fmt: String; Args: array of const;
ErrorPosEl: TPasElement); ErrorPosEl: TPasElement);
begin begin
LogMsg(id,mtError,MsgNumber,Fmt,Args,ErrorPosEl); LogMsg(id,mtError,MsgNumber,Fmt,Args,ErrorPosEl);

View File

@ -1801,7 +1801,7 @@ type
fExprEvaluator: TResExprEvaluator; fExprEvaluator: TResExprEvaluator;
procedure OnExprEvalLog(Sender: TResExprEvaluator; const id: TMaxPrecInt; procedure OnExprEvalLog(Sender: TResExprEvaluator; const id: TMaxPrecInt;
MsgType: TMessageType; MsgNumber: integer; const Fmt: String; MsgType: TMessageType; MsgNumber: integer; const Fmt: String;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; PosEl: TPasElement); virtual; Args: array of const; PosEl: TPasElement); virtual;
function OnExprEvalIdentifier(Sender: TResExprEvaluator; function OnExprEvalIdentifier(Sender: TResExprEvaluator;
Expr: TPrimitiveExpr; Flags: TResEvalFlags): TResEvalValue; virtual; Expr: TPrimitiveExpr; Flags: TResEvalFlags): TResEvalValue; virtual;
function OnExprEvalParams(Sender: TResExprEvaluator; function OnExprEvalParams(Sender: TResExprEvaluator;
@ -2174,10 +2174,10 @@ type
class function GetDbgSourcePosStr(El: TPasElement): string; class function GetDbgSourcePosStr(El: TPasElement): string;
function GetElementSourcePosStr(El: TPasElement): string; function GetElementSourcePosStr(El: TPasElement): string;
procedure SetLastMsg(const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer; procedure SetLastMsg(const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer;
Const Fmt : String; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}; Const Fmt : String; Args : Array of const;
PosEl: TPasElement); PosEl: TPasElement);
procedure LogMsg(const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer; procedure LogMsg(const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: Array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Fmt: String; Args: Array of const;
PosEl: TPasElement); overload; PosEl: TPasElement); overload;
class function GetWarnIdentifierNumbers(Identifier: string; class function GetWarnIdentifierNumbers(Identifier: string;
out MsgNumbers: TIntegerDynArray): boolean; virtual; out MsgNumbers: TIntegerDynArray): boolean; virtual;
@ -2188,7 +2188,7 @@ type
procedure GetIncompatibleProcParamsDesc(GotType, ExpType: TPasProcedureType; procedure GetIncompatibleProcParamsDesc(GotType, ExpType: TPasProcedureType;
out GotDesc, ExpDesc: string); out GotDesc, ExpDesc: string);
procedure RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; const Fmt: String; procedure RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; const Fmt: String;
Args: Array of {$ifdef pas2js}jsvalue{$else}const{$endif}; Args: Array of const;
ErrorPosEl: TPasElement); virtual; ErrorPosEl: TPasElement); virtual;
procedure RaiseNotYetImplemented(id: TMaxPrecInt; El: TPasElement; Msg: string = ''); virtual; procedure RaiseNotYetImplemented(id: TMaxPrecInt; El: TPasElement; Msg: string = ''); virtual;
procedure RaiseInternalError(id: TMaxPrecInt; const Msg: string = ''); procedure RaiseInternalError(id: TMaxPrecInt; const Msg: string = '');
@ -2202,13 +2202,13 @@ type
procedure RaiseVarExpected(id: TMaxPrecInt; ErrorEl: TPasElement; IdentEl: TPasElement); procedure RaiseVarExpected(id: TMaxPrecInt; ErrorEl: TPasElement; IdentEl: TPasElement);
procedure RaiseRangeCheck(id: TMaxPrecInt; ErrorEl: TPasElement); procedure RaiseRangeCheck(id: TMaxPrecInt; ErrorEl: TPasElement);
procedure RaiseIncompatibleTypeDesc(id: TMaxPrecInt; MsgNumber: integer; procedure RaiseIncompatibleTypeDesc(id: TMaxPrecInt; MsgNumber: integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
const GotDesc, ExpDesc: String; ErrorEl: TPasElement); const GotDesc, ExpDesc: String; ErrorEl: TPasElement);
procedure RaiseIncompatibleType(id: TMaxPrecInt; MsgNumber: integer; procedure RaiseIncompatibleType(id: TMaxPrecInt; MsgNumber: integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
GotType, ExpType: TPasType; ErrorEl: TPasElement); GotType, ExpType: TPasType; ErrorEl: TPasElement);
procedure RaiseIncompatibleTypeRes(id: TMaxPrecInt; MsgNumber: integer; procedure RaiseIncompatibleTypeRes(id: TMaxPrecInt; MsgNumber: integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
const GotType, ExpType: TPasResolverResult; const GotType, ExpType: TPasResolverResult;
ErrorEl: TPasElement); ErrorEl: TPasElement);
procedure RaiseHelpersCannotBeUsedAsType(id: TMaxPrecInt; ErrorEl: TPasElement); procedure RaiseHelpersCannotBeUsedAsType(id: TMaxPrecInt; ErrorEl: TPasElement);
@ -15459,7 +15459,7 @@ end;
procedure TPasResolver.OnExprEvalLog(Sender: TResExprEvaluator; procedure TPasResolver.OnExprEvalLog(Sender: TResExprEvaluator;
const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer; const id: TMaxPrecInt; MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Fmt: String; Args: array of const;
PosEl: TPasElement); PosEl: TPasElement);
begin begin
if MsgType<=mtError then if MsgType<=mtError then
@ -23070,7 +23070,7 @@ end;
procedure TPasResolver.SetLastMsg(const id: TMaxPrecInt; MsgType: TMessageType; procedure TPasResolver.SetLastMsg(const id: TMaxPrecInt; MsgType: TMessageType;
MsgNumber: integer; const Fmt: String; MsgNumber: integer; const Fmt: String;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; Args: array of const;
PosEl: TPasElement); PosEl: TPasElement);
var var
{$IFDEF VerbosePasResolver} {$IFDEF VerbosePasResolver}
@ -23112,7 +23112,7 @@ begin
end; end;
procedure TPasResolver.RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; procedure TPasResolver.RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Fmt: String; Args: array of const;
ErrorPosEl: TPasElement); ErrorPosEl: TPasElement);
var var
E: EPasResolve; E: EPasResolve;
@ -23224,25 +23224,22 @@ begin
end; end;
procedure TPasResolver.RaiseIncompatibleTypeDesc(id: TMaxPrecInt; MsgNumber: integer; procedure TPasResolver.RaiseIncompatibleTypeDesc(id: TMaxPrecInt; MsgNumber: integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
const GotDesc, ExpDesc: String; ErrorEl: TPasElement); const GotDesc, ExpDesc: String; ErrorEl: TPasElement);
function GetString(ArgNo: integer): string; function GetString(ArgNo: integer): string;
begin begin
if ArgNo>High(Args) then if ArgNo>High(Args) then
exit('invalid param '+IntToStr(ArgNo)); exit('invalid param '+IntToStr(ArgNo));
{$ifdef pas2js}
if isString(Args[ArgNo]) then
Result:=String(Args[ArgNo])
else
Result:='invalid param '+jsTypeOf(Args[ArgNo]);
{$else}
case Args[ArgNo].VType of case Args[ArgNo].VType of
{$IFDEF PAS2JS}
vtUnicodeString: Result:=Args[ArgNo].VUnicodeString;
{$ELSE}
vtAnsiString: Result:=AnsiString(Args[ArgNo].VAnsiString); vtAnsiString: Result:=AnsiString(Args[ArgNo].VAnsiString);
{$ENDIF}
else else
Result:='invalid param '+IntToStr(Ord(Args[ArgNo].VType)); Result:='invalid param '+IntToStr(Ord(Args[ArgNo].VType));
end; end;
{$endif}
end; end;
begin begin
@ -23270,7 +23267,7 @@ begin
end; end;
procedure TPasResolver.RaiseIncompatibleType(id: TMaxPrecInt; MsgNumber: integer; procedure TPasResolver.RaiseIncompatibleType(id: TMaxPrecInt; MsgNumber: integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
GotType, ExpType: TPasType; ErrorEl: TPasElement); GotType, ExpType: TPasType; ErrorEl: TPasElement);
var var
GotDesc, ExpDesc: String; GotDesc, ExpDesc: String;
@ -23280,7 +23277,7 @@ begin
end; end;
procedure TPasResolver.RaiseIncompatibleTypeRes(id: TMaxPrecInt; MsgNumber: integer; procedure TPasResolver.RaiseIncompatibleTypeRes(id: TMaxPrecInt; MsgNumber: integer;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
const GotType, ExpType: TPasResolverResult; const GotType, ExpType: TPasResolverResult;
ErrorEl: TPasElement); ErrorEl: TPasElement);
var var
@ -23315,7 +23312,7 @@ end;
procedure TPasResolver.LogMsg(const id: TMaxPrecInt; MsgType: TMessageType; procedure TPasResolver.LogMsg(const id: TMaxPrecInt; MsgType: TMessageType;
MsgNumber: integer; const Fmt: String; MsgNumber: integer; const Fmt: String;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; Args: array of const;
PosEl: TPasElement); PosEl: TPasElement);
var var
Scanner: TPascalScanner; Scanner: TPascalScanner;

View File

@ -311,7 +311,7 @@ type
function IsSpecializedGenericType(El: TPasElement): boolean; function IsSpecializedGenericType(El: TPasElement): boolean;
procedure EmitMessage(Id: TMaxPrecInt; MsgType: TMessageType; procedure EmitMessage(Id: TMaxPrecInt; MsgType: TMessageType;
MsgNumber: integer; Fmt: String; MsgNumber: integer; Fmt: String;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
PosEl: TPasElement); PosEl: TPasElement);
procedure EmitMessage(Msg: TPAMessage); procedure EmitMessage(Msg: TPAMessage);
class function GetWarnIdentifierNumbers(Identifier: string; class function GetWarnIdentifierNumbers(Identifier: string;
@ -3229,7 +3229,7 @@ end;
procedure TPasAnalyzer.EmitMessage(Id: TMaxPrecInt; MsgType: TMessageType; procedure TPasAnalyzer.EmitMessage(Id: TMaxPrecInt; MsgType: TMessageType;
MsgNumber: integer; Fmt: String; MsgNumber: integer; Fmt: String;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
PosEl: TPasElement); PosEl: TPasElement);
var var
Msg: TPAMessage; Msg: TPAMessage;

View File

@ -297,7 +297,7 @@ type
Function SaveComments(Const AValue : String) : String; Function SaveComments(Const AValue : String) : String;
function LogEvent(E : TPParserLogEvent) : Boolean; inline; function LogEvent(E : TPParserLogEvent) : Boolean; inline;
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Msg : String; SkipSourceInfo : Boolean = False);overload; Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Msg : String; SkipSourceInfo : Boolean = False);overload;
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif};SkipSourceInfo : Boolean = False);overload; Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const;SkipSourceInfo : Boolean = False);overload;
function GetProcTypeFromToken(tk: TToken; IsClass: Boolean=False ): TProcType; function GetProcTypeFromToken(tk: TToken; IsClass: Boolean=False ): TProcType;
procedure ParseAsmBlock(AsmBlock: TPasImplAsmStatement); virtual; procedure ParseAsmBlock(AsmBlock: TPasImplAsmStatement); virtual;
procedure ParseRecordMembers(ARec: TPasRecordType; AEndToken: TToken; AllowMethods : Boolean); procedure ParseRecordMembers(ARec: TPasRecordType; AEndToken: TToken; AllowMethods : Boolean);
@ -314,7 +314,7 @@ type
ProcType: TProcType): boolean; ProcType: TProcType): boolean;
function CheckVisibility(S: String; var AVisibility: TPasMemberVisibility; IsObjCProtocol : Boolean = False): Boolean; function CheckVisibility(S: String; var AVisibility: TPasMemberVisibility; IsObjCProtocol : Boolean = False): Boolean;
procedure ParseExc(MsgNumber: integer; const Msg: String); procedure ParseExc(MsgNumber: integer; const Msg: String);
procedure ParseExc(MsgNumber: integer; const Fmt: String; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}); procedure ParseExc(MsgNumber: integer; const Fmt: String; Args : Array of const);
procedure ParseExcExpectedIdentifier; procedure ParseExcExpectedIdentifier;
procedure ParseExcSyntaxError; procedure ParseExcSyntaxError;
procedure ParseExcTokenError(const Arg: string); procedure ParseExcTokenError(const Arg: string);
@ -372,7 +372,7 @@ type
public public
constructor Create(AScanner: TPascalScanner; AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer); constructor Create(AScanner: TPascalScanner; AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer);
Destructor Destroy; override; Destructor Destroy; override;
procedure SetLastMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}); procedure SetLastMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const);
// General parsing routines // General parsing routines
function CurTokenName: String; function CurTokenName: String;
function CurTokenText: String; function CurTokenText: String;
@ -988,7 +988,7 @@ begin
end; end;
procedure TPasParser.ParseExc(MsgNumber: integer; const Fmt: String; procedure TPasParser.ParseExc(MsgNumber: integer; const Fmt: String;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Args: array of const);
var var
p: TPasSourcePos; p: TPasSourcePos;
begin begin
@ -2326,7 +2326,7 @@ begin
tkCaret : Result:=eopDeref; tkCaret : Result:=eopDeref;
else else
result:=eopAdd; // Fool compiler result:=eopAdd; // Fool compiler
ParseExc(nParserNotAnOperand,SParserNotAnOperand,[AToken,TokenInfos[AToken]]); ParseExc(nParserNotAnOperand,SParserNotAnOperand,[ord(AToken),TokenInfos[AToken]]);
end; end;
end; end;
@ -4890,7 +4890,7 @@ begin
end; end;
procedure TPasParser.SetLastMsg(MsgType: TMessageType; MsgNumber: integer; procedure TPasParser.SetLastMsg(MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); const Fmt: String; Args: array of const);
begin begin
FLastMsgType := MsgType; FLastMsgType := MsgType;
FLastMsgNumber := MsgNumber; FLastMsgNumber := MsgNumber;
@ -4906,7 +4906,7 @@ begin
end; end;
procedure TPasParser.DoLog(MsgType: TMessageType; MsgNumber: integer; procedure TPasParser.DoLog(MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Fmt: String; Args: array of const;
SkipSourceInfo: Boolean); SkipSourceInfo: Boolean);
Var Var

View File

@ -591,7 +591,7 @@ type
TCEEvalVarEvent = function(Sender: TCondDirectiveEvaluator; Name: String; out Value: string): boolean of object; TCEEvalVarEvent = function(Sender: TCondDirectiveEvaluator; Name: String; out Value: string): boolean of object;
TCEEvalFunctionEvent = function(Sender: TCondDirectiveEvaluator; Name, Param: String; out Value: string): boolean of object; TCEEvalFunctionEvent = function(Sender: TCondDirectiveEvaluator; Name, Param: String; out Value: string): boolean of object;
TCELogEvent = procedure(Sender: TCondDirectiveEvaluator; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}) of object; TCELogEvent = procedure(Sender: TCondDirectiveEvaluator; Args : Array of const) of object;
{ TCondDirectiveEvaluator - evaluate $IF expression } { TCondDirectiveEvaluator - evaluate $IF expression }
@ -631,7 +631,7 @@ type
function IsExtended(const Value: String; out e: TMaxFloat): boolean; function IsExtended(const Value: String; out e: TMaxFloat): boolean;
procedure NextToken; procedure NextToken;
procedure Log(aMsgType: TMessageType; aMsgNumber: integer; procedure Log(aMsgType: TMessageType; aMsgNumber: integer;
const aMsgFmt: String; const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; MsgPos: integer = 0); const aMsgFmt: String; const Args: array of const; MsgPos: integer = 0);
procedure LogXExpectedButTokenFound(const X: String; ErrorPos: integer = 0); procedure LogXExpectedButTokenFound(const X: String; ErrorPos: integer = 0);
procedure ReadOperand(Skip: boolean = false); // unary operators plus one operand procedure ReadOperand(Skip: boolean = false); // unary operators plus one operand
procedure ReadExpression; // binary operators procedure ReadExpression; // binary operators
@ -786,8 +786,7 @@ type
function IndexOfWarnMsgState(Number: integer; InsertPos: boolean): integer; function IndexOfWarnMsgState(Number: integer; InsertPos: boolean): integer;
function OnCondEvalFunction(Sender: TCondDirectiveEvaluator; Name, function OnCondEvalFunction(Sender: TCondDirectiveEvaluator; Name,
Param: String; out Value: string): boolean; Param: String; out Value: string): boolean;
procedure OnCondEvalLog(Sender: TCondDirectiveEvaluator; procedure OnCondEvalLog(Sender: TCondDirectiveEvaluator; Args: array of const);
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif});
function OnCondEvalVar(Sender: TCondDirectiveEvaluator; Name: String; out function OnCondEvalVar(Sender: TCondDirectiveEvaluator; Name: String; out
Value: string): boolean; Value: string): boolean;
procedure SetAllowedBoolSwitches(const AValue: TBoolSwitches); procedure SetAllowedBoolSwitches(const AValue: TBoolSwitches);
@ -806,11 +805,11 @@ type
function FetchLine: boolean; function FetchLine: boolean;
procedure AddFile(aFilename: string); virtual; procedure AddFile(aFilename: string); virtual;
function GetMacroName(const Param: String): String; function GetMacroName(const Param: String): String;
procedure SetCurMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif}); procedure SetCurMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const);
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Msg : String; SkipSourceInfo : Boolean = False);overload; Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Msg : String; SkipSourceInfo : Boolean = False);overload;
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif};SkipSourceInfo : Boolean = False);overload; Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const;SkipSourceInfo : Boolean = False);overload;
procedure Error(MsgNumber: integer; const Msg: string);overload; procedure Error(MsgNumber: integer; const Msg: string);overload;
procedure Error(MsgNumber: integer; const Fmt: string; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif});overload; procedure Error(MsgNumber: integer; const Fmt: string; Args: array of const);overload;
procedure PushSkipMode; procedure PushSkipMode;
function GetMultiLineStringLineEnd(aReader: TLineReader): string; function GetMultiLineStringLineEnd(aReader: TLineReader): string;
@ -1246,8 +1245,8 @@ function FilenameIsUnixAbsolute(const TheFilename: string): boolean;
function IsNamedToken(Const AToken : String; Out T : TToken) : Boolean; function IsNamedToken(Const AToken : String; Out T : TToken) : Boolean;
Function ExtractFilenameOnly(Const AFileName : String) : String; Function ExtractFilenameOnly(Const AFileName : String) : String;
procedure CreateMsgArgs(var MsgArgs: TMessageArgs; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); procedure CreateMsgArgs(var MsgArgs: TMessageArgs; Args: array of const);
function SafeFormat(const Fmt: string; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): string; function SafeFormat(const Fmt: string; Args: array of const): string;
implementation implementation
@ -1341,7 +1340,7 @@ begin
T:=SortedTokens[I]; T:=SortedTokens[I];
end; end;
procedure CreateMsgArgs(var MsgArgs: TMessageArgs; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); procedure CreateMsgArgs(var MsgArgs: TMessageArgs; Args: array of const);
var var
i: Integer; i: Integer;
{$ifdef pas2js} {$ifdef pas2js}
@ -1394,7 +1393,7 @@ begin
{$endif} {$endif}
end; end;
function SafeFormat(const Fmt: string; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): string; function SafeFormat(const Fmt: string; Args: array of const): string;
var var
MsgArgs: TMessageArgs; MsgArgs: TMessageArgs;
i: Integer; i: Integer;
@ -1804,7 +1803,7 @@ end;
procedure TCondDirectiveEvaluator.Log(aMsgType: TMessageType; procedure TCondDirectiveEvaluator.Log(aMsgType: TMessageType;
aMsgNumber: integer; const aMsgFmt: String; aMsgNumber: integer; const aMsgFmt: String;
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Args: array of const;
MsgPos: integer); MsgPos: integer);
begin begin
if MsgPos<1 then if MsgPos<1 then
@ -3331,7 +3330,7 @@ begin
end; end;
procedure TPascalScanner.Error(MsgNumber: integer; const Fmt: string; procedure TPascalScanner.Error(MsgNumber: integer; const Fmt: string;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Args: array of const);
begin begin
SetCurMsg(mtError,MsgNumber,Fmt,Args); SetCurMsg(mtError,MsgNumber,Fmt,Args);
raise EScannerError.CreateFmt('%s(%d,%d) Error: %s', raise EScannerError.CreateFmt('%s(%d,%d) Error: %s',
@ -5281,7 +5280,7 @@ begin
end; end;
procedure TPascalScanner.OnCondEvalLog(Sender: TCondDirectiveEvaluator; procedure TPascalScanner.OnCondEvalLog(Sender: TCondDirectiveEvaluator;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Args: array of const);
Var Var
Msg : String; Msg : String;
@ -5505,7 +5504,7 @@ begin
end; end;
procedure TPascalScanner.DoLog(MsgType: TMessageType; MsgNumber: integer; procedure TPascalScanner.DoLog(MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}; const Fmt: String; Args: array of const;
SkipSourceInfo: Boolean); SkipSourceInfo: Boolean);
Var Var
@ -5656,7 +5655,7 @@ begin
end; end;
procedure TPascalScanner.SetCurMsg(MsgType: TMessageType; MsgNumber: integer; procedure TPascalScanner.SetCurMsg(MsgType: TMessageType; MsgNumber: integer;
const Fmt: String; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); const Fmt: String; Args: array of const);
begin begin
FLastMsgType := MsgType; FLastMsgType := MsgType;
FLastMsgNumber := MsgNumber; FLastMsgNumber := MsgNumber;

View File

@ -1660,7 +1660,7 @@ type
RaiseOnIncompatible: boolean): integer; override; RaiseOnIncompatible: boolean): integer; override;
// utility // utility
procedure RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; const Fmt: String; procedure RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; const Fmt: String;
Args: array of {$IFDEF pas2js}jsvalue{$ELSE}const{$ENDIF}; ErrorPosEl: TPasElement); override; Args: array of const; ErrorPosEl: TPasElement); override;
function GetOverloadName(El: TPasElement): string; function GetOverloadName(El: TPasElement): string;
function GetBaseDescription(const R: TPasResolverResult; AddPath: boolean= function GetBaseDescription(const R: TPasResolverResult; AddPath: boolean=
false): string; override; false): string; override;
@ -1961,9 +1961,9 @@ type
// Error functions // Error functions
Procedure DoError(Id: TMaxPrecInt; Const Msg : String); Procedure DoError(Id: TMaxPrecInt; Const Msg : String);
Procedure DoError(Id: TMaxPrecInt; Const Msg : String; Procedure DoError(Id: TMaxPrecInt; Const Msg : String;
const Args: array of {$IFDEF pas2js}jsvalue{$ELSE}const{$ENDIF}); const Args: array of const);
Procedure DoError(Id: TMaxPrecInt; MsgNumber: integer; const MsgPattern: string; Procedure DoError(Id: TMaxPrecInt; MsgNumber: integer; const MsgPattern: string;
const Args: array of {$IFDEF pas2js}jsvalue{$ELSE}const{$ENDIF}; El: TPasElement); const Args: array of const; El: TPasElement);
procedure RaiseNotSupported(El: TPasElement; AContext: TConvertContext; Id: TMaxPrecInt; const Msg: string = ''); procedure RaiseNotSupported(El: TPasElement; AContext: TConvertContext; Id: TMaxPrecInt; const Msg: string = '');
procedure RaiseIdentifierNotFound(Identifier: string; El: TPasElement; Id: TMaxPrecInt); procedure RaiseIdentifierNotFound(Identifier: string; El: TPasElement; Id: TMaxPrecInt);
procedure RaiseInconsistency(Id: TMaxPrecInt; El: TPasElement); procedure RaiseInconsistency(Id: TMaxPrecInt; El: TPasElement);
@ -7163,7 +7163,7 @@ begin
end; end;
procedure TPas2JSResolver.RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer; procedure TPas2JSResolver.RaiseMsg(const Id: TMaxPrecInt; MsgNumber: integer;
const Fmt: String; Args: array of {$IFDEF pas2js}jsvalue{$ELSE}const{$ENDIF}; const Fmt: String; Args: array of const;
ErrorPosEl: TPasElement); ErrorPosEl: TPasElement);
begin begin
{$IFDEF VerbosePas2JS} {$IFDEF VerbosePas2JS}
@ -26779,7 +26779,7 @@ begin
end; end;
procedure TPasToJSConverter.DoError(Id: TMaxPrecInt; const Msg: String; procedure TPasToJSConverter.DoError(Id: TMaxPrecInt; const Msg: String;
const Args: array of {$IFDEF pas2js}jsvalue{$ELSE}const{$ENDIF}); const Args: array of const);
var var
E: EPas2JS; E: EPas2JS;
begin begin
@ -26791,7 +26791,7 @@ end;
procedure TPasToJSConverter.DoError(Id: TMaxPrecInt; MsgNumber: integer; procedure TPasToJSConverter.DoError(Id: TMaxPrecInt; MsgNumber: integer;
const MsgPattern: string; const MsgPattern: string;
const Args: array of {$IFDEF pas2js}jsvalue{$ELSE}const{$ENDIF}; const Args: array of const;
El: TPasElement); El: TPasElement);
var var
E: EPas2JS; E: EPas2JS;

View File

@ -459,7 +459,7 @@ type
Protected Protected
procedure CfgSyntaxError(const Msg: string); procedure CfgSyntaxError(const Msg: string);
function ConditionEvalVariable(Sender: TCondDirectiveEvaluator; aName: String; out Value: string): boolean; function ConditionEvalVariable(Sender: TCondDirectiveEvaluator; aName: String; out Value: string): boolean;
procedure ConditionEvalLog(Sender: TCondDirectiveEvaluator; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); procedure ConditionEvalLog(Sender: TCondDirectiveEvaluator; Args: array of const);
property ConditionEvaluator: TCondDirectiveEvaluator read FConditionEval; property ConditionEvaluator: TCondDirectiveEvaluator read FConditionEval;
property CurrentCfgFilename: string read FCurrentCfgFilename; property CurrentCfgFilename: string read FCurrentCfgFilename;
property CurrentCfgLineNumber: integer read FCurrentCfgLineNumber; property CurrentCfgLineNumber: integer read FCurrentCfgLineNumber;
@ -1946,7 +1946,7 @@ begin
end; end;
procedure TPas2JSConfigSupport.ConditionEvalLog(Sender: TCondDirectiveEvaluator; procedure TPas2JSConfigSupport.ConditionEvalLog(Sender: TCondDirectiveEvaluator;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Args: array of const);
begin begin
CfgSyntaxError(SafeFormat(Sender.MsgPattern,Args)); CfgSyntaxError(SafeFormat(Sender.MsgPattern,Args));
end; end;
@ -2139,7 +2139,7 @@ function TPas2jsCompiler.MarkNeedBuilding(aFile: TPas2jsCompilerFile;
Checked: TPasAnalyzerKeySet; var SrcFileCount: integer): boolean; Checked: TPasAnalyzerKeySet; var SrcFileCount: integer): boolean;
procedure Mark(MsgNumber: integer; procedure Mark(MsgNumber: integer;
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}); Args: array of const);
begin begin
if aFile.NeedBuild then exit; if aFile.NeedBuild then exit;
aFile.NeedBuild:=true; aFile.NeedBuild:=true;

View File

@ -162,23 +162,23 @@ type
function FindMsg(MsgNumber: integer; ExceptionOnNotFound: boolean): TPas2jsMessage; function FindMsg(MsgNumber: integer; ExceptionOnNotFound: boolean): TPas2jsMessage;
procedure Sort; procedure Sort;
procedure LogRaw(const Msg: string); overload; procedure LogRaw(const Msg: string); overload;
procedure LogRaw(Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); overload; procedure LogRaw(Args: array of const); overload;
procedure LogLn; procedure LogLn;
procedure LogPlain(const Msg: string); overload; procedure LogPlain(const Msg: string); overload;
procedure LogPlain(Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); overload; procedure LogPlain(Args: array of const); overload;
procedure LogMsg(MsgNumber: integer; procedure LogMsg(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}; Args: array of const;
const Filename: string = ''; Line: integer = 0; Col: integer = 0; const Filename: string = ''; Line: integer = 0; Col: integer = 0;
UseFilter: boolean = true); UseFilter: boolean = true);
procedure Log(MsgType: TMessageType; Msg: string; MsgNumber: integer = 0; procedure Log(MsgType: TMessageType; Msg: string; MsgNumber: integer = 0;
const Filename: string = ''; Line: integer = 0; Col: integer = 0; const Filename: string = ''; Line: integer = 0; Col: integer = 0;
UseFilter: boolean = true); UseFilter: boolean = true);
procedure LogMsgIgnoreFilter(MsgNumber: integer; procedure LogMsgIgnoreFilter(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); Args: array of const);
procedure LogExceptionBackTrace(E: Exception); procedure LogExceptionBackTrace(E: Exception);
function MsgTypeToStr(MsgType: TMessageType): string; function MsgTypeToStr(MsgType: TMessageType): string;
function GetMsgText(MsgNumber: integer; function GetMsgText(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}): string; Args: array of const): string;
function FormatMsg(MsgType: TMessageType; Msg: string; MsgNumber: integer = 0; function FormatMsg(MsgType: TMessageType; Msg: string; MsgNumber: integer = 0;
const Filename: string = ''; Line: integer = 0; Col: integer = 0): string; const Filename: string = ''; Line: integer = 0; Col: integer = 0): string;
function FormatJSONMsg(MsgType: TMessageType; Msg: string; MsgNumber: integer = 0; function FormatJSONMsg(MsgType: TMessageType; Msg: string; MsgNumber: integer = 0;
@ -192,7 +192,7 @@ type
procedure CloseDebugLog; procedure CloseDebugLog;
procedure DebugLogWriteLn(Msg: string); overload; procedure DebugLogWriteLn(Msg: string); overload;
function GetEncodingCaption: string; function GetEncodingCaption: string;
class function Concatenate(Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}): string; class function Concatenate(Args: array of const): string;
public public
property Encoding: string read FEncoding write SetEncoding; // normalized property Encoding: string read FEncoding write SetEncoding; // normalized
property MsgCount: integer read GetMsgCount; property MsgCount: integer read GetMsgCount;
@ -810,7 +810,7 @@ begin
end; end;
function TPas2jsLogger.GetMsgText(MsgNumber: integer; function TPas2jsLogger.GetMsgText(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}): string; Args: array of const): string;
var var
Msg: TPas2jsMessage; Msg: TPas2jsMessage;
begin begin
@ -825,7 +825,7 @@ begin
end; end;
procedure TPas2jsLogger.LogRaw( procedure TPas2jsLogger.LogRaw(
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); Args: array of const);
begin begin
LogRaw(Concatenate(Args)); LogRaw(Concatenate(Args));
end; end;
@ -870,7 +870,7 @@ begin
end; end;
class function TPas2jsLogger.Concatenate( class function TPas2jsLogger.Concatenate(
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}): string; Args: array of const): string;
var var
s: String; s: String;
i: Integer; i: Integer;
@ -940,13 +940,13 @@ begin
end; end;
procedure TPas2jsLogger.LogPlain( procedure TPas2jsLogger.LogPlain(
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); Args: array of const);
begin begin
LogPlain(Concatenate(Args)); LogPlain(Concatenate(Args));
end; end;
procedure TPas2jsLogger.LogMsg(MsgNumber: integer; procedure TPas2jsLogger.LogMsg(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}; Args: array of const;
const Filename: string; Line: integer; Col: integer; UseFilter: boolean); const Filename: string; Line: integer; Col: integer; UseFilter: boolean);
var var
Msg: TPas2jsMessage; Msg: TPas2jsMessage;
@ -977,7 +977,7 @@ begin
end; end;
procedure TPas2jsLogger.LogMsgIgnoreFilter(MsgNumber: integer; procedure TPas2jsLogger.LogMsgIgnoreFilter(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); Args: array of const);
begin begin
LogMsg(MsgNumber,Args,'',0,0,false); LogMsg(MsgNumber,Args,'',0,0,false);
end; end;

View File

@ -43,7 +43,7 @@ type
constructor Create(AScanner: TPascalScanner; constructor Create(AScanner: TPascalScanner;
AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer); reintroduce; AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer); reintroduce;
procedure RaiseParserError(MsgNumber: integer; procedure RaiseParserError(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); Args: array of const);
procedure ParseSubModule(var Module: TPasModule); procedure ParseSubModule(var Module: TPasModule);
property Log: TPas2jsLogger read FLog write FLog; property Log: TPas2jsLogger read FLog write FLog;
end; end;
@ -116,7 +116,7 @@ begin
end; end;
procedure TPas2jsPasParser.RaiseParserError(MsgNumber: integer; procedure TPas2jsPasParser.RaiseParserError(MsgNumber: integer;
Args: array of {$IFDEF Pas2JS}jsvalue{$ELSE}const{$ENDIF}); Args: array of const);
var var
Msg: TPas2jsMessage; Msg: TPas2jsMessage;
begin begin