fcl-passrc: clean up

git-svn-id: trunk@42291 -
This commit is contained in:
Mattias Gaertner 2019-06-26 19:32:34 +00:00
parent 02b66457f5
commit ec3c050ac7
2 changed files with 16 additions and 3 deletions

View File

@ -14369,6 +14369,19 @@ end;
procedure TPasResolver.BI_LowHigh_OnEval(Proc: TResElDataBuiltInProc;
Params: TParamsExpr; Flags: TResEvalFlags; out Evaluated: TResEvalValue);
function IsDynArrayConstExpr(IdentEl: TPasElement): boolean;
begin
Result:=false;
if not (IdentEl is TPasVariable) then exit;
if not (TPasVariable(IdentEl).Expr is TPasExpr) then exit;
if (IdentEl.ClassType=TPasConst) and TPasConst(IdentEl).IsConst then
exit(true);
if fExprEvaluator.IsConst(Params) then
exit(true); // a const refers an initial value
end;
var
Param: TPasExpr;
ParamResolved: TPasResolverResult;
@ -14398,8 +14411,7 @@ begin
// dyn or open array
if Proc.BuiltIn=bfLow then
Evaluated:=TResEvalInt.CreateValue(0)
else if (ParamResolved.IdentEl is TPasVariable)
and (TPasVariable(ParamResolved.IdentEl).Expr is TPasExpr) then
else if IsDynArrayConstExpr(ParamResolved.IdentEl) then
begin
Expr:=TPasVariable(ParamResolved.IdentEl).Expr;
if Expr is TArrayValues then

View File

@ -511,7 +511,9 @@ Function TokenToAssignKind( tk : TToken) : TAssignKind;
implementation
{$IF FPC_FULLVERSION>=30301}
uses strutils;
{$ENDIF}
const
WhitespaceTokensToIgnore = [tkWhitespace, tkComment, tkLineEnding, tkTab];
@ -711,7 +713,6 @@ function ParseSource(AEngine: TPasTreeContainer;
var
FileResolver: TBaseFileResolver;
Parser: TPasParser;
Start, CurPos: integer; // in FPCCommandLine
Filename: String;
Scanner: TPascalScanner;