modern_proc_type 0

This commit is contained in:
miks1965 2015-05-19 22:53:44 +03:00
parent b6b39c0489
commit 8b09b83b54
18 changed files with 348 additions and 28 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "2";
public const string Minor = "2";
public const string Build = "0";
public const string Revision = "945";
public const string Revision = "949";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=2
%REVISION%=945
%REVISION%=949
%MAJOR%=2
%COREVERSION%=0

Binary file not shown.

View file

@ -1140,14 +1140,7 @@ simple_type
}
| identifier tkArrow identifier
{
var l = new List<ident>();
l.Add(new ident("System"));
l.Add(new ident("Func"));
var t = new template_param_list();
t.Add(new named_type_reference($1,@1));
t.Add(new named_type_reference($3,@3));
t.source_context = @$;
$$ = new template_type_reference(new named_type_reference(l), t, @$);
$$ = new modern_proc_type($1,null,$3,@$);
}
| tkRoundOpen tkRoundClose tkArrow identifier
{

View file

@ -303,6 +303,7 @@
<name value="object_type" />
<name value="record_type" />
<name value="proc_type_decl" />
<name value="simple_type" />
</tag>
<tag value="Ключевые слова">
<name value="meth_modificator" />

View file

@ -63,6 +63,8 @@ script=

View file

@ -1 +1 @@
!define VERSION '2.2.0.945'
!define VERSION '2.2.0.949'

View file

@ -860,6 +860,10 @@ namespace PascalABCCompiler.SyntaxTree
public virtual void visit(sequence_type _sequence_type)
{
}
public virtual void visit(modern_proc_type _modern_proc_type)
{
}
}

View file

@ -1701,6 +1701,30 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public virtual void pre_do_visit(closure_substituting_node _closure_substituting_node)
{
}
public virtual void post_do_visit(closure_substituting_node _closure_substituting_node)
{
}
public virtual void pre_do_visit(sequence_type _sequence_type)
{
}
public virtual void post_do_visit(sequence_type _sequence_type)
{
}
public virtual void pre_do_visit(modern_proc_type _modern_proc_type)
{
}
public virtual void post_do_visit(modern_proc_type _modern_proc_type)
{
}
public override void visit(syntax_tree_node _syntax_tree_node)
{
pre_do_visit(_syntax_tree_node);
@ -1964,7 +1988,7 @@ namespace PascalABCCompiler.SyntaxTree
{
pre_do_visit(_array_type);
visit(array_type.indexers);
visit(array_type.elemets_types);
visit(array_type.elements_type);
post_do_visit(_array_type);
}
@ -3233,6 +3257,7 @@ namespace PascalABCCompiler.SyntaxTree
visit(function_lambda_definition.parameters);
for (int i = 0; i < defs.Count; i++)
visit(function_lambda_definition.defs[i]);
visit(function_lambda_definition.substituting_node);
post_do_visit(_function_lambda_definition);
}
@ -3315,6 +3340,29 @@ namespace PascalABCCompiler.SyntaxTree
visit(matching_expression.right);
post_do_visit(_matching_expression);
}
public override void visit(closure_substituting_node _closure_substituting_node)
{
pre_do_visit(_closure_substituting_node);
visit(closure_substituting_node.substitution);
post_do_visit(_closure_substituting_node);
}
public override void visit(sequence_type _sequence_type)
{
pre_do_visit(_sequence_type);
visit(sequence_type.elements_type);
post_do_visit(_sequence_type);
}
public override void visit(modern_proc_type _modern_proc_type)
{
pre_do_visit(_modern_proc_type);
visit(modern_proc_type.aloneparam);
visit(modern_proc_type.el);
visit(modern_proc_type.res);
post_do_visit(_modern_proc_type);
}
}

View file

@ -448,6 +448,8 @@ namespace PascalABCCompiler.SyntaxTree
return new closure_substituting_node();
case 213:
return new sequence_type();
case 214:
return new modern_proc_type();
}
return null;
}
@ -3805,6 +3807,20 @@ namespace PascalABCCompiler.SyntaxTree
_sequence_type.elements_type = _read_node() as type_definition;
}
public void visit(modern_proc_type _modern_proc_type)
{
read_modern_proc_type(_modern_proc_type);
}
public void read_modern_proc_type(modern_proc_type _modern_proc_type)
{
read_type_declaration(_modern_proc_type);
_modern_proc_type.aloneparam = _read_node() as ident;
_modern_proc_type.el = _read_node() as enumerator_list;
_modern_proc_type.res = _read_node() as ident;
}
}

