Skip to content

Commit

Permalink
a.Rows a.Cols для матриц
Browse files Browse the repository at this point in the history
Drawman - увеличена толщина линий
StandOutExprWithLambdaInForeachSequenceVisitor
  • Loading branch information
miks1965 committed Nov 14, 2016
1 parent dc66fb1 commit 5e4b3e0
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Configuration/GlobalAssemblyInfo.cs
Expand Up @@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "2";
public const string Build = "0";
public const string Revision = "1334";
public const string Revision = "1336";

public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Version.defs
@@ -1,4 +1,4 @@
%MINOR%=2
%REVISION%=1334
%REVISION%=1336
%COREVERSION%=0
%MAJOR%=3
2 changes: 1 addition & 1 deletion ReleaseGenerators/PascalABCNET_version.nsh
@@ -1 +1 @@
!define VERSION '3.2.0.1334'
!define VERSION '3.2.0.1336'
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PascalABCCompiler.SyntaxTree;

public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseEnterExitVisitor
{
public static StandOutExprWithLambdaInForeachSequenceVisitor New
{
get
{
return new StandOutExprWithLambdaInForeachSequenceVisitor();
}
}

private int GenIdNum = 0;
public ident GenIdentName()
{
GenIdNum++;
return new ident("$GenContFE" + GenIdNum.ToString());
}

public void ReplaceStatement(statement from, IEnumerable<statement> to)
{
foreach (var x in to)
x.Parent = from.Parent;
var sl = from.Parent as statement_list;
if (sl != null)
{
sl.ReplaceInList(from, to);
}
else
{
var l = new statement_list();
l.AddMany(to);
l.source_context = from.source_context;
from.Parent.Replace(from, l);
}
}


public override void visit(foreach_stmt fe)
{
if (fe.in_what.DescendantNodes().OfType<function_lambda_definition>().Count()>0)
{
var id = GenIdentName();
id.Parent = fe;
var ass = new var_statement(id, fe.in_what, fe.in_what.source_context);
fe.in_what = id;
var l = new List<statement>();
l.Add(ass);
l.Add(fe);
ReplaceStatement(fe, l);
}

base.visit(fe);
}

}
5 changes: 3 additions & 2 deletions StandardSyntaxTreeConverter/StandardSyntaxConverters.cs
Expand Up @@ -11,8 +11,9 @@ class StandardSyntaxTreeConverter: ISyntaxTreeConverter
public string Name { get; } = "Standard";
public syntax_tree_node Convert(syntax_tree_node root)
{
FillParentNodeVisitor.New.ProcessNode(root); // прошивание ссылками на Parent nodes
// Пока нельзя вызывать - если это делать, то ObjectCopier.Clone провоцирует катастрофически долгое время работы!!!
FillParentNodeVisitor.New.ProcessNode(root); // прошивание ссылками на Parent nodes. Должно идти первым
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root); // выносим выражения с лямбдами из заголовка foreach

