This commit is contained in:
miks1965 2017-02-03 11:31:48 +03:00
commit 0adea40920
34 changed files with 212 additions and 285 deletions

View file

@ -2774,10 +2774,10 @@ namespace CodeFormatters
}
}
public override void visit(tuple_node_for_formatter _tuple_node_for_formatter)
public override void visit(tuple_node _tuple_node)
{
sb.Append("(");
visit_node(_tuple_node_for_formatter.el);
visit_node(_tuple_node.el);
}
public override void visit(uses_closure uc)
@ -2849,6 +2849,17 @@ namespace CodeFormatters
if (_slice_expr.step != null)
visit_node(_slice_expr.step);
}
public override void visit(slice_expr_question _slice_expr_question)
{
visit_node(_slice_expr_question.v);
if (_slice_expr_question.from != null)
visit_node(_slice_expr_question.from);
if (_slice_expr_question.to != null)
visit_node(_slice_expr_question.to);
if (_slice_expr_question.step != null)
visit_node(_slice_expr_question.step);
}
#endregion
}
}

View file

@ -1550,11 +1550,14 @@ namespace CodeCompletion
}*/
if (!parse_only_interface)
_procedure_definition.proc_body.visit(this);
ProcRealization pr = (cur_scope as ProcScope).proc_realization;
if (pr == null)
cur_scope.body_loc = get_location(_procedure_definition.proc_body);
else
pr.body_loc = get_location(_procedure_definition.proc_body);
if (cur_scope != null && cur_scope is ProcScope)
{
ProcRealization pr = (cur_scope as ProcScope).proc_realization;
if (pr == null)
cur_scope.body_loc = get_location(_procedure_definition.proc_body);
else
pr.body_loc = get_location(_procedure_definition.proc_body);
}
}
cur_scope = tmp;
}
@ -3662,7 +3665,7 @@ namespace CodeCompletion
}
catch (Exception e)
{
cur_scope = impl_scope;
}
}
}

View file

