Skip to content

Commit

Permalink
Несколько важных правок в syntax_tree_visitor.cs, связанных с обходом…
Browse files Browse the repository at this point in the history
… statement_list

Теперь оператор внутриблочного описания возвращает нулевой semantic_node (всё добавлено в семантическое дерево ранее). В семантические дерево узлы, возвращающие нулевой semantic_node, не добавляются

Добавлены также операторы сравнения < > для Tuples
  • Loading branch information
miks1965 committed Jan 19, 2017
1 parent d4f9cea commit 9ccc781
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 73 deletions.
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 = "2";
public const string Build = "0";
public const string Revision = "1374";
public const string Revision = "1376";

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%=2
%REVISION%=1374
%REVISION%=1376
%COREVERSION%=0
%MAJOR%=3
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.2.0.1374'
!define VERSION '3.2.0.1376'
4 changes: 4 additions & 0 deletions StandardSyntaxTreeConverter/StandardSyntaxConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using PascalABCCompiler.SyntaxTree;
using SyntaxVisitors;
using SyntaxVisitors.SugarVisitors;

namespace PascalABCCompiler.SyntaxTreeConverters
{
Expand All @@ -19,6 +20,9 @@ public syntax_tree_node Convert(syntax_tree_node root)
// Выносим выражения с лямбдами из заголовка foreach
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);

// Пока не доделали
//SliceQuestionDesugarVisitor.New.ProcessNode(root);

