Избавился от предупреждений в PABCSystem и ABCObjects

This commit is contained in:
Бондарев Иван 2016-09-27 20:42:57 +02:00
parent 573e22d818
commit 0423e6bdcf
3 changed files with 138 additions and 157 deletions

View file

@ -139,22 +139,42 @@ namespace PascalABCCompiler
{
local_variable vdn = vdn2 as local_variable;
VarInfo vi = helper.GetVariable(vdn);
if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 && vdn.is_ret_value && !cmn.name.StartsWith("<>") && !cmn.cont_type.IsInterface && cmn.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual_abstract
&& cmn.return_value_type != null && !cmn.return_value_type.IsPointer && !cmn.is_constructor && cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cmn)) warns.Add(new UndefinedReturnValue(cmn.name, cmn.function_code.location));
//if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.name.Contains("$")) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
if (vi.num_use == 0 && !vdn.is_special_name)
warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 &&
vdn.is_ret_value &&
!cmn.name.StartsWith("<") &&
!cmn.cont_type.IsInterface &&
cmn.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual_abstract &&
cmn.return_value_type != null &&
!cmn.return_value_type.IsPointer &&
!cmn.is_constructor &&
cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record &&
cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cmn))
warns.Add(new UndefinedReturnValue(cmn.name, cmn.function_code.location));
}
else if (vdn2 is local_block_variable)
{
local_block_variable vdn = vdn2 as local_block_variable;
VarInfo vi = helper.GetVariable(vdn);
if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 && vdn.is_ret_value && !cmn.name.StartsWith("<>") && !cmn.cont_type.IsInterface && cmn.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual_abstract
&& cmn.return_value_type != null && !cmn.return_value_type.IsPointer && !cmn.is_constructor && cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cmn)) warns.Add(new UndefinedReturnValue(cmn.name, cmn.function_code.location));
if (vi.num_use == 0 && !vdn.is_special_name)
warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 &&
vdn.is_ret_value &&
!cmn.name.StartsWith("<") &&
!cmn.cont_type.IsInterface &&
cmn.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual_abstract &&
cmn.return_value_type != null &&
!cmn.return_value_type.IsPointer &&
!cmn.is_constructor &&
cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record &&
cmn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cmn))
warns.Add(new UndefinedReturnValue(cmn.name, cmn.function_code.location));
}
if (vdn2.inital_value != null) VisitExpression(vdn2.inital_value);
if (vdn2.inital_value != null)
VisitExpression(vdn2.inital_value);
}
foreach (common_parameter prm in cmn.parameters)
{
@ -236,34 +256,53 @@ namespace PascalABCCompiler
{
local_variable vdn = vdn2 as local_variable;
VarInfo vi = helper.GetVariable(vdn);
if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 && vdn.is_ret_value && !cnfn.name.StartsWith("<>") && cnfn.return_value_type != null && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && !cnfn.return_value_type.IsPointer && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cnfn)) warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
//if (vi.num_ass == 0 && vi.act_num_use > 0) helper.AddRealWarning(vdn, warns);
if (vi.num_use == 0 && !vdn.is_special_name)
warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 &&
vdn.is_ret_value &&
!cnfn.name.StartsWith("<") &&
cnfn.return_value_type != null &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record &&
!cnfn.return_value_type.IsPointer &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper &&
!helper.IsExternal(cnfn))
warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name)
warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
}
else if (vdn2 is local_block_variable)
{
local_block_variable vdn = vdn2 as local_block_variable;
VarInfo vi = helper.GetVariable(vdn);
if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 && vdn.is_ret_value && !cnfn.name.StartsWith("<>") && cnfn.return_value_type != null && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && !cnfn.return_value_type.IsPointer && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cnfn)) warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
//if (vi.num_ass == 0 && vi.act_num_use > 0) helper.AddRealWarning(vdn, warns);
if (vi.num_use == 0 && !vdn.is_special_name)
warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 &&
vdn.is_ret_value &&
!cnfn.name.StartsWith("<") &&
cnfn.return_value_type != null &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record &&
!cnfn.return_value_type.IsPointer &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper &&
!helper.IsExternal(cnfn))
warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name)
warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
}
if (vdn2.inital_value != null) VisitExpression(vdn2.inital_value);
if (vdn2.inital_value != null)
VisitExpression(vdn2.inital_value);
}
foreach (common_parameter prm in cnfn.parameters)
{
ParamInfo vi = helper.GetParameter(prm);
if (prm.inital_value != null) VisitExpression(prm.inital_value);
if (prm.inital_value != null)
VisitExpression(prm.inital_value);
//if (vi.num_use == 0 && !prm.name.Contains("$")) warns.Add(new UnusedParameter(prm.name, prm.loc));
}
foreach (var_definition_node vdn in cnfn.var_definition_nodes_list)
{
VarInfo vi = helper.GetVariable(vdn);
if (vdn.inital_value != null) VisitExpression(vdn.inital_value);
if (vdn.inital_value != null)
VisitExpression(vdn.inital_value);
}
}
@ -285,34 +324,51 @@ namespace PascalABCCompiler
{
local_variable vdn = vdn2 as local_variable;
VarInfo vi = helper.GetVariable(vdn);
if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 && vdn.is_ret_value && !cnfn.name.StartsWith("<>") && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && !cnfn.return_value_type.IsPointer && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cnfn)) warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
//if (vi.num_ass == 0 && vi.act_num_use > 0) helper.AddRealWarning(vdn, warns);
if (vi.num_use == 0 && !vdn.is_special_name)
warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 &&
vdn.is_ret_value &&
!cnfn.name.StartsWith("<") &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record &&
!cnfn.return_value_type.IsPointer &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper &&
!helper.IsExternal(cnfn))
warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name)
warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
}
else if (vdn2 is local_block_variable)
{
local_block_variable vdn = vdn2 as local_block_variable;
VarInfo vi = helper.GetVariable(vdn);
if (vi.num_use == 0 && !vdn.is_special_name) warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 && vdn.is_ret_value && !cnfn.name.StartsWith("<>") && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record && !cnfn.return_value_type.IsPointer && cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper
&& !helper.IsExternal(cnfn)) warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name) warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
//if (vi.num_ass == 0 && vi.act_num_use > 0) helper.AddRealWarning(vdn, warns);
if (vi.num_use == 0 && !vdn.is_special_name)
warns.Add(new UnusedVariable(vdn.name, vdn.loc));
else if (vi.num_ass == 0 &&
vdn.is_ret_value &&
!cnfn.name.StartsWith("<") &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.record &&
!cnfn.return_value_type.IsPointer &&
cnfn.return_value_type.type_special_kind != SemanticTree.type_special_kind.array_wrapper &&
!helper.IsExternal(cnfn))
warns.Add(new UndefinedReturnValue(cnfn.name, cnfn.function_code.location));
if (vi.num_ass > 0 && vi.act_num_use == 0 && !vdn.is_special_name)
warns.Add(new AssignWithoutUsing(vdn.name, vi.last_ass_loc));
}
if (vdn2.inital_value != null) VisitExpression(vdn2.inital_value);
if (vdn2.inital_value != null)
VisitExpression(vdn2.inital_value);
}
foreach (common_parameter prm in cnfn.parameters)
{
ParamInfo vi = helper.GetParameter(prm);
if (prm.inital_value != null) VisitExpression(prm.inital_value);
if (prm.inital_value != null)
VisitExpression(prm.inital_value);
//if (vi.num_use == 0 && !prm.name.Contains("$")) warns.Add(new UnusedParameter(prm.name, prm.loc));
}
foreach (var_definition_node vdn in cnfn.var_definition_nodes_list)
{
VarInfo vi = helper.GetVariable(vdn);
if (vdn.inital_value != null) VisitExpression(vdn.inital_value);
if (vdn.inital_value != null)
VisitExpression(vdn.inital_value);
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
///Модуль реализует векторные графические объекты с возможностью масштабирования, наложения друг на друга,
@ -671,7 +671,6 @@ procedure drawRect(r: GRectangle);
// Низкоуровневая процедура (не вызывается пользователем). Вызывает безусловную перерисовку прямоугольника.
var
/// b: Picture;
i: integer;
g: ObjectABC;
gb: System.Drawing.Graphics;
db: boolean;
@ -706,14 +705,14 @@ begin
bmp1.Dispose;
bmp1 := nil;
for i:=0 to __l.Count-1 do
for var i:=0 to __l.Count-1 do
begin
g := ObjectABC(__l[i]);
if g.Visible and g.IntersectRect(r) then
g.Draw(g.Left-r.Left,g.Top-r.Top,gb);
end;
for i:=0 to __lUI.Count-1 do
for var i:=0 to __lUI.Count-1 do
begin
g := ObjectABC(__lUI[i]);
if g.Visible and g.IntersectRect(r) then
@ -794,14 +793,11 @@ begin
end;
function ObjectUnderPoint(x,y: integer): ObjectABC;
var
i: integer;
g: ObjectABC;
begin
Result:=nil;
for i := Objects.Count-1 downto 0 do
for var i := Objects.Count-1 downto 0 do
begin
g := Objects[i];
var g := Objects[i];
if g.PtInside(x,y) then
begin
Result:=g;
@ -824,14 +820,11 @@ begin
end;
function UIElementUnderPoint(x,y: integer): UIElementABC;
var
i: integer;
g: UIElementABC;
begin
Result:=nil;
for i:=__lUI.Count-1 downto 0 do
for var i:=__lUI.Count-1 downto 0 do
begin
g := UIElementABC(__lUI[i]);
var g := UIElementABC(__lUI[i]);
if g.PtInside(x,y) then
begin
Result := g;
@ -1746,18 +1739,15 @@ begin
end;
procedure RegularPolygonABC.Draw(x,y: integer; g: Graphics);
var
i,r,z,x0,y0: integer;
phi: real;
begin
SetDrawSettings;
phi := -90 + Angle;
z := BorderWidth div 2;
r := Width div 2;
var phi := -90 + Angle;
var z := BorderWidth div 2;
var r := Width div 2;
r := r - z;
x0 := x + Width div 2;
y0 := y + Width div 2;
for i:=0 to n-1 do
var x0 := x + Width div 2;
var y0 := y + Width div 2;
for var i:=0 to n-1 do
begin
a[i].x := round(r*cos(phi*Pi/180)) + x0;
a[i].y := round(r*sin(phi*Pi/180)) + y0;
@ -1940,7 +1930,7 @@ end;
procedure StarABC.Draw(x,y: integer; g: Graphics);
var
i,r,rr,z,x0,y0: integer;
r,rr,z,x0,y0: integer;
phi: real;
begin
SetDrawSettings;
@ -1951,7 +1941,7 @@ begin
x0 := x + Width div 2;
y0 := y + Width div 2;
rr := round(r/r_rr);
for i:=0 to Count*2-1 do
for var i:=0 to Count*2-1 do
begin
if i mod 2 = 0 then
begin
@ -2351,15 +2341,12 @@ begin
end;
procedure ContainerABC.InitBy(g: ContainerABC);
var
i: integer;
ob: ObjectABC;
begin
l := new System.Collections.ArrayList;
inherited InitBy(g);
for i:=0 to g.Count-1 do
for var i:=0 to g.Count-1 do
begin
ob := g[i].Clone0;
var ob := g[i].Clone0;
ob.Owner := Self;
end;
end;
@ -2406,14 +2393,11 @@ begin
end;
procedure ContainerABC.Draw(x,y: integer; g: Graphics);
var
i: integer;
ob: ObjectABC;
begin
LockGraphics;
for i:=0 to l.Count-1 do
for var i:=0 to l.Count-1 do
begin
ob := ObjectABC(l[i]);
var ob := ObjectABC(l[i]);
if ob.Visible then
ob.Draw(x+ob.Left,y+ob.Top,g);
end;
@ -2421,14 +2405,11 @@ begin
end;
function ContainerABC.PtInside(x,y:integer): boolean;
var
i: integer;
g: ObjectABC;
begin
Result:=False;
for i:=0 to l.Count-1 do
for var i:=0 to l.Count-1 do
begin
g := ObjectABC(l[i]);
var g := ObjectABC(l[i]);
if g.PtInside(x-Left,y-Top) then
begin
Result := True;
@ -2438,17 +2419,13 @@ begin
end;
procedure ContainerABC.SetWidth(Width: integer);
var
i: integer;
scale: real;
g: ObjectABC;
begin
if Self.Width = 0 then
Exit;
scale := Width/Self.Width;
for i:=0 to l.Count-1 do
var scale := Width/Self.Width;
for var i:=0 to l.Count-1 do
begin
g := ObjectABC(l[i]);
var g := ObjectABC(l[i]);
g.Left := round(g.Left*scale);
g.Width := round(g.Width*scale);
end;
@ -2456,16 +2433,12 @@ begin
end;
procedure ContainerABC.SetHeight(Height: integer);
var
i: integer;
scale: real;
g: ObjectABC;
begin
if Self.Height=0 then Exit;
scale:=Height/Self.Height;
for i:=1 to l.Count do
var scale:=Height/Self.Height;
for var i:=1 to l.Count do
begin
g := ObjectABC(l[i]);
var g := ObjectABC(l[i]);
g.Top := round(g.Top*scale);
g.Height := round(g.Height*scale);
end;
@ -2473,19 +2446,16 @@ begin
end;
procedure ContainerABC.RecalcBounds;
var
i: integer;
r: GRectangle;
begin
if Count=0 then Exit;
r := ObjectABC(l[0]).Bounds;
for i:=1 to l.Count-1 do
var r := ObjectABC(l[0]).Bounds;
for var i:=1 to l.Count-1 do
r := GRectangle.Union(r,ObjectABC(l[i]).Bounds);
fx := fx + r.Left;
fy := fy + r.Top;
fw := r.Right - r.Left;
fh := r.Bottom - r.Top;
for i:=0 to l.Count-1 do
for var i:=0 to l.Count-1 do
ObjectABC(l[i]).SetCoords(ObjectABC(l[i]).Left-r.Left,ObjectABC(l[i]).Top-r.Top);
end;
@ -2586,14 +2556,13 @@ begin
end;
procedure BoardABC.Draw(x,y: integer; g: Graphics);
var i: integer;
begin
SetDrawSettings;
LockGraphics;
FillRectangle(x,y,x+Width,y+Height,g);
for i:=0 to nx do
for var i:=0 to nx do
Line(x+i*szx,y,x+i*szx,y+Height-1,g);
for i:=0 to ny do
for var i:=0 to ny do
Line(x,y+i*szy,x+Width-1,y+i*szy,g);
UnLockGraphics;
end;
@ -2610,20 +2579,18 @@ end;
//------ ObjectBoardABC ------
procedure ObjectBoardABC.Init(x,y,nn,mm,sszx,sszy: integer; cl: GColor);
var i: integer;
begin
inherited Init(x,y,nn,mm,sszx,sszy,cl);
SetLength(ar,nn*mm);
for i:=0 to nn*mm-1 do
for var i:=0 to nn*mm-1 do
ar[i] := nil;
end;
procedure ObjectBoardABC.InitBy(g: ObjectBoardABC);
var i: integer;
begin
inherited InitBy(g);
SetLength(ar,g.ar.Length);
for i:=0 to g.ar.Length-1 do
for var i:=0 to g.ar.Length-1 do
ar[i] := g.ar[i].Clone;
end;

View file

@ -2350,8 +2350,6 @@ end;
procedure TypedSet.IncludeElement(elem: object);
var
diap: Diapason;
i: integer;
c: char;
begin
if elem = nil then exit;
elem := convert_elem(elem);
@ -2374,7 +2372,7 @@ begin
diap := Diapason(elem);
if diap.clow = nil then
begin
for i := diap.low to diap.high do
for var i := diap.low to diap.high do
begin
ht[i] := i;
//if copy_ht <> nil then
@ -2385,7 +2383,7 @@ begin
begin
if diap.clow is char then
begin
for c := char(diap.clow) to char(diap.chigh) do
for var c := char(diap.clow) to char(diap.chigh) do
begin
ht[c] := c;
//if copy_ht <> nil then
@ -2399,7 +2397,7 @@ begin
end
else if diap.clow.GetType().IsEnum then
begin
for i := integer(diap.clow) to integer(diap.chigh) do
for var i := integer(diap.clow) to integer(diap.chigh) do
begin
var obj := Enum.ToObject(diap.clow.GetType(), i);
ht[obj] := obj;
@ -2416,15 +2414,11 @@ begin
if elem.GetType().IsEnum then
begin
ht.Remove(elem);
//if copy_ht <> nil then
// copy_ht.Remove(elem);
end
else
begin
elem := convert_elem(elem);
ht.Remove(elem);
//if copy_ht <> nil then
// copy_ht.Remove(elem);
end
end;
@ -2609,11 +2603,9 @@ end;
[System.Diagnostics.DebuggerStepThrough]
function CreateSet(params elems: array of object): TypedSet;
var
i: integer;
begin
Result := new TypedSet();
for i := 0 to elems.Length - 1 do
for var i := 0 to elems.Length - 1 do
Result.IncludeElement(elems[i]);
end;
@ -5981,7 +5973,6 @@ var
elem: object;
fa: array of System.Reflection.FieldInfo;
NullBasedArray: System.Array;
i: integer;
begin
if t.IsPrimitive then
begin
@ -6002,38 +5993,13 @@ begin
TypeCode.Single: Result := ReadSingle;
end;
{
if t = typeof(integer) then
Result := f.br.ReadInt32
else if t = typeof(real) then
Result := f.br.ReadDouble
else if t = typeof(boolean) then
Result := f.br.ReadBoolean
else if t = typeof(char) then
Result := f.br.ReadChar
else if t = typeof(byte) then
Result := f.br.ReadByte
else if t = typeof(shortint) then // sizeof(shortint)=1
Result := f.br.ReadSByte
else if t = typeof(smallint) then // sizeof(smallint)=2
Result := f.br.ReadInt16
else if t = typeof(word) then
Result := f.br.ReadUInt16
else if t = typeof(longword) then
Result := f.br.ReadUInt32
else if t = typeof(int64) then
Result := f.br.ReadInt64
else if t = typeof(uint64) then
Result := f.br.ReadUInt64
else if t = typeof(single) then
Result := f.br.ReadSingle{}
end
else if t.IsEnum then Result := f.br.ReadInt32
else if t.IsValueType then
begin
elem := Activator.CreateInstance(t);
fa := t.GetFields;
for i := 0 to fa.Length - 1 do
for var i := 0 to fa.Length - 1 do
if not fa[i].IsStatic then
fa[i].SetValue(elem, AbstractBinaryFileReadT(f, fa[i].FieldType, ind, in_arr));
Result := elem;
@ -6066,7 +6032,7 @@ begin
t1 := NullBasedArray.GetType.GetElementType;
var tmp := ind;
var tmp2 := 0;
for i := 0 to NullBasedArray.Length - 1 do
for var i := 0 to NullBasedArray.Length - 1 do
begin
NullBasedArray.SetValue(AbstractBinaryFileReadT(f, t1, ind, i = 0 ? false : true), i);
if i = 0 then
@ -6083,7 +6049,6 @@ procedure Write(f: AbstractBinaryFile; val: object; arr: boolean; var ind: integ
var
t: System.Type;
fa: array of System.Reflection.FieldInfo;
i: integer;
NullBasedArray: System.Array;
begin
t := val.GetType;
@ -6123,7 +6088,7 @@ begin
else if t.IsValueType then
begin
fa := t.GetFields;
for i := 0 to fa.Length - 1 do
for var i := 0 to fa.Length - 1 do
begin
if not fa[i].IsStatic then
Write(f, fa[i].GetValue(val), true, ind, in_arr);
@ -6152,7 +6117,7 @@ begin
begin
var tmp := ind;
var tmp2 := 0;
for i := 0 to NullBasedArray.Length - 1 do
for var i := 0 to NullBasedArray.Length - 1 do
begin
Write(f, NullBasedArray.GetValue(i), true, ind, i = 0 ? false : true);
if i = 0 then
@ -6165,18 +6130,14 @@ begin
end;
procedure Write(f: AbstractBinaryFile; params vals: array of object);
var
i: integer;
begin
if f.fi = nil then raise new System.IO.IOException(GetTranslation(FILE_NOT_ASSIGNED));
if f.fs = nil then raise new System.IO.IOException(GetTranslation(FILE_NOT_OPENED));
for i := 0 to vals.Length - 1 do
for var i := 0 to vals.Length - 1 do
begin
var NullBasedArray := GetNullBasedArray(vals[i]);
var ind := 0;
Write(f, vals[i], NullBasedArray <> nil, ind, false);
//if (f is TypedFile) and ((f as TypedFile).offset > 0) then
//f.bw.Write(new byte[tmp+(f as TypedFile).ElementSize-f.fs.Position]);
end;
end;
@ -9669,7 +9630,6 @@ var
elem: object;
fa: array of System.Reflection.FieldInfo;
NullBasedArray: System.Array;
i: integer;
fi: System.Reflection.FieldInfo;
begin
if t.IsPrimitive or t.IsEnum then
@ -9697,7 +9657,7 @@ begin
//elem := Activator.CreateInstance(t); //ssyy commented
fa := t.GetFields;
Result := 0;
for i := 0 to fa.Length - 1 do
for var i := 0 to fa.Length - 1 do
if not fa[i].IsStatic then
Result := Result + RunTimeSizeOf(fa[i].FieldType)
end
@ -9855,7 +9815,6 @@ end;
procedure CheckCanUsePointerOnType(T: System.Type);
var
fields: array of System.Reflection.FieldInfo;
fi: System.Reflection.FieldInfo;
begin
if T.IsPointer then
begin
@ -9865,7 +9824,7 @@ begin
if T.IsValueType then
begin
fields := T.GetFields();
foreach fi in fields do
foreach var fi in fields do
if not fi.IsStatic then
CheckCanUsePointerOnType(fi.FieldType);
exit;
@ -9876,7 +9835,6 @@ end;
procedure CheckCanUseTypeForFiles(T: System.Type; FileIsBinary: boolean);
var
fields: array of System.Reflection.FieldInfo;
fi: System.Reflection.FieldInfo;
begin
if T.IsPrimitive or T.IsEnum then
exit;
@ -9893,7 +9851,7 @@ begin
if T.IsValueType then
begin
fields := T.GetFields();
foreach fi in fields do
foreach var fi in fields do
if not fi.IsStatic then
CheckCanUseTypeForFiles(fi.FieldType, FileIsBinary);
exit;