@ -3018,7 +3018,7 @@ namespace CodeCompletion
public override List<SymScope> FindOverloadNamesOnlyInType(string name)
{
if (!is_dynamic_arr)
if (!is_dynamic_arr && !IsMultiDynArray)
return new List<SymScope>();
List<SymScope> syms = base.FindOverloadNamesOnlyInType(name);
if (implemented_interfaces != null)
@ -3037,7 +3037,7 @@ namespace CodeCompletion
public override SymScope FindName(string name)
{
if (!is_dynamic_arr)
if (!is_dynamic_arr && !IsMultiDynArray)
return null;
SymScope sc = null;
if (baseScope != null && is_dynamic_arr) sc = baseScope.FindNameOnlyInType(name);
@ -3049,7 +3049,7 @@ namespace CodeCompletion
public override List<SymScope> FindOverloadNames(string name)
{
List<SymScope> names = new List<SymScope>();
if (!is_dynamic_arr)
if (!is_dynamic_arr && !IsMultiDynArray)
return names;
if (baseScope != null && is_dynamic_arr) names.AddRange(baseScope.FindOverloadNamesOnlyInType(name));
if (topScope != null)
@ -3059,7 +3059,7 @@ namespace CodeCompletion
public override SymScope FindNameInAnyOrder(string name)
{
if (!is_dynamic_arr)
if (!is_dynamic_arr && !IsMultiDynArray)
return null;
SymScope sc = null;
if (baseScope != null && is_dynamic_arr) sc = baseScope.FindNameOnlyInType(name);
@ -3109,20 +3109,6 @@ namespace CodeCompletion
return this.indexes.Length == arrs.indexes.Length;
}
return true;
/*if (this.indexes == null && arrs.indexes == null) return true;//?????
if (this.indexes != null && arrs.indexes != null)
{
if (this.indexes.Length != arrs.indexes.Length) return false;
for (int i=0; i<this.indexes.Length; i++)
if (this.indexes[i] == null && arrs.indexes[i] == null)
continue;
else if (this.indexes[i] == null && arrs.indexes[i] != null || this.indexes[i] != null && arrs.indexes[i] == null)
return false;
else
if (!this.indexes[i].IsEqual(arrs.indexes[i])) return false;
return true;
}
return false;*/
}
public override bool IsEqual(SymScope ts)

View file

@ -142,10 +142,6 @@
<Project>{613E0DDA-AA8A-437C-AC45-507B47429FF9}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<ProjectReference Include="..\StandardSyntaxTreeConverter\StandardSyntaxTreeConverter.csproj">
<Project>{4d36d4ce-56fd-4bec-b846-d54b3a39ffd5}</Project>
<Name>StandardSyntaxTreeConverter</Name>
</ProjectReference>
<ProjectReference Include="..\SyntaxTreeConverters\SyntaxTreeConverters.csproj">
<Project>{f10a5330-dcf4-4533-877c-7b1b1be23884}</Project>
<Name>SyntaxTreeConverters</Name>

View file

@ -2809,6 +2809,8 @@ namespace PascalABCCompiler.PCU
cnfn.ConnectedToType.original_generic.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.IsDelegate && cnfn.ConnectedToType.base_type.IsDelegate)
compiled_type_node.get_type_node(typeof(Delegate)).Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.typed_file && cnfn.ConnectedToType.element_type.is_generic_parameter && SystemLibrary.SystemLibInitializer.TypedFileType.sym_info != null)
(SystemLibrary.SystemLibInitializer.TypedFileType.sym_info as type_node).Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
return cnfn;
}
@ -2906,6 +2908,10 @@ namespace PascalABCCompiler.PCU
cnfn.ConnectedToType.base_type.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
else if (cnfn.ConnectedToType is compiled_generic_instance_type_node && cnfn.ConnectedToType.original_generic.Scope != null)
cnfn.ConnectedToType.original_generic.Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.IsDelegate && cnfn.ConnectedToType.base_type.IsDelegate)
compiled_type_node.get_type_node(typeof(Delegate)).Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
else if (cnfn.ConnectedToType != null && cnfn.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.typed_file && cnfn.ConnectedToType.element_type.is_generic_parameter && SystemLibrary.SystemLibInitializer.TypedFileType.sym_info != null)
(SystemLibrary.SystemLibInitializer.TypedFileType.sym_info as type_node).Scope.AddSymbol(cnfn.name, new SymbolInfo(cnfn));
br.BaseStream.Seek(pos,SeekOrigin.Begin);
return cnfn;
}

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-8EAQPI9
// DateTime: 21.01.2017 21:29:18
// DateTime: 26.01.2017 15:17:45
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -2945,26 +2945,15 @@ default_expr
tuple
: tkRoundOpen expr_l1 tkComma expr_l1_list lambda_type_ref optional_full_lambda_fp_list tkRoundClose // lambda_type_ref optional_full_lambda_fp_list íóæíî îñòàâèòü ÷òîáû íå áûëî êîíôëèêòîâ ñ ãðàììàòèêîé ëÿìáä
{
/*
($4 as expression_list).expressions.Insert(0,$2);
if (($4 as expression_list).expressions.Count>7)
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@5);
if (parsertools.build_tree_for_formatter)
$$ = new tuple_node_for_formatter($4 as expression_list,@$);
else
{
var dn = new dot_node(new dot_node(new ident("?System"),new ident("Tuple")),new ident("Create",@$));
$$ = new method_call(dn,$4 as expression_list,@$);
}*/
/*if ($5 != null)
parsertools.AddErrorFromResource("BAD_TUPLE",@5);
if ($6 != null)
parsertools.AddErrorFromResource("BAD_TUPLE",@6);*/
if (($4 as expression_list).expressions.Count>7)
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@$);
($4 as expression_list).expressions.Insert(0,$2);
$$ = new tuple_node_for_formatter($4 as expression_list,@$);
$$ = new tuple_node($4 as expression_list,@$);
}
;

View file

