Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ibond84 committed Feb 4, 2024
2 parents 8cf8487 + 5496eb1 commit 71df546
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 47 deletions.
16 changes: 8 additions & 8 deletions Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,14 +2005,14 @@ private void SetOutputPlatformOption(NETGenerator.CompilerOptions compilerOption
}
if (CompilerOptions.Only32Bit)
compilerOptions.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x86;

// целевой framework
if (this.compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.compiler_directive_targetframework, out compilerDirectivesList))
}
if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.compiler_directive_targetframework, out compilerDirectivesList))
{
compilerOptions.TargetFramework = compilerDirectivesList[0].directive;
if (!(new string[] { "net40", "net403", "net45", "net451", "net452", "net46", "net461", "net462", "net47", "net471", "net472", "net48", "net481" })
.Contains(compilerOptions.TargetFramework))
{
compilerOptions.TargetFramework = compilerDirectivesList[0].directive;
if (!(new string[] { "net40", "net403", "net45", "net451", "net452", "net46", "net461", "net462", "net47", "net471", "net472", "net48", "net481" })
.Contains(compilerOptions.TargetFramework))
ErrorsList.Add(new UnsupportedTargetFramework(compilerOptions.TargetFramework, compilerDirectivesList[0].location));
ErrorsList.Add(new UnsupportedTargetFramework(compilerOptions.TargetFramework, compilerDirectivesList[0].location));
}
}
}
Expand Down Expand Up @@ -2329,7 +2329,7 @@ private void PrebuildMainSemanticTreeActions(out NETGenerator.CompilerOptions co

compilerOptions = new NETGenerator.CompilerOptions();

// выяснение целевой платформы
// выяснение TargetFramework и целевой платформы
SetOutputPlatformOption(compilerOptions);

// остальные директивы
Expand Down
2 changes: 1 addition & 1 deletion Configuration/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "9";
public const string Build = "0";
public const string Revision = "3417";
public const string Revision = "3419";

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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%MINOR%=9
%REVISION%=3417
%REVISION%=3419
%COREVERSION%=0
%MAJOR%=3
Binary file modified Localization/DefaultLang.resources
Binary file not shown.
2 changes: 1 addition & 1 deletion Release/pabcversion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.0.3417
3.9.0.3419
2 changes: 1 addition & 1 deletion ReleaseGenerators/PascalABCNET_version.nsh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!define VERSION '3.9.0.3417'
!define VERSION '3.9.0.3419'
2 changes: 1 addition & 1 deletion SyntaxTreeConverters/StandardSyntaxConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public syntax_tree_node Convert(syntax_tree_node root)
// stat.ProcessNode(root);
#endif
// SSM 02.01.24
LetExprVisitor.New.ProcessNode(root);
//LetExprVisitor.New.ProcessNode(root);

// new range - до всего! До выноса выражения с лямбдой из foreach. 11.07 добавил поиск yields и присваивание pd.HasYield
NewRangeDesugarAndFindHasYieldVisitor.New.ProcessNode(root);
Expand Down
20 changes: 8 additions & 12 deletions TestSuite/CompilationSamples/PABCSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8882,17 +8882,15 @@ procedure Reverse(var s: string; index, count: integer);

procedure Shuffle<T>(a: array of T);
begin
var n := a.Length;
for var i := 0 to n - 1 do
Swap(a[i], a[Random(n)]);
for var i := a.Length - 1 downto 1 do
Swap(a[i], a[Random(i + 1)]);
end;

procedure Shuffle<T>(l: List<T>);
begin
var n := l.Count;
for var i := 0 to n - 1 do
for var i := l.Count - 1 downto 1 do
begin
var ind := Random(n);
var ind := Random(i + 1);
var v := l[i];
l[i] := l[ind];
l[ind] := v;
Expand Down Expand Up @@ -10756,10 +10754,9 @@ function Indices<T>(Self: List<T>; cond: (T,integer) ->boolean): sequence of int
/// Перемешивает элементы списка случайным образом
function Shuffle<T>(Self: List<T>): List<T>; extensionmethod;
begin
var n := Self.Count;
for var i := 0 to n - 1 do
for var i := Self.Count - 1 downto 1 do
begin
var r := Random(n);
var r := Random(i + 1);
var v := Self[i];
Self[i] := Self[r];
Self[r] := v;
Expand Down Expand Up @@ -11814,9 +11811,8 @@ function RandomElement<T>(Self: array of T): T; extensionmethod;
/// Перемешивает элементы массива случайным образом
function Shuffle<T>(Self: array of T): array of T; extensionmethod;
begin
var n := Self.Length;
for var i := 0 to n - 1 do
Swap(Self[i], Self[Random(n)]);
for var i := Self.Length - 1 downto 1 do
Swap(Self[i], Self[Random(i + 1)]);
Result := Self;
end;

Expand Down
2 changes: 1 addition & 1 deletion TestSuite/CompilationSamples/Tasks1Loops.pas
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ procedure CheckTaskT(name: string);
end;
'Min3': begin
CheckData(InitialInput := |cRe|*3);
Generatetests(10,tRe(1,100)*2);
Generatetests(10,tRe(1,100)*3);
CheckOutput(Min(Re(0),Re(1),Re(2)));
end;
'SeriesMin2': begin
Expand Down
4 changes: 2 additions & 2 deletions TestSuite/CompilationSamples/TasksStr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ procedure CheckTaskT(name: string);
end;
'Insert2': begin
CheckData(Input := Empty);
CheckOutput('Петр первый был великим русским императором');
CheckOutput('Петр Первый был великим русским императором');
end;
'StrChange1': begin
CheckData(Input := Empty);
Expand All @@ -306,7 +306,7 @@ procedure CheckTaskT(name: string);
end;
'StrSlice2': begin
CheckData(Input := Empty);
CheckOutputSeq(Arr('клад зарыт на юго западе', 'клад зарыт на юго западе'));
CheckOutputSeq(Arr('клад зарыт на юго западе', 'зашифрованное сообщение'));
end;
'StrSlice4': begin
CheckData(Input := Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ public override void visit(var_def_statement varDefStmt)
}
}