View file

@ -6017,6 +6017,45 @@ namespace PascalABCCompiler.SyntaxTree
}
}
public void visit(modern_proc_type _modern_proc_type)
{
bw.Write((Int16)214);
write_modern_proc_type(_modern_proc_type);
}
public void write_modern_proc_type(modern_proc_type _modern_proc_type)
{
write_type_declaration(_modern_proc_type);
if (_modern_proc_type.aloneparam == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_modern_proc_type.aloneparam.visit(this);
}
if (_modern_proc_type.el == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_modern_proc_type.el.visit(this);
}
if (_modern_proc_type.res == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_modern_proc_type.res.visit(this);
}
}
}

View file

@ -28165,6 +28165,188 @@ namespace PascalABCCompiler.SyntaxTree
}
///<summary>
///
///</summary>
[Serializable]
public class modern_proc_type : type_declaration
{
///<summary>
///Конструктор без параметров.
///</summary>
public modern_proc_type()
{
}
///<summary>
///Конструктор с параметрами.
///</summary>
public modern_proc_type(ident _aloneparam,enumerator_list _el,ident _res)
{
this._aloneparam=_aloneparam;
this._el=_el;
this._res=_res;
}
///<summary>
///Конструктор с параметрами.
///</summary>
public modern_proc_type(ident _aloneparam,enumerator_list _el,ident _res,SourceContext sc)
{
this._aloneparam=_aloneparam;
this._el=_el;
this._res=_res;
source_context = sc;
}
///<summary>
///Конструктор с параметрами.
///</summary>
public modern_proc_type(ident _type_name,type_definition _type_def,ident _aloneparam,enumerator_list _el,ident _res)
{
this._type_name=_type_name;
this._type_def=_type_def;
this._aloneparam=_aloneparam;
this._el=_el;
this._res=_res;
}
///<summary>
///Конструктор с параметрами.
///</summary>
public modern_proc_type(ident _type_name,type_definition _type_def,ident _aloneparam,enumerator_list _el,ident _res,SourceContext sc)
{
this._type_name=_type_name;
this._type_def=_type_def;
this._aloneparam=_aloneparam;
this._el=_el;
this._res=_res;
source_context = sc;
}
protected ident _aloneparam;
protected enumerator_list _el;
protected ident _res;
///<summary>
///
///</summary>
public ident aloneparam
{
get
{
return _aloneparam;
}
set
{
_aloneparam=value;
}
}
///<summary>
///
///</summary>
public enumerator_list el
{
get
{
return _el;
}
set
{
_el=value;
}
}
///<summary>
///
///</summary>
public ident res
{
get
{
return _res;
}
set
{
_res=value;
}
}
///<summary>
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
///</summary>
public override Int32 subnodes_count
{
get
{
return 5;
}
}
///<summary>
///Индексатор для получения всех подузлов
///</summary>
public override object this[Int32 ind]
{
get
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
return type_name;
case 1:
return type_def;
case 2:
return aloneparam;
case 3:
return el;
case 4:
return res;
}
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
type_name = (ident)value;
break;
case 1:
type_def = (type_definition)value;
break;
case 2:
aloneparam = (ident)value;
break;
case 3:
el = (enumerator_list)value;
break;
case 4:
res = (ident)value;
break;
}
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
}

View file

@ -1288,6 +1288,12 @@ namespace PascalABCCompiler.SyntaxTree
///<param name="_sequence_type">Node to visit</param>
///<returns> Return value is void </returns>
void visit(sequence_type _sequence_type);
///<summary>
///Method to visit modern_proc_type.
///</summary>
///<param name="_modern_proc_type">Node to visit</param>
///<returns> Return value is void </returns>
void visit(modern_proc_type _modern_proc_type);
}

Binary file not shown.

View file

@ -17730,6 +17730,21 @@ namespace PascalABCCompiler.TreeConverter
var tr = new template_type_reference(new named_type_reference(l), new template_param_list(_sequence_type.elements_type, _sequence_type.elements_type.source_context), _sequence_type.source_context);
visit(tr);
}
public override void visit(SyntaxTree.modern_proc_type _modern_proc_type)
{
if (_modern_proc_type.aloneparam != null && _modern_proc_type.el == null && _modern_proc_type.res != null)
{
var l = new List<ident>();
l.Add(new ident("System"));
l.Add(new ident("Func"));
var t = new template_param_list();
t.Add(new named_type_reference(_modern_proc_type.aloneparam,_modern_proc_type.aloneparam.source_context));
t.Add(new named_type_reference(_modern_proc_type.res,_modern_proc_type.res.source_context));
t.source_context = _modern_proc_type.source_context;
var ttr = new template_type_reference(new named_type_reference(l), t, _modern_proc_type.source_context);
visit(ttr);
}
}
}
}