@ -2,7 +2,7 @@
// GPPG version 1.3.6
// Machine: DESKTOP-8EAQPI9
// DateTime: 21.01.2017 21:29:18
// DateTime: 26.01.2017 15:17:46
// UserName: ?????????
// Input file <J:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y>
@ -4904,8 +4904,6 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
{
/*
($4 as expression_list).expressions.Insert(0,$2);
if (($4 as expression_list).expressions.Count>7)
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@5);
if (parsertools.build_tree_for_formatter)
$$ = new tuple_node_for_formatter($4 as expression_list,@$);
@ -4920,8 +4918,10 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
if ($6 != null)
parsertools.AddErrorFromResource("BAD_TUPLE",@6);*/
if ((ValueStack[ValueStack.Depth-4].stn as expression_list).expressions.Count>7)
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",CurrentLocationSpan);
(ValueStack[ValueStack.Depth-4].stn as expression_list).expressions.Insert(0,ValueStack[ValueStack.Depth-6].ex);
CurrentSemanticValue.ex = new tuple_node_for_formatter(ValueStack[ValueStack.Depth-4].stn as expression_list,CurrentLocationSpan);
CurrentSemanticValue.ex = new tuple_node(ValueStack[ValueStack.Depth-4].stn as expression_list,CurrentLocationSpan);
}
break;
case 596: // factor -> tkNil

View file

@ -158,5 +158,6 @@ script=

View file

@ -1274,6 +1274,29 @@
</i>
</OCtx>
</Node>
<Node ID="visit" Name="Обработка auto_type в assign_node" NL="0,8925781" NG="-1">
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
<Note>Обработка auto_type в assign_node</Note>
<Text>if (to.type is auto_type)</Text>
<OCtx>
<i Type="Method">public override void visit ( SyntaxTree . assign _assign )</i>
<i Type="ClassOrNamespace">public partial class syntax_tree_visitor : SyntaxTree . WalkingVisitorNew</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
</Node>
<Node ID="visit" Name="visit(SyntaxTree.yield_unknown_expression_type" NL="0,9160156" NG="-1">
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
<Text>public override void visit(SyntaxTree.yield_unknown_expression_type _unk_expr)</Text>
<OCtx>
<i Type="Method">public override void visit ( SyntaxTree . yield_unknown_expression_type _unk_expr )</i>
<i Type="ClassOrNamespace">public partial class syntax_tree_visitor : SyntaxTree . WalkingVisitorNew</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
</Node>
</Items>
</Node>
<Node Name="a.Sort((row1, row2) -&gt; 1)" NL="0" NG="0">
@ -1391,6 +1414,20 @@
</Node>
<Node Name="Ядро преобраз-я синт. деревьев" NL="0" NG="0">
<Items>
<Node ID="StandardSyntaxTreeConverter" Name="StandardSyntaxTreeConverter" NL="-1" NG="0,2734375">
<FileName>\standardsyntaxtreeconverter\standardsyntaxconverter.cs</FileName>
<OCtx>
<i Type="ClassOrNamespace">public class StandardSyntaxTreeConverter : ISyntaxTreeConverter</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . SyntaxTreeConverters</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Method">public string Name</i>
<i Type="Field">=</i>
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
<Node Name="SyntaxTree = Convert(SyntaxTree)" NL="0" NG="0">
<FileName>\Compiler\Compiler.cs</FileName>
<Text>CurrentUnit.SyntaxTree = syntaxTreeConvertersController.Convert(CurrentUnit.SyntaxTree) as SyntaxTree.compilation_unit;</Text>
@ -1449,20 +1486,6 @@
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
<Node ID="StandardSyntaxTreeConverter" Name="StandardSyntaxTreeConverter" NL="-1" NG="0,2734375">
<FileName>\standardsyntaxtreeconverter\standardsyntaxconverter.cs</FileName>
<OCtx>
<i Type="ClassOrNamespace">public class StandardSyntaxTreeConverter : ISyntaxTreeConverter</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . SyntaxTreeConverters</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Method">public string Name</i>
<i Type="Field">=</i>
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
</Items>
</Node>
<Node Name="visit(SyntaxTree.dot_node" NL="0" NG="0">

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualPascalABCNET", "VisualPascalABCNET", "{26843C5D-9D7E-4C2C-AC14-2D227FA5592E}"
EndProject
@ -101,8 +101,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxVisitors", "SyntaxVis
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldConversionSyntax", "Yield\YieldConversionSyntax\YieldConversionSyntax.csproj", "{276EE073-60F6-46D2-8811-1B8026BCAADA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandardSyntaxTreeConverter", "StandardSyntaxTreeConverter\StandardSyntaxTreeConverter.csproj", "{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -455,18 +453,6 @@ Global
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|x86.ActiveCfg = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|x86.Build.0 = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Any CPU.Build.0 = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|x86.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -509,6 +495,5 @@ Global
{CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{276EE073-60F6-46D2-8811-1B8026BCAADA} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5} = {F8CE2712-826B-450B-A72F-D32D80C99858}
EndGlobalSection
EndGlobal

View file

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Управление общими сведениями о сборке осуществляется с помощью
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("StandardSyntaxTreeConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StandardSyntaxTreeConverter")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
// для COM-компонентов. Если требуется обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("4d36d4ce-56fd-4bec-b846-d54b3a39ffd5")]
// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PascalABCCompiler.SyntaxTree;
public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseChangeVisitor
{
public static StandOutExprWithLambdaInForeachSequenceVisitor New
{
get
{
return new StandOutExprWithLambdaInForeachSequenceVisitor();
}
}
private int GenIdNum = 0;
public ident GenIdentName()
{
GenIdNum++;
return new ident("$GenContFE" + GenIdNum.ToString());
}
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> { ass,fe };
ReplaceStatement(fe, l);
}
base.visit(fe);
}
}