return root;
}
}
Expand Down
Expand Up @@ -41,6 +41,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StandardSyntaxConverters.cs" />
<Compile Include="StandOutExprWithLambdaInForeachSequenceConverter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SyntaxTreeConverters\SyntaxTreeConverters.csproj">
Expand Down
5 changes: 0 additions & 5 deletions SyntaxTreeConverters/SampleSyntaxTreeConverter.cs
Expand Up @@ -83,11 +83,6 @@ public override void visit(bin_expr n)
public class SampleSyntaxTreeConvIChangeNameToExcludeFromConvertersList: ISyntaxTreeConverter
{
public string Name { get; } = "Sample";
public string Version { get; set; }
public string Description { get; set; }
public string Copyright { get; set; }
public ConverterType ConverterType { get; set; }
public ExecutionOrder ExecutionOrder { get; set; }
public syntax_tree_node Convert(syntax_tree_node root)
{
//var v = new SampleVisitor();
Expand Down
6 changes: 4 additions & 2 deletions TestSuite/CompilationSamples/PABCSystem.pas
Expand Up @@ -8626,12 +8626,14 @@ function Print(Self: array [,] of real; w: integer := 7; f: integer := 2): array

function Println<T>(Self: array [,] of T; w: integer := 4): array [,] of T; extensionmethod;
begin
Self.Print(w)
Self.Print(w);
Result := Self;
end;

function Println(Self: array [,] of real; w: integer := 7; f: integer := 2): array [,] of real; extensionmethod;
begin
Self.Println(w,f)
Self.Println(w,f);
Result := Self;
end;

// -----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion TreeConverter/TreeConversion/syntax_tree_visitor.cs
Expand Up @@ -13993,7 +13993,7 @@ private expression_node additional_indexer_convertion(expression_node ind_expr,
if (ent != null)
{
var t = ent.compiled_type;
if (t.FullName.StartsWith("System.Tuple"))
if (t != null && !t.IsArray && t.FullName.StartsWith("System.Tuple"))
{
expression eee = parameters.expressions[0];

Expand Down
Expand Up @@ -16,17 +16,10 @@ namespace YieldDesugarSyntaxTreeConverter
public class YieldDesugarSyntaxTreeConverter : ISyntaxTreeConverter
{
public string Name { get; } = "YieldDesugar";
public string Version { get; set; }
public string Description { get; set; }
public string Copyright { get; set; }

public ConverterType ConverterType { get; set; }
public ExecutionOrder ExecutionOrder { get; set; }
public syntax_tree_node Convert(syntax_tree_node root)
{
root.visit(new MarkMethodHasYieldAndCheckSomeErrorsVisitor());
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
//root.visit(py); - пропускал корень

#if DEBUG
try
Expand Down
31 changes: 19 additions & 12 deletions bin/Lib/DrawManField.pas
Expand Up @@ -44,6 +44,7 @@ TDMField = class
procedure DrawFieldOnly;
procedure DrawXY;
public
dmwidth := 2;
// Добавил - МА
TaskName: string;
//
Expand All @@ -70,6 +71,8 @@ TDMField = class
procedure MakerPenDown;
procedure MakerToPoint(x,y: integer);
procedure MakerOnVector(x,y: integer);

procedure SetDrawManWidth(w: integer);

// примитивы для выполнителя
procedure DrawDM;
Expand Down Expand Up @@ -217,16 +220,14 @@ procedure TDMField.Draw;
end;

procedure TDMField.DrawDMDrawing;
var i: integer;
begin
for i:=0 to DMColl.Count-1 do
for var i:=0 to DMColl.Count-1 do
DMLine(DMColl[i].p.x,DMColl[i].p.y,DMColl[i].p.x+DMColl[i].v.x,DMColl[i].p.y+DMColl[i].v.y,colorSolve);
end;

procedure TDMField.DrawDMMakerDrawing;
var i: integer;
begin
for i:=0 to DMMakerColl.Count-1 do
for var i:=0 to DMMakerColl.Count-1 do
DMLine(DMMakerColl[i].p.x,DMMakerColl[i].p.y,DMMakerColl[i].p.x+DMMakerColl[i].v.x,DMMakerColl[i].p.y+DMMakerColl[i].v.y,colorTask);
end;

Expand All @@ -243,17 +244,16 @@ procedure TDMField.DrawCentered;
end;

procedure TDMField.DrawFieldOnly;
var ix,iy,w,h: integer;
begin
w := CellSize*DimX;
h := CellSize*DimY;
var w := CellSize*DimX;
var h := CellSize*DimY;
Brush.Color := clWhite;
FillRectangle(X0,Y0,X0+ZazX1+w+1+ZazX2,Y0+ZazY1+h+1+ZazY2);
Pen.Width := 1;
Pen.Color := RGB(191,191,191);
for ix:=0 to DimX do
for var ix:=0 to DimX do
Line(X0+ZazX1+ix*CellSize,Y0+ZazY1,X0+ZazX1+ix*CellSize,Y0+ZazY1+h);
for iy:=0 to DimY do
for var iy:=0 to DimY do
Line(X0+ZazX1,Y0+ZazY1+iy*CellSize,X0+ZazX1+w,Y0+ZazY1+iy*CellSize);
Pen.Color := clGray;
if (orx>-DimX) and (orx<0) then
Expand All @@ -266,7 +266,7 @@ procedure TDMField.DrawFieldOnly;
end;

procedure TDMField.DrawXY;
var x,y,ww: integer;
var ww: integer;
s: string;
interval: integer;
bs: BrushStyleType;
Expand All @@ -283,15 +283,15 @@ procedure TDMField.DrawXY;
Brush.Style := bsClear;
Font.Name := 'MS Sans Serif';
Font.Size := 8;
for x:=0 to DimX do
for var x:=0 to DimX do
if (x+orx) mod interval = 0 then
begin
s:=IntToStr(x+orx);
ww:=TextWidth(s);
// hh:=Canvas.TextHeight(s);
TextOut(X0+ZazX1+x*CellSize-ww div 2+1,Y0+ZazY1+DimY*CellSize+1+2,s);
end;
for y:=0 to DimY do
for var y:=0 to DimY do
if (y+ory) mod interval = 0 then
begin
s:=IntToStr(y+ory);
Expand All @@ -306,6 +306,7 @@ procedure TDMField.DrawXY;

procedure TDMField.DMLine(x1,y1,x2,y2: integer; c: GraphABC.Color);
begin
Pen.Width := dmwidth;
Line(X0+ZazX1+(x1-orx)*CellSize,Y0+ZazY1+(DimY-y1+ory)*CellSize,X0+ZazX1+(x2-orx)*CellSize,Y0+ZazY1+(DimY-y2+ory)*CellSize,c);
end;

Expand Down Expand Up @@ -364,6 +365,11 @@ procedure TDMField.MakerOnVector(x,y: integer);
MakerToPoint(MakerX+x,MakerY+y);
end;

procedure TDMField.SetDrawManWidth(w: integer);
begin
dmwidth := 2;
end;

procedure TDMField.DrawDM;
var
ZZ: integer;
Expand All @@ -376,6 +382,7 @@ procedure TDMField.DrawDM;
r1 := r;
r1.Offset(X0+ZazX1+(DMX-orx)*CellSize-4+1,Y0+ZazY1+(DimY-DMY+ory)*CellSize-4+1);
DMPicture.CopyRect(r,GraphBufferBitmap,r1);
Pen.Width := 1;
DrawRectangle(X0+ZazX1+(DMX-orx)*CellSize-ZZ+1,Y0+ZazY1+(DimY+ory-DMY)*CellSize-ZZ+1,X0+ZazX1+(DMX-orx)*CellSize+ZZ,Y0+ZazY1+(DimY+ory-DMY)*CellSize+ZZ);
end;

Expand Down
10 changes: 9 additions & 1 deletion bin/Lib/Drawman.pas
@@ -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)

///Исполнитель Чертежник предназначен для построения рисунков и чертежей на плоскости с координатами.
Expand Down Expand Up @@ -29,6 +29,9 @@ procedure Start;
/// Остановить Чертежника
procedure Stop;

/// Установить ширину пера Чертежника
procedure SetDrawmanWidth(w: integer);

///--
procedure __InitModule__;
///--
Expand All @@ -38,6 +41,11 @@ implementation

uses DMTaskMaker,DMZadan,DrawmanField;

procedure SetDrawmanWidth(w: integer);
begin
DMField.dmwidth := w
end;

procedure Start;
begin
DMField.Start;
Expand Down
3 changes: 3 additions & 0 deletions bin/Lib/GraphABC.pas
Expand Up @@ -2904,7 +2904,10 @@ function PenColor: Color;
procedure SetPenWidth(Width: integer);
begin
lock f do
begin
Pen.NETPen.Width := Width;
_ColorLinePen.Width := Width;
end;
end;

function PenWidth: integer;
Expand Down
Binary file modified bin/Lib/PABCRtl.dll
Binary file not shown.
16 changes: 14 additions & 2 deletions bin/Lib/PABCSystem.pas
Expand Up @@ -8626,12 +8626,24 @@ function Print(Self: array [,] of real; w: integer := 7; f: integer := 2): array

function Println<T>(Self: array [,] of T; w: integer := 4): array [,] of T; extensionmethod;
begin
Self.Print(w)
Self.Print(w);
Result := Self;
end;

function Println(Self: array [,] of real; w: integer := 7; f: integer := 2): array [,] of real; extensionmethod;
begin
Self.Println(w,f)
Self.Println(w,f);
Result := Self;
end;

function Rows<T>(Self: array [,] of T): integer; extensionmethod;
begin
Result := Self.GetLength(0);
end;

function Cols<T>(Self: array [,] of T): integer; extensionmethod;
begin
Result := Self.GetLength(1);
end;

// -----------------------------------------------------
Expand Down

0 comments on commit 5e4b3e0

Please sign in to comment.