// Всё, связанное с yield
root.visit(new MarkMethodHasYieldAndCheckSomeErrorsVisitor());
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
Expand Down
1 change: 1 addition & 0 deletions SyntaxVisitors/SyntaxVisitors.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Compile Include="BaseVisitors\HasStatementVisitor.cs" />
<Compile Include="BaseVisitors\SmallHelperVisitors.cs" />
<Compile Include="ChangeWhileVisitor.cs" />
<Compile Include="SugarVisitors\SliceQuestionDesugarVisitor.cs" />
<Compile Include="YieldVisitors\ObjectCopier\ObjectCopier.cs" />
<Compile Include="Optimization\CalcConstExprs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
64 changes: 36 additions & 28 deletions TestSuite/CompilationSamples/PABCSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9808,41 +9808,49 @@ function operator+<T1, T2, T3, T4, T5, T6, T7> (Self: (T1,T2,T3,T4,T5,T6); v: T7
end;

///--
function operator=<T1, T2> (Self: (T1,T2); v: (T1,T2)): boolean; extensionmethod;
begin
Result := Self.Equals( v ) ;
end;

function operator=<T1, T2> (Self: (T1,T2); v: (T1,T2)); extensionmethod := Self.Equals( v ) ;
///--
function operator<><T1, T2> (Self: (T1,T2); v: (T1,T2)): boolean; extensionmethod;
begin
Result := not Self.Equals( v ) ;
end;

function operator<><T1, T2> (Self: (T1,T2); v: (T1,T2)); extensionmethod := not Self.Equals( v );
///--
function operator<<T1, T2> (Self: (T1,T2); v: (T1,T2)): boolean; extensionmethod;
begin
Result := (Self as System.IComparable).CompareTo( v ) < 0 ;
end;

function CompareToTup2<T1,T2>(v1: (T1,T2); v2: (T1,T2)) := (v1 as System.IComparable).CompareTo(v2);
///--
function operator<=<T1, T2> (Self: (T1,T2); v: (T1,T2)): boolean; extensionmethod;
begin
Result := (Self as System.IComparable).CompareTo( v ) <= 0 ;
end;

function operator<<T1, T2> (Self: (T1,T2); v: (T1,T2)); extensionmethod := CompareToTup2(Self,v) < 0;
///--
function operator><T1, T2> (Self: (T1,T2); v: (T1,T2)): boolean; extensionmethod;
begin
Result := (Self as System.IComparable).CompareTo( v ) > 0 ;
end;
function operator<=<T1, T2> (Self: (T1,T2); v: (T1,T2)); extensionmethod := CompareToTup2(Self,v) <= 0;
///--
function operator><T1, T2> (Self: (T1,T2); v: (T1,T2)); extensionmethod := CompareToTup2(Self,v) > 0;
///--
function operator>=<T1, T2> (Self: (T1,T2); v: (T1,T2)); extensionmethod := CompareToTup2(Self,v) >= 0;

///--
function operator>=<T1, T2> (Self: (T1,T2); v: (T1,T2)): boolean; extensionmethod;
begin
Result := (Self as System.IComparable).CompareTo( v ) >= 0 ;
end;
function operator=<T1, T2, T3> (Self: (T1,T2,T3); v: (T1,T2,T3)); extensionmethod := Self.Equals( v ) ;
///--
function operator<><T1, T2, T3> (Self: (T1,T2,T3); v: (T1,T2,T3)); extensionmethod := not Self.Equals( v );
///--
function CompareToTup3<T1,T2,T3>(v1: (T1,T2,T3); v2: (T1,T2,T3)) := (v1 as System.IComparable).CompareTo(v2);
///--
function operator<<T1,T2,T3> (Self: (T1,T2,T3); v: (T1,T2,T3)); extensionmethod := CompareToTup3(Self,v) < 0;
///--
function operator<=<T1,T2,T3> (Self: (T1,T2,T3); v: (T1,T2,T3)); extensionmethod := CompareToTup3(Self,v) <= 0;
///--
function operator><T1,T2,T3> (Self: (T1,T2,T3); v: (T1,T2,T3)); extensionmethod := CompareToTup3(Self,v) > 0;
///--
function operator>=<T1,T2,T3> (Self: (T1,T2,T3); v: (T1,T2,T3)); extensionmethod := CompareToTup3(Self,v) >= 0;

///--
function operator=<T1, T2, T3, T4> (Self: (T1,T2,T3,T4); v: (T1,T2,T3,T4)); extensionmethod := Self.Equals( v ) ;
///--
function operator<><T1, T2, T3, T4> (Self: (T1,T2,T3,T4); v: (T1,T2,T3,T4)); extensionmethod := not Self.Equals( v );
///--
function CompareToTup4<T1,T2,T3,T4>(v1: (T1,T2,T3,T4); v2: (T1,T2,T3,T4)) := (v1 as System.IComparable).CompareTo(v2);
///--
function operator<<T1,T2,T3,T4> (Self: (T1,T2,T3,T4); v: (T1,T2,T3,T4)); extensionmethod := CompareToTup4(Self,v) < 0;
///--
function operator<=<T1,T2,T3,T4> (Self: (T1,T2,T3,T4); v: (T1,T2,T3,T4)); extensionmethod := CompareToTup4(Self,v) <= 0;
///--
function operator><T1,T2,T3,T4> (Self: (T1,T2,T3,T4); v: (T1,T2,T3,T4)); extensionmethod := CompareToTup4(Self,v) > 0;
///--
function operator>=<T1,T2,T3,T4> (Self: (T1,T2,T3,T4); v: (T1,T2,T3,T4)); extensionmethod := CompareToTup4(Self,v) >= 0;

// --------------------------------------------
// Методы расширения типа Tuple # Extension methods for Tuple
Expand Down
6 changes: 6 additions & 0 deletions TestSuite/tuple_var1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
begin
var pair := (3,5);
(var a, var b) := pair;
Assert((a=3) and (b=5) );
Assert((a,b)=(3,5));
end.
21 changes: 13 additions & 8 deletions TreeConverter/TreeConversion/syntax_tree_visitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,9 @@ internal statement_node convert_strong(SyntaxTree.statement st)
//try
{
sn = ret.visit(st);
if (sn == null)
sn = new empty_statement(null);
// SSM 19/01/17 закомментировал две следующие строчки
//if (sn == null)
// sn = new empty_statement(null);
}
/*catch (PascalABCCompiler.Errors.Error e)
{
Expand Down Expand Up @@ -16287,10 +16288,12 @@ public override void visit(SyntaxTree.statement_list _statement_list)
statement syntax_statement = _statement_list.subnodes[i];
try
{
if (syntax_statement is SyntaxTree.var_statement)
visit(syntax_statement as SyntaxTree.var_statement);
else if (MustVisitBody)
{
// SSM выкинул эти три строки - теперь внутриблочные описания обрабатываются как обычные операторы.
// При этом в конце visit(var_statement) стоит вызов ret.reset(), который возвращает нулевой semantic_statement - и всё работает эквивалентно
//if (syntax_statement is SyntaxTree.var_statement)
// visit(syntax_statement as SyntaxTree.var_statement); // Добавление в текущий statements_list происходит опосредованно !!
//else if (MustVisitBody) // MustVisitBody - всегда True!!!
//{
//(ssyy) TODO Сделать по-другому!!!
statement_node semantic_statement = convert_strong(syntax_statement);
//(ssyy) Проверка для C
Expand All @@ -16304,7 +16307,7 @@ public override void visit(SyntaxTree.statement_list _statement_list)
}

context.allow_inherited_ctor_call = false;
}
//}
}
catch (Errors.Error ex)
{
Expand Down Expand Up @@ -17781,6 +17784,7 @@ public override void visit(SyntaxTree.operator_name_ident node)
public override void visit(SyntaxTree.var_statement node)
{
visit(node.var_def);
ret.reset(); // SSM 19.01.17 не возвращать семантическое значение т.к. ничего не нужно добавлять в текущий список операторов!!
}

public override void visit(SyntaxTree.expression_as_statement node)
Expand Down Expand Up @@ -19202,7 +19206,8 @@ public override void visit(SyntaxTree.assign_var_tuple assvartup)
new dot_node(new ident(tname),new ident("Item" + (i + 1).ToString())),
assvartup.vars.variables[i].source_context
);
//visit(a); // Остальные элементы обходить не надо - они обходятся на следующих итерациях при обходе внешнего statement_list
// Остальные элементы обходить не надо (!!!уже надо!) - они обходятся на следующих итерациях при обходе внешнего statement_list
//visit(a);
sl.Add(a);
}
ReplaceStatementUsingParent(assvartup, sl);
Expand Down
Binary file modified bin/Lib/PABCRtl.dll
Binary file not shown.
105 changes: 99 additions & 6 deletions bin/Lib/PABCSystem.axml
Original file line number Diff line number Diff line change
Expand Up @@ -2188,23 +2188,116 @@
</i>
</OCtx>
</Node>
<Node Name="Операции для List&lt;T&gt;, Dictionary&lt;T&gt; и т.д.">
<Node Name="Операции для HashSet, SortedSet">
<FileName>\PABCSystem.pas</FileName>
<Text>function List&lt;T&gt;.operator+=(var Self: List&lt;T&gt;; x: T): List&lt;T&gt;;</Text>
<Text>function HashSet&lt;T&gt;.operator in(x: T; Self: HashSet&lt;T&gt;): boolean;</Text>
<OCtx>
<i Type="Method">function List &lt; T &gt; . operator + = ( var Self : List &lt; T &gt; ; x : T ) : List &lt; T &gt;</i>
<i Type="Method">function HashSet &lt; T &gt; . operator in ( x : T ; Self : HashSet &lt; T &gt; ) : boolean</i>
<i Type="PAS_TreeNode">
</i>
</OCtx>
</Node>
<Node Name="Операции для HashSet, SortedSet">
<Node Name="Операции для Tuple">
<FileName>\PABCSystem.pas</FileName>
<Text>function HashSet&lt;T&gt;.operator in(x: T; Self: HashSet&lt;T&gt;): boolean;</Text>
<Text>// Операции для Tuple</Text>
<OCtx>
<i Type="Method">function Low ( self : System . Array ) extensionmethod : = Low ( Self )</i>
<i Type="Method">function High ( self : System . Array ) extensionmethod : = High ( Self )</i>
<i Type="PAS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Method">function CreateSliceFromArrayInternal &lt; T &gt; ( Self : array of T ; from , step , count : integer ) : array of T</i>
<i Type="Method">function SliceArrayImpl &lt; T &gt; ( Self : array of T ; from , step , count : integer ) : array of T</i>
<i Type="Method">function Slice &lt; T &gt; ( Self : array of T ; from , step : integer ) : array of T extensionmethod</i>
<i Type="Method">function Slice &lt; T &gt; ( Self : array of T ; from , step , count : integer ) : array of T extensionmethod</i>
<i Type="Method">function SystemSliceArrayImpl &lt; T &gt; ( Self : array of T ; situation : integer ; from , &amp;to : integer ; step : integer : = 1 ) : array of T</i>
<i Type="Method">function SystemSlice &lt; T &gt; ( Self : array of T ; situation : integer ; from , &amp;to : integer ) : array of T extensionmethod</i>
<i Type="Method">function SystemSlice &lt; T &gt; ( Self : array of T ; situation : integer ; from , &amp;to , step : integer ) : array of T extensionmethod</i>
<i Type="Method">function SystemSliceArrayImplQuestion &lt; T &gt; ( Self : array of T ; situation : integer ; from , &amp;to : integer ; step : integer : = 1 ) : array of T</i>
<i Type="Method">function SystemSliceQuestion &lt; T &gt; ( Self : array of T ; situation : integer ; from , &amp;to : integer ) : array of T extensionmethod</i>
<i Type="Method">function SystemSliceQuestion &lt; T &gt; ( Self : array of T ; situation : integer ; from , &amp;to , step : integer ) : array of T extensionmethod</i>
</ICtx>
</Node>
<Node Name="Операции для List&lt;T&gt; ">
<FileName>\PABCSystem.pas</FileName>
<Text>// Операции для List&lt;T&gt;</Text>
<OCtx>
<i Type="Method">function HashSet &lt; T &gt; . operator in ( x : T ; Self : HashSet &lt; T &gt; ) : boolean</i>
<i Type="PAS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Field">unit PABCSystem</i>
<i Type="Field">uses System . Runtime . InteropServices , System . IO , System . Collections , System . Collections . Generic , System</i>
<i Type="Field">MaxShortInt = shortint . MaxValue</i>
<i Type="Field">MaxByte = byte . MaxValue</i>
<i Type="Field">MaxSmallInt = smallint . MaxValue</i>
<i Type="Field">MaxWord = word . MaxValue</i>
<i Type="Field">MaxLongWord = longword . MaxValue</i>
<i Type="Field">MaxInt64 = int64 . MaxValue</i>
<i Type="Field">MaxUInt64 = uint64 . MaxValue</i>
<i Type="Field">MaxDouble = real . MaxValue</i>
</ICtx>
</Node>
<Node Name="Операции для HashSet&lt;T&gt; ">
<FileName>\PABCSystem.pas</FileName>
<Text>// Операции для HashSet&lt;T&gt;</Text>
<OCtx>
<i Type="PAS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Field">unit PABCSystem</i>
<i Type="Field">uses System . Runtime . InteropServices , System . IO , System . Collections , System . Collections . Generic , System</i>
<i Type="Field">MaxShortInt = shortint . MaxValue</i>
<i Type="Field">MaxByte = byte . MaxValue</i>
<i Type="Field">MaxSmallInt = smallint . MaxValue</i>
<i Type="Field">MaxWord = word . MaxValue</i>
<i Type="Field">MaxLongWord = longword . MaxValue</i>
<i Type="Field">MaxInt64 = int64 . MaxValue</i>
<i Type="Field">MaxUInt64 = uint64 . MaxValue</i>
<i Type="Field">MaxDouble = real . MaxValue</i>
</ICtx>
</Node>
<Node Name="Операции для SortedSet&lt;T&gt; ">
<FileName>\PABCSystem.pas</FileName>
<Text>// Операции для SortedSet&lt;T&gt;</Text>
<OCtx>
<i Type="PAS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Field">unit PABCSystem</i>
<i Type="Field">uses System . Runtime . InteropServices , System . IO , System . Collections , System . Collections . Generic , System</i>
<i Type="Field">MaxShortInt = shortint . MaxValue</i>
<i Type="Field">MaxByte = byte . MaxValue</i>
<i Type="Field">MaxSmallInt = smallint . MaxValue</i>
<i Type="Field">MaxWord = word . MaxValue</i>
<i Type="Field">MaxLongWord = longword . MaxValue</i>
<i Type="Field">MaxInt64 = int64 . MaxValue</i>
<i Type="Field">MaxUInt64 = uint64 . MaxValue</i>
<i Type="Field">MaxDouble = real . MaxValue</i>
</ICtx>
</Node>
<Node Name="Операции для Dictionary&lt;K,V&gt;, SortedDictionary&lt;K,V&gt;, SortedList&lt;K,V&gt;">
<FileName>\PABCSystem.pas</FileName>
<Text>// Операции для Dictionary&lt;K,V&gt;, SortedDictionary&lt;K,V&gt;, SortedList&lt;K,V&gt;</Text>
<OCtx>
<i Type="PAS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Field">unit PABCSystem</i>
<i Type="Field">uses System . Runtime . InteropServices , System . IO , System . Collections , System . Collections . Generic , System</i>
<i Type="Field">MaxShortInt = shortint . MaxValue</i>
<i Type="Field">MaxByte = byte . MaxValue</i>
<i Type="Field">MaxSmallInt = smallint . MaxValue</i>
<i Type="Field">MaxWord = word . MaxValue</i>
<i Type="Field">MaxLongWord = longword . MaxValue</i>
<i Type="Field">MaxInt64 = int64 . MaxValue</i>
<i Type="Field">MaxUInt64 = uint64 . MaxValue</i>
<i Type="Field">MaxDouble = real . MaxValue</i>
</ICtx>
</Node>
</Items>
</Node>
Expand Down
Loading

0 comments on commit 9ccc781

Please sign in to comment.