View file

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StandardSyntaxTreeConverter</RootNamespace>
<AssemblyName>StandardSyntaxTreeConverter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StandardSyntaxConverter.cs" />
<Compile Include="StandOutExprWithLambdaInForeachSequenceVisitor.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SyntaxTreeConverters\SyntaxTreeConverters.csproj">
<Project>{f10a5330-dcf4-4533-877c-7b1b1be23884}</Project>
<Name>SyntaxTreeConverters</Name>
</ProjectReference>
<ProjectReference Include="..\SyntaxTree\SyntaxTree.csproj">
<Project>{c2cac65a-b2ae-4ccc-b067-e6b8e75df73a}</Project>
<Name>SyntaxTree</Name>
</ProjectReference>
<ProjectReference Include="..\SyntaxVisitors\SyntaxVisitors.csproj">
<Project>{a9ab4282-83b4-41a7-86c3-e5bf6a45e7e2}</Project>
<Name>SyntaxVisitors</Name>
</ProjectReference>
<ProjectReference Include="..\Yield\YieldConversionSyntax\YieldConversionSyntax.csproj">
<Project>{276ee073-60f6-46d2-8811-1b8026bcaada}</Project>
<Name>YieldConversionSyntax</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -1043,9 +1043,9 @@ namespace PascalABCCompiler.SyntaxTree
DefaultVisit(_addressed_value_list);
}
public virtual void visit(tuple_node_for_formatter _tuple_node_for_formatter)
public virtual void visit(tuple_node _tuple_node)
{
DefaultVisit(_tuple_node_for_formatter);
DefaultVisit(_tuple_node);
}
public virtual void visit(uses_closure _uses_closure)

View file

@ -1661,11 +1661,11 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public virtual void pre_do_visit(tuple_node_for_formatter _tuple_node_for_formatter)
public virtual void pre_do_visit(tuple_node _tuple_node)
{
}
public virtual void post_do_visit(tuple_node_for_formatter _tuple_node_for_formatter)
public virtual void post_do_visit(tuple_node _tuple_node)
{
}
@ -3552,12 +3552,12 @@ namespace PascalABCCompiler.SyntaxTree
post_do_visit(_addressed_value_list);
}
public override void visit(tuple_node_for_formatter _tuple_node_for_formatter)
public override void visit(tuple_node _tuple_node)
{
DefaultVisit(_tuple_node_for_formatter);
pre_do_visit(_tuple_node_for_formatter);
visit(tuple_node_for_formatter.el);
post_do_visit(_tuple_node_for_formatter);
DefaultVisit(_tuple_node);
pre_do_visit(_tuple_node);
visit(tuple_node.el);
post_do_visit(_tuple_node);
}
public override void visit(uses_closure _uses_closure)

View file

