PABCSystem несколько переопределений операций для SortedSet

This commit is contained in:
miks1965 2016-05-16 09:53:51 +03:00
parent c91e2e76e8
commit a5b8eaac6f
6 changed files with 92 additions and 17 deletions

View file

@ -532,8 +532,8 @@ namespace PascalABCCompiler.SyntaxTree
_statement_list.subnodes.Add(_read_node() as statement);
}
}
_statement_list.left_logical_bracket = _read_node() as syntax_tree_node;
_statement_list.right_logical_bracket = _read_node() as syntax_tree_node;
_statement_list.left_logical_bracket = _read_node() as token_info;
_statement_list.right_logical_bracket = _read_node() as token_info;
_statement_list.expr_lambda_body = br.ReadBoolean();
}

View file

@ -255,7 +255,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Конструктор с параметрами.
///</summary>
public statement_list(List<statement> _subnodes,syntax_tree_node _left_logical_bracket,syntax_tree_node _right_logical_bracket,bool _expr_lambda_body)
public statement_list(List<statement> _subnodes,token_info _left_logical_bracket,token_info _right_logical_bracket,bool _expr_lambda_body)
{
this._subnodes=_subnodes;
this._left_logical_bracket=_left_logical_bracket;
@ -266,7 +266,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Конструктор с параметрами.
///</summary>
public statement_list(List<statement> _subnodes,syntax_tree_node _left_logical_bracket,syntax_tree_node _right_logical_bracket,bool _expr_lambda_body,SourceContext sc)
public statement_list(List<statement> _subnodes,token_info _left_logical_bracket,token_info _right_logical_bracket,bool _expr_lambda_body,SourceContext sc)
{
this._subnodes=_subnodes;
this._left_logical_bracket=_left_logical_bracket;
@ -283,8 +283,8 @@ namespace PascalABCCompiler.SyntaxTree
// Окончание конструкторов списка
protected List<statement> _subnodes=new List<statement>();
protected syntax_tree_node _left_logical_bracket;
protected syntax_tree_node _right_logical_bracket;
protected token_info _left_logical_bracket;
protected token_info _right_logical_bracket;
protected bool _expr_lambda_body=new bool();
///<summary>
@ -305,7 +305,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Левая операторная скобка
///</summary>
public syntax_tree_node left_logical_bracket
public token_info left_logical_bracket
{
get
{
@ -320,7 +320,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Правая операторная скобка
///</summary>
public syntax_tree_node right_logical_bracket
public token_info right_logical_bracket
{
get
{
@ -471,10 +471,10 @@ namespace PascalABCCompiler.SyntaxTree
switch(ind)
{
case 0:
left_logical_bracket = (syntax_tree_node)value;
left_logical_bracket = (token_info)value;
break;
case 1:
right_logical_bracket = (syntax_tree_node)value;
right_logical_bracket = (token_info)value;
break;
}
Int32 index_counter=ind - 2;

View file

@ -872,7 +872,7 @@ namespace PascalABCCompiler.SyntaxTree
public partial class initfinal_part
{
public initfinal_part(syntax_tree_node stn1, statement_list init, syntax_tree_node stn2, statement_list fin, syntax_tree_node stn3, SourceContext sc)
public initfinal_part(token_info stn1, statement_list init, token_info stn2, statement_list fin, token_info stn3, SourceContext sc)
{
_initialization_sect = init;
_finalization_sect = fin;

Binary file not shown.

Binary file not shown.

View file

@ -3198,23 +3198,35 @@ end;
// Операции для HashSet<T>
//------------------------------------------------------------------------------
///--
function HashSet<T>.operator in(x: T; Self: HashSet<T>): boolean;
function operator in<T>(x: T; Self: HashSet<T>): boolean; extensionmethod;
begin
Result := Self.Contains(x);
end;
function HashSet<T>.operator+=(var Self: HashSet<T>; x: T): HashSet<T>;
function operator+=<T>(var Self: HashSet<T>; x: T): HashSet<T>; extensionmethod;
begin
Self.Add(x);
Result := Self;
end;
function HashSet<T>.operator-=(var Self: HashSet<T>; x: T): HashSet<T>;
function operator+=<T>(var Self: HashSet<T>; x: sequence of T): HashSet<T>; extensionmethod;
begin
Self.UnionWith(x);
Result := Self;
end;
function operator-=<T>(var Self: HashSet<T>; x: T): HashSet<T>; extensionmethod;
begin
Self.Remove(x);
Result := Self;
end;
function operator-=<T>(var Self: HashSet<T>; x: sequence of T): HashSet<T>; extensionmethod;
begin
Self.ExceptWith(x);
Result := Self;
end;
function operator=<T>(x,y: HashSet<T>): boolean; extensionmethod;
begin
Result := x.SetEquals(y)
@ -3269,23 +3281,86 @@ end;
//------------------------------------------------------------------------------
// Операции для SortedSet<T>
//------------------------------------------------------------------------------
function SortedSet<T>.operator in(x: T; Self: SortedSet<T>): boolean;
function operator in<T>(x: T; Self: SortedSet<T>): boolean; extensionmethod;
begin
Result := Self.Contains(x);
end;
function SortedSet<T>.operator+=(var Self: SortedSet<T>; x: T): SortedSet<T>;
function operator+=<T>(var Self: SortedSet<T>; x: T): SortedSet<T>; extensionmethod;
begin
Self.Add(x);
Result := Self;
end;
function SortedSet<T>.operator-=(var Self: SortedSet<T>; x: T): SortedSet<T>;
function operator+=<T>(var Self: SortedSet<T>; x: sequence of T): SortedSet<T>; extensionmethod;
begin
Self.UnionWith(x);
Result := Self;
end;
function operator-=<T>(var Self: SortedSet<T>; x: T): SortedSet<T>; extensionmethod;
begin
Self.Remove(x);
Result := Self;
end;
function operator-=<T>(var Self: SortedSet<T>; x: sequence of T): SortedSet<T>; extensionmethod;
begin
Self.ExceptWith(x);
Result := Self;
end;
function operator=<T>(x,y: SortedSet<T>): boolean; extensionmethod;
begin
Result := x.SetEquals(y)
end;
function operator<><T>(x,y: SortedSet<T>): boolean; extensionmethod;
begin
Result := not x.SetEquals(y)
end;
function operator-<T>(x,y: SortedSet<T>): SortedSet<T>; extensionmethod;
begin
var v := new SortedSet<T>(x);
v.ExceptWith(y);
Result := v;
end;
function operator+<T>(x,y: SortedSet<T>): SortedSet<T>; extensionmethod;
begin
var v := new SortedSet<T>(x);
v.UnionWith(y);
Result := v;
end;
function operator*<T>(x,y: SortedSet<T>): SortedSet<T>; extensionmethod;
begin
var v := new SortedSet<T>(x);
v.IntersectWith(y);
Result := v;
end;
function operator< <T>(x,y: SortedSet<T>): boolean; extensionmethod;
begin
Result := x.IsProperSubsetOf(y);
end;
function operator<= <T>(x,y: SortedSet<T>): boolean; extensionmethod;
begin
Result := x.IsSubsetOf(y);
end;
function operator> <T>(x,y: SortedSet<T>): boolean; extensionmethod;
begin
Result := x.IsProperSupersetOf(y);
end;
function operator>= <T>(x,y: SortedSet<T>): boolean; extensionmethod;
begin
Result := x.IsSupersetOf(y);
end;
//------------------------------------------------------------------------------
// Операции для Dictionary<K,V>, SortedDictionary<K,V>, SortedList<K,V>
//------------------------------------------------------------------------------