// SSM 2024.01.09
public override void visit(let_var_expr letVarExpr)
{
ProcessNode(letVarExpr.ex);

_visitor.ProcessNode(letVarExpr);

SymbolInfo si = _visitor.context.find_first(letVarExpr.id.name);
_currentTreeNode.VariablesDefinedInScope.Add(new CapturedVariablesTreeNode.CapturedSymbolInfo(letVarExpr, si));
}

public override void visit(statement_list stmtList)
{
if (stmtList.IsInternal) // просто обойти как продолжение объемлющего statement_list
Expand Down
30 changes: 30 additions & 0 deletions TreeConverter/TreeConversion/syntax_tree_visitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19809,6 +19809,36 @@ public override void visit(SyntaxTree.var_statement node)
ret.reset(); // SSM 19.01.17 не возвращать семантическое значение т.к. ничего не нужно добавлять в текущий список операторов!!
}

// создать словарик чтобы для одного _visitor.context.CurrentScope.ScopeNum и для одного letVarExpr
// мы заходили в этот visit один раз
private Dictionary<let_var_expr, List<int>> letDict = new Dictionary<let_var_expr, List<int>>();

// можно попробовать в одно ПИ не добавлять дважды - хранить словарь (let-переменная, номера ПИ в кот добавлена)
public override void visit(SyntaxTree.let_var_expr let_expr)
{
if (letDict.ContainsKey(let_expr) && letDict[let_expr].Contains(context.CurrentScope.ScopeNum))
return;

if (!letDict.ContainsKey(let_expr))
letDict[let_expr] = new List<int>();
letDict[let_expr].Add(context.CurrentScope.ScopeNum);

var exn = (expression_node)convert_strong(let_expr.ex);
var sav = new semantic_addr_value(exn);
var vds = new var_statement(let_expr.id, sav, let_expr.source_context);
if (let_expr.visit_var)
{
visit(vds.var_def);
//let_expr.visit_var = false;
}
else
{

}
return_value(exn);
}