@ -435,7 +435,7 @@ namespace PascalABCCompiler.SyntaxTree
case 206:
return new addressed_value_list();
case 207:
return new tuple_node_for_formatter();
return new tuple_node();
case 208:
return new uses_closure();
case 209:
@ -3709,15 +3709,15 @@ namespace PascalABCCompiler.SyntaxTree
}
public void visit(tuple_node_for_formatter _tuple_node_for_formatter)
public void visit(tuple_node _tuple_node)
{
read_tuple_node_for_formatter(_tuple_node_for_formatter);
read_tuple_node(_tuple_node);
}
public void read_tuple_node_for_formatter(tuple_node_for_formatter _tuple_node_for_formatter)
public void read_tuple_node(tuple_node _tuple_node)
{
read_expression(_tuple_node_for_formatter);
_tuple_node_for_formatter.el = _read_node() as expression_list;
read_expression(_tuple_node);
_tuple_node.el = _read_node() as expression_list;
}

View file

@ -5779,23 +5779,23 @@ namespace PascalABCCompiler.SyntaxTree
}
public void visit(tuple_node_for_formatter _tuple_node_for_formatter)
public void visit(tuple_node _tuple_node)
{
bw.Write((Int16)207);
write_tuple_node_for_formatter(_tuple_node_for_formatter);
write_tuple_node(_tuple_node);
}
public void write_tuple_node_for_formatter(tuple_node_for_formatter _tuple_node_for_formatter)
public void write_tuple_node(tuple_node _tuple_node)
{
write_expression(_tuple_node_for_formatter);
if (_tuple_node_for_formatter.el == null)
write_expression(_tuple_node);
if (_tuple_node.el == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_tuple_node_for_formatter.el.visit(this);
_tuple_node.el.visit(this);
}
}

View file

@ -36800,13 +36800,13 @@ namespace PascalABCCompiler.SyntaxTree
///
///</summary>
[Serializable]
public partial class tuple_node_for_formatter : expression
public partial class tuple_node : expression
{
///<summary>
///Конструктор без параметров.
///</summary>
public tuple_node_for_formatter()
public tuple_node()
{
}
@ -36814,7 +36814,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Конструктор с параметрами.
///</summary>
public tuple_node_for_formatter(expression_list _el)
public tuple_node(expression_list _el)
{
this._el=_el;
}
@ -36822,7 +36822,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Конструктор с параметрами.
///</summary>
public tuple_node_for_formatter(expression_list _el,SourceContext sc)
public tuple_node(expression_list _el,SourceContext sc)
{
this._el=_el;
source_context = sc;
@ -36848,7 +36848,7 @@ namespace PascalABCCompiler.SyntaxTree
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
tuple_node_for_formatter copy = new tuple_node_for_formatter();
tuple_node copy = new tuple_node();
copy.Parent = this.Parent;
if (source_context != null)
copy.source_context = new SourceContext(source_context);
@ -36866,9 +36866,9 @@ namespace PascalABCCompiler.SyntaxTree
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new tuple_node_for_formatter TypedClone()
public new tuple_node TypedClone()
{
return Clone() as tuple_node_for_formatter;
return Clone() as tuple_node;
}
///<summary>
@ -37854,7 +37854,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Узел для вычисления типа выражения используемого в теле функции-итератора (с yield)
///Узел для вычисления типа выражения используемого в теле функции-итератора (с yield). Используется для описаний всех переменных с автовыводом типов в теле yield: например, для var a := 1; Дело в том, что эти переменные становятся полями класса, а для описания полей класса нужен тип
///</summary>
[Serializable]
public partial class yield_unknown_expression_type : type_definition

View file

@ -1247,11 +1247,11 @@ namespace PascalABCCompiler.SyntaxTree
///<returns> Return value is void </returns>
void visit(addressed_value_list _addressed_value_list);
///<summary>
///Method to visit tuple_node_for_formatter.
///Method to visit tuple_node.
///</summary>
///<param name="_tuple_node_for_formatter">Node to visit</param>
///<param name="_tuple_node">Node to visit</param>
///<returns> Return value is void </returns>
void visit(tuple_node_for_formatter _tuple_node_for_formatter);
void visit(tuple_node _tuple_node);
///<summary>
///Method to visit uses_closure.
///</summary>

Binary file not shown.

View file

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PascalABCCompiler.SyntaxTreeConverters
{
class StandardSyntaxConverters: ISyntaxTreeConverter
{
public string Name { get; } = "Standard";
public syntax_tree_node Convert(syntax_tree_node root)
{
//var v = new SampleVisitor();
//v.ProcessNode(root);
return root;
}
}
}

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PascalABCCompiler.SyntaxTree;
namespace PascalABCCompiler.SyntaxTreeConverters
{
public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseChangeVisitor
{
public static StandOutExprWithLambdaInForeachSequenceVisitor New
{
get
{
return new StandOutExprWithLambdaInForeachSequenceVisitor();
}
}
private int GenIdNum = 0;
public ident GenIdentName()
{
GenIdNum++;
return new ident("$GenContFE" + GenIdNum.ToString());
}
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> { ass, fe };
ReplaceStatement(fe, l);
}
base.visit(fe);
}
}
}

