Skip to content

Commit

Permalink
New TScriptDynamicNativeBooleanArray currently wrapping TBits for mem…
Browse files Browse the repository at this point in the history
…ory compacity

Improved unit test coverage for dynamic arrays
Support implicit conversion for .IndexOf()
Support natural Sort on boolean arrays
  • Loading branch information
EricGrange committed Feb 26, 2021
1 parent 3dba39b commit d15530d
Show file tree
Hide file tree
Showing 16 changed files with 638 additions and 17 deletions.
11 changes: 8 additions & 3 deletions Source/dwsCompiler.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7968,9 +7968,12 @@ function TdwsCompiler.ReadArrayMethod(const name : String; const namePos : TScri
CheckDynamicOrStatic;
indexOfClass := TArrayIndexOfExpr.ArrayIndexOfExprClass(arraySym);
if CheckArguments(1, 2) then begin
if (argList[0].Typ=nil) or not arraySym.Typ.IsCompatible(argList[0].Typ) then
IncompatibleTypes(argPosArray[0], CPE_IncompatibleParameterTypes,
arraySym.Typ, argList[0].Typ);
if (argList[0].Typ=nil) or not arraySym.Typ.IsCompatible(argList[0].Typ) then begin
// IncompatibleTypes(argPosArray[0], CPE_IncompatibleParameterTypes,
// arraySym.Typ, argList[0].Typ);
argList[0] := CompilerUtils.WrapWithImplicitConversion(FCompilerContext, argList[0], arraySym.Typ,
argPosArray[0], CPE_IncompatibleParameterTypes);
end;
if argList.Count>1 then begin
if (argList[1].Typ=nil) or not argList[1].Typ.IsOfType(FCompilerContext.TypInteger) then
FMsgs.AddCompilerError(argPosArray[0], CPE_IntegerExpressionExpected);
Expand Down Expand Up @@ -8085,6 +8088,8 @@ function TdwsCompiler.ReadArrayMethod(const name : String; const namePos : TScri
Result:=TArraySortNaturalIntegerExpr.Create(FCompilerContext, namePos, baseExpr)
else if arraySym.Typ.IsOfType(FCompilerContext.TypFloat) then
Result:=TArraySortNaturalFloatExpr.Create(FCompilerContext, namePos, baseExpr)
else if arraySym.Typ.IsOfType(FCompilerContext.TypBoolean) then
Result:=TArraySortNaturalExpr.Create(FCompilerContext, namePos, baseExpr)
else begin
FMsgs.AddCompilerError(namePos, CPE_ArrayDoesNotHaveNaturalSortOrder);
Result:=TArraySortNaturalExpr.Create(FCompilerContext, namePos, baseExpr);
Expand Down
Loading

0 comments on commit d15530d

Please sign in to comment.