public override void visit(SyntaxTree.expression_as_statement node)
{
return_value((statement_node)convert_strong(node.expr));
Expand Down
8 changes: 4 additions & 4 deletions bin/Lib/CRT.pas
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ function ReadKey: char;// TODO продумать это
var
KeyInfo: ConsoleKeyInfo;
begin
if NextKey <> Chr(0) then
if NextKey <> #0 then
begin
ReadKey := nextkey;
ReadKey := NextKey;
NextKey := #0;
end
else
Expand All @@ -172,7 +172,7 @@ function ReadKey: char;// TODO продумать это

function KeyPressed: boolean;
begin
KeyPressed := Console.KeyAvailable;
KeyPressed := (NextKey <> #0) or Console.KeyAvailable;
end;

function WindowWidth: integer;
Expand Down Expand Up @@ -300,4 +300,4 @@ procedure __InitModule__;
begin
//zdes oshibka ISConsoleApplication u nas nikogda ne inicializiruetsja
__InitModule;
end.
end.
20 changes: 8 additions & 12 deletions bin/Lib/PABCSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8882,17 +8882,15 @@ procedure Reverse(var s: string; index, count: integer);

procedure Shuffle<T>(a: array of T);
begin
var n := a.Length;
for var i := 0 to n - 1 do
Swap(a[i], a[Random(n)]);
for var i := a.Length - 1 downto 1 do
Swap(a[i], a[Random(i + 1)]);
end;

procedure Shuffle<T>(l: List<T>);
begin
var n := l.Count;
for var i := 0 to n - 1 do
for var i := l.Count - 1 downto 1 do
begin
var ind := Random(n);
var ind := Random(i + 1);
var v := l[i];
l[i] := l[ind];
l[ind] := v;
Expand Down Expand Up @@ -10756,10 +10754,9 @@ function Indices<T>(Self: List<T>; cond: (T,integer) ->boolean): sequence of int
/// Перемешивает элементы списка случайным образом
function Shuffle<T>(Self: List<T>): List<T>; extensionmethod;
begin
var n := Self.Count;
for var i := 0 to n - 1 do
for var i := Self.Count - 1 downto 1 do
begin
var r := Random(n);
var r := Random(i + 1);
var v := Self[i];
Self[i] := Self[r];
Self[r] := v;
Expand Down Expand Up @@ -11814,9 +11811,8 @@ function RandomElement<T>(Self: array of T): T; extensionmethod;
/// Перемешивает элементы массива случайным образом
function Shuffle<T>(Self: array of T): array of T; extensionmethod;
begin
var n := Self.Length;
for var i := 0 to n - 1 do
Swap(Self[i], Self[Random(n)]);
for var i := Self.Length - 1 downto 1 do
Swap(Self[i], Self[Random(i + 1)]);
Result := Self;
end;

Expand Down
2 changes: 1 addition & 1 deletion bin/Lib/Tasks1Loops.pas
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ procedure CheckTaskT(name: string);
end;
'Min3': begin
CheckData(InitialInput := |cRe|*3);
Generatetests(10,tRe(1,100)*2);
Generatetests(10,tRe(1,100)*3);
CheckOutput(Min(Re(0),Re(1),Re(2)));
end;
'SeriesMin2': begin
Expand Down
4 changes: 2 additions & 2 deletions bin/Lib/TasksStr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ procedure CheckTaskT(name: string);
end;
'Insert2': begin
CheckData(Input := Empty);
CheckOutput('Петр первый был великим русским императором');
CheckOutput('Петр Первый был великим русским императором');
end;
'StrChange1': begin
CheckData(Input := Empty);
Expand All @@ -306,7 +306,7 @@ procedure CheckTaskT(name: string);
end;
'StrSlice2': begin
CheckData(Input := Empty);
CheckOutputSeq(Arr('клад зарыт на юго западе', 'клад зарыт на юго западе'));
CheckOutputSeq(Arr('клад зарыт на юго западе', 'зашифрованное сообщение'));
end;
'StrSlice4': begin
CheckData(Input := Empty);
Expand Down

0 comments on commit 71df546

Please sign in to comment.