View file

@ -29,15 +29,14 @@ namespace PascalABCCompiler.SyntaxTreeConverters
AssignTuplesDesugarVisitor.New.ProcessNode(root);
// slice_expr и slice_expr_question
SliceQuestionDesugarVisitor.New.ProcessNode(root);
SliceDesugarVisitor.New.ProcessNode(root);
// Всё, связанное с yield
root.visit(new MarkMethodHasYieldAndCheckSomeErrorsVisitor());
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
return root;
}
}

View file

@ -36,6 +36,8 @@
<ItemGroup>
<Compile Include="ISyntaxTreeConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StandardSyntaxConverter.cs" />
<Compile Include="StandOutExprWithLambdaInForeachSequenceVisitor.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Errors\Errors.csproj">
@ -50,6 +52,10 @@
<Project>{c2cac65a-b2ae-4ccc-b067-e6b8e75df73a}</Project>
<Name>SyntaxTree</Name>
</ProjectReference>
<ProjectReference Include="..\SyntaxVisitors\SyntaxVisitors.csproj">
<Project>{a9ab4282-83b4-41a7-86c3-e5bf6a45e7e2}</Project>
<Name>SyntaxVisitors</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -7,11 +7,11 @@ using PascalABCCompiler.SyntaxTree;
namespace SyntaxVisitors.SugarVisitors
{
public class SliceQuestionDesugarVisitor : BaseChangeVisitor
public class SliceDesugarVisitor : BaseChangeVisitor
{
public static SliceQuestionDesugarVisitor New
public static SliceDesugarVisitor New
{
get { return new SliceQuestionDesugarVisitor(); }
get { return new SliceDesugarVisitor(); }
}
expression_list construct_expression_list_for_slice_expr(slice_expr sl)

View file

@ -14,14 +14,14 @@ namespace SyntaxVisitors.SugarVisitors
get { return new TupleVisitor(); }
}
public override void visit(tuple_node_for_formatter tup)
public override void visit(tuple_node tup)
{
var dn = new dot_node(new dot_node(new ident("?System"), new ident("Tuple")), new ident("Create", tup.source_context));
var mc = new method_call(dn, tup.el, tup.source_context);
var sug = new sugared_expression(tup, mc, tup.source_context);
//var sug = new sugared_expression(tup, mc, tup.source_context); - нет никакой семантической проверки - всё - на уровне синтаксиса!
ReplaceUsingParent(tup, sug);
ReplaceUsingParent(tup, mc);
visit(mc);
}

View file

@ -49,7 +49,7 @@
<Compile Include="BaseVisitors\SmallHelperVisitors.cs" />
<Compile Include="ChangeWhileVisitor.cs" />
<Compile Include="SugarVisitors\AssignTuplesDesugarVisitor.cs" />
<Compile Include="SugarVisitors\SliceQuestionDesugarVisitor.cs" />
<Compile Include="SugarVisitors\SliceDesugarVisitor.cs" />
<Compile Include="SugarVisitors\TupleVisitor.cs" />
<Compile Include="YieldVisitors\ObjectCopier\ObjectCopier.cs" />
<Compile Include="Optimization\CalcConstExprs.cs" />

View file

@ -17,6 +17,11 @@ namespace SyntaxVisitors
private Stack<procedure_definition> MethodsStack = new Stack<procedure_definition>();
public static MarkMethodHasYieldAndCheckSomeErrorsVisitor New
{
get { return new MarkMethodHasYieldAndCheckSomeErrorsVisitor(); }
}
public override void visit(function_lambda_definition ld)
{
if (ld.DescendantNodes().OfType<yield_node>().Count() > 0)

View file

@ -8967,6 +8967,7 @@ begin
end;
end;
///--
type
AdjGroupClass<T> = class
private

View file

@ -75,10 +75,10 @@ namespace PascalABCCompiler.TreeConverter
}
}
void semantic_check_tuple(SyntaxTree.tuple_node_for_formatter tup)
/*void semantic_check_tuple(SyntaxTree.tuple_node tup)
{
if (tup.el.expressions.Count > 7)
AddError(get_location(tup),"TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7");
}
//if (tup.el.expressions.Count > 7)
// AddError(get_location(tup),"TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7");
}*/
}
}