Binary file not shown.

View file

@ -792,13 +792,13 @@ procedure WriteFormat(f: Text; formatstr: string; params args: array of object);
///è îñóùåñòâëÿåò ïåðåõîä íà íîâóþ ñòðîêó
procedure WritelnFormat(f: Text; formatstr: string; params args: array of object);
/// Выводит значения args на экран, разделяя их пробелами
/// Выводит значения args на экран, выводя после каждого значения пробел
procedure Print(params args: array of object);
/// Выводит значения args на экран, разделяя их пробелами, и переходит на новую строчку
/// Выводит значения args на экран, выводя после каждого значения пробел, и переходит на новую строчку
procedure Println(params args: array of object);
/// Выводит значения args в текстовый файл f, разделяя их пробелами
/// Выводит значения args в текстовый файл f, выводя после каждого значения пробел
procedure Print(f: Text; params args: array of object);
/// Выводит значения args в текстовый файл f, разделяя их пробелами, и переходит на новую строчку
/// Выводит значения args в текстовый файл f, выводя после каждого значения пробел, и переходит на новую строчку
procedure Println(f: Text; params args: array of object);
// -----------------------------------------------------
@ -849,25 +849,29 @@ procedure Rename(f: Text; newname: string);
///--
procedure TextFileInit(var f: Text);
/// Считывает строки файла
/// Считывает строки из файла и превращает их в последовательность строк
function ReadLines(path: string): sequence of string;
/// Считывает строки файла с кодировкой en
/// Считывает строки из файла с кодировкой en и превращает их в последовательность строк
function ReadLines(path: string; en: Encoding): sequence of string;
/// Считывает строки файла
/// Считывает строки из файла в массив строк
function ReadAllLines(path: string): array of string;
/// Считывает строки файла с кодировкой en
/// Считывает строки из файла с кодировкой en в массив строк
function ReadAllLines(path: string; en: Encoding): array of string;
/// Ñ÷èòûâàåò ñîäåðæèìîå ôàéëà â ñòðîêó
function ReadAllText(path: string): string;
/// Ñ÷èòûâàåò ñîäåðæèìîå ôàéëà ñ êîäèðîâêîé en â ñòðîêó
function ReadAllText(path: string; en: Encoding): string;
/// Записывает строки в файл
procedure WriteAllLines(path: string; ss: sequence of string);
/// Записывает строки в файл с кодировкой en
procedure WriteAllLines(path: string; ss: sequence of string; en: Encoding);
/// Создает новый файл, записывает в него содержимое строки и закрывает файл
/// Создает новый файл, записывает в него строки из последовательности
procedure WriteLines(path: string; ss: sequence of string);
/// Создает новый файл с кодировкой en, записывает в него строки из последовательности
procedure WriteLines(path: string; ss: sequence of string; en: Encoding);
/// Создает новый файл, записывает в него строки из массива
procedure WriteAllLines(path: string; ss: array of string);
/// Создает новый файл с кодировкой en, записывает в него строки из массива
procedure WriteAllLines(path: string; ss: array of string; en: Encoding);
/// Создает новый файл, записывает в него содержимое строки
procedure WriteAllText(path: string; s: string);
/// Создает новый файл с кодировкой en, записывает в него содержимое строки и закрывает файл
/// Создает новый файл с кодировкой en, записывает в него содержимое строки
procedure WriteAllText(path: string; s: string; en: Encoding);
// -----------------------------------------------------
@ -5033,12 +5037,22 @@ begin
Result := System.IO.File.ReadAllText(path,en);
end;
procedure WriteAllLines(path: string; ss: sequence of string);
procedure WriteLines(path: string; ss: sequence of string);
begin
WriteLines(path,ss,Encoding.GetEncoding(1251));
end;
procedure WriteLines(path: string; ss: sequence of string; en: Encoding);
begin
System.IO.File.WriteAllLines(path,ss,en);
end;
procedure WriteAllLines(path: string; ss: array of string);
begin
WriteAllLines(path,ss,Encoding.GetEncoding(1251));
end;
procedure WriteAllLines(path: string; ss: sequence of string; en: Encoding);
procedure WriteAllLines(path: string; ss: array of string; en: Encoding);
begin
System.IO.File.WriteAllLines(path,ss,en);
end;

Binary file not shown.