View file

@ -12444,6 +12444,8 @@ namespace PascalABCCompiler.TreeConverter
top_function.ConnectedToType.original_generic.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
else if (top_function.ConnectedToType.IsDelegate && top_function.ConnectedToType.base_type.IsDelegate)
compiled_type_node.get_type_node(typeof(Delegate)).Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
else if (top_function.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.typed_file && top_function.ConnectedToType.element_type.is_generic_parameter && SystemLibrary.SystemLibInitializer.TypedFileType.sym_info != null)
(SystemLibrary.SystemLibInitializer.TypedFileType.sym_info as type_node).Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
if (top_function.ConnectedToType.IsDelegate && context.top_function.IsOperator && (context.top_function.name == "+" || context.top_function.name == "-" || context.top_function.name == "+=" || context.top_function.name == "-="))
AddError(get_location(_procedure_attributes_list), "CANNOT_EXTEND_STANDARD_OPERATORS_FOR_DELEGATE");
if (context.top_function.IsOperator && (context.top_function.name == compiler_string_consts.implicit_operator_name || context.top_function.name == compiler_string_consts.explicit_operator_name) && context.top_function.parameters.Count == 1 && context.top_function.return_value_type != null)
@ -19297,6 +19299,15 @@ namespace PascalABCCompiler.TreeConverter
}
}
public override void visit(SyntaxTree.yield_node yn)
{
// надо что то сгенерировать, иначе выдается ложное предупреждение о недостижимом коде и проч.
/*var ass = new assign("Result", new nil_const());
visit(ass);
var pc = new procedure_call("exit");
visit(pc);*/
}
// frninja - захват полей класса для yield
public override void visit(SyntaxTree.yield_unknown_ident _unk)
{
@ -19318,15 +19329,6 @@ namespace PascalABCCompiler.TreeConverter
t.visit(this);
}
public override void visit(SyntaxTree.yield_node yn)
{
// надо что то сгенерировать, иначе выдается ложное предупреждение о недостижимом коде и проч.
var ass = new assign("Result", new nil_const());
visit(ass);
var pc = new procedure_call("exit");
visit(pc);
}
/*public SyntaxTree.question_colon_expression ConvertToQCE(dot_question_node dqn)
{
// Неверно работает. Пока не используется. Доделать
@ -19359,13 +19361,13 @@ namespace PascalABCCompiler.TreeConverter
public override void visit(SyntaxTree.sugared_expression ex)
{
if (ex.sugared_expr is SyntaxTree.tuple_node_for_formatter)
/*if (ex.sugared_expr is SyntaxTree.tuple_node)
{
semantic_check_tuple(ex.sugared_expr as SyntaxTree.tuple_node_for_formatter);
semantic_check_tuple(ex.sugared_expr as SyntaxTree.tuple_node);
}
else
else*/
{
AddError(get_location(ex), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", ex.GetType().Name);
AddError(get_location(ex), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", ex.sugared_expr.GetType().Name);
}
ProcessNode(ex.new_expr); // обойти десахарное выражение - обязательно ProcessNode - visit нельзя!
@ -19379,7 +19381,7 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
AddError(get_location(av), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", av.GetType().Name);
AddError(get_location(av), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", av.sugared_expr.GetType().Name);
}
ProcessNode(av.new_addr_value); // обойти десахарное

Binary file not shown.

View file

@ -8967,6 +8967,7 @@ begin
end;
end;
///--
type
AdjGroupClass<T> = class
private