Compare commits
21 commits
master
...
async-awai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a3239a7d1 | ||
|
|
a193b9c3ed | ||
|
|
3e3319000b | ||
|
|
418a64a2c1 | ||
|
|
0c997a59db | ||
|
|
6b1b7d6792 | ||
|
|
ba4d274058 | ||
|
|
53e850ba45 | ||
|
|
729881a836 | ||
|
|
43c728883f | ||
|
|
46e98e8c71 | ||
|
|
e466c4b07b | ||
|
|
ced4424196 | ||
|
|
4100032f2b | ||
|
|
015bd7a78c | ||
|
|
e19b4ec4fa | ||
|
|
57157f5138 | ||
|
|
6de1848ec9 | ||
|
|
9fb7fba1e1 | ||
|
|
7287a68805 | ||
|
|
155d0a01ba |
20
.github/workflows/buildandruntests.yml
vendored
20
.github/workflows/buildandruntests.yml
vendored
|
|
@ -19,11 +19,10 @@ defaults:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
name: Prepare and build on Windows Server 2016 VM
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies into Virtual Environment...
|
||||
run: _RegisterHelixNUnit.bat
|
||||
|
|
@ -42,3 +41,20 @@ jobs:
|
|||
# with:
|
||||
# name: All_distros
|
||||
# path: Release
|
||||
|
||||
build-PABCNETCclear-separate:
|
||||
name: Build PABCNETCclear project without invoking full rebuild
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build and run PABCNETCclear project
|
||||
shell: pwsh
|
||||
run: |
|
||||
|
||||
$project = 'PABCNETCclear'
|
||||
.\Studio.bat "pabcnetc_clear\$project.csproj"
|
||||
|
||||
'##' | Set-Content 'a.pas'
|
||||
&".\bin\$project.exe" .\a.pas
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -49,7 +49,7 @@
|
|||
**/StringConstants.dll
|
||||
**/ParserTools.dll
|
||||
**/PascalABCParser.dll
|
||||
**/PascalLanguage.dll
|
||||
**/PascalABCLanguageInfo.dll
|
||||
**/PluginsSupport.dll
|
||||
**/PluginsSupportLinux.dll
|
||||
**/Properties.Resources.Designer.cs.dll
|
||||
|
|
|
|||
|
|
@ -2903,9 +2903,9 @@ namespace PascalABCCompiler
|
|||
try
|
||||
{
|
||||
var FullFileName = Path.Combine(curr_path, FileName);
|
||||
if (System.IO.File.Exists(FullFileName))
|
||||
if (File.Exists(FullFileName))
|
||||
{
|
||||
var NewFileName = Path.Combine(CompilerOptions.OutputDirectory, Path.GetFileName(FullFileName));
|
||||
var NewFileName = Path.GetFullPath(Path.Combine(CompilerOptions.OutputDirectory, Path.GetFileName(FullFileName)));
|
||||
if (FullFileName != NewFileName)
|
||||
{
|
||||
if (overwrite)
|
||||
|
|
|
|||
|
|
@ -1335,7 +1335,7 @@ namespace PascalABCCompiler.PCU
|
|||
loc = ReadDebugInfo();
|
||||
type_node elem_type = GetTypeReference();
|
||||
int rank = br.ReadInt32();
|
||||
return type_constructor.instance.create_unsized_array(elem_type, null, rank, loc);
|
||||
return type_constructor.instance.create_unsized_array(elem_type, rank, loc);
|
||||
case 6:
|
||||
return GetTemplateInstance();
|
||||
case 7:
|
||||
|
|
@ -1847,7 +1847,10 @@ namespace PascalABCCompiler.PCU
|
|||
common_method_node raise_meth = null;
|
||||
if (CanReadObject())
|
||||
raise_meth = GetClassMethod(br.ReadInt32());
|
||||
class_field cf = GetClassField(br.ReadInt32());
|
||||
int field_off = br.ReadInt32();
|
||||
class_field cf = null;
|
||||
if (field_off > 0)
|
||||
cf = GetClassField(field_off);
|
||||
common_type_node cont = (common_type_node)GetTypeReference(br.ReadInt32());
|
||||
if (name==null)
|
||||
name = GetStringInClass(cont, name_ref);
|
||||
|
|
|
|||
|
|
@ -3021,7 +3021,10 @@ namespace PascalABCCompiler.PCU
|
|||
bw.Write(GetMemberOffset(_event.remove_method));
|
||||
if (CanWriteObject(_event.raise_method))
|
||||
bw.Write(GetMemberOffset(_event.raise_method));
|
||||
bw.Write(GetMemberOffset(_event.field));
|
||||
if (!_event.cont_type.IsInterface)
|
||||
bw.Write(GetMemberOffset(_event.field));
|
||||
else
|
||||
bw.Write(0);
|
||||
bw.Write(offset);
|
||||
bw.Write((byte)_event.field_access_level);
|
||||
bw.Write((byte)_event.polymorphic_state);
|
||||
|
|
|
|||
|
|
@ -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 = "3488";
|
||||
public const string Revision = "3500";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=3488
|
||||
%REVISION%=3500
|
||||
%MINOR%=9
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace Languages.Integration
|
|||
|
||||
DirectoryInfo directory = new DirectoryInfo(directoryName);
|
||||
|
||||
FileInfo[] dllFiles = directory.GetFiles("*Language.dll");
|
||||
FileInfo[] dllFiles = directory.GetFiles("*LanguageInfo.dll");
|
||||
|
||||
foreach (FileInfo languageFile in dllFiles)
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 15.06.2024 19:27:08
|
||||
// DateTime: 06.07.2024 22:37:02
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// GPPG version 1.3.6
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 15.06.2024 19:27:09
|
||||
// DateTime: 06.07.2024 22:37:03
|
||||
// UserName: ?????????
|
||||
// Input file <ABCPascal.y>
|
||||
|
||||
|
|
@ -380,6 +380,5 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{1443F539-DCC7-4491-B4FD-B716C739DB3C}</ProjectGuid>
|
||||
<ProjectGuid>{0ED020FF-D28E-4791-BBDD-B8B9BA714096}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Languages.Pascal.Frontend</RootNamespace>
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\bin\</OutputPath>
|
||||
<OutputPath>..\..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\..\bin\</OutputPath>
|
||||
<OutputPath>..\..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
@ -111,31 +111,31 @@
|
|||
<Compile Include="StringResources.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Errors\Errors.csproj">
|
||||
<ProjectReference Include="..\..\Errors\Errors.csproj">
|
||||
<Project>{44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}</Project>
|
||||
<Name>Errors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<ProjectReference Include="..\..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Localization\Localization.csproj">
|
||||
<ProjectReference Include="..\..\Localization\Localization.csproj">
|
||||
<Project>{2DE2842F-0912-4251-BC0F-480854C44A13}</Project>
|
||||
<Name>Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\ParserTools\ParserTools.csproj">
|
||||
<ProjectReference Include="..\..\ParserTools\ParserTools.csproj">
|
||||
<Project>{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\StringConstants\StringConstants.csproj">
|
||||
<ProjectReference Include="..\..\StringConstants\StringConstants.csproj">
|
||||
<Project>{e8aefbf9-0113-4fa4-be45-6cda555498b7}</Project>
|
||||
<Name>StringConstants</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\SyntaxTree\SyntaxTree.csproj">
|
||||
<ProjectReference Include="..\..\SyntaxTree\SyntaxTree.csproj">
|
||||
<Project>{C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}</Project>
|
||||
<Name>SyntaxTree</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\SyntaxVisitors\SyntaxVisitors.csproj">
|
||||
<ProjectReference Include="..\..\SyntaxVisitors\SyntaxVisitors.csproj">
|
||||
<Project>{a9ab4282-83b4-41a7-86c3-e5bf6a45e7e2}</Project>
|
||||
<Name>SyntaxVisitors</Name>
|
||||
</ProjectReference>
|
||||
|
|
@ -10,10 +10,10 @@ using PascalABCCompiler.TreeConverter;
|
|||
|
||||
namespace Languages.Pascal
|
||||
{
|
||||
public class PascalLanguage : BaseLanguage
|
||||
public class PascalABCLanguage : BaseLanguage
|
||||
{
|
||||
|
||||
public PascalLanguage() : base(
|
||||
public PascalABCLanguage() : base(
|
||||
name: StringConstants.pascalLanguageName,
|
||||
version: "1.2",
|
||||
copyright: "Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich",
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Languages.Pascal</RootNamespace>
|
||||
<AssemblyName>PascalLanguage</AssemblyName>
|
||||
<AssemblyName>PascalABCLanguageInfo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
@ -40,46 +40,46 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PascalLanguage.cs" />
|
||||
<Compile Include="PascalABCLanguage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\LambdaAnySynToSemConverter\LambdaAnySynToSemConverter.csproj">
|
||||
<ProjectReference Include="..\LambdaAnySynToSemConverter\LambdaAnySynToSemConverter.csproj">
|
||||
<Project>{27d9800e-2689-4aa1-a2d6-128e4a9bae98}</Project>
|
||||
<Name>LambdaAnySynToSemConverter</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<ProjectReference Include="..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\ParserTools\ParserTools.csproj">
|
||||
<ProjectReference Include="..\Parsers\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj">
|
||||
<Project>{0ed020ff-d28e-4791-bbdd-b8b9ba714096}</Project>
|
||||
<Name>PascalABCSaushkinParser</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ParserTools\ParserTools.csproj">
|
||||
<Project>{af2efd7b-69dd-4b43-af65-b59b29349c23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\StringConstants\StringConstants.csproj">
|
||||
<ProjectReference Include="..\StringConstants\StringConstants.csproj">
|
||||
<Project>{e8aefbf9-0113-4fa4-be45-6cda555498b7}</Project>
|
||||
<Name>StringConstants</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\SyntaxTree\SyntaxTree.csproj">
|
||||
<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">
|
||||
<ProjectReference Include="..\SyntaxVisitors\SyntaxVisitors.csproj">
|
||||
<Project>{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}</Project>
|
||||
<Name>SyntaxVisitors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\TreeConverter\TreeConverter.csproj">
|
||||
<ProjectReference Include="..\TreeConverter\TreeConverter.csproj">
|
||||
<Project>{1c9c945a-586d-42a2-a06b-65d84fa7ff78}</Project>
|
||||
<Name>TreeConverter</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj">
|
||||
<Project>{1443f539-dcc7-4491-b4fd-b716c739db3c}</Project>
|
||||
<Name>PascalABCSaushkinParser</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SyntaxTreeConverters\SyntaxTreeConverters\SyntaxTreeConverters.csproj">
|
||||
<Project>{f10a5330-dcf4-4533-877c-7b1b1be23884}</Project>
|
||||
<Name>SyntaxTreeConverters</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -61,7 +61,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Optimizer", "Optimizer\Opti
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCompletion", "CodeCompletion\CodeCompletion.csproj", "{1AB15F6E-C22E-499A-A7ED-54BA7DE5CFA6}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Languages", "Languages", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguagePlugins", "LanguagePlugins", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Trees", "Trees", "{94EED2FF-0641-4562-8167-CBC280A733AF}"
|
||||
EndProject
|
||||
|
|
@ -103,21 +103,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanguageIntegrator", "Langu
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringConstants", "StringConstants\StringConstants.csproj", "{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pascal", "Pascal", "{17A1159B-4039-451E-BBEF-F4643A39F1E6}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{0CD99885-0BBF-431E-A83C-21CFFB506FF0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Languages\Pascal\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{1443F539-DCC7-4491-B4FD-B716C739DB3C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNETParser", "Languages\VisualBasic\VBNETParser\VBNETParser.csproj", "{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalLanguage", "Languages\Pascal\PascalLanguage\PascalLanguage.csproj", "{BD902586-E0D5-407A-904A-32249B8B709E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SyntaxTreeConverters", "SyntaxTreeConverters", "{BE2CCDAD-74BE-401F-A92A-81CEF4725E96}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LambdaAnySynToSemConverter", "LambdaAnySynToSemConverter\LambdaAnySynToSemConverter.csproj", "{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTreeConverters", "Languages\Pascal\SyntaxTreeConverters\SyntaxTreeConverters\SyntaxTreeConverters.csproj", "{F10A5330-DCF4-4533-877C-7B1B1BE23884}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Parsers", "Parsers", "{E952792F-B9F0-450C-B0D8-3128DF95EF19}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Parsers\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{0ED020FF-D28E-4791-BBDD-B8B9BA714096}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCLanguageInfo", "PascalABCLanguageInfo\PascalABCLanguageInfo.csproj", "{BD902586-E0D5-407A-904A-32249B8B709E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTreeConverters", "SyntaxTreeConverters\SyntaxTreeConverters.csproj", "{F10A5330-DCF4-4533-877C-7B1B1BE23884}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -493,40 +487,6 @@ Global
|
|||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -539,6 +499,30 @@ Global
|
|||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|x86.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -594,14 +578,11 @@ Global
|
|||
{536CC813-7C4E-42BC-AE3A-BA1427F38756} = {EC68A3D8-6D63-4A79-ABA6-BF8E9D7756D7}
|
||||
{A48D9069-D569-4110-9252-A10F139B669B} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{17A1159B-4039-451E-BBEF-F4643A39F1E6} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F}
|
||||
{0CD99885-0BBF-431E-A83C-21CFFB506FF0} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F}
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C} = {17A1159B-4039-451E-BBEF-F4643A39F1E6}
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE} = {0CD99885-0BBF-431E-A83C-21CFFB506FF0}
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E} = {17A1159B-4039-451E-BBEF-F4643A39F1E6}
|
||||
{BE2CCDAD-74BE-401F-A92A-81CEF4725E96} = {17A1159B-4039-451E-BBEF-F4643A39F1E6}
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884} = {BE2CCDAD-74BE-401F-A92A-81CEF4725E96}
|
||||
{E952792F-B9F0-450C-B0D8-3128DF95EF19} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096} = {E952792F-B9F0-450C-B0D8-3128DF95EF19}
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {68E993E6-EE86-4DDF-B0A1-4FE884F8AC39}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Optimizer", "Optimizer\Opti
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCompletion", "CodeCompletion\CodeCompletion.csproj", "{1AB15F6E-C22E-499A-A7ED-54BA7DE5CFA6}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Languages", "Languages", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguagePlugins", "LanguagePlugins", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Trees", "Trees", "{94EED2FF-0641-4562-8167-CBC280A733AF}"
|
||||
EndProject
|
||||
|
|
@ -95,22 +95,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanguageIntegrator", "Langu
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringConstants", "StringConstants\StringConstants.csproj", "{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pascal", "Pascal", "{2C15CC70-9793-4E37-B2B9-6EF0E10ED954}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Languages\Pascal\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{1443F539-DCC7-4491-B4FD-B716C739DB3C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{9169D94E-A787-4919-B42E-E56302253F7B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNETParser", "Languages\VisualBasic\VBNETParser\VBNETParser.csproj", "{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalLanguage", "Languages\Pascal\PascalLanguage\PascalLanguage.csproj", "{BD902586-E0D5-407A-904A-32249B8B709E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SyntaxTreeConverters", "SyntaxTreeConverters", "{7B2FFEB8-783B-4280-BB5F-3F069DCEF554}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTreeConverters", "Languages\Pascal\SyntaxTreeConverters\SyntaxTreeConverters\SyntaxTreeConverters.csproj", "{F10A5330-DCF4-4533-877C-7B1B1BE23884}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LambdaAnySynToSemConverter", "LambdaAnySynToSemConverter\LambdaAnySynToSemConverter.csproj", "{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTreeConverters", "SyntaxTreeConverters\SyntaxTreeConverters.csproj", "{F10A5330-DCF4-4533-877C-7B1B1BE23884}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Parsers", "Parsers", "{A7AA76D0-7E64-4080-B311-822DD0BCEB6F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Parsers\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{0ED020FF-D28E-4791-BBDD-B8B9BA714096}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCLanguageInfo", "PascalABCLanguageInfo\PascalABCLanguageInfo.csproj", "{BD902586-E0D5-407A-904A-32249B8B709E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -437,52 +431,6 @@ Global
|
|||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -495,6 +443,42 @@ Global
|
|||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096}.Release|x86.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -534,14 +518,11 @@ Global
|
|||
{3AA92A45-7142-4C59-B12F-56DAE32A40E3} = {EC68A3D8-6D63-4A79-ABA6-BF8E9D7756D7}
|
||||
{A48D9069-D569-4110-9252-A10F139B669B} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{E8AEFBF9-0113-4FA4-BE45-6CDA555498B7} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{2C15CC70-9793-4E37-B2B9-6EF0E10ED954} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F}
|
||||
{1443F539-DCC7-4491-B4FD-B716C739DB3C} = {2C15CC70-9793-4E37-B2B9-6EF0E10ED954}
|
||||
{9169D94E-A787-4919-B42E-E56302253F7B} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F}
|
||||
{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE} = {9169D94E-A787-4919-B42E-E56302253F7B}
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E} = {2C15CC70-9793-4E37-B2B9-6EF0E10ED954}
|
||||
{7B2FFEB8-783B-4280-BB5F-3F069DCEF554} = {2C15CC70-9793-4E37-B2B9-6EF0E10ED954}
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884} = {7B2FFEB8-783B-4280-BB5F-3F069DCEF554}
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{F10A5330-DCF4-4533-877C-7B1B1BE23884} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{A7AA76D0-7E64-4080-B311-822DD0BCEB6F} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
{0ED020FF-D28E-4791-BBDD-B8B9BA714096} = {A7AA76D0-7E64-4080-B311-822DD0BCEB6F}
|
||||
{BD902586-E0D5-407A-904A-32249B8B709E} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {97A10B06-9161-4E2B-9C6F-10EEF45013EC}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.9.0.3488
|
||||
3.9.0.3500
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
cd ..\bin
|
||||
del ..\Release\PACNETConsole.zip
|
||||
..\utils\pkzipc\pkzipc.exe -add ..\Release\PABCNETC.zip pabcnetc.exe pabcnetcclear.exe Compiler.dll CompilerTools.dll Errors.dll Localization.dll NETGenerator.dll ParserTools.dll ICSharpCode.NRefactory.dll SemanticTree.dll SyntaxTree.dll TreeConverter.dll OptimizerConversion.dll PascalABCParser.dll PascalLanguage.dll licence.txt PascalABCNET.chm System.Threading.dll SyntaxTreeConverters.dll YieldHelpers.dll SyntaxVisitors.dll LambdaAnySynToSemConverter.dll LanguageIntegrator.dll StringConstants.dll
|
||||
..\utils\pkzipc\pkzipc.exe -add ..\Release\PABCNETC.zip pabcnetc.exe pabcnetcclear.exe Compiler.dll CompilerTools.dll Errors.dll Localization.dll NETGenerator.dll ParserTools.dll ICSharpCode.NRefactory.dll SemanticTree.dll SyntaxTree.dll TreeConverter.dll OptimizerConversion.dll PascalABCParser.dll PascalABCLanguageInfo.dll licence.txt PascalABCNET.chm System.Threading.dll SyntaxTreeConverters.dll YieldHelpers.dll SyntaxVisitors.dll LambdaAnySynToSemConverter.dll LanguageIntegrator.dll StringConstants.dll
|
||||
..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PABCNETC.zip Lib\*.pcu
|
||||
..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PABCNETC.zip Lng\*.dat
|
||||
..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PABCNETC.zip Lng\*.LanguageName
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
cd ..\bin
|
||||
del ..\Release\PascalABCNETMono.zip
|
||||
..\utils\pkzipc\pkzipc.exe -add ..\Release\PascalABCNETMono.zip PascalABCNETMono.exe pabcnetc.exe pabcnetc PascalABCNET Compiler.dll CompilerTools.dll Errors.dll Localization.dll NETGenerator.dll ParserTools.dll SyntaxTreeConverters.dll ICSharpCode.NRefactory.dll SemanticTree.dll SyntaxTree.dll TreeConverter.dll OptimizerConversion.dll PascalABCParser.dll PascalLanguage.dll licence.txt PascalABCNET.chm System.Threading.dll PluginsSupport.dll InternalErrorReport.dll ICSharpCode.TextEditor.dll ICSharpCode.SharpZipLib.dll CodeCompletion.dll Debugger.Core.dll Mono.Debugger.Soft.dll Mono.Debugging.dll Mono.Debugging.Soft.dll NETXP.Controls.dll NETXP.Controls.Bars.dll NETXP.Library.dll NETXP.Win32.dll WeifenLuo.WinFormsUI.Docking.dll template.pct YieldHelpers.dll LanguageIntegrator.dll StringConstants.dll
|
||||
..\utils\pkzipc\pkzipc.exe -add ..\Release\PascalABCNETMono.zip PascalABCNETMono.exe pabcnetc.exe pabcnetc PascalABCNET Compiler.dll CompilerTools.dll Errors.dll Localization.dll NETGenerator.dll ParserTools.dll SyntaxTreeConverters.dll ICSharpCode.NRefactory.dll SemanticTree.dll SyntaxTree.dll TreeConverter.dll OptimizerConversion.dll PascalABCParser.dll PascalABCLanguageInfo.dll licence.txt PascalABCNET.chm System.Threading.dll PluginsSupport.dll InternalErrorReport.dll ICSharpCode.TextEditor.dll ICSharpCode.SharpZipLib.dll CodeCompletion.dll Debugger.Core.dll Mono.Debugger.Soft.dll Mono.Debugging.dll Mono.Debugging.Soft.dll NETXP.Controls.dll NETXP.Controls.Bars.dll NETXP.Library.dll NETXP.Win32.dll WeifenLuo.WinFormsUI.Docking.dll template.pct YieldHelpers.dll LanguageIntegrator.dll StringConstants.dll
|
||||
..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PascalABCNETMono.zip Lib\*.pcu
|
||||
..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PascalABCNETMono.zip Highlighting\*.xshd
|
||||
..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PascalABCNETMono.zip Ico\*.ico
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.9.0.3488'
|
||||
!define VERSION '3.9.0.3500'
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
SectionIn 1 2 RO
|
||||
SetOutPath "$INSTDIR"
|
||||
File "..\bin\PascalABCParser.dll"
|
||||
File "..\bin\PascalLanguage.dll"
|
||||
File "..\bin\PascalABCLanguageInfo.dll"
|
||||
${AddFile} "PascalABCParser.dll"
|
||||
${AddFile} "PascalLanguage.dll"
|
||||
${AddFile} "PascalABCLanguageInfo.dll"
|
||||
; File "..\bin\PascalABCPartParser.dll"
|
||||
SetOutPath "$INSTDIR\Highlighting"
|
||||
File "..\bin\Highlighting\PascalABCNET.xshd"
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
Call NGEN
|
||||
; Push "PascalABCPartParser.dll"
|
||||
; Call NGEN
|
||||
Push "PascalLanguage.dll"
|
||||
Push "PascalABCLanguageInfo.dll"
|
||||
Call NGEN
|
||||
SetOutPath "$INSTDIR\Ico"
|
||||
File "..\bin\Ico\pas.ico"
|
||||
|
|
|
|||
|
|
@ -1317,6 +1317,16 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
DefaultVisit(_let_var_expr);
|
||||
}
|
||||
|
||||
public virtual void visit(await_node _await_node)
|
||||
{
|
||||
DefaultVisit(_await_node);
|
||||
}
|
||||
|
||||
public virtual void visit(await_node_statement _await_node_statement)
|
||||
{
|
||||
DefaultVisit(_await_node_statement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2101,6 +2101,22 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void pre_do_visit(await_node _await_node)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void post_do_visit(await_node _await_node)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void pre_do_visit(await_node_statement _await_node_statement)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void post_do_visit(await_node_statement _await_node_statement)
|
||||
{
|
||||
}
|
||||
|
||||
public override void visit(expression _expression)
|
||||
{
|
||||
DefaultVisit(_expression);
|
||||
|
|
@ -4342,6 +4358,22 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
visit(let_var_expr.ex);
|
||||
post_do_visit(_let_var_expr);
|
||||
}
|
||||
|
||||
public override void visit(await_node _await_node)
|
||||
{
|
||||
DefaultVisit(_await_node);
|
||||
pre_do_visit(_await_node);
|
||||
visit(await_node.ex);
|
||||
post_do_visit(_await_node);
|
||||
}
|
||||
|
||||
public override void visit(await_node_statement _await_node_statement)
|
||||
{
|
||||
DefaultVisit(_await_node_statement);
|
||||
pre_do_visit(_await_node_statement);
|
||||
visit(await_node_statement.aw);
|
||||
post_do_visit(_await_node_statement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -544,6 +544,10 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
return new ref_var_def_statement();
|
||||
case 261:
|
||||
return new let_var_expr();
|
||||
case 262:
|
||||
return new await_node();
|
||||
case 263:
|
||||
return new await_node_statement();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -4569,6 +4573,30 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
_let_var_expr.ex = _read_node() as expression;
|
||||
}
|
||||
|
||||
|
||||
public void visit(await_node _await_node)
|
||||
{
|
||||
read_await_node(_await_node);
|
||||
}
|
||||
|
||||
public void read_await_node(await_node _await_node)
|
||||
{
|
||||
read_expression(_await_node);
|
||||
_await_node.ex = _read_node() as expression;
|
||||
}
|
||||
|
||||
|
||||
public void visit(await_node_statement _await_node_statement)
|
||||
{
|
||||
read_await_node_statement(_await_node_statement);
|
||||
}
|
||||
|
||||
public void read_await_node_statement(await_node_statement _await_node_statement)
|
||||
{
|
||||
read_statement(_await_node_statement);
|
||||
_await_node_statement.aw = _read_node() as await_node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7181,6 +7181,48 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void visit(await_node _await_node)
|
||||
{
|
||||
bw.Write((Int16)262);
|
||||
write_await_node(_await_node);
|
||||
}
|
||||
|
||||
public void write_await_node(await_node _await_node)
|
||||
{
|
||||
write_expression(_await_node);
|
||||
if (_await_node.ex == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_await_node.ex.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void visit(await_node_statement _await_node_statement)
|
||||
{
|
||||
bw.Write((Int16)263);
|
||||
write_await_node_statement(_await_node_statement);
|
||||
}
|
||||
|
||||
public void write_await_node_statement(await_node_statement _await_node_statement)
|
||||
{
|
||||
write_statement(_await_node_statement);
|
||||
if (_await_node_statement.aw == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_await_node_statement.aw.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55897,6 +55897,320 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class await_node : expression
|
||||
{
|
||||
|
||||
///<summary>
|
||||
///Конструктор без параметров.
|
||||
///</summary>
|
||||
public await_node()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public await_node(expression _ex)
|
||||
{
|
||||
this._ex=_ex;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public await_node(expression _ex,SourceContext sc)
|
||||
{
|
||||
this._ex=_ex;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
protected expression _ex;
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public expression ex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ex;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ex=value;
|
||||
if (_ex != null)
|
||||
_ex.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
{
|
||||
await_node copy = new await_node();
|
||||
copy.Parent = this.Parent;
|
||||
if (source_context != null)
|
||||
copy.source_context = new SourceContext(source_context);
|
||||
if (attributes != null)
|
||||
{
|
||||
copy.attributes = (attribute_list)attributes.Clone();
|
||||
copy.attributes.Parent = copy;
|
||||
}
|
||||
if (ex != null)
|
||||
{
|
||||
copy.ex = (expression)ex.Clone();
|
||||
copy.ex.Parent = copy;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary> Получает копию данного узла корректного типа </summary>
|
||||
public new await_node TypedClone()
|
||||
{
|
||||
return Clone() as await_node;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
|
||||
public override void FillParentsInDirectChilds()
|
||||
{
|
||||
if (attributes != null)
|
||||
attributes.Parent = this;
|
||||
if (ex != null)
|
||||
ex.Parent = this;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||
public override void FillParentsInAllChilds()
|
||||
{
|
||||
FillParentsInDirectChilds();
|
||||
attributes?.FillParentsInAllChilds();
|
||||
ex?.FillParentsInAllChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов без элементов поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_without_list_elements_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Индексатор для получения всех подузлов
|
||||
///</summary>
|
||||
public override syntax_tree_node this[Int32 ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
return ex;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
ex = (expression)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Метод для обхода дерева посетителем
|
||||
///</summary>
|
||||
///<param name="visitor">Объект-посетитель.</param>
|
||||
///<returns>Return value is void</returns>
|
||||
public override void visit(IVisitor visitor)
|
||||
{
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class await_node_statement : statement
|
||||
{
|
||||
|
||||
///<summary>
|
||||
///Конструктор без параметров.
|
||||
///</summary>
|
||||
public await_node_statement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public await_node_statement(await_node _aw)
|
||||
{
|
||||
this._aw=_aw;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public await_node_statement(await_node _aw,SourceContext sc)
|
||||
{
|
||||
this._aw=_aw;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
protected await_node _aw;
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public await_node aw
|
||||
{
|
||||
get
|
||||
{
|
||||
return _aw;
|
||||
}
|
||||
set
|
||||
{
|
||||
_aw=value;
|
||||
if (_aw != null)
|
||||
_aw.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
{
|
||||
await_node_statement copy = new await_node_statement();
|
||||
copy.Parent = this.Parent;
|
||||
if (source_context != null)
|
||||
copy.source_context = new SourceContext(source_context);
|
||||
if (attributes != null)
|
||||
{
|
||||
copy.attributes = (attribute_list)attributes.Clone();
|
||||
copy.attributes.Parent = copy;
|
||||
}
|
||||
if (aw != null)
|
||||
{
|
||||
copy.aw = (await_node)aw.Clone();
|
||||
copy.aw.Parent = copy;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary> Получает копию данного узла корректного типа </summary>
|
||||
public new await_node_statement TypedClone()
|
||||
{
|
||||
return Clone() as await_node_statement;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
|
||||
public override void FillParentsInDirectChilds()
|
||||
{
|
||||
if (attributes != null)
|
||||
attributes.Parent = this;
|
||||
if (aw != null)
|
||||
aw.Parent = this;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||
public override void FillParentsInAllChilds()
|
||||
{
|
||||
FillParentsInDirectChilds();
|
||||
attributes?.FillParentsInAllChilds();
|
||||
aw?.FillParentsInAllChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов без элементов поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_without_list_elements_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Индексатор для получения всех подузлов
|
||||
///</summary>
|
||||
public override syntax_tree_node this[Int32 ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
return aw;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
aw = (await_node)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Метод для обхода дерева посетителем
|
||||
///</summary>
|
||||
///<param name="visitor">Объект-посетитель.</param>
|
||||
///<returns>Return value is void</returns>
|
||||
public override void visit(IVisitor visitor)
|
||||
{
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1576,6 +1576,18 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<param name="_let_var_expr">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(let_var_expr _let_var_expr);
|
||||
///<summary>
|
||||
///Method to visit await_node.
|
||||
///</summary>
|
||||
///<param name="_await_node">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(await_node _await_node);
|
||||
///<summary>
|
||||
///Method to visit await_node_statement.
|
||||
///</summary>
|
||||
///<param name="_await_node_statement">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(await_node_statement _await_node_statement);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3368,6 +3368,26 @@
|
|||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
<SyntaxNode Name="await_node" BaseName="expression">
|
||||
<Fields>
|
||||
<SyntaxField Name="ex" SyntaxType="expression" />
|
||||
</Fields>
|
||||
<Methods />
|
||||
<Tags>
|
||||
<CategoryIndices />
|
||||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
<SyntaxNode Name="await_node_statement" BaseName="statement">
|
||||
<Fields>
|
||||
<SyntaxField Name="aw" SyntaxType="await_node" />
|
||||
</Fields>
|
||||
<Methods />
|
||||
<Tags>
|
||||
<CategoryIndices />
|
||||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
</SyntaxNodes>
|
||||
<Settings>
|
||||
<FileName>Tree.cs</FileName>
|
||||
|
|
@ -3414,6 +3434,7 @@
|
|||
<HelpData Key=".aloneparam" Value="" />
|
||||
<HelpData Key=".attr" Value="" />
|
||||
<HelpData Key=".attributes" Value="" />
|
||||
<HelpData Key=".aw" Value="" />
|
||||
<HelpData Key=".body" Value="" />
|
||||
<HelpData Key=".cconst" Value="Значение константы." />
|
||||
<HelpData Key=".char_num" Value="Номер символа." />
|
||||
|
|
@ -3572,6 +3593,10 @@
|
|||
<HelpData Key="attribute_list.attributes" Value="" />
|
||||
<HelpData Key="attribute_list.void Add(simple_attribute_list sal, SourceContext sc)" Value="" />
|
||||
<HelpData Key="attribute_list.w" Value="" />
|
||||
<HelpData Key="await_node" Value="" />
|
||||
<HelpData Key="await_node.ex" Value="" />
|
||||
<HelpData Key="await_node_statement" Value="" />
|
||||
<HelpData Key="await_node_statement.aw" Value="" />
|
||||
<HelpData Key="bigint_const" Value="" />
|
||||
<HelpData Key="bigint_const.val" Value="" />
|
||||
<HelpData Key="bin_expr" Value="Бинарное выражение" />
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ namespace Languages.Pascal.Frontend.Converters
|
|||
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
|
||||
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
|
||||
|
||||
AsyncVisitor.New.ProcessNode(root);
|
||||
|
||||
CacheFunctionVisitor.New.ProcessNode(root);
|
||||
|
||||
// При наличии файла lightpt.dat подключает модули LightPT и Tasks
|
||||
|
|
@ -99,7 +101,7 @@ namespace Languages.Pascal.Frontend.Converters
|
|||
{
|
||||
root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.txt"));
|
||||
}
|
||||
catch(Exception e)
|
||||
catch(System.Exception e)
|
||||
{
|
||||
|
||||
System.IO.File.AppendAllText(@"d:\\zzz1.txt",e.Message);
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\..\..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
@ -39,23 +39,23 @@
|
|||
<Compile Include="StandardSyntaxConverter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Errors\Errors.csproj">
|
||||
<ProjectReference Include="..\Errors\Errors.csproj">
|
||||
<Project>{44a01f9e-dce7-470c-aae5-c3de0ccbee3b}</Project>
|
||||
<Name>Errors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Localization\Localization.csproj">
|
||||
<ProjectReference Include="..\Localization\Localization.csproj">
|
||||
<Project>{2de2842f-0912-4251-bc0f-480854c44a13}</Project>
|
||||
<Name>Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\SyntaxTree\SyntaxTree.csproj">
|
||||
<ProjectReference Include="..\SyntaxTree\SyntaxTree.csproj">
|
||||
<Project>{c2cac65a-b2ae-4ccc-b067-e6b8e75df73a}</Project>
|
||||
<Name>SyntaxTree</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\SyntaxVisitors\SyntaxVisitors.csproj">
|
||||
<ProjectReference Include="..\SyntaxVisitors\SyntaxVisitors.csproj">
|
||||
<Project>{a9ab4282-83b4-41a7-86c3-e5bf6a45e7e2}</Project>
|
||||
<Name>SyntaxVisitors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\TreeConverter\TreeConverter.csproj">
|
||||
<ProjectReference Include="..\TreeConverter\TreeConverter.csproj">
|
||||
<Project>{1c9c945a-586d-42a2-a06b-65d84fa7ff78}</Project>
|
||||
<Name>TreeConverter</Name>
|
||||
</ProjectReference>
|
||||
431
SyntaxVisitors/Async/AsyncBuilder.cs
Normal file
431
SyntaxVisitors/Async/AsyncBuilder.cs
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
// Билдер для построения StateMachine для каждого асинхронного метода
|
||||
internal class AsyncBuilder
|
||||
{
|
||||
// корень дерева
|
||||
private program_module program_Module { get; set; }
|
||||
// нужен для перестановки defs, содержащихся в блоке program block
|
||||
public List<declarations> declarationsList = new List<declarations>();
|
||||
// список всех асинхронных методов
|
||||
public List<procedure_definition> pdList = new List<procedure_definition>();
|
||||
|
||||
// Словарик переменных, которые нужно будет переименовать
|
||||
public Dictionary<string, string> RepVarsDict = new Dictionary<string, string>();
|
||||
|
||||
int LabelNameCounter = 0;
|
||||
private int StateCounter = 1;
|
||||
|
||||
// копирует блоки построенной StateMachine и передает их в declarationsList
|
||||
private declarations Decls = new declarations();
|
||||
|
||||
public AsyncBuilder(program_module program_Module)
|
||||
{
|
||||
this.program_Module = program_Module;
|
||||
}
|
||||
// Подключаем необходимые модули
|
||||
public void AddUsesCompilerServices()
|
||||
{
|
||||
if (program_Module.used_units != null)
|
||||
{
|
||||
program_Module.used_units.Add(new unit_or_namespace(new ident_list(new ident("System"),
|
||||
new ident("Runtime"), new ident("CompilerServices"))), program_Module.used_units.source_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
program_Module.used_units = new uses_list(new unit_or_namespace(new ident_list(new ident("System"),
|
||||
new ident("Runtime"), new ident("CompilerServices"))), program_Module.source_context);
|
||||
}
|
||||
}
|
||||
|
||||
public string NewStateMachine()
|
||||
{
|
||||
return "@StateMachine@_" + StateCounter++;
|
||||
}
|
||||
|
||||
// Создаем StateMachine вручную
|
||||
public void BuildStateMachine()
|
||||
{
|
||||
var defs = program_Module.program_block.defs;
|
||||
var vds = new var_def_statement(new ident("state"), new named_type_reference(new ident("integer")), defs.source_context);
|
||||
var vds2 = new var_def_statement(new ident("tbuilder"), new named_type_reference(new ident("AsyncVoidMethodBuilder")), defs.source_context);
|
||||
var ph = new procedure_header();
|
||||
ph.name = new method_name();
|
||||
ph.name.meth_name = new ident("MoveNext");
|
||||
ph.proc_attributes = new procedure_attributes_list();
|
||||
ph.source_context = defs.source_context;
|
||||
var ph2 = new procedure_header();
|
||||
ph2.name = new method_name();
|
||||
ph2.name.meth_name = new ident("SetStateMachine");
|
||||
ph2.source_context = defs.source_context;
|
||||
|
||||
var namedtr = new named_type_reference(new ident("System"), defs.source_context);
|
||||
namedtr.Add(new ident("Runtime"));
|
||||
namedtr.Add(new ident("CompilerServices"));
|
||||
namedtr.Add(new ident("IAsyncStateMachine"));
|
||||
var tp = new typed_parameters(new ident("stateMachine"), namedtr, defs.source_context);
|
||||
ph2.parameters = new formal_parameters(tp);
|
||||
ph2.proc_attributes = new procedure_attributes_list();
|
||||
|
||||
List<declaration> members = new List<declaration>{ vds, vds2, ph, ph2 };
|
||||
|
||||
var cm = new class_members(members, new access_modifer_node(access_modifer.public_modifer), defs.source_context);
|
||||
var classbodylist = new class_body_list(cm, defs.source_context);
|
||||
|
||||
var ntr = new named_type_reference_list(new named_type_reference(new ident("IAsyncStateMachine")), defs.source_context);
|
||||
var cd = new class_definition(ntr, classbodylist, defs.source_context);
|
||||
var td = new type_declaration(new ident("StateMachine"), cd, program_Module.source_context);
|
||||
|
||||
var pd = new procedure_definition();
|
||||
pd.proc_header = ph2;
|
||||
var a = new assign(new ident("tbuilder"), new dot_node(new ident("AsyncVoidMethodBuilder"), new ident("Create")), Operators.Assignment, defs.source_context);
|
||||
var p = new procedure_call(new method_call(new dot_node(new ident("tbuilder"), new ident("SetStateMachine")), new expression_list(new ident("stateMachine"))), defs.source_context);
|
||||
var subnodes = new List<statement> { a, p };
|
||||
var stlist = new statement_list(subnodes, new token_info("begin"), new token_info("end"), false, defs.source_context);
|
||||
pd.proc_body = new block(new declarations(), stlist, defs.source_context);
|
||||
pd.source_context = defs.source_context;
|
||||
|
||||
|
||||
|
||||
var pd2 = new procedure_definition();
|
||||
pd2.proc_header = ph;
|
||||
pd2.source_context = defs.source_context;
|
||||
stlist = new statement_list(new empty_statement(), defs.source_context);
|
||||
stlist.left_logical_bracket = new token_info("try", defs.source_context);
|
||||
|
||||
a = new assign(new ident("state"), new un_expr(new int32_const(2), Operators.Minus), Operators.Assignment, defs.source_context);
|
||||
var e = new new_expr(new named_type_reference(new ident("Exception")), new expression_list(new string_const("MoveNextException")), defs.source_context);
|
||||
p = new procedure_call(new method_call(new dot_node(new ident("tbuilder"), new ident("SetException")), new expression_list(e)), defs.source_context);
|
||||
var exception_block = new exception_block();
|
||||
exception_block.stmt_list = new statement_list(a, p, new procedure_call(new ident("exit")), new empty_statement());
|
||||
exception_block.source_context = defs.source_context;
|
||||
exception_block.stmt_list.source_context = defs.source_context;
|
||||
var try_handler = new try_handler_except(exception_block, defs.source_context);
|
||||
|
||||
var tr = new try_stmt(stlist, try_handler, defs.source_context);
|
||||
var mc = new method_call();
|
||||
mc.source_context = defs.source_context;
|
||||
mc.dereferencing_value = new dot_node(new ident("tbuilder"), new ident("SetResult"), defs.source_context);
|
||||
p = new procedure_call(mc, defs.source_context);
|
||||
subnodes = new List<statement> { tr, a, p, new empty_statement() };
|
||||
stlist = new statement_list(subnodes, new token_info("begin"), new token_info("end"), false);
|
||||
stlist.source_context = defs.source_context;
|
||||
pd2.proc_body = new block(new declarations(), stlist, defs.source_context);
|
||||
|
||||
Decls.Add(new type_declarations(td, defs.source_context), defs.source_context);
|
||||
Decls.Add(pd, defs.source_context);
|
||||
Decls.Add(pd2, defs.source_context);
|
||||
}
|
||||
|
||||
|
||||
// Генерируем StateMachine
|
||||
public void ParseStateMachine(procedure_definition p)
|
||||
{
|
||||
var defs = program_Module.program_block.defs;
|
||||
BuildStateMachine();
|
||||
|
||||
var name = NewStateMachine();
|
||||
var t_name = Decls.list[0] as type_declarations;
|
||||
t_name.types_decl[0].type_name = name;
|
||||
|
||||
var tdef2 = t_name.types_decl[0];
|
||||
var cd2 = tdef2.type_def as class_definition;
|
||||
var bd2 = cd2.body;
|
||||
var cm2 = bd2[0] as class_members;
|
||||
|
||||
var ph = new procedure_header();
|
||||
ph.name = new method_name();
|
||||
ph.name.meth_name = new ident("MoveNext");
|
||||
ph.proc_attributes = new procedure_attributes_list();
|
||||
ph.source_context = defs.source_context;
|
||||
|
||||
var ph2 = new procedure_header();
|
||||
ph2.name = new method_name();
|
||||
ph2.name.meth_name = new ident("SetStateMachine", defs.source_context);
|
||||
ph2.source_context = defs.source_context;
|
||||
|
||||
var namedtr = new named_type_reference(new ident("System"), defs.source_context);
|
||||
namedtr.Add(new ident("Runtime"));
|
||||
namedtr.Add(new ident("CompilerServices"));
|
||||
namedtr.Add(new ident("IAsyncStateMachine"));
|
||||
var tp = new typed_parameters(new ident("stateMachine"), namedtr, defs.source_context);
|
||||
ph2.parameters = new formal_parameters(tp, defs.source_context);
|
||||
ph2.proc_attributes = new procedure_attributes_list();
|
||||
ph2.source_context = defs.source_context;
|
||||
|
||||
cm2.members[2] = ph;
|
||||
ph.Parent = cm2;
|
||||
cm2.members[3] = ph2;
|
||||
ph2.Parent = cm2;
|
||||
|
||||
var pd1 = Decls.list[1] as procedure_definition;
|
||||
pd1.proc_header.name.class_name = name;
|
||||
var pd2 = Decls.list[2] as procedure_definition;
|
||||
pd2.proc_header.name.class_name = name;
|
||||
|
||||
var dc = new declarations();
|
||||
dc.Add(Decls.list[0], defs.source_context);
|
||||
dc.Add(Decls.list[1], defs.source_context);
|
||||
dc.Add(Decls.list[2], defs.source_context);
|
||||
dc.Add(p, defs.source_context);
|
||||
|
||||
declarationsList.Add(dc);
|
||||
Decls.list.Clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Для каждого асинхронного метода вызываем ParseStateMachine
|
||||
public void ParseStateMachines()
|
||||
{
|
||||
var defs = program_Module.program_block.defs;
|
||||
var t = new List<procedure_definition>();
|
||||
foreach (var item in pdList)
|
||||
{
|
||||
t.Add(item);
|
||||
defs.Remove(item);
|
||||
}
|
||||
|
||||
t.Reverse();
|
||||
foreach (var pd in t)
|
||||
{
|
||||
ParseStateMachine(pd);
|
||||
}
|
||||
declarationsList.Reverse();
|
||||
|
||||
foreach (var item in declarationsList)
|
||||
{
|
||||
defs.AddFirst(item.list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Переставляем асинхронные методы в нужном порядке
|
||||
public void SortBlocks()
|
||||
{
|
||||
var defs = program_Module.program_block.defs;
|
||||
var ind = pdList.Count * 4;
|
||||
int k = 0;
|
||||
for (int i = ind; i < defs.list.Count; i++)
|
||||
{
|
||||
if (defs.list[i] is procedure_definition)
|
||||
{
|
||||
var p = defs.list[i] as procedure_definition;
|
||||
if (p.proc_header.IsAsync)
|
||||
continue;
|
||||
var d = defs.list[i];
|
||||
defs.list.Remove(d);
|
||||
defs.AddFirst(d);
|
||||
k++;
|
||||
|
||||
}
|
||||
}
|
||||
var sortedNumbers = new List<declaration>();
|
||||
for (int i = k - 1; i >= 0; i--)
|
||||
{
|
||||
sortedNumbers.Add(defs.list[i]);
|
||||
}
|
||||
for (int i = k; i < defs.list.Count; i++)
|
||||
{
|
||||
sortedNumbers.Add(defs.list[i]);
|
||||
}
|
||||
defs.list.Clear();
|
||||
foreach (var item in sortedNumbers)
|
||||
{
|
||||
defs.list.Add(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < defs.list.Count; i++)
|
||||
{
|
||||
if (defs.list[i] is variable_definitions || defs.list[i] is type_declarations)
|
||||
{
|
||||
var d = defs.list[i];
|
||||
defs.list.Remove(d);
|
||||
defs.AddFirst(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void GetMethods(procedure_definition p)
|
||||
{
|
||||
pdList.Add(p);
|
||||
}
|
||||
// Для каждого асинхронного метода вызываем ChangeBody
|
||||
public void ChangeBodies()
|
||||
{
|
||||
StateCounter = 1;
|
||||
pdList.Reverse();
|
||||
foreach (var item in pdList)
|
||||
{
|
||||
var b = item.proc_header is function_header;
|
||||
var s = "Void";
|
||||
if (b)
|
||||
{
|
||||
var fh = item.proc_header as function_header;
|
||||
s = fh.return_type.ToString();
|
||||
if (s.Contains("."))
|
||||
{
|
||||
s = s.Substring(s.LastIndexOf('.') + 1);
|
||||
}
|
||||
if (!s.Contains("Task"))
|
||||
throw new SyntaxVisitorError("Возвращаемым типом асинхронного метода должен быть void, Task, Task<T> или аналогичный тип, IAsyncEnumerable<T> или IAsyncEnumerator<T>",
|
||||
item.proc_header.source_context);
|
||||
}
|
||||
if (s == "Void" || s == "Task")
|
||||
{
|
||||
ChangeBody(item, b, "Async" + s + "MethodBuilder");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeBody(item, b, "AsyncTaskMethodBuilder" + s.Substring(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
public string newLabelName(string old)
|
||||
{
|
||||
LabelNameCounter++;
|
||||
return "@awvar@_" + LabelNameCounter.ToString() + "_" + old;
|
||||
}
|
||||
|
||||
// Изменяем тело асинхронной функции, добавляя AsyncBuilder для запуска StateMachine
|
||||
public void ChangeBody(procedure_definition pd, bool IsFunc, string Type)
|
||||
{
|
||||
var state = "@awst@_";
|
||||
var block = pd.proc_body as block;
|
||||
|
||||
if (pd.proc_header.IsAsync == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var i = new ident(state, block.source_context);
|
||||
var v = new var_def_statement(i, new new_expr(NewStateMachine()), block.source_context); // st:= new StateMachine();
|
||||
var st = new var_statement(v, block.source_context); // st:= new StateMachine();
|
||||
var d = new dot_node(i, new ident("state"), block.source_context);
|
||||
var a = new assign(d, new int32_const(1), Operators.Assignment, block.source_context);//st.state := 1;
|
||||
|
||||
var parsList = new statement_list();
|
||||
parsList.source_context = block.source_context;
|
||||
if (pd.proc_header.parameters != null)
|
||||
{
|
||||
var par = pd.proc_header.parameters;
|
||||
foreach (var pp in par.params_list)
|
||||
{
|
||||
|
||||
foreach (var id in pp.idents.list)
|
||||
{
|
||||
if (!RepVarsDict.ContainsKey(id.name))
|
||||
{
|
||||
var nv = newLabelName(id.name);
|
||||
RepVarsDict.Add(id.name, nv);
|
||||
parsList.Add(new assign(new dot_node(i, id), id, Operators.Assignment), block.source_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
var nv = newLabelName(id.name);
|
||||
RepVarsDict[id.name] = nv;
|
||||
parsList.Add(new assign(new dot_node(i, id), id, Operators.Assignment), block.source_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parsList.source_context = block.source_context;
|
||||
|
||||
|
||||
|
||||
|
||||
var fr2 = new method_call();
|
||||
fr2.source_context = block.source_context;
|
||||
|
||||
|
||||
if (Type.StartsWith("AsyncVoidMethodBuilder") || Type == "AsyncTaskMethodBuilder")
|
||||
{
|
||||
fr2.dereferencing_value = new dot_node(new ident(Type), new ident("Create"), block.source_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ttt = Type.Substring(23);
|
||||
ttt = ttt.Replace(">", "");
|
||||
var tpl = new template_param_list();
|
||||
tpl.source_context = block.source_context;
|
||||
tpl.params_list.Add(new named_type_reference(new ident(ttt, block.source_context)));
|
||||
fr2.dereferencing_value = new dot_node(new ident_with_templateparams(new ident("AsyncTaskMethodBuilder", block.source_context), tpl, block.source_context), new ident("Create", block.source_context), block.source_context);
|
||||
}
|
||||
|
||||
var a2 = new assign(new dot_node(i, new ident("tbuilder", block.source_context)), fr2, Operators.Assignment, block.source_context);//st.tbuilder := AsyncTaskMethodBuilder.Create();
|
||||
|
||||
var m = new method_call(new expression_list(i), block.source_context);
|
||||
m.dereferencing_value = new dot_node(new dot_node(i, new ident("tbuilder", block.source_context)), new ident("Start", block.source_context), block.source_context);
|
||||
var p = new procedure_call(m, block.source_context);//st.tbuilder.Start(st);
|
||||
|
||||
var temp_def = new declarations();
|
||||
var defsCount = 0;
|
||||
if (block.defs != null)
|
||||
{
|
||||
foreach (var dl in block.defs.list)
|
||||
{
|
||||
if (dl is variable_definitions)
|
||||
{
|
||||
defsCount++;
|
||||
var ddl = dl as variable_definitions;
|
||||
foreach (var item in ddl.list)
|
||||
{
|
||||
(pd.proc_body as block).program_code.AddFirst(new var_statement(item));
|
||||
}
|
||||
}
|
||||
else
|
||||
temp_def.Add(dl);
|
||||
}
|
||||
}
|
||||
|
||||
if (defsCount > 0)
|
||||
{
|
||||
block.defs = temp_def;
|
||||
if (temp_def != null)
|
||||
foreach (var dl in temp_def.list)
|
||||
{
|
||||
dl.Parent = block.defs;
|
||||
}
|
||||
}
|
||||
var stl = new statement_list((pd.proc_body as block).program_code, st, a, parsList, a2);
|
||||
|
||||
|
||||
var class_name = pd.proc_header.name.class_name;
|
||||
if (class_name != null)
|
||||
{
|
||||
if (!pd.proc_header.class_keyword)
|
||||
{
|
||||
var ascl = new assign(new dot_node(i, "@awclass", pd.source_context), new ident("self", pd.source_context), pd.source_context); // st:= new StateMachine();
|
||||
stl.Add(ascl);
|
||||
}
|
||||
}
|
||||
stl.Add(p);
|
||||
if (IsFunc)
|
||||
{
|
||||
var a3 = new assign(new ident("Result", pd.source_context), new dot_node(new dot_node(new ident(state, block.source_context), new ident("tbuilder", block.source_context)), new ident("Task", block.source_context)), Operators.Assignment, pd.source_context);
|
||||
stl.Add(a3);
|
||||
}
|
||||
stl.source_context = pd.source_context;
|
||||
pd.proc_body = new block(stl);
|
||||
var tt = pd.proc_body as block;
|
||||
tt.defs = block.defs;
|
||||
if (block.defs != null)
|
||||
{
|
||||
foreach (var item in block.defs.list)
|
||||
{
|
||||
item.Parent = tt.defs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
251
SyntaxVisitors/Async/AsyncVisitor.cs
Normal file
251
SyntaxVisitors/Async/AsyncVisitor.cs
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
using System.Collections.Generic;
|
||||
using PascalABCCompiler.SyntaxTree;
|
||||
using SyntaxVisitors.Async;
|
||||
|
||||
namespace SyntaxVisitors
|
||||
{
|
||||
public class AsyncVisitor : BaseChangeVisitor
|
||||
{
|
||||
private program_module program_Module { get; set; }
|
||||
|
||||
// текущий асинхронный метод, для которого будет построена StateMachine
|
||||
private procedure_definition proc_def { get; set; }
|
||||
|
||||
// список всех асинхронных методов
|
||||
private List<procedure_definition> proc_def_List = new List<procedure_definition>();
|
||||
|
||||
// Тип билдера, который нужно менять в зависимости от возвращаемого
|
||||
// типа асинхронного типа
|
||||
private string BuilderType = "AsyncVoidMethodBuilder";
|
||||
|
||||
private int AwaiterCounter = 1;
|
||||
|
||||
private AwaitBuilder AwaitBuilder;
|
||||
|
||||
private AsyncBuilder AsyncBuilder;
|
||||
|
||||
private bool IsFirstAwait = true;
|
||||
|
||||
private bool IsFirstAsync = true;
|
||||
|
||||
// Нужен, чтобы понимать с какой машиной
|
||||
// состояний мы сейчас работаем
|
||||
private int StateMachineNumber = 0;
|
||||
|
||||
// Множество всех процедур
|
||||
public static HashSet<string> ProcedureSet = new HashSet<string>();
|
||||
|
||||
// Множество всех функций
|
||||
public static HashSet<string> FunctionSet = new HashSet<string>();
|
||||
|
||||
|
||||
public static AsyncVisitor New
|
||||
{
|
||||
get { return new AsyncVisitor(); }
|
||||
}
|
||||
|
||||
public override void visit(procedure_definition pd)
|
||||
{
|
||||
if (pd.proc_header is function_header)
|
||||
{
|
||||
var ph = pd.proc_header as function_header;
|
||||
if (ph.name != null)
|
||||
{
|
||||
FunctionSet.Add(ph.name.meth_name.name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var ph = pd.proc_header;
|
||||
if (ph.name != null)
|
||||
{
|
||||
ProcedureSet.Add(ph.name.meth_name.name);
|
||||
|
||||
}
|
||||
}
|
||||
// Собираем все асинхронные методы в proc_def_List
|
||||
if (pd.proc_header.IsAsync)
|
||||
{
|
||||
MainVisitor.HasAwait = false;
|
||||
MainVisitor.Accept(pd);
|
||||
if (!MainVisitor.HasAwait)
|
||||
{
|
||||
var b = pd.proc_body as block;
|
||||
if (b != null)
|
||||
{
|
||||
var await = new await_node_statement();
|
||||
await.source_context = b.source_context;
|
||||
await.aw = new await_node();
|
||||
await.aw.source_context = b.source_context;
|
||||
var mc = new method_call();
|
||||
mc.dereferencing_value = new dot_node(new dot_node(new dot_node(new dot_node(new ident("System"),
|
||||
new ident("Threading")), new ident("Tasks")), new ident("Task")), new ident("Delay"));
|
||||
mc.parameters = new expression_list(new int32_const(0));
|
||||
mc.source_context = b.source_context;
|
||||
|
||||
await.aw.ex = mc;
|
||||
b.program_code.list.Add(await);
|
||||
await.Parent = b.program_code;
|
||||
}
|
||||
}
|
||||
proc_def = pd;
|
||||
proc_def_List.Add(pd);
|
||||
if (IsFirstAsync)
|
||||
{
|
||||
|
||||
IsFirstAsync = false;
|
||||
AsyncBuilder = new AsyncBuilder(program_Module);
|
||||
AsyncBuilder.AddUsesCompilerServices();
|
||||
}
|
||||
LoweringAsyncVisitor.Accept(pd);
|
||||
AsyncBuilder.GetMethods(pd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pd.proc_body is block)
|
||||
{
|
||||
var procedure_code = (pd.proc_body as block).program_code;
|
||||
for (int i = 0; i < procedure_code.list.Count; i++)
|
||||
{
|
||||
if (procedure_code.list[i] is await_node_statement)
|
||||
{
|
||||
throw new SyntaxVisitorError("Ключевое слово 'await' может быть использовано " +
|
||||
"только в асинхронных методах ", procedure_code.list[i].source_context);
|
||||
}
|
||||
if (procedure_code.list[i] is var_statement)
|
||||
{
|
||||
var pp = procedure_code.list[i] as var_statement;
|
||||
if (pp.var_def.inital_value is await_node)
|
||||
{
|
||||
throw new SyntaxVisitorError("Ключевое слово 'await' может быть использовано " +
|
||||
"только в асинхронных методах ", pp.var_def.inital_value.source_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void visit(await_node_statement astat)
|
||||
{
|
||||
ProcessNode(astat.aw);
|
||||
}
|
||||
|
||||
public override void visit(await_node a)
|
||||
{
|
||||
// сразу обернуть в sugared_addressed_value
|
||||
//var sug = new sugared_expression(a, a.ex, a.ex.source_context);
|
||||
//ReplaceUsingParent(a, sug);
|
||||
AwaiterCounter++;
|
||||
if (IsFirstAwait)
|
||||
{
|
||||
IsFirstAwait = false;
|
||||
AwaitBuilder = new AwaitBuilder(program_Module, proc_def);
|
||||
AwaitBuilder.VarsHelper.RepVarsDict = AsyncBuilder.RepVarsDict;
|
||||
AwaitBuilder.GetCode();
|
||||
AwaitBuilder.AddAwaiter(true, a.ex, StateMachineNumber);
|
||||
AwaitBuilder.ChangeBuilder(BuilderType, StateMachineNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
AwaitBuilder.ChangeBuilder(BuilderType, StateMachineNumber);
|
||||
AwaitBuilder.AddAwaiter(false, a.ex, StateMachineNumber);
|
||||
}
|
||||
if (AwaitBuilder.AwaiterCounter == AwaiterCounter - 1)
|
||||
{
|
||||
|
||||
AwaitBuilder.GenAwait(StateMachineNumber + 2);
|
||||
AwaitBuilder.DeleteBody();
|
||||
}
|
||||
}
|
||||
public void GenMain(program_module pm)
|
||||
{
|
||||
if (MainVisitor.HasAwait)
|
||||
{
|
||||
var d = pm.program_block.defs;
|
||||
var p = new procedure_definition();
|
||||
p.proc_header = new function_header(new template_type_reference(new named_type_reference(new ident("Task",
|
||||
d.source_context), d.source_context),
|
||||
new template_param_list(new named_type_reference(new ident("integer", d.source_context),
|
||||
d.source_context), d.source_context), d.source_context), d.source_context);
|
||||
p.proc_header.name = new method_name();
|
||||
p.proc_header.name.meth_name = new ident("@AsyncMain", d.source_context);
|
||||
p.proc_header.IsAsync = true;
|
||||
p.source_context = d.source_context;
|
||||
var b = new block();
|
||||
b.source_context = d.source_context;
|
||||
b.program_code = new statement_list();
|
||||
b.program_code.source_context = d.source_context;
|
||||
foreach (var item in pm.program_block.program_code.list)
|
||||
{
|
||||
b.program_code.list.Add(item);
|
||||
item.Parent = b.program_code;
|
||||
}
|
||||
p.proc_body = b;
|
||||
pm.program_block.program_code.list.Clear();
|
||||
d.Add(p);
|
||||
var mc = new method_call();
|
||||
mc.dereferencing_value = new ident("@AsyncMain");
|
||||
mc.source_context = d.source_context;
|
||||
var vst = new var_statement(new var_def_statement(new ident("@aw_main",
|
||||
d.source_context), mc, d.source_context), d.source_context);
|
||||
var pc = new procedure_call(new dot_node(new dot_node(new ident("@aw_main", d.source_context),
|
||||
new ident("GetAwaiter")), new ident("GetResult"), d.source_context), d.source_context);
|
||||
pm.program_block.program_code.list.Add(vst);
|
||||
vst.Parent = pm.program_block.program_code;
|
||||
pm.program_block.program_code.list.Add(pc);
|
||||
pc.Parent = pm.program_block.program_code;
|
||||
|
||||
}
|
||||
}
|
||||
public override void visit(program_module pm)
|
||||
{
|
||||
program_Module = pm;
|
||||
MainVisitor.HasAwait = false;
|
||||
MainVisitor.Accept(pm.program_block.program_code);
|
||||
GenMain(pm);
|
||||
|
||||
DefaultVisit(pm);
|
||||
if (proc_def_List.Count > 0)
|
||||
{
|
||||
AsyncBuilder.ParseStateMachines();
|
||||
AsyncBuilder.ChangeBodies();
|
||||
proc_def_List.Reverse();
|
||||
foreach (var p in proc_def_List)
|
||||
{
|
||||
AwaiterCounter = 1;
|
||||
IsFirstAwait = true;
|
||||
proc_def = p;
|
||||
if (p.proc_header.IsAsync)
|
||||
{
|
||||
if (p.proc_header is function_header)
|
||||
{
|
||||
var fh = p.proc_header as function_header;
|
||||
var s = fh.return_type.ToString();
|
||||
if (s.Contains("."))
|
||||
{
|
||||
s = s.Substring(s.LastIndexOf('.') + 1);
|
||||
}
|
||||
if (s.StartsWith("Task"))
|
||||
{
|
||||
BuilderType = "AsyncTaskMethodBuilder" + s.Substring(4);
|
||||
}
|
||||
else
|
||||
BuilderType = "Async" + fh.return_type.ToString() + "MethodBuilder";
|
||||
}
|
||||
else
|
||||
{
|
||||
BuilderType = "AsyncVoidMethodBuilder";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
DefaultVisit(p);
|
||||
StateMachineNumber += 4;
|
||||
}
|
||||
AsyncBuilder.SortBlocks();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
814
SyntaxVisitors/Async/AwaitBuilder.cs
Normal file
814
SyntaxVisitors/Async/AwaitBuilder.cs
Normal file
|
|
@ -0,0 +1,814 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
internal class AwaitBuilder
|
||||
{
|
||||
// корень дерева
|
||||
private program_module program_Module { get; set; }
|
||||
|
||||
// текущий асинхронный метод
|
||||
public procedure_definition proc_def { get; set; }
|
||||
|
||||
int lbnum = 0;
|
||||
|
||||
// тело асинхронного метода
|
||||
private statement_list code_list = new statement_list();
|
||||
|
||||
// Список Taskов, принадлежащих к какому-нибудь await
|
||||
public expression_list TaskList = new expression_list();
|
||||
|
||||
// Счетчик awaitов
|
||||
public int AwaiterCounter = 0;
|
||||
|
||||
// Счетчик временных переменных для Task
|
||||
public int TempTaskCounter = 1;
|
||||
|
||||
public VarsHelper VarsHelper;
|
||||
|
||||
// Возвращаемый тип асинхронного метода
|
||||
public string ResultType = "";
|
||||
|
||||
// Результат работы асинхронного метода
|
||||
public expression ResultVal = new expression();
|
||||
|
||||
//ctor
|
||||
public AwaitBuilder(program_module pm, procedure_definition pd)
|
||||
{
|
||||
program_Module = pm;
|
||||
proc_def = pd;
|
||||
VarsHelper = new VarsHelper();
|
||||
|
||||
}
|
||||
|
||||
public int NewAwaiterCounter = 1;
|
||||
public string NewAwaiter()
|
||||
{
|
||||
return "@aw@_" + NewAwaiterCounter++;
|
||||
}
|
||||
// для каждого await добавляем awaiter
|
||||
public void AddAwaiter(bool IsFirstTime, expression ex, int c)
|
||||
{
|
||||
|
||||
var a_name = NewAwaiter();
|
||||
TaskList.AddFirst(ex);
|
||||
var tdecl = program_Module.program_block.defs.list[c] as type_declarations;
|
||||
var tdef = tdecl.types_decl[0];
|
||||
var cd = tdef.type_def as class_definition;
|
||||
var bd = cd.body;
|
||||
var vds = new var_def_statement(new ident(a_name, bd.source_context), new named_type_reference(new ident("string", bd.source_context)), bd.source_context);
|
||||
var class_name = proc_def.proc_header.name.class_name;
|
||||
if (IsFirstTime)
|
||||
{
|
||||
List<declaration> members = new List<declaration> { vds };
|
||||
if (class_name != null)
|
||||
{
|
||||
members.Add(new var_statement(new var_def_statement(new ident("@awclass", bd.source_context), new named_type_reference(class_name), bd.source_context), bd.source_context));
|
||||
|
||||
}
|
||||
var cm = new class_members(members, new access_modifer_node(access_modifer.private_modifer), bd.source_context);
|
||||
bd.AddFirst(cm);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var cm2 = bd.class_def_blocks[0];
|
||||
cm2.Add(vds);
|
||||
}
|
||||
}
|
||||
// Меняем тип AsyncBuilder
|
||||
public void ChangeBuilder(string Type, int ChangeBuilderCounter)
|
||||
{
|
||||
var tdecl = program_Module.program_block.defs.list[ChangeBuilderCounter] as type_declarations;
|
||||
var tdef = tdecl.types_decl[0];
|
||||
var cd = tdef.type_def as class_definition;
|
||||
var bd = cd.body;
|
||||
var cm = bd[1] as class_members;
|
||||
var vdf = cm[2] as var_def_statement;
|
||||
var pd = program_Module.program_block.defs.list[ChangeBuilderCounter + 1] as procedure_definition;
|
||||
var pb = pd.proc_body as block;
|
||||
var st = pb.program_code;
|
||||
var a = st.list[0] as assign;
|
||||
var mc = new method_call();
|
||||
mc.source_context = st.source_context;
|
||||
|
||||
if (Type.StartsWith("AsyncVoidMethodBuilder") || Type == "AsyncTaskMethodBuilder")
|
||||
{
|
||||
|
||||
vdf.vars_type = new named_type_reference(Type, vdf.source_context);
|
||||
mc.dereferencing_value = new dot_node(new ident(Type, vdf.source_context), new ident("Create"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var tt = Type.Substring(23);
|
||||
tt = tt.Replace(">", "");
|
||||
ResultType = tt;
|
||||
var tpl = new template_param_list();
|
||||
tpl.source_context = vdf.source_context;
|
||||
tpl.params_list.Add(new named_type_reference(new ident(tt, vdf.source_context)));
|
||||
vdf.vars_type = new template_type_reference("AsyncTaskMethodBuilder", tpl);
|
||||
mc.dereferencing_value = new dot_node(new ident_with_templateparams(new ident("AsyncTaskMethodBuilder", vdf.source_context),
|
||||
tpl, vdf.source_context), new ident("Create", vdf.source_context), vdf.source_context);
|
||||
}
|
||||
|
||||
a.from = mc;
|
||||
}
|
||||
|
||||
public string newLabelName()
|
||||
{
|
||||
lbnum++;
|
||||
return "@awlb@_" + lbnum.ToString();
|
||||
}
|
||||
|
||||
// Обрабатываем тело асинхронного метода
|
||||
public void GetCode()
|
||||
{
|
||||
var class_name = proc_def.proc_header.name.class_name;
|
||||
if (class_name != null)
|
||||
{
|
||||
foreach (var item in program_Module.program_block.defs.list)
|
||||
{
|
||||
if (item is type_declarations)
|
||||
{
|
||||
var tds = item as type_declarations;
|
||||
foreach (var tdef in tds.types_decl)
|
||||
{
|
||||
if (tdef.type_name.name == class_name.name)
|
||||
{
|
||||
var cd = tdef.type_def as class_definition;
|
||||
var bd = cd.body;
|
||||
for (int i = 0; i < bd.Count; i++)
|
||||
{
|
||||
if (bd[i] is class_members)
|
||||
{
|
||||
var cm = bd[i] as class_members;
|
||||
foreach (var mem in cm.members)
|
||||
{
|
||||
if (mem is var_def_statement)
|
||||
{
|
||||
var vm = mem as var_def_statement;
|
||||
if (vm.var_attr != definition_attribute.Static)
|
||||
{
|
||||
foreach (var vms in vm.vars.list)
|
||||
{
|
||||
VarsHelper.ClassIdentSet.Add(vms.name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var vms in vm.vars.list)
|
||||
{
|
||||
VarsHelper.ClassStaticSet.Add(vms.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var b = proc_def.proc_header is function_header;
|
||||
var procedure_code = (proc_def.proc_body as block).program_code.list[0] as statement_list;
|
||||
var temp_list = new statement_list();
|
||||
var r_list = new statement_list();
|
||||
|
||||
|
||||
if (proc_def.proc_header.parameters != null)
|
||||
{
|
||||
var par = proc_def.proc_header.parameters;
|
||||
foreach (var p in par.params_list)
|
||||
{
|
||||
if (p.param_kind is parametr_kind.var_parametr)
|
||||
{
|
||||
throw new SyntaxVisitorError("var-параметры нельзя использовать в асинхронных методах ", p.source_context);
|
||||
}
|
||||
foreach (var id in p.idents.list)
|
||||
{
|
||||
var v = new var_statement(new var_def_statement(id, p.vars_type, p.source_context), p.source_context);
|
||||
VarsHelper.VarsList.Add(v);
|
||||
VarsHelper.Parametrs.Add(id.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var await_counter = 0;
|
||||
bool flag = true;
|
||||
for (int i = 0; i < procedure_code.list.Count; i++)
|
||||
{
|
||||
if (procedure_code.list[i] is await_node_statement)
|
||||
{
|
||||
var pp = procedure_code.list[i] as await_node_statement;
|
||||
await_counter++;
|
||||
flag = false;
|
||||
var a = pp.aw;
|
||||
if (a.ex is ident)
|
||||
{
|
||||
VarsHelper.ExprHash.Add(a.ex.ToString());
|
||||
if (!VarsHelper.TaskIdents.ContainsKey(a.ex.ToString()))
|
||||
{
|
||||
VarsHelper.TaskIdents.Add(a.ex.ToString(), await_counter.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (procedure_code.list[i] is if_node)
|
||||
{
|
||||
var if_node = procedure_code.list[i] as if_node;
|
||||
|
||||
OperationsVisitor.HasAwait = false;
|
||||
OperationsVisitor.Accept(if_node);
|
||||
if (OperationsVisitor.HasAwait == true)
|
||||
{
|
||||
temp_list.Add(procedure_code.list[i]);
|
||||
if (i + 1 >= procedure_code.Count)
|
||||
{
|
||||
await_counter++;
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
if (!(procedure_code.list[i + 1] is if_node))
|
||||
{
|
||||
await_counter++;
|
||||
flag = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// бывший цикл while
|
||||
if (procedure_code.list[i] is labeled_statement)
|
||||
{
|
||||
var lb = procedure_code.list[i] as labeled_statement;
|
||||
if (lb.to_statement is if_node)
|
||||
{
|
||||
var if_node = lb.to_statement as if_node;
|
||||
OperationsVisitor.HasAwait = false;
|
||||
OperationsVisitor.Accept(if_node);
|
||||
if (OperationsVisitor.HasAwait == true)
|
||||
{
|
||||
temp_list.Add(procedure_code.list[i]);
|
||||
await_counter++;
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (procedure_code.list[i] is var_statement)
|
||||
{
|
||||
var pp = procedure_code.list[i] as var_statement;
|
||||
if (pp.var_def.inital_value is bin_expr || pp.var_def.inital_value is un_expr)
|
||||
{
|
||||
OperationsVisitor.HasAwait = false;
|
||||
OperationsVisitor.Accept(pp.var_def);
|
||||
}
|
||||
if (pp.var_def.inital_value is await_node)
|
||||
{
|
||||
var a = pp.var_def.inital_value as await_node;
|
||||
VarsHelper.VarsList.Add(pp);
|
||||
foreach (var v in pp.var_def.vars.list)
|
||||
{
|
||||
var mmc = new method_call();
|
||||
mmc.source_context = v.source_context;
|
||||
|
||||
if (a.ex is method_call)
|
||||
mmc.dereferencing_value = GenGetResult(new dot_node(a.ex as method_call,
|
||||
new ident("GetAwaiter", v.source_context)), v);
|
||||
else
|
||||
mmc.dereferencing_value = GenGetResult(new dot_node(new ident(a.ex.ToString(), v.source_context),
|
||||
new ident("GetAwaiter", v.source_context)), v);
|
||||
|
||||
|
||||
var ass = new assign(v, mmc, Operators.Assignment, v.source_context);
|
||||
ass.first_assignment_defines_type = true;
|
||||
r_list.Add(ass);
|
||||
}
|
||||
await_counter++;
|
||||
flag = false;
|
||||
|
||||
if (a.ex is ident)
|
||||
{
|
||||
VarsHelper.ExprHash.Add(a.ex.ToString());
|
||||
if (!VarsHelper.TaskIdents.ContainsKey(a.ex.ToString()))
|
||||
{
|
||||
VarsHelper.TaskIdents.Add(a.ex.ToString(), await_counter.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pp.var_def.inital_value != null)
|
||||
{
|
||||
if (pp.var_def.inital_value is ident)
|
||||
{
|
||||
var id = pp.var_def.inital_value as ident;
|
||||
if (AsyncVisitor.ProcedureSet.Contains(id.name.ToString()))
|
||||
{
|
||||
pp.var_def.inital_value = null;
|
||||
pp.var_def.vars_type = new procedure_header();
|
||||
VarsHelper.VarsList.Add(pp);
|
||||
foreach (var item in pp.var_def.vars.list)
|
||||
{
|
||||
var ass = new assign(item, id, Operators.Assignment, item.source_context);
|
||||
temp_list.Add(ass);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (AsyncVisitor.FunctionSet.Contains(id.name.ToString()))
|
||||
{
|
||||
var mc = new method_call();
|
||||
mc.dereferencing_value = id;
|
||||
pp.var_def.inital_value = mc;
|
||||
}
|
||||
}
|
||||
foreach (var item in pp.var_def.vars.list)
|
||||
{
|
||||
var ass = new assign(item, pp.var_def.inital_value, Operators.Assignment, item.source_context);
|
||||
ass.first_assignment_defines_type = true;
|
||||
temp_list.Add(ass);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pp.var_def.vars_type.ToString().Contains("Task"))
|
||||
{
|
||||
pp.var_def.inital_value = new default_operator(new named_type_reference
|
||||
(pp.var_def.vars_type.ToString()));
|
||||
pp.var_def.vars_type = null;
|
||||
foreach (var item in pp.var_def.vars.list)
|
||||
{
|
||||
var ass = new assign(item, pp.var_def.inital_value, Operators.Assignment, item.source_context);
|
||||
ass.first_assignment_defines_type = true;
|
||||
temp_list.Add(ass);
|
||||
}
|
||||
}
|
||||
}
|
||||
VarsHelper.VarsList.Add(pp);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (procedure_code.list[i] is assign)
|
||||
{
|
||||
var a = procedure_code.list[i] as assign;
|
||||
|
||||
OperationsVisitor.HasAwait = false;
|
||||
OperationsVisitor.Accept(a);
|
||||
if (OperationsVisitor.HasAwait == true)
|
||||
{
|
||||
temp_list.Add(procedure_code.list[i]);
|
||||
await_counter++;
|
||||
flag = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (procedure_code.list[i] is assign && b)
|
||||
{
|
||||
var pa = procedure_code.list[i] as assign;
|
||||
if (pa.to is ident)
|
||||
{
|
||||
var pat = pa.to as ident;
|
||||
if (pat.name == "Result")
|
||||
{
|
||||
ResultVal = pa.from;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
temp_list.Add(procedure_code.list[i]);
|
||||
else
|
||||
{
|
||||
flag = true;
|
||||
code_list.Add(temp_list);
|
||||
temp_list = r_list;
|
||||
r_list = new statement_list();
|
||||
}
|
||||
}
|
||||
VarsHelper.MarkVars();
|
||||
AwaiterCounter = await_counter;
|
||||
code_list.Add(temp_list);
|
||||
code_list.source_context = procedure_code.source_context;
|
||||
|
||||
}
|
||||
|
||||
// Изменяем метод MoveNext в зависимости от количества await
|
||||
public void GenAwait(int c)
|
||||
{
|
||||
var pd = program_Module.program_block.defs.list[c] as procedure_definition;
|
||||
var bl = pd.proc_body as block;
|
||||
|
||||
var class_name = proc_def.proc_header.name.class_name;
|
||||
var awaiter = "@aw@_";
|
||||
var aw_temp = "@awtemp@_";
|
||||
var extp = "awextemp@_";
|
||||
|
||||
// используется если await внутри цикла
|
||||
if ((proc_def.proc_body as block).defs != null)
|
||||
{
|
||||
var loopLabelsList = (proc_def.proc_body as block).defs.list;
|
||||
if (loopLabelsList != null)
|
||||
foreach (var b in loopLabelsList)
|
||||
{
|
||||
bl.defs.Add(b);
|
||||
}
|
||||
}
|
||||
|
||||
var lb1 = newLabelName();
|
||||
bl.defs.Add(new label_definitions(new ident(lb1, bl.source_context)), bl.source_context);
|
||||
var ts = bl.program_code.list[0] as try_stmt;
|
||||
var g1 = new goto_statement(lb1, ts.source_context);
|
||||
var ls = new labeled_statement(lb1);
|
||||
ls.source_context = ts.source_context;
|
||||
(code_list.list[1] as statement_list).source_context = ts.source_context;
|
||||
|
||||
ts.stmt_list.Remove(ts.stmt_list.Last());
|
||||
|
||||
|
||||
// если метод возвращает значение
|
||||
if (ResultType != "")
|
||||
{
|
||||
var r_pc = new procedure_call(new method_call(new dot_node(new ident("tbuilder", ts.source_context),
|
||||
new ident("SetResult", ts.source_context)),
|
||||
new expression_list(new ident("@aw_res", ts.source_context), ts.source_context), ts.source_context), ts.source_context);
|
||||
bl.program_code.list[2] = r_pc;
|
||||
r_pc.Parent = bl.program_code;
|
||||
}
|
||||
|
||||
////// if (state == 1)
|
||||
|
||||
var ifnode = new if_node();
|
||||
ifnode.source_context = ts.source_context;
|
||||
ifnode.condition = new bin_expr(new dot_node(new ident("self"), new ident("state")), new int32_const(1), Operators.Equal, ts.source_context);
|
||||
|
||||
var extemp = new var_statement(new var_def_statement(new ident(extp, TaskList[0].source_context),
|
||||
TaskList[0] as expression, TaskList[0].source_context), TaskList[0].source_context);
|
||||
(code_list.list[0] as statement_list).Add(extemp);
|
||||
|
||||
var mcс = new method_call();
|
||||
mcс.dereferencing_value = new dot_node(new ident(extp, TaskList[0].source_context), new ident("GetAwaiter", TaskList[0].source_context));
|
||||
mcс.source_context = TaskList[0].source_context;
|
||||
|
||||
var assign_ = new assign(new ident("@aw@_" + "1", ts.source_context), mcс, Operators.Assignment, ts.source_context);
|
||||
assign_.first_assignment_defines_type = true;
|
||||
|
||||
|
||||
var if2 = new if_node();
|
||||
if2.source_context = ts.source_context;
|
||||
if2.condition = new bin_expr(new dot_node(new ident("@aw@_" + "1", ts.source_context), new ident("IsCompleted", ts.source_context), ts.source_context),
|
||||
new ident("False", ts.source_context), Operators.Equal, ts.source_context);
|
||||
|
||||
var a1 = new assign(new dot_node(new ident("self", if2.source_context), new ident("state", ts.source_context), if2.source_context), new int32_const(2, ts.source_context), Operators.Assignment, ts.source_context);
|
||||
|
||||
var temp = new var_statement(new var_def_statement(new ident(aw_temp, ts.source_context), new ident("self", ts.source_context)), ts.source_context);
|
||||
var dt = new dot_node(new dot_node(new ident("self", ts.source_context), new ident("tbuilder", ts.source_context)),
|
||||
new ident("AwaitUnsafeOnCompleted", ts.source_context), ts.source_context);
|
||||
var ex = new expression_list(new ident("@aw@_" + "1", ts.source_context), ts.source_context);
|
||||
ex.Add(new ident(aw_temp));
|
||||
var mc = new method_call(dt, ex, ts.source_context);
|
||||
var pc = new procedure_call(mc, ts.source_context);
|
||||
var ifnode_body2 = new statement_list(a1, temp, pc, new procedure_call(new ident("exit"), ts.source_context), new empty_statement());
|
||||
ifnode_body2.left_logical_bracket = new token_info("begin");
|
||||
ifnode_body2.right_logical_bracket = new token_info("end");
|
||||
if2.then_body = ifnode_body2;
|
||||
if2.then_body.source_context = ts.source_context;
|
||||
|
||||
(code_list.list[0] as statement_list).Add(assign_, ts.source_context);
|
||||
(code_list.list[0] as statement_list).Add(if2, ts.source_context);
|
||||
(code_list.list[0] as statement_list).Add(new empty_statement(), ts.source_context);
|
||||
var ifnode_body1 = new statement_list(code_list.list[0], ts.source_context);
|
||||
|
||||
ifnode_body1.Add(g1, ts.source_context);
|
||||
|
||||
ifnode_body1.left_logical_bracket = new token_info("begin");
|
||||
ifnode_body1.right_logical_bracket = new token_info("end");
|
||||
ifnode.then_body = ifnode_body1;
|
||||
ifnode.source_context = ts.source_context;
|
||||
FillTypedVars(c - 2);
|
||||
|
||||
ts.stmt_list.Add(ifnode, ts.source_context);
|
||||
////// if (state == 1)
|
||||
|
||||
|
||||
// Добавляем метки для переходов по состояниям
|
||||
var awCount = AwaiterCounter;
|
||||
while (awCount > 1)
|
||||
{
|
||||
awCount--;
|
||||
lb1 = newLabelName();
|
||||
bl.defs.Add(new label_definitions(new ident(lb1, ts.source_context)), ts.source_context);
|
||||
}
|
||||
|
||||
lbnum = 0;
|
||||
awCount = AwaiterCounter;
|
||||
|
||||
// Когда Task уже завершен
|
||||
while (awCount != 0)
|
||||
{
|
||||
awCount--;
|
||||
|
||||
///if (state == 2,3,4 ...)
|
||||
var ifnode2 = new if_node();
|
||||
ifnode2.condition = new bin_expr(new dot_node(new ident("self", ts.source_context), new ident("state", ts.source_context)),
|
||||
new int32_const(lbnum + 2, ts.source_context), Operators.Equal, ts.source_context);
|
||||
///state = -1;
|
||||
var a5 = new assign(new dot_node(new ident("self", ts.source_context),
|
||||
new ident("state", ts.source_context)), new un_expr(new int32_const(1, ts.source_context),
|
||||
Operators.Minus, ts.source_context), Operators.Assignment, ts.source_context);
|
||||
///goto label;
|
||||
var stlist3 = new statement_list(a5, new goto_statement(newLabelName(), ts.source_context), new empty_statement());
|
||||
stlist3.left_logical_bracket = new token_info("begin");
|
||||
stlist3.right_logical_bracket = new token_info("end");
|
||||
ifnode2.then_body = stlist3;
|
||||
ifnode2.then_body.source_context = ts.source_context;
|
||||
ifnode2.source_context = ts.source_context;
|
||||
ts.stmt_list.Add(ifnode2, ts.source_context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
lbnum = 1;
|
||||
awCount = AwaiterCounter;
|
||||
ts.stmt_list.Add(ls, ts.source_context);
|
||||
var mc2 = new method_call();
|
||||
mc2.source_context = ts.source_context;
|
||||
|
||||
// начиная со второго встреченного await
|
||||
while (awCount > 1)
|
||||
{
|
||||
awCount--;
|
||||
var lb2 = newLabelName();
|
||||
var g2 = new goto_statement(lb2, ts.source_context);
|
||||
var ls2 = new labeled_statement(lb2);
|
||||
ls2.source_context = ts.source_context;
|
||||
|
||||
|
||||
mc2 = new method_call();
|
||||
mc2.source_context = ts.source_context;
|
||||
mc2.dereferencing_value = GenGetResult(new ident(awaiter + (lbnum - 1).ToString(), ts.source_context), ts);
|
||||
|
||||
ts.stmt_list.Add(new procedure_call(mc2, ts.source_context), ts.source_context);
|
||||
var tt = code_list.list[lbnum - 1] as statement_list;
|
||||
var fg = true;
|
||||
|
||||
|
||||
foreach (var stat in tt.list)
|
||||
{
|
||||
if (stat is assign && fg)
|
||||
{
|
||||
var asstat = stat as assign;
|
||||
if (asstat.from.ToString().Contains("GetResult"))
|
||||
{
|
||||
asstat.from = mc2;
|
||||
mc2.Parent = asstat;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
fg = false;
|
||||
ts.stmt_list.Add(stat, stat.source_context);
|
||||
}
|
||||
|
||||
extemp = new var_statement(new var_def_statement(new ident(extp + lbnum.ToString(), TaskList[lbnum - 1].source_context),
|
||||
TaskList[lbnum - 1] as expression, TaskList[lbnum - 1].source_context), TaskList[lbnum - 1].source_context);
|
||||
extemp.source_context = TaskList[lbnum - 1].source_context;
|
||||
ts.stmt_list.Add(extemp, TaskList[lbnum - 1].source_context);
|
||||
var mccc = new method_call();
|
||||
mccc.dereferencing_value = new dot_node(new ident(extp + lbnum.ToString(), TaskList[lbnum - 1].source_context),
|
||||
new ident("GetAwaiter", TaskList[lbnum - 1].source_context), TaskList[lbnum - 1].source_context);
|
||||
mccc.source_context = TaskList[lbnum - 1].source_context;
|
||||
|
||||
var assign22_ = new assign(new ident(awaiter + lbnum.ToString(), ts.source_context), mccc, Operators.Assignment, ts.source_context);
|
||||
assign22_.source_context = ts.source_context;
|
||||
assign22_.first_assignment_defines_type = true;
|
||||
|
||||
ts.stmt_list.Add(assign22_, ts.source_context);
|
||||
|
||||
var if3 = new if_node();
|
||||
if3.source_context = ts.source_context;
|
||||
if3.condition = new bin_expr(new dot_node(new ident(awaiter + lbnum.ToString(), ts.source_context),
|
||||
new ident("IsCompleted", ts.source_context)),
|
||||
new ident("False", ts.source_context), Operators.Equal, ts.source_context);
|
||||
|
||||
var a11 = new assign(new dot_node(new ident("self", ts.source_context), new ident("state", ts.source_context)),
|
||||
new int32_const(lbnum + 1), Operators.Assignment, ts.source_context);
|
||||
var temp2 = new var_statement(new var_def_statement
|
||||
(new ident(aw_temp, ts.source_context),
|
||||
new ident("self", ts.source_context), ts.source_context), ts.source_context);
|
||||
var dt1 = new dot_node(new dot_node(new ident("self", ts.source_context),
|
||||
new ident("tbuilder", ts.source_context), ts.source_context),
|
||||
new ident("AwaitUnsafeOnCompleted", ts.source_context), ts.source_context);
|
||||
|
||||
var ex1 = new expression_list(new ident(awaiter + lbnum.ToString(), ts.source_context), ts.source_context);
|
||||
ex1.Add(new ident(aw_temp, ts.source_context), ts.source_context);
|
||||
var mc11 = new method_call(dt1, ex1, ts.source_context);
|
||||
var pc11 = new procedure_call(mc11, ts.source_context);
|
||||
var stlist4 = new statement_list(a11, temp2, pc11, new procedure_call(new ident("exit")), new empty_statement());
|
||||
stlist4.source_context = ts.source_context;
|
||||
stlist4.left_logical_bracket = new token_info("begin");
|
||||
stlist4.right_logical_bracket = new token_info("end");
|
||||
if3.then_body = stlist4;
|
||||
ts.stmt_list.Add(if3, ts.source_context);
|
||||
ts.stmt_list.Add(g2, ts.source_context);
|
||||
ts.stmt_list.Add(ls2, ts.source_context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Когда await закончились и пора выводить результат
|
||||
mc2 = new method_call();
|
||||
mc2.source_context = ts.source_context;
|
||||
mc2.dereferencing_value = GenGetResult(new ident(awaiter + lbnum.ToString(), ts.source_context), ts);
|
||||
|
||||
ts.stmt_list.Add(new procedure_call(mc2, ts.source_context), ts.source_context);
|
||||
var tt2 = code_list.list.Last() as statement_list;
|
||||
var fg2 = true;
|
||||
foreach (var stat in tt2.list)
|
||||
{
|
||||
if (stat is assign && fg2)
|
||||
{
|
||||
var asstat = stat as assign;
|
||||
if (asstat.from.ToString().Contains("GetResult"))
|
||||
{
|
||||
asstat.from = mc2;
|
||||
mc2.Parent = asstat;
|
||||
|
||||
}
|
||||
}
|
||||
fg2 = false;
|
||||
ts.stmt_list.Add(stat, stat.source_context);
|
||||
}
|
||||
|
||||
// Переименование всех переменных класса, находящихся в теле асинхронного метода
|
||||
foreach (var cis in VarsHelper.ClassIdentSet)
|
||||
{
|
||||
var replacerVis = new ReplaceVarNamesVisitor(cis, "@awclass." + cis);
|
||||
ts.visit(replacerVis);
|
||||
if (replacerVis.counter != 0 && proc_def.proc_header.class_keyword)
|
||||
{
|
||||
throw new SyntaxVisitorError("Для нестатического поля, метода или свойства требуется ссылка на объект",
|
||||
ts.source_context);
|
||||
}
|
||||
}
|
||||
// Переименование всех статических переменных класса, находящихся в теле асинхронного метода
|
||||
foreach (var cis in VarsHelper.ClassStaticSet)
|
||||
{
|
||||
var replacerVis = new ReplaceVarNamesVisitor(cis, class_name + "." + cis);
|
||||
ts.visit(replacerVis);
|
||||
}
|
||||
var MethodsSet = new HashSet<string>();
|
||||
if (class_name != null)
|
||||
{
|
||||
foreach (var dec in program_Module.program_block.defs.list)
|
||||
{
|
||||
if (dec is type_declarations)
|
||||
{
|
||||
var td = (type_declarations)dec;
|
||||
|
||||
foreach (var tdeff in td.types_decl)
|
||||
{
|
||||
if (tdeff.type_name.name != class_name.name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (tdeff.type_def is class_definition)
|
||||
{
|
||||
var cd = tdeff.type_def as class_definition;
|
||||
var bd = cd.body;
|
||||
for (int j = 0; j < bd.Count; j++)
|
||||
{
|
||||
if (bd[j] is class_members)
|
||||
{
|
||||
var cm = bd[j] as class_members;
|
||||
foreach (var item in cm.members)
|
||||
{
|
||||
if (item is procedure_header)
|
||||
{
|
||||
|
||||
var pph = item as procedure_header;
|
||||
if (!pph.class_keyword)
|
||||
{
|
||||
MethodsSet.Add(pph.name.meth_name.name);
|
||||
}
|
||||
}
|
||||
if (item is function_header)
|
||||
{
|
||||
var fh = item as function_header;
|
||||
if (!fh.class_keyword)
|
||||
MethodsSet.Add(fh.name.meth_name.name);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in MethodsSet)
|
||||
{
|
||||
var replacerVis = new ReplaceVarNamesVisitor(item, "@awclass." + item);
|
||||
ts.visit(replacerVis);
|
||||
}
|
||||
|
||||
|
||||
// Сохранение результата асинхронного метода
|
||||
if (ResultType != "")
|
||||
{
|
||||
if (ResultVal.Parent == null && ResultVal.Parent == null)
|
||||
{
|
||||
ts.stmt_list.Add(new assign(new ident("@aw_res", ts.source_context),
|
||||
new default_operator(new named_type_reference(ResultType, ts.source_context),
|
||||
ts.source_context), ts.source_context), ts.source_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
var replacerVis = new ReplaceVarNamesVisitor("Result", "@aw_res");
|
||||
ts.visit(replacerVis);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// Генерируем GetResult, заменяя GetResult на GenGetResult
|
||||
public static dot_node GenGetResult(syntax_tree_node stn, syntax_tree_node ts)
|
||||
{
|
||||
if (stn is ident)
|
||||
{
|
||||
return new dot_node(stn as ident, new ident("GetResult"), ts.source_context);
|
||||
}
|
||||
return new dot_node(stn as dot_node, new ident("GetResult"), ts.source_context);
|
||||
}
|
||||
|
||||
// Объявляем локальные переменные полями класса StateMachine
|
||||
public void FillTypedVars(int c)
|
||||
{
|
||||
var tdecl = program_Module.program_block.defs.list[c] as type_declarations;
|
||||
var tdef = tdecl.types_decl[0];
|
||||
var cd = tdef.type_def as class_definition;
|
||||
var bd = cd.body;
|
||||
var cm = bd[1] as class_members;
|
||||
if (ResultType != "")
|
||||
{
|
||||
var r_vds = new var_def_statement(new ident("@aw_res", cm.source_context),
|
||||
new named_type_reference(new ident(ResultType, cm.source_context), cm.source_context), cm.source_context);
|
||||
cm.Add(r_vds);
|
||||
}
|
||||
foreach (var vt in VarsHelper.TasksHash)
|
||||
{
|
||||
var vd = new var_def_statement(new ident_list(), new named_type_reference("string", vt.source_context));
|
||||
foreach (var w in vt.var_def.vars.list)
|
||||
{
|
||||
vd.vars.Add(w, w.source_context);
|
||||
|
||||
}
|
||||
cm.Add(vd);
|
||||
}
|
||||
foreach (var v in VarsHelper.VarsList)
|
||||
{
|
||||
if (VarsHelper.TasksHash.Contains(v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (VarsHelper.NoneTypedVarsList.Contains(v))
|
||||
{
|
||||
var vv = new var_statement();
|
||||
vv.source_context = v.source_context;
|
||||
vv.var_def = new var_def_statement(v.var_def.vars,
|
||||
new named_type_reference(new ident("string", v.source_context), v.source_context), v.source_context);
|
||||
cm.Add(vv.var_def);
|
||||
continue;
|
||||
}
|
||||
cm.Add(v.var_def);
|
||||
}
|
||||
}
|
||||
|
||||
// Удаляем тело асинхронной функции
|
||||
public void DeleteBody()
|
||||
{
|
||||
var b = proc_def.proc_body as block;
|
||||
var st = b.program_code;
|
||||
st.list.Remove(st.list.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
522
SyntaxVisitors/Async/LoweringAsyncVisitor.cs
Normal file
522
SyntaxVisitors/Async/LoweringAsyncVisitor.cs
Normal file
|
|
@ -0,0 +1,522 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
|
||||
public class VarNames
|
||||
{
|
||||
public string VarName { get; set; }
|
||||
public string VarEndName { get; set; }
|
||||
|
||||
public VarNames()
|
||||
{
|
||||
}
|
||||
|
||||
public VarNames(string varName, string varEndName)
|
||||
{
|
||||
VarName = varName;
|
||||
VarEndName = varEndName;
|
||||
}
|
||||
}
|
||||
|
||||
public class LoweringAsyncVisitor : BaseChangeVisitor
|
||||
{
|
||||
public static LoweringAsyncVisitor New
|
||||
{
|
||||
get { return new LoweringAsyncVisitor(); }
|
||||
}
|
||||
|
||||
private int _varnum = 0;
|
||||
private int _foreachCollectionNum = 0;
|
||||
private int _enumeratorNum = 0;
|
||||
|
||||
private VarNames NewVarNames(ident name)
|
||||
{
|
||||
_varnum++;
|
||||
return new VarNames()
|
||||
{
|
||||
VarName = "$" + name.name + _varnum,
|
||||
VarEndName = "<>varLV" + _varnum
|
||||
};
|
||||
}
|
||||
|
||||
private ident NewEnumeratorName()
|
||||
{
|
||||
++_enumeratorNum;
|
||||
return "$enumerator$" + _enumeratorNum;
|
||||
}
|
||||
|
||||
private ident NewForeachCollectionName()
|
||||
{
|
||||
++_foreachCollectionNum;
|
||||
return "$coll$" + _foreachCollectionNum;
|
||||
}
|
||||
public static void Accept(procedure_definition pd)
|
||||
{
|
||||
New.ProcessNode(pd);
|
||||
}
|
||||
|
||||
public override void Enter(syntax_tree_node st)
|
||||
{
|
||||
base.Enter(st);
|
||||
if (!(st is procedure_definition || st is block || st is statement_list
|
||||
|| st.GetType() == typeof(case_node) || st.GetType() == typeof(for_node) || st.GetType() == typeof(foreach_stmt)
|
||||
|| st.GetType() == typeof(if_node)
|
||||
|| st.GetType() == typeof(repeat_node) || st.GetType() == typeof(while_node)
|
||||
|| st.GetType() == typeof(with_statement) || st is try_stmt || st.GetType() == typeof(lock_stmt)))
|
||||
{
|
||||
//visitNode = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void visit(yield_unknown_foreach_type _unk)
|
||||
{
|
||||
// DO NOTHING
|
||||
}
|
||||
|
||||
// frninja 21/05/16
|
||||
public override void visit(foreach_stmt frch)
|
||||
{
|
||||
// Полный код Loweringа c yield_unknown_foreach_type = integer
|
||||
// var a: System.Collections.Generic.IEnumerable<integer>;
|
||||
// a := l;
|
||||
// var en := a.GetEnumerator();
|
||||
// while en.MoveNext do
|
||||
// begin
|
||||
// var curr := en.Current; // var не нужно ставить если curr была описана раньше
|
||||
// Print(curr);
|
||||
// end;
|
||||
///
|
||||
|
||||
// var a: System.Collections.Generic.IEnumerable<yield_unknown_foreach_type> := l;
|
||||
var foreachCollIdent = this.NewForeachCollectionName();
|
||||
var foreachCollType = new template_type_reference(new named_type_reference("System.Collections.Generic.IEnumerable"),
|
||||
new template_param_list(new yield_unknown_foreach_type(frch)));
|
||||
var foreachCollVarDef = new var_statement(foreachCollIdent, foreachCollType);
|
||||
|
||||
var ass = new assign(foreachCollIdent, frch.in_what);
|
||||
|
||||
// var en := a.GetEnumerator();
|
||||
var enumeratorIdent = this.NewEnumeratorName();
|
||||
var enumeratorVarDef = new var_statement(enumeratorIdent, new method_call(new dot_node(foreachCollIdent, new ident("GetEnumerator")), new expression_list()));
|
||||
|
||||
//var curr := en.Current;
|
||||
// Переменная цикла foreach. Есть три варианта:
|
||||
// 1. foreach x in l do -> curr := en.Current;
|
||||
// 2. foreach var x in l do -> var curr := en.Current;
|
||||
// 3. foreach var x: T in l do -> var curr: T := en.Current;
|
||||
var currentIdent = frch.identifier;
|
||||
statement st = null;
|
||||
|
||||
var curExpr = new dot_node(enumeratorIdent, "Current");
|
||||
|
||||
// С типом
|
||||
if (frch.type_name == null) // 1. foreach x in l do -> curr := en.Current;
|
||||
{
|
||||
st = new assign(currentIdent, curExpr);
|
||||
}
|
||||
else if (frch.type_name is no_type_foreach) // 2. foreach var x in l do -> var curr := en.Current;
|
||||
{
|
||||
// Получаем служебное имя с $ и заменяем его в теле цикла
|
||||
currentIdent = this.NewVarNames(frch.identifier).VarName;
|
||||
var replacerVis = new ReplaceVariableNameVisitor(frch.identifier, currentIdent);
|
||||
frch.visit(replacerVis);
|
||||
|
||||
st = new var_statement(currentIdent, curExpr);
|
||||
}
|
||||
else // 3. foreach var x: T in l do -> var curr: T := en.Current;
|
||||
{
|
||||
// Получаем служебное имя с $ и заменяем его в теле цикла
|
||||
currentIdent = this.NewVarNames(frch.identifier).VarName;
|
||||
var replacerVis = new ReplaceVariableNameVisitor(frch.identifier, currentIdent);
|
||||
frch.visit(replacerVis);
|
||||
|
||||
st = new var_statement(currentIdent, frch.type_name, curExpr);
|
||||
}
|
||||
|
||||
// Добавляем тело цикла в stl
|
||||
var stl = new statement_list(st);
|
||||
ProcessNode(frch.stmt); // для обработки вложенных конструкций
|
||||
stl.Add(frch.stmt);
|
||||
|
||||
var whileNode = new while_node(new method_call(new dot_node(enumeratorIdent, "MoveNext"), new expression_list()),
|
||||
stl,
|
||||
WhileCycleType.While);
|
||||
|
||||
var sq = SeqStatements(foreachCollVarDef, ass, enumeratorVarDef, whileNode);
|
||||
|
||||
ReplaceStatement(frch, sq);
|
||||
|
||||
visit(whileNode); // Lowering оставшегося whileNode
|
||||
}
|
||||
|
||||
private expression CreateConditionFromCaseVariant(expression param, expression_list list)
|
||||
{
|
||||
var res = list.expressions.Aggregate(new bool_const(false) as expression, (acc, expr) =>
|
||||
{
|
||||
bin_expr currentExpr = null;
|
||||
diapason_expr diap = expr as diapason_expr;
|
||||
if (diap != null)
|
||||
{
|
||||
currentExpr = new bin_expr(new bin_expr(param, diap.left, Operators.GreaterEqual),
|
||||
new bin_expr(param, diap.right, Operators.LessEqual),
|
||||
Operators.LogicalAND);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentExpr = new bin_expr(param, expr, Operators.Equal);
|
||||
}
|
||||
|
||||
return new bin_expr(acc, currentExpr, Operators.LogicalOR);
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// frninja 30/05/16
|
||||
public override void visit(case_node csn)
|
||||
{
|
||||
//var b = HasStatementVisitor<yield_node>.Has(csn);
|
||||
//if (!b)
|
||||
// return;
|
||||
|
||||
/*
|
||||
*
|
||||
* case i of
|
||||
* cv1: bla1;
|
||||
* cv2: bla2;
|
||||
* ..
|
||||
* cvN: blaN;
|
||||
* else: bla_else;
|
||||
*
|
||||
* --->
|
||||
*
|
||||
* if i satisfy cv1
|
||||
* then bla1
|
||||
* else if i satisfy cv2
|
||||
* then bla2
|
||||
* ..
|
||||
* else if i satisfy cvN
|
||||
* then blaN
|
||||
* else bla_else
|
||||
*
|
||||
*/
|
||||
|
||||
if_node currentIfNode = null;
|
||||
statement currentIfElseClause = (csn.else_statement != null) ? csn.else_statement : new statement_list(new empty_statement()); ;
|
||||
|
||||
for (int i = csn.conditions.variants.Count - 1; i >= 0; --i)
|
||||
{
|
||||
case_variant cv = csn.conditions.variants[i];
|
||||
|
||||
ProcessNode(cv.exec_if_true);
|
||||
|
||||
var ifCondition = this.CreateConditionFromCaseVariant(csn.param, cv.conditions);
|
||||
currentIfNode = new if_node(ifCondition, new statement_list(cv.exec_if_true), new statement_list(currentIfElseClause));
|
||||
currentIfElseClause = currentIfNode;
|
||||
}
|
||||
|
||||
if_node finalIfNode = currentIfNode;
|
||||
|
||||
if (finalIfNode == null) // SSM - значит, в цикл мы не заходили и у case отсутствуют все ветви кроме else - поскольку yieldы в case есть
|
||||
{
|
||||
ReplaceStatement(csn, csn.else_statement);
|
||||
}
|
||||
else
|
||||
ReplaceStatement(csn, finalIfNode);
|
||||
|
||||
if (finalIfNode != null)
|
||||
visit(finalIfNode);
|
||||
}
|
||||
|
||||
public override void visit(if_node ifn)
|
||||
{
|
||||
ProcessNode(ifn.then_body);
|
||||
ProcessNode(ifn.else_body);
|
||||
|
||||
//var b = HasStatementVisitor<yield_node>.Has(ifn);
|
||||
//if (!b)
|
||||
// return;
|
||||
|
||||
var gtAfter = goto_statement.New;
|
||||
var lbAfter = new labeled_statement(gtAfter.label);
|
||||
|
||||
if ((object)ifn.else_body == null)
|
||||
{
|
||||
var if0 = new if_node(un_expr.Not(ifn.condition), gtAfter);
|
||||
//Replace(ifn, SeqStatements(gotoStartIfCondition, ifn.then_body, lbAfter));
|
||||
ReplaceStatementUsingParent(ifn, SeqStatements(if0, ifn.then_body, lbAfter));
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
if (bl.defs is null)
|
||||
bl.defs = new declarations();
|
||||
bl.defs.Add(new label_definitions(gtAfter.label));
|
||||
}
|
||||
else
|
||||
{
|
||||
var gtAlt = goto_statement.New;
|
||||
var lbAlt = new labeled_statement(gtAlt.label, ifn.else_body);
|
||||
|
||||
var if0 = new if_node(un_expr.Not(ifn.condition), gtAlt);
|
||||
|
||||
ReplaceStatementUsingParent(ifn, SeqStatements(if0, ifn.then_body, gtAfter, lbAlt, lbAfter));
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
if (bl.defs is null)
|
||||
bl.defs = new declarations();
|
||||
|
||||
bl.defs.Add(new label_definitions(gtAfter.label, gtAlt.label));
|
||||
}
|
||||
}
|
||||
|
||||
public override void visit(repeat_node rn)
|
||||
{
|
||||
//var b = HasStatementVisitor<yield_node>.Has(rn);
|
||||
//if (!b)
|
||||
// return;
|
||||
|
||||
var gotoContinue = goto_statement.New;
|
||||
var gotoBreak = goto_statement.New;
|
||||
|
||||
ReplaceBreakContinueWithGotoLabelVisitor replaceBreakContinueVis = new ReplaceBreakContinueWithGotoLabelVisitor(gotoContinue, gotoBreak);
|
||||
rn.statements.visit(replaceBreakContinueVis);
|
||||
|
||||
ProcessNode(rn.statements);
|
||||
|
||||
var gotoContinueIfNotCondition = new if_node(un_expr.Not(rn.expr), gotoContinue);
|
||||
var continueLabeledStatement = new labeled_statement(gotoContinue.label, new statement_list(rn.statements, gotoContinueIfNotCondition));
|
||||
|
||||
var breakLabeledStatement = new labeled_statement(gotoBreak.label);
|
||||
|
||||
|
||||
ReplaceStatementUsingParent(rn, SeqStatements(gotoContinue, continueLabeledStatement, breakLabeledStatement));
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
|
||||
if (bl.defs == null)
|
||||
bl.defs = new declarations();
|
||||
|
||||
bl.defs.Add(new label_definitions(gotoContinue.label, gotoBreak.label));
|
||||
|
||||
}
|
||||
|
||||
public override void visit(while_node wn)
|
||||
{
|
||||
//var b = HasStatementVisitor<yield_node>.Has(wn);
|
||||
//if (!b)
|
||||
// return;
|
||||
|
||||
var gotoBreak = goto_statement.New;
|
||||
var gotoContinue = goto_statement.New;
|
||||
|
||||
ReplaceBreakContinueWithGotoLabelVisitor replaceBreakContinueVis = new ReplaceBreakContinueWithGotoLabelVisitor(gotoContinue, gotoBreak);
|
||||
wn.statements.visit(replaceBreakContinueVis);
|
||||
|
||||
ProcessNode(wn.statements);
|
||||
|
||||
statement if0;
|
||||
//if (wn.expr is ident && (wn.expr as ident).name.ToLower() == "true")
|
||||
// if0 = gotoBreak;
|
||||
//else
|
||||
if0 = new if_node(un_expr.Not(wn.expr), gotoBreak);
|
||||
var lb2 = new labeled_statement(gotoContinue.label, if0); // continue
|
||||
var lb1 = new labeled_statement(gotoBreak.label); // break
|
||||
|
||||
ReplaceStatementUsingParent(wn, SeqStatements(lb2, wn.statements, gotoContinue, lb1));
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
|
||||
if (bl.defs == null)
|
||||
bl.defs = new declarations();
|
||||
|
||||
bl.defs.Add(new label_definitions(gotoBreak.label, gotoContinue.label));
|
||||
}
|
||||
|
||||
public override void visit(function_lambda_definition fld)
|
||||
{
|
||||
// Нельзя Lowerить содержимое лямбды !!! Баг #1641!
|
||||
}
|
||||
|
||||
public override void visit(for_node fn)
|
||||
{
|
||||
//var b = HasStatementVisitor<yield_node>.Has(fn);
|
||||
//if (!b)
|
||||
// return;
|
||||
|
||||
var gotoContinue = goto_statement.New;
|
||||
var gotoBreak = goto_statement.New;
|
||||
var gotoStart = goto_statement.New;
|
||||
|
||||
ReplaceBreakContinueWithGotoLabelVisitor replaceBreakContinueVis = new ReplaceBreakContinueWithGotoLabelVisitor(gotoContinue, gotoBreak);
|
||||
fn.statements.visit(replaceBreakContinueVis);
|
||||
|
||||
ProcessNode(fn.statements);
|
||||
|
||||
var newNames = this.NewVarNames(fn.loop_variable);
|
||||
|
||||
var newLoopVar = fn.create_loop_variable ? new ident(newNames.VarName) : fn.loop_variable;
|
||||
|
||||
// Нужно заменить fn.loop_variable -> newLoopVar в теле цикла
|
||||
var replacerVis = new ReplaceVariableNameVisitor(fn.loop_variable, newLoopVar);
|
||||
fn.visit(replacerVis);
|
||||
|
||||
fn.loop_variable = newLoopVar;
|
||||
|
||||
var endtemp = new ident(newNames.VarEndName); //new ident(newVarName());
|
||||
|
||||
//var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value);
|
||||
//var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value);
|
||||
//var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value);
|
||||
|
||||
// Исправления в связи с #1254 (новый алгоритм)
|
||||
// цикл for i:=a to b do
|
||||
// i := a
|
||||
// if i > b then goto break
|
||||
//Start: stmts
|
||||
// if i >= b then goto break
|
||||
//Continue: Inc(i)
|
||||
// goto Start
|
||||
//Break:
|
||||
|
||||
// цикл for i:=a downto b do
|
||||
// i := a
|
||||
// if i < b then goto break
|
||||
//Start: stmts
|
||||
// if i <= b then goto break
|
||||
//Continue: Dec(i)
|
||||
// goto Start
|
||||
//Break:
|
||||
|
||||
// frninja 05/06/16 - фиксим для !fn.create_variable
|
||||
var ass1 = fn.create_loop_variable
|
||||
? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement
|
||||
: new assign(fn.loop_variable, fn.initial_value) as statement;
|
||||
|
||||
var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
bin_expr.Greater(fn.loop_variable, fn.finish_value) :
|
||||
bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak);
|
||||
|
||||
var if1 = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
bin_expr.GreaterEqual(fn.loop_variable, fn.finish_value) :
|
||||
bin_expr.LessEqual(fn.loop_variable, fn.finish_value), gotoBreak);
|
||||
|
||||
var lb1 = new labeled_statement(gotoStart.label);
|
||||
var lb2 = new labeled_statement(gotoBreak.label); // пустой оператор
|
||||
var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ?
|
||||
new ident("Inc") :
|
||||
new ident("Dec"), new expression_list(fn.loop_variable)));
|
||||
|
||||
var lbInc = new labeled_statement(gotoContinue.label, Inc);
|
||||
|
||||
ReplaceStatementUsingParent(fn, SeqStatements(ass1, if0, lb1, fn.statements, if1, lbInc, gotoStart, lb2));
|
||||
|
||||
/*var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
bin_expr.Greater(fn.loop_variable, fn.finish_value) :
|
||||
bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak);
|
||||
|
||||
var lb2 = new labeled_statement(gotoStart.label, if0);
|
||||
var lb1 = new labeled_statement(gotoBreak.label); // пустой оператор
|
||||
var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ?
|
||||
new ident("Inc") :
|
||||
new ident("Dec"), new expression_list(fn.loop_variable)));
|
||||
|
||||
var lbInc = new labeled_statement(gotoContinue.label, Inc);
|
||||
|
||||
ReplaceStatement(fn, SeqStatements(ass1, lb2, fn.statements, lbInc, gotoStart, lb1));*/
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
|
||||
if (bl.defs == null)
|
||||
bl.defs = new declarations();
|
||||
bl.defs.Add(new label_definitions(gotoContinue.label, gotoBreak.label, gotoStart.label));
|
||||
}
|
||||
|
||||
/*
|
||||
public override void visit(for_node fn)
|
||||
{
|
||||
|
||||
* initializer;
|
||||
* goto end;
|
||||
* start:
|
||||
* body;
|
||||
* continue:
|
||||
* increment;
|
||||
* end:
|
||||
* GotoIfTrue condition start;
|
||||
* break:
|
||||
|
||||
|
||||
|
||||
var b = HasStatementVisitor<yield_node>.Has(fn);
|
||||
if (!b)
|
||||
return;
|
||||
|
||||
var gotoStart = goto_statement.New;
|
||||
var gotoEnd = goto_statement.New;
|
||||
var gotoStart = goto_statement.New;
|
||||
var gotoBreak = goto_statement.New;
|
||||
|
||||
ReplaceBreakContinueWithGotoLabelVisitor replaceBreakContinueVis = new ReplaceBreakContinueWithGotoLabelVisitor(gotoStart, gotoBreak);
|
||||
fn.statements.visit(replaceBreakContinueVis);
|
||||
|
||||
ProcessNode(fn.statements);
|
||||
|
||||
|
||||
var newNames = this.NewVarNames(fn.loop_variable);
|
||||
|
||||
var newLoopVar = fn.create_loop_variable ? new ident(newNames.VarName) : fn.loop_variable;
|
||||
|
||||
// Нужно заменить fn.loop_variable -> newLoopVar в теле цикла
|
||||
var replacerVis = new ReplaceVariableNameVisitor(fn.loop_variable, newLoopVar);
|
||||
fn.visit(replacerVis);
|
||||
|
||||
fn.loop_variable = newLoopVar;
|
||||
|
||||
var endtemp = new ident(newNames.VarEndName); //new ident(newVarName());
|
||||
|
||||
//var initializer = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value);
|
||||
//var initializer = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value);
|
||||
//var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value);
|
||||
|
||||
// frninja 05/06/16 - фиксим для !fn.create_variable
|
||||
var initializer = fn.create_loop_variable
|
||||
? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement
|
||||
: new assign(fn.loop_variable, fn.initial_value) as statement;
|
||||
|
||||
|
||||
var gotoStartIfCondition = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
new bin_expr(fn.loop_variable, fn.finish_value, Operators.LessEqual) :
|
||||
new bin_expr(fn.loop_variable, fn.finish_value, Operators.GreaterEqual), gotoStart);
|
||||
|
||||
var endLabeledStatement = new labeled_statement(gotoEnd.label, gotoStartIfCondition);
|
||||
var startLabeledStatement = new labeled_statement(gotoStart.label, fn.statements);
|
||||
var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ?
|
||||
new ident("Inc") :
|
||||
new ident("Dec"), new expression_list(fn.loop_variable)));
|
||||
|
||||
var continueLabeledStatement = new labeled_statement(gotoStart.label, Inc);
|
||||
var breakLabeledStatement = new labeled_statement(gotoBreak.label);
|
||||
|
||||
ReplaceStatement(fn, SeqStatements(initializer, gotoEnd, startLabeledStatement, continueLabeledStatement, endLabeledStatement, breakLabeledStatement));
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
|
||||
bl.defs.Add(new label_definitions(gotoStart.label, gotoEnd.label, gotoStart.label, gotoBreak.label));
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
31
SyntaxVisitors/Async/MainVisitor.cs
Normal file
31
SyntaxVisitors/Async/MainVisitor.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
internal class MainVisitor :BaseChangeVisitor
|
||||
{
|
||||
// Визитор, который проверяет, есть ли хоть
|
||||
// один await в асинхронном методе
|
||||
public static bool HasAwait = false;
|
||||
public static MainVisitor New
|
||||
{
|
||||
get { return new MainVisitor(); }
|
||||
}
|
||||
public static void Accept(statement_list st)
|
||||
{
|
||||
New.ProcessNode(st);
|
||||
}
|
||||
public static void Accept(procedure_definition pd)
|
||||
{
|
||||
New.ProcessNode(pd);
|
||||
}
|
||||
public override void visit(await_node_statement ans)
|
||||
{
|
||||
HasAwait = true;
|
||||
}
|
||||
public override void visit(await_node aw)
|
||||
{
|
||||
HasAwait = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
103
SyntaxVisitors/Async/OperationsVisitor.cs
Normal file
103
SyntaxVisitors/Async/OperationsVisitor.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
// Визитор, который заменяет все await
|
||||
// на await.GetResult
|
||||
internal class OperationsVisitor : BaseChangeVisitor
|
||||
{
|
||||
public static bool HasAwait = false;
|
||||
public string ExprType = "";
|
||||
public static OperationsVisitor New
|
||||
{
|
||||
get { return new OperationsVisitor(); }
|
||||
}
|
||||
|
||||
public static void Accept(if_node if_nd)
|
||||
{
|
||||
if (if_nd == null)
|
||||
return;
|
||||
if (if_nd.condition[0] is bin_expr)
|
||||
{
|
||||
New.ProcessNode(if_nd.condition[0] as bin_expr);
|
||||
return;
|
||||
}
|
||||
if (if_nd.condition is bin_expr)
|
||||
{
|
||||
New.ProcessNode(if_nd.condition as bin_expr);
|
||||
return;
|
||||
}
|
||||
if (if_nd.condition is un_expr)
|
||||
{
|
||||
New.ProcessNode(if_nd.condition);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
public static void Accept(var_def_statement vds)
|
||||
{
|
||||
if (vds == null)
|
||||
return;
|
||||
if (vds.inital_value is bin_expr)
|
||||
{
|
||||
New.ProcessNode(vds.inital_value as bin_expr);
|
||||
}
|
||||
if (vds.inital_value is un_expr)
|
||||
{
|
||||
New.ProcessNode(vds.inital_value as un_expr);
|
||||
}
|
||||
|
||||
}
|
||||
public static void Accept(assign a)
|
||||
{
|
||||
if (a == null)
|
||||
return;
|
||||
New.ProcessNode(a.from);
|
||||
}
|
||||
|
||||
public override void visit(un_expr un_Expr)
|
||||
{
|
||||
ProcessNode(un_Expr.subnode);
|
||||
}
|
||||
public override void visit(bin_expr b_epxr)
|
||||
{
|
||||
ExprType = "left";
|
||||
ProcessNode(b_epxr.left);
|
||||
ExprType = "right";
|
||||
ProcessNode(b_epxr.right);
|
||||
}
|
||||
public override void visit(await_node a)
|
||||
{
|
||||
if (a.Parent == null)
|
||||
return;
|
||||
var mmc = new method_call();
|
||||
mmc.source_context = a.source_context;
|
||||
if (a.ex is method_call)
|
||||
mmc.dereferencing_value = AwaitBuilder.GenGetResult(new dot_node(a.ex as method_call,
|
||||
new ident("GetAwaiter", a.source_context)),a);
|
||||
else
|
||||
mmc.dereferencing_value = AwaitBuilder.GenGetResult(new dot_node(new ident(a.ex.ToString(), a.source_context),
|
||||
new ident("GetAwaiter", a.source_context)), a);
|
||||
if (a.Parent is bin_expr)
|
||||
{
|
||||
if (ExprType == "left")
|
||||
(a.Parent as bin_expr).left = mmc;
|
||||
if (ExprType == "right")
|
||||
(a.Parent as bin_expr).right = mmc;
|
||||
}
|
||||
if (a.Parent is un_expr)
|
||||
{
|
||||
(a.Parent as un_expr).subnode = mmc;
|
||||
}
|
||||
if (a.Parent is assign)
|
||||
{
|
||||
(a.Parent as assign).from = mmc;
|
||||
}
|
||||
HasAwait = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
SyntaxVisitors/Async/ReplaceVarNamesVisitor.cs
Normal file
32
SyntaxVisitors/Async/ReplaceVarNamesVisitor.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
public class ReplaceVarNamesVisitor: BaseChangeVisitor
|
||||
{
|
||||
private string _oldName;
|
||||
private string _newName;
|
||||
public int counter = 0;
|
||||
|
||||
public ReplaceVarNamesVisitor(ident oldName, ident newName)
|
||||
{
|
||||
_oldName = oldName.name;
|
||||
_newName = newName.name;
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
public override void visit(ident id)
|
||||
{
|
||||
if (id.name == _oldName)
|
||||
{
|
||||
id.name = _newName;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
public override void visit(try_stmt tr)
|
||||
{
|
||||
ProcessNode(tr.stmt_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
85
SyntaxVisitors/Async/VarsHelper.cs
Normal file
85
SyntaxVisitors/Async/VarsHelper.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SyntaxVisitors.Async
|
||||
{
|
||||
// Класс для работы с переменными
|
||||
public class VarsHelper
|
||||
{
|
||||
// Множество всех переменных, находящихся в данном асинхронном методе
|
||||
public HashSet<var_statement> VarsList = new HashSet<var_statement>();
|
||||
|
||||
// Множество всех явно типизированных переменных
|
||||
public HashSet<var_statement> TypedVarsList = new HashSet<var_statement>();
|
||||
|
||||
// Множество всех неявно типизированных переменных
|
||||
public HashSet<var_statement> NoneTypedVarsList = new HashSet<var_statement>();
|
||||
|
||||
// Множество всех параметров асинхронного метода
|
||||
public HashSet<string> Parametrs = new HashSet<string>();
|
||||
|
||||
// Множество переменных, находящихся внутри await
|
||||
public HashSet<string> ExprHash = new HashSet<string>();
|
||||
|
||||
// Множество переменных, являющихся Task<T>
|
||||
public HashSet<var_statement> TasksHash = new HashSet<var_statement>();
|
||||
|
||||
// Словарик переменных, которые нужно переименовать
|
||||
public Dictionary<string,string> RepVarsDict = new Dictionary<string,string>();
|
||||
|
||||
// Список переменных класса
|
||||
public HashSet<string> ClassIdentSet = new HashSet<string>();
|
||||
|
||||
// Список статических переменных класса
|
||||
public HashSet<string> ClassStaticSet = new HashSet<string>();
|
||||
|
||||
// Словарик переменных, являющихся Task<T>
|
||||
public Dictionary<string, string> TaskIdents = new Dictionary<string, string>();
|
||||
|
||||
int LabelNameCounter = 0;
|
||||
public string newLabelName(string old)
|
||||
{
|
||||
LabelNameCounter++;
|
||||
return "@awvar@_" + LabelNameCounter.ToString() +"_" + old;
|
||||
}
|
||||
// Добавляем новую переменную, которую нужно будет переименовать
|
||||
public void AddNewRep(var_statement var_Statement)
|
||||
{
|
||||
foreach (var v in var_Statement.var_def.vars.list)
|
||||
if (!RepVarsDict.ContainsKey(v.name))
|
||||
{
|
||||
if (v.name.StartsWith("@"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var nv = newLabelName(v.name);
|
||||
|
||||
RepVarsDict.Add(v.name, nv);
|
||||
v.name = nv;
|
||||
}
|
||||
}
|
||||
// Помечаем какими являются переменные, чтобы знать
|
||||
// что делать с ними дальше
|
||||
public void MarkVars()
|
||||
{
|
||||
foreach (var var in VarsList)
|
||||
{
|
||||
var v = var.var_def;
|
||||
if (v.vars_type != null)
|
||||
TypedVarsList.Add(var);
|
||||
else
|
||||
NoneTypedVarsList.Add(var);
|
||||
var vd = var.var_def;
|
||||
if (ExprHash.Contains(vd.vars.list[0].name))
|
||||
{
|
||||
TasksHash.Add(var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,14 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AllVarsInProcYieldsProba.cs" />
|
||||
<Compile Include="Async\AsyncBuilder.cs" />
|
||||
<Compile Include="Async\AsyncVisitor.cs" />
|
||||
<Compile Include="Async\AwaitBuilder.cs" />
|
||||
<Compile Include="Async\OperationsVisitor.cs" />
|
||||
<Compile Include="Async\LoweringAsyncVisitor.cs" />
|
||||
<Compile Include="Async\MainVisitor.cs" />
|
||||
<Compile Include="Async\ReplaceVarNamesVisitor.cs" />
|
||||
<Compile Include="Async\VarsHelper.cs" />
|
||||
<Compile Include="BaseSyntaxTreeConverter.cs" />
|
||||
<Compile Include="BaseVisitors\CollectNamespaces.cs" />
|
||||
<Compile Include="BaseVisitors\HasStatementVisitor.cs" />
|
||||
|
|
|
|||
|
|
@ -111,10 +111,42 @@ function MatrRandomReal(m: integer; n: integer): array [,] of real;
|
|||
|
||||
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры
|
||||
function ReadInteger(prompt: string): integer;
|
||||
/// Выводит приглашение к вводу и возвращает два значения типа integer, введенные с клавиатуры
|
||||
function ReadInteger2(prompt: string): (integer, integer);
|
||||
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры
|
||||
function ReadlnInteger(prompt: string): integer;
|
||||
/// Выводит приглашение к вводу и возвращает два значения типа integer, введенные с клавиатуры
|
||||
function ReadInteger2(prompt: string): (integer, integer);
|
||||
/// Выводит приглашение к вводу и возвращает два значения типа integer, введенные с клавиатуры
|
||||
function ReadlnInteger2(prompt: string): (integer, integer);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа integer, введенные с клавиатуры
|
||||
function ReadInteger3(prompt: string): (integer, integer, integer);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа integer, введенные с клавиатуры
|
||||
function ReadlnInteger3(prompt: string): (integer, integer, integer);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа integer, введенные с клавиатуры
|
||||
function ReadInteger4(prompt: string): (integer, integer, integer, integer);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа integer, введенные с клавиатуры
|
||||
function ReadlnInteger4(prompt: string): (integer, integer, integer, integer);
|
||||
|
||||
/// Выводит приглашение к вводу и возвращает значение типа real, введенное с клавиатуры
|
||||
function ReadReal(prompt: string): real;
|
||||
/// Выводит приглашение к вводу и возвращает значение типа real, введенное с клавиатуры
|
||||
function ReadlnReal(prompt: string): real;
|
||||
/// Выводит приглашение к вводу и возвращает два значения типа real, введенные с клавиатуры
|
||||
function ReadReal2(prompt: string): (real, real);
|
||||
/// Выводит приглашение к вводу и возвращает два значения типа real, введенные с клавиатуры
|
||||
function ReadlnReal2(prompt: string): (real, real);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа real, введенные с клавиатуры
|
||||
function ReadReal3(prompt: string): (real, real, real);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа real, введенные с клавиатуры
|
||||
function ReadlnReal3(prompt: string): (real, real, real);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа real, введенные с клавиатуры
|
||||
function ReadReal4(prompt: string): (real, real, real, real);
|
||||
/// Выводит приглашение к вводу и возвращает три значения типа real, введенные с клавиатуры
|
||||
function ReadlnReal4(prompt: string): (real, real, real, real);
|
||||
|
||||
/// Выводит приглашение к вводу и возвращает значение типа char, введенное с клавиатуры
|
||||
function ReadChar(prompt: string): char;
|
||||
/// Выводит приглашение к вводу и возвращает значение типа char, введенное с клавиатуры
|
||||
function ReadlnChar(prompt: string): char;
|
||||
|
||||
/// Выводит приглашение к вводу и возвращает значение типа string, введенное с клавиатуры
|
||||
function ReadString(prompt: string): string;
|
||||
|
|
@ -169,7 +201,10 @@ procedure CheckInput(a: array of System.Type);
|
|||
procedure CheckOutput(params arr: array of object);
|
||||
/// Проверить значения при выводе. Сообщения ColoredMessage гасить. Нужно для повторных вызовов CheckOutput
|
||||
procedure CheckOutputSilent(params arr: array of object);
|
||||
|
||||
/// Проверить значения при выводе
|
||||
procedure CheckOutput(a: ObjectList);
|
||||
/// Проверить значения при выводе. Сообщения ColoredMessage гасить. Нужно для повторных вызовов CheckOutput
|
||||
procedure CheckOutputSilent(a: ObjectList);
|
||||
|
||||
/// Проверить, что данные не вводились
|
||||
procedure CheckInputIsEmpty;
|
||||
|
|
@ -520,7 +555,7 @@ procedure GenerateTests<T1,T2,T3>(params a: array of (T1,T2,T3));
|
|||
{=========================================================}
|
||||
{ Фильтрация выходного списка }
|
||||
{=========================================================}
|
||||
/// Преобразование строк, являющихся целыми, в целые в OutputList
|
||||
/// Преобразование строк и символов, являющихся числами, в числа в OutputList
|
||||
procedure ConvertStringsToNumbersInOutputList;
|
||||
/// Если в OutputList массивы, вытянуть их в единый список
|
||||
procedure FlattenOutput;
|
||||
|
|
@ -943,7 +978,8 @@ begin
|
|||
end;
|
||||
|
||||
/// надо ли пополнять список ввода в функциях, используемых для ввода
|
||||
function NeedAddDataToInputList: boolean := IsLightPT and ((TestMode = tmNone) or (TestMode = tmAutoTest));
|
||||
function NeedAddDataToInputList: boolean
|
||||
:= IsLightPT and ((TestMode = tmNone) or (TestMode = tmAutoTest));
|
||||
|
||||
/// Полный путь к папке auth-файла
|
||||
function FindAuthDat: string;
|
||||
|
|
@ -1395,6 +1431,13 @@ begin
|
|||
else if s.TryToReal(rval) then
|
||||
Result := rval
|
||||
end
|
||||
else if ob is char then
|
||||
begin
|
||||
var s := ''+char(ob);
|
||||
var ival: integer;
|
||||
if s.TryToInteger(ival) then
|
||||
Result := ival
|
||||
end
|
||||
end;
|
||||
|
||||
procedure ConvertStringsToNumbersInOutputList;
|
||||
|
|
@ -1720,6 +1763,11 @@ end;
|
|||
/// Возвращает случайное целое в диапазоне от a до b
|
||||
function Random(a, b: integer): integer;
|
||||
begin
|
||||
// Есть три состояния:
|
||||
// 1. Вызов в основной программе (первый запуск) - TestMode = tmNone
|
||||
// 2. Вызов в основной программе (последующие запуски) - TestMode = tmTest
|
||||
// 3. Вызов в функции GenerateTestData - TestMode = tmGenTest - тогда срабатывает обычная ArrRandomInteger
|
||||
// как и в случае 1.
|
||||
if TestMode = tmTest then
|
||||
Result := InputList.ReadTestDataInt // считать следующее данное из заполненного в GenTestMode InputList
|
||||
else Result := PABCSystem.Random(a, b);
|
||||
|
|
@ -1885,17 +1933,13 @@ begin
|
|||
// Есть три состояния:
|
||||
// 1. Вызов в основной программе (первый запуск) - TestMode = tmNone
|
||||
// 2. Вызов в основной программе (последующие запуски) - TestMode = tmTest
|
||||
// 3. Вызов в функции GenerateTestData - TestMode = tmGenTest - это только в состоянии TestMode = True
|
||||
{if GenTest then
|
||||
begin
|
||||
Result := PABCSystem.ArrRandomInteger(n, a, b); // приходится вызывать дважды!
|
||||
exit;
|
||||
end;}
|
||||
// 3. Вызов в функции GenerateTestData - TestMode = tmGenTest - тогда срабатывает обычная ArrRandomInteger
|
||||
// как и в случае 1.
|
||||
if TestMode = tmTest then
|
||||
Result := InputList.ReadTestDataIntArr(n)
|
||||
else Result := PABCSystem.ArrRandomInteger(n, a, b);
|
||||
|
||||
if NeedAddDataToInputList then // IsLightPT and (TestMode = tmNone)
|
||||
if NeedAddDataToInputList then // IsLightPT and ((TestMode = tmNone) or (TestMode = tmAutoTest))
|
||||
for var i:=0 to n-1 do
|
||||
InputList.Add(Result[i]);
|
||||
end;
|
||||
|
|
@ -1945,46 +1989,131 @@ begin
|
|||
InputList.Add(x);
|
||||
end;
|
||||
|
||||
/// Возвращает двумерный массив размера m x n, заполненный случайными вещественными значениями
|
||||
function MatrRandomReal(m: integer; n: integer): array [,] of real := MatrRandomReal(m,n,0,10);
|
||||
|
||||
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры
|
||||
procedure ReadRemainderAction;
|
||||
begin
|
||||
if not IsPT then
|
||||
begin
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
CreateNewLineBeforeMessage := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ReadInteger(prompt: string): integer;
|
||||
begin
|
||||
Result := PABCSystem.ReadInteger(prompt);
|
||||
if IsPT then exit;
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
CreateNewLineBeforeMessage := False;
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры
|
||||
function ReadlnInteger(prompt: string): integer;
|
||||
begin
|
||||
Result := PABCSystem.ReadlnInteger(prompt);
|
||||
if IsPT then exit;
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
CreateNewLineBeforeMessage := False;
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
/// Выводит приглашение к вводу и возвращает два значения типа integer, введенные с клавиатуры
|
||||
function ReadInteger2(prompt: string): (integer, integer);
|
||||
begin
|
||||
Result := PABCSystem.ReadInteger2(prompt);
|
||||
if IsPT then exit;
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
CreateNewLineBeforeMessage := False;
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnInteger2(prompt: string): (integer,integer);
|
||||
begin
|
||||
Result := PABCSystem.ReadlnInteger2(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadInteger3(prompt: string): (integer,integer,integer);
|
||||
begin
|
||||
Result := PABCSystem.ReadInteger3(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnInteger3(prompt: string): (integer,integer,integer);
|
||||
begin
|
||||
Result := PABCSystem.ReadlnInteger3(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadInteger4(prompt: string): (integer, integer,integer,integer);
|
||||
begin
|
||||
Result := PABCSystem.ReadInteger4(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnInteger4(prompt: string): (integer,integer,integer,integer);
|
||||
begin
|
||||
Result := PABCSystem.ReadlnInteger4(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadReal(prompt: string): real;
|
||||
begin
|
||||
Result := PABCSystem.ReadReal(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnReal(prompt: string): real;
|
||||
begin
|
||||
Result := PABCSystem.ReadlnReal(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadReal2(prompt: string): (real, real);
|
||||
begin
|
||||
Result := PABCSystem.ReadReal2(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnReal2(prompt: string): (real, real);
|
||||
begin
|
||||
Result := PABCSystem.ReadlnReal2(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadReal3(prompt: string): (real, real, real);
|
||||
begin
|
||||
Result := PABCSystem.ReadReal3(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnReal3(prompt: string): (real, real, real);
|
||||
begin
|
||||
Result := PABCSystem.ReadlnReal3(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadReal4(prompt: string): (real, real, real, real);
|
||||
begin
|
||||
Result := PABCSystem.ReadReal4(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnReal4(prompt: string): (real, real, real, real);
|
||||
begin
|
||||
Result := PABCSystem.ReadlnReal4(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadChar(prompt: string): char;
|
||||
begin
|
||||
Result := PABCSystem.ReadChar(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnChar(prompt: string): char;
|
||||
begin
|
||||
Result := PABCSystem.ReadlnChar(prompt);
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
|
||||
function ReadString(prompt: string): string;
|
||||
begin
|
||||
Result := PABCSystem.ReadString(prompt);
|
||||
if IsPT then exit;
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
OutputList.RemoveAt(OutputList.Count - 1);
|
||||
CreateNewLineBeforeMessage := False;
|
||||
ReadRemainderAction;
|
||||
end;
|
||||
|
||||
function ReadlnString(prompt: string) := ReadString(prompt);
|
||||
|
|
@ -2139,23 +2268,44 @@ begin
|
|||
CreateNewLineBeforeMessage := False;
|
||||
end;
|
||||
|
||||
procedure CheckOutputHelper(i0: integer; params arr: array of object);
|
||||
procedure OutputTestResult;
|
||||
function FlattenElement(x: object): List<object>;
|
||||
begin
|
||||
var res := new List<object>;
|
||||
if x is string then
|
||||
res.Add(x)
|
||||
else if x is IEnumerable<object> (var xen) then
|
||||
foreach var ob in xen do
|
||||
res.AddRange(FlattenElement(ob))
|
||||
else if x is System.Collections.IEnumerable (var xx) then
|
||||
begin
|
||||
ColoredMessage($'Основной запуск верный',MsgColorGray);
|
||||
ColoredMessage($'Ошибочное решение на тесте:',MsgColorOrange);
|
||||
ColoredMessage($'Тестовые данные : {InputList.JoinToString}',MsgColorGray);
|
||||
ColoredMessage($'Полученный результат : {OutputList.JoinToString}',MsgColorGray);
|
||||
if i0 = 0 then
|
||||
ColoredMessage($'Правильный результат : {arr.JoinToString}',MsgColorGray)
|
||||
else ColoredMessage($'Правильный результат : {(OutputList[:i0]+arr).JoinToString}',MsgColorGray)
|
||||
end;
|
||||
var en := xx.GetEnumerator;
|
||||
while en.MoveNext do
|
||||
res.Add(en.Current)
|
||||
end
|
||||
else res.Add(x);
|
||||
Result := res;
|
||||
end;
|
||||
|
||||
procedure OutputTestResult(i0: integer; arr: array of object);
|
||||
begin
|
||||
ColoredMessage($'Основной запуск верный',MsgColorGray);
|
||||
ColoredMessage($'Ошибочное решение на тесте:',MsgColorOrange);
|
||||
ColoredMessage($'Тестовые данные : {InputList.JoinToString}',MsgColorGray);
|
||||
ColoredMessage($'Полученный результат : {OutputList.JoinToString}',MsgColorGray);
|
||||
if i0 = 0 then
|
||||
ColoredMessage($'Правильный результат : {arr.JoinToString}',MsgColorGray)
|
||||
else ColoredMessage($'Правильный результат : {(OutputList[:i0]+arr).JoinToString}',MsgColorGray)
|
||||
end;
|
||||
|
||||
procedure CheckOutputHelper(i0: integer; params arr: array of object);
|
||||
begin
|
||||
if (TaskResult = InitialTask) and CancelMessagesIfInitial
|
||||
or (TaskResult = BadInitialTask) then
|
||||
exit;
|
||||
|
||||
|
||||
// SSM 28.06.24 - вытягиваем в линию выходные данные
|
||||
arr := arr.SelectMany(x -> FlattenElement(x)).ToArray;
|
||||
|
||||
// Если мы попали сюда, то OutputList.Count >= InitialOutputList.Count
|
||||
var mn := Min(arr.Length, OutputList.Count - i0);
|
||||
|
||||
|
|
@ -2167,7 +2317,7 @@ begin
|
|||
then
|
||||
begin
|
||||
if TestNumber > 0 then
|
||||
OutputTestResult
|
||||
OutputTestResult(i0,arr)
|
||||
else
|
||||
begin
|
||||
if i > InitialOutputList.Count then
|
||||
|
|
@ -2181,7 +2331,7 @@ begin
|
|||
if i >= InitialOutputList.Count then // ? Если первое данное неправильное - всё равно попадаем сюда!!!
|
||||
begin
|
||||
if TestNumber > 0 then
|
||||
OutputTestResult
|
||||
OutputTestResult(i0,arr)
|
||||
else
|
||||
begin
|
||||
if i > InitialOutputList.Count then
|
||||
|
|
@ -2199,7 +2349,7 @@ begin
|
|||
if arr.Length <> OutputList.Count - i0 then
|
||||
begin
|
||||
if TestNumber > 0 then
|
||||
OutputTestResult
|
||||
OutputTestResult(i0,arr)
|
||||
else
|
||||
if OutputList.Count > 0 then begin
|
||||
if arr.Length > OutputList.Count - i0 then // выведено меньше чем надо
|
||||
|
|
@ -2218,6 +2368,8 @@ begin
|
|||
CheckOutputHelper(0,arr);
|
||||
end;
|
||||
|
||||
procedure CheckOutput(a: ObjectList) := CheckOutputSeq(a);
|
||||
|
||||
procedure CheckOutputSilent(params arr: array of object);
|
||||
begin
|
||||
Silent := True;
|
||||
|
|
@ -2225,6 +2377,8 @@ begin
|
|||
Silent := False;
|
||||
end;
|
||||
|
||||
procedure CheckOutputSilent(a: ObjectList) := CheckOutputSeqSilent(a);
|
||||
|
||||
procedure CheckOutputAfterInitial(params arr: array of object);
|
||||
begin
|
||||
CheckOutputHelper(InitialOutputList.Count,arr);
|
||||
|
|
@ -2311,7 +2465,7 @@ type
|
|||
IntAr2 = array [,] of integer;
|
||||
RealAr2 = array [,] of real;
|
||||
|
||||
function FlattenElement(x: object): List<object>;
|
||||
{function FlattenElement(x: object): List<object>;
|
||||
begin
|
||||
var lst := new List<object>;
|
||||
if x is IntAr (var iarr) then
|
||||
|
|
@ -2328,7 +2482,7 @@ begin
|
|||
lst.AddRange(lrarr.Select(x -> object(x)))
|
||||
else lst.Add(x);
|
||||
Result := lst;
|
||||
end;
|
||||
end;}
|
||||
|
||||
procedure FlattenOutput;
|
||||
begin
|
||||
|
|
@ -2634,6 +2788,7 @@ begin
|
|||
TName := ConvertTaskName(TaskName);
|
||||
TestMode := tmNone;
|
||||
TestNumber := 0;
|
||||
FlattenOutput; // SSM 28.06.24
|
||||
CheckTask(TName); // может выдавать сообщения, предваряющие неверное решение, в CheckOutput.
|
||||
if {not IsPT and not IsRobot and not IsDrawMan and} (TestCount > 0) then // То это LightPT - т.к. только в LightPT TestCount м.б. > 0
|
||||
begin
|
||||
|
|
@ -2660,6 +2815,7 @@ begin
|
|||
//InputList := InputList;
|
||||
//OutputList := OutputList;
|
||||
|
||||
FlattenOutput; // SSM 28.06.24 - и перед каждым тестом
|
||||
CheckTask(TName);
|
||||
if TaskResult = BadSolution then
|
||||
break; // хоть один тест неудачный - выходим!
|
||||
|
|
|
|||
|
|
@ -1430,24 +1430,26 @@ function ParamStr(i: integer): string;
|
|||
/// Возвращает текущий каталог
|
||||
function GetDir: string;
|
||||
/// Меняет текущий каталог
|
||||
procedure ChDir(s: string);
|
||||
procedure ChDir(dirName: string);
|
||||
/// Создает каталог
|
||||
procedure MkDir(s: string);
|
||||
procedure MkDir(dirName: string);
|
||||
/// Удаляет каталог
|
||||
procedure RmDir(s: string);
|
||||
procedure RmDir(dirName: string);
|
||||
|
||||
/// Создает каталог. Возвращает True, если каталог успешно создан
|
||||
function CreateDir(s: string): boolean;
|
||||
function CreateDir(dirName: string): boolean;
|
||||
/// Удаляет файл. Если файл не может быть удален, то возвращает False
|
||||
function DeleteFile(fname: string): boolean;
|
||||
function DeleteFile(fileName: string): boolean;
|
||||
/// Возвращает текущий каталог
|
||||
function GetCurrentDir: string;
|
||||
/// Удаляет каталог. Возвращает True, если каталог успешно удален
|
||||
function RemoveDir(s: string): boolean;
|
||||
function RemoveDir(dirName: string): boolean;
|
||||
/// Переименовывает файл fileName, давая ему новое имя newfileName. Возвращает True, если файл успешно переименован
|
||||
function RenameFile(fileName, newfileName: string): boolean;
|
||||
/// Переименовывает каталог dirName, давая ему новое имя newDirName. Возвращает True, если каталог успешно переименован
|
||||
function RenameDirectory(dirName, newDirName: string): boolean;
|
||||
/// Устанавливает текущий каталог. Возвращает True, если каталог успешно удален
|
||||
function SetCurrentDir(s: string): boolean;
|
||||
function SetCurrentDir(dirName: string): boolean;
|
||||
|
||||
/// Изменяет расширение файла с именем fileName на newExt
|
||||
function ChangeFileNameExtension(fileName, newExt: string): string;
|
||||
|
|
@ -1462,9 +1464,9 @@ procedure Assert(cond: boolean; sourceFile: string := ''; line: integer := 0);
|
|||
procedure Assert(cond: boolean; message: string; sourceFile: string := ''; line: integer := 0);
|
||||
|
||||
/// Возвращает свободное место в байтах на диске с именем diskname
|
||||
function DiskFree(diskname: string): int64;
|
||||
function DiskFree(diskName: string): int64;
|
||||
/// Возвращает размер в байтах на диске с именем diskname
|
||||
function DiskSize(diskname: string): int64;
|
||||
function DiskSize(diskName: string): int64;
|
||||
/// Возвращает свободное место в байтах на диске disk. disk=0 - текущий диск, disk=1 - диск A: , disk=2 - диск B: и т.д.
|
||||
function DiskFree(disk: integer): int64;
|
||||
/// Возвращает размер в байтах на диске disk. disk=0 - текущий диск, disk=1 - диск A: , disk=2 - диск B: и т.д.
|
||||
|
|
@ -5213,7 +5215,34 @@ begin
|
|||
raise new System.ArgumentException('step = 0');
|
||||
if (step > 0) and (b < a) or (step < 0) and (b > a) then
|
||||
exit;
|
||||
var n := Round(Abs(b - a) / step);
|
||||
if a = b then
|
||||
begin
|
||||
yield a;
|
||||
exit;
|
||||
end;
|
||||
// SSM 30/06/24
|
||||
// Шкалируем [a,b] к отрезку [0,1]
|
||||
var stepScaled := decimal(step) / (decimal(a) - decimal(b));
|
||||
if stepScaled < 0 then
|
||||
stepScaled := -stepScaled;
|
||||
// Находим n - количество частей (левая точка последней части может не входить)
|
||||
var n := decimal.ToInt32(decimal.Round(1/stepScaled));
|
||||
//Println('-->',stepScaled,n);
|
||||
// Возможны 3 ситуации:
|
||||
// 1) - stepScaled * n < 1 - 1e-14 - тогда надо делать n+1 шаг
|
||||
// 2) - stepScaled * n и диапазоне [1 - 1e-14, 1 + 1e-14] - тогда надо делать n+1 шаг и последнюю точку примагничивать к b
|
||||
// 3) - stepScaled * n > 1 + 1e-14 - тогда надо делать n шагов
|
||||
// Сделаем n шагов, а потом решим, делать ли последний шаг
|
||||
for var i:=0 to n-1 do
|
||||
yield a + i * step; // нельзя просто прибавлять step - при больших a,b они просто не будут меняться
|
||||
var delta := decimal(1e-14); // относительная погрешность относительно 1
|
||||
if (stepScaled * n >= 1 - delta) and (stepScaled * n <= 1 + delta) then
|
||||
yield b // вернуть ровно b - то, ради чего всё затевалось
|
||||
else if stepScaled * n < 1 - delta then
|
||||
yield a + n * step; // что ж, step задан неверно и мы "не долетаем" до b
|
||||
// Если "перелетаем" b, то ничего и не возвращаем на конце
|
||||
// Старый алгоритм
|
||||
{var n := Round(Abs(b - a) / step);
|
||||
var delta := n / Abs(b - a) * 1e-14;
|
||||
var bplus := b + delta;
|
||||
var bminus := b - delta;
|
||||
|
|
@ -5236,7 +5265,7 @@ begin
|
|||
end;
|
||||
if a > bminus then
|
||||
yield b;
|
||||
end
|
||||
end}
|
||||
end;
|
||||
|
||||
function ArrRandom(n: integer; a: integer; b: integer): array of integer;
|
||||
|
|
@ -8459,41 +8488,41 @@ begin
|
|||
Result := Environment.CurrentDirectory;
|
||||
end;
|
||||
|
||||
procedure ChDir(s: string);
|
||||
procedure ChDir(dirName: string);
|
||||
begin
|
||||
Environment.CurrentDirectory := s;
|
||||
Environment.CurrentDirectory := dirName;
|
||||
end;
|
||||
|
||||
procedure MkDir(s: string);
|
||||
procedure MkDir(dirName: string);
|
||||
begin
|
||||
Directory.CreateDirectory(s);
|
||||
Directory.CreateDirectory(dirName);
|
||||
end;
|
||||
|
||||
procedure RmDir(s: string);
|
||||
procedure RmDir(dirName: string);
|
||||
begin
|
||||
Directory.Delete(s);
|
||||
Directory.Delete(dirName);
|
||||
end;
|
||||
|
||||
function CreateDir(s: string): boolean;
|
||||
function CreateDir(dirName: string): boolean;
|
||||
begin
|
||||
try
|
||||
Result := True;
|
||||
Directory.CreateDirectory(s);
|
||||
Directory.CreateDirectory(dirName);
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DeleteFile(fname: string): boolean;
|
||||
function DeleteFile(fileName: string): boolean;
|
||||
begin
|
||||
if not &File.Exists(fname) then
|
||||
if not &File.Exists(fileName) then
|
||||
begin
|
||||
Result := False;
|
||||
exit
|
||||
end;
|
||||
try
|
||||
Result := True;
|
||||
&File.Delete(fname);
|
||||
&File.Delete(fileName);
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
|
|
@ -8504,11 +8533,11 @@ begin
|
|||
Result := Environment.CurrentDirectory;
|
||||
end;
|
||||
|
||||
function RemoveDir(s: string): boolean;
|
||||
function RemoveDir(dirName: string): boolean;
|
||||
begin
|
||||
try
|
||||
Result := True;
|
||||
Directory.Delete(s);
|
||||
Directory.Delete(dirName);
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
|
|
@ -8524,11 +8553,21 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function SetCurrentDir(s: string): boolean;
|
||||
function RenameDirectory(dirName, newDirName: string): boolean;
|
||||
begin
|
||||
try
|
||||
Result := True;
|
||||
Environment.CurrentDirectory := s;
|
||||
Directory.Move(dirName, newDirName);
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function SetCurrentDir(dirName: string): boolean;
|
||||
begin
|
||||
try
|
||||
Result := True;
|
||||
Environment.CurrentDirectory := dirName;
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
|
|
@ -8596,7 +8635,7 @@ begin
|
|||
System.Diagnostics.Contracts.Contract.Assert(cond,'Файл '+sourceFile+', строка '+line.ToString() + ': ' + message)
|
||||
end;
|
||||
|
||||
function DiskFree(diskname: string): int64;
|
||||
function DiskFree(diskName: string): int64;
|
||||
begin
|
||||
try
|
||||
var d := new System.IO.DriveInfo(diskname);
|
||||
|
|
@ -8606,7 +8645,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function DiskSize(diskname: string): int64;
|
||||
function DiskSize(diskName: string): int64;
|
||||
begin
|
||||
try
|
||||
var d := new System.IO.DriveInfo(diskname);
|
||||
|
|
@ -13743,6 +13782,23 @@ begin
|
|||
Result := Self.Split(delims.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
end;
|
||||
|
||||
/// Преобразует многострочную строку в массив строк
|
||||
function ToLines(Self: string): array of string; extensionmethod;
|
||||
begin
|
||||
Result := Self.Split(|
|
||||
#13#10, // CR+LF: Win
|
||||
#10, // LF: Linux
|
||||
#13 // CR: Mac
|
||||
// https://en.m.wikipedia.org/wiki/Newline#Unicode
|
||||
// But standard .Net things like System.IO.StringReader don't support these, so for now - commented out
|
||||
// #11, // Vertical Tab
|
||||
// #12, // Form feed
|
||||
// char($85), // Next Line
|
||||
// char($2028), // Line Separator
|
||||
// char($2029), // Paragraph SeparatorS
|
||||
|, System.StringSplitOptions.None);
|
||||
end;
|
||||
|
||||
procedure PassSpaces(var s: string; var from: integer);
|
||||
begin
|
||||
while (from <= s.Length) and char.IsWhiteSpace(s[from]) do
|
||||
|
|
|
|||
|
|
@ -1126,8 +1126,11 @@ begin
|
|||
FillRectangle(0,0,1280,1024);
|
||||
Pen.RoundCap := True;
|
||||
|
||||
LoadIni(settings);
|
||||
MainForm.Invoke(SetWindowBounds, new System.Drawing.Rectangle(settings.Left,settings.Top,settings.Width,settings.Height));
|
||||
try
|
||||
LoadIni(settings);
|
||||
MainForm.Invoke(SetWindowBounds, new System.Drawing.Rectangle(settings.Left,settings.Top,settings.Width,settings.Height));
|
||||
except
|
||||
end;
|
||||
|
||||
//var (sw,sh) := ScreenSize;
|
||||
MainForm.Invoke(InitControls);
|
||||
|
|
|
|||
|
|
@ -6,50 +6,43 @@ var AllTaskNames: array of string;
|
|||
|
||||
procedure CheckTaskT(name: string);
|
||||
begin
|
||||
FlattenOutput;
|
||||
ClearOutputListFromSpaces;
|
||||
case name of
|
||||
'Arr0': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(Arr(5,4,3,2,1,777,5,4,3,2,1,777));
|
||||
CheckOutput(5,4,3,2,1,777,5,4,3,2,1,777);
|
||||
end;
|
||||
'Arr1': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(Arr(777,1,1,1,777));
|
||||
CheckOutput(777,1,1,1,777);
|
||||
end;
|
||||
'Arr2': begin
|
||||
var n := 5;
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Input := |cInt|*n);
|
||||
CheckData(Input := cInt*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il.Select(x->x+1));
|
||||
CheckOutput(il.Select(x->x+1));
|
||||
end;
|
||||
'Arr3': begin
|
||||
var n := 5;
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Input := |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il.Select(x->x*2));
|
||||
CheckOutput(il.Select(x->x*2));
|
||||
end;
|
||||
'Arr4': begin
|
||||
var n := 10;
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Input := |cInt|*n);
|
||||
CheckData(Input := cInt*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il+il.Select(x->x*x));
|
||||
CheckOutput(il+il.Select(x->x*x));
|
||||
end;
|
||||
'Arr5': begin
|
||||
var n := 10;
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Input := |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
CheckData(Input := cInt*n);
|
||||
GenerateTests(10, tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il+il.Reverse);
|
||||
CheckOutput(il, il.Reverse);
|
||||
end;
|
||||
'ArrErr1': begin
|
||||
TaskResult := TaskStatus.ErrFix
|
||||
|
|
@ -59,88 +52,79 @@ begin
|
|||
end;
|
||||
'Arr1Sum': begin
|
||||
var n := 10;
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Input := |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
CheckData(Input := cInt*n);
|
||||
GenerateTests(10, tInt*n);
|
||||
var il := InputListAsIntegers.Select(x->x*0.1);
|
||||
CheckOutputSeq(il+il.Sum);
|
||||
CheckOutput(il, il.Sum);
|
||||
end;
|
||||
'Arr2Prod': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
ClearOutputListFromSpaces;
|
||||
CancelMessagesIfInitial := False; // !
|
||||
var n := 8;
|
||||
CheckData(|cRe|*n, |cRe|*n);
|
||||
GenerateTests(10,tRe(1,10,1)*n);
|
||||
CheckData(cRe*n, cRe*n);
|
||||
GenerateTests(10, tRe(1,10,1)*n);
|
||||
var il := ReArr(n).Select(x->x);
|
||||
CheckOutputAfterInitial(il.Product);
|
||||
end;
|
||||
'Arr1_If': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
ClearOutputListFromSpaces;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il+il.Where(x->x.IsEven));
|
||||
CheckOutput(il, il.Where(x->x.IsEven));
|
||||
end;
|
||||
'Arr2_If': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
ClearOutputListFromSpaces;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il+il.Where((x,i)->i.IsOdd));
|
||||
CheckOutput(il, il.Where((x,i)->i.IsOdd));
|
||||
end;
|
||||
'Arr0_Count': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
ClearOutputListFromSpaces;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := IntArr(n);
|
||||
CheckOutputSeq(il+il.Count(x->x.IsOdd));
|
||||
CheckOutput(il, il.Count(x->x.IsOdd));
|
||||
end;
|
||||
'Arr1_Sum': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := InputList.Count;
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := InputListAsIntegers.Where(x->x in 3..5).ToArray;
|
||||
CheckOutputSeq(InputListAsIntegers+il+il.sum);
|
||||
GenerateTests(10, tInt*n);
|
||||
var a := IntArr(n);
|
||||
var il := a.Where(x->x in 3..5).ToArray;
|
||||
CheckOutput(a, il, il.sum);
|
||||
end;
|
||||
'Arr2_Count': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := InputList.Count;
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := InputListAsIntegers;
|
||||
CheckOutputSeq(il+il.CountOf(2)+il.CountOf(3)+il.CountOf(4)+il.CountOf(5));
|
||||
GenerateTests(10, tInt*n);
|
||||
var a := IntArr(n);
|
||||
CheckOutput(a, a.CountOf(2), a.CountOf(3), a.CountOf(4), a.CountOf(5));
|
||||
end;
|
||||
'Arr1_MinMax': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := InputList.Count;
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := InputListAsIntegers;
|
||||
CheckOutputSeq(il+il.Min);
|
||||
GenerateTests(10, tInt*n);
|
||||
var a := IntArr(n);
|
||||
CheckOutput(a, a.Min);
|
||||
end;
|
||||
'Arr2_MinMax': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := InputList.Count;
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := InputListAsIntegers;
|
||||
CheckOutputSeq(il+il.Max);
|
||||
var a := IntArr(n);
|
||||
CheckOutput(a, a.Max);
|
||||
end;
|
||||
'Arr3_MinMax': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := InputList.Count;
|
||||
GenerateTests(10,tInt*n);
|
||||
var il := InputListAsIntegers;
|
||||
CheckOutputSeq(il+il.IndexMin);
|
||||
var a := IntArr(n);
|
||||
CheckOutput(a, a.IndexMin);
|
||||
end;
|
||||
'ПоискВМассиве': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var a := InputListAsIntegers;
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt*n);
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitial(5 in a);
|
||||
end;
|
||||
'ПоискВМассивеСтрок': begin
|
||||
|
|
@ -152,52 +136,52 @@ begin
|
|||
end;
|
||||
'Заполнение1': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(Arr(0,1,4,9,16,25,36,49,64,81));
|
||||
CheckOutput(0,1,4,9,16,25,36,49,64,81);
|
||||
end;
|
||||
'Заполнение2Арифм': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(10,1,x->x+2));
|
||||
CheckOutput(ArrGen(10,1,x->x+2));
|
||||
end;
|
||||
'Заполнение3Арифм': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(10,1,x->x+2));
|
||||
CheckOutput(ArrGen(10,1,x->x+2));
|
||||
end;
|
||||
'Заполнение4Арифм': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(10,1.0,x->x+0.5));
|
||||
CheckOutput(ArrGen(10,1.0,x->x+0.5));
|
||||
end;
|
||||
'Заполнение1Геом': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(10,1,x->x*2));
|
||||
CheckOutput(ArrGen(10,1,x->x*2));
|
||||
end;
|
||||
'ЗаполнениеЧисламиФибоначчи': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(10,1,1,(x,y)->x+y));
|
||||
CheckOutput(ArrGen(10,1,1,(x,y)->x+y));
|
||||
end;
|
||||
'СоседниеЭлементы1': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var a := IntArr(n);
|
||||
var ol := new ObjectList;
|
||||
ol.AddRange(a.Pairwise.Where(\(x,y)->x<y).Select(t->t[1]));
|
||||
CheckOutputAfterInitialSeq(ol);
|
||||
CheckOutputAfterInitial(ol);
|
||||
end;
|
||||
'СоседниеЭлементы2': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt*n);
|
||||
var a := InputListAsIntegers;
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt*n);
|
||||
var a := IntArr(n);
|
||||
var ol := new ObjectList;
|
||||
ol.AddRange(a);
|
||||
ol.Add(a.Pairwise.Where(\(x,y)->x<y).Count);
|
||||
CheckOutputSeq(ol);
|
||||
CheckOutput(ol);
|
||||
end;
|
||||
'ИнвертированиеМассива1': begin
|
||||
var n := 7;
|
||||
CheckData(InitialOutput := |cStr|*n);
|
||||
var a := OutSliceStrArr(0,n-1);
|
||||
CheckOutputSeq(a + a.Reverse);
|
||||
CheckOutput(a + a.Reverse);
|
||||
end;
|
||||
'ИнвертированиеМассива2': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
|
|
@ -213,15 +197,16 @@ begin
|
|||
end;
|
||||
var a := IntArr(n);
|
||||
var ares := a.Reverse.ToArray;
|
||||
CheckOutputAfterInitialSeq(ares);
|
||||
CheckOutputAfterInitial(ares);
|
||||
end;
|
||||
'СтрокаКакМассив1': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
CheckData(InitialOutput := |cStr|*2);
|
||||
CheckOutputSeq(Arr('бочка','ночка','дочка','кочка','почка','точка'));
|
||||
CheckOutput('бочка','ночка','дочка','кочка','почка','точка');
|
||||
end;
|
||||
'СтрокаКакМассив2': begin
|
||||
CheckOutputSeq(Arr('миг','мир','пир','пар'));
|
||||
CheckData(Empty);
|
||||
CheckOutput('миг','мир','пир','пар');
|
||||
end;
|
||||
'СтрокаКакМассив3': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
|
|
@ -234,13 +219,13 @@ begin
|
|||
CheckOutputSeq(ol);
|
||||
end;
|
||||
'СтрокаКакМассив4': begin
|
||||
CheckData(Empty);
|
||||
CheckOutput(True);
|
||||
end;
|
||||
'СтрокаКакМассив5': begin
|
||||
CheckOutputSeq(Arr('абракадабра','эбрэкэдэбрэ'));
|
||||
CheckData(Empty);
|
||||
CheckOutput('абракадабра','эбрэкэдэбрэ');
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ begin
|
|||
CheckOutput(3,32);
|
||||
end;
|
||||
'Var_2': begin
|
||||
CheckData(InitialOutput := |cInt|*2);
|
||||
CheckData(InitialOutput := cInt*2);
|
||||
CheckOutput(3,4,20,45);
|
||||
end;
|
||||
'Var_4': begin
|
||||
|
|
@ -34,7 +34,7 @@ begin
|
|||
end;
|
||||
'Calculations2': begin
|
||||
CheckData(InitialOutput := |cInt,cInt,cStr,cInt|);
|
||||
CheckOutput(35,65,cStr,35+65,cStr,35*65);
|
||||
CheckOutput(35,65,cStr,35+65,cStr,35*65); // Это круто - можно перемежать типы и значения!
|
||||
end;
|
||||
'Calculations3': begin
|
||||
CheckData(InitialOutput := |cStr,cInt,cInt,cInt|);
|
||||
|
|
@ -61,7 +61,7 @@ begin
|
|||
TestCount := 10;
|
||||
GenerateTests(10, tRe(1,10,digits := 0)*2);
|
||||
CheckOutputSilent(S,P); // Все сообщения ColoredMessage гасятся
|
||||
if TaskResult <> Solved then
|
||||
if TaskResult <> Solved then // Это прикольный способ - проверить, что вывел то, но не в том порядке!
|
||||
CheckOutput(P,S);
|
||||
end;
|
||||
'Task1': begin
|
||||
|
|
@ -107,7 +107,7 @@ begin
|
|||
begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(InitialOutput := |cInt, cInt|);
|
||||
CheckOutputSeq(Arr(1..9));
|
||||
CheckOutput(Arr(1..9));
|
||||
end;
|
||||
'AssignAdd2':
|
||||
begin
|
||||
|
|
@ -167,13 +167,13 @@ begin
|
|||
begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Input := Empty);
|
||||
// Просто поясняющее сообщение
|
||||
// Просто поясняющее сообщение. Ничего не проверяется
|
||||
ColoredMessage('Abs - функция, убирающая знак числа. В математике известна как модуль числа', MsgColorGray);
|
||||
end;
|
||||
'Abs_2_AB':
|
||||
begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(InitialOutput := |cInt| * 6);
|
||||
CheckData(InitialOutput := cInt * 6);
|
||||
CheckOutput(5,3,2,-1,5,6,7,4,3,9,18,9);
|
||||
end;
|
||||
'SwapProc1':
|
||||
|
|
@ -209,7 +209,7 @@ begin
|
|||
CheckData(Input := Empty);
|
||||
if OutputList.Count = 6 then
|
||||
begin
|
||||
if CompareValues(OutputList[0],37) then
|
||||
if CompareValues(OutputList[0],37) then // Здесь используется CompareValues, а не CompareWithOutput т к логика сложнее
|
||||
ColoredMessage('Измените значение a на 123', MsgColorGray)
|
||||
else if CompareValues(OutputList[0],123) then
|
||||
ColoredMessage('Верно. Проверьте еще значение a = 12345', MsgColorGray)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ begin
|
|||
|
||||
case name of
|
||||
'Types1': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Empty);
|
||||
CheckOutput(cInt,cRe,cStr);
|
||||
end;
|
||||
|
|
@ -50,8 +49,8 @@ begin
|
|||
end;
|
||||
'If1Пароль': begin
|
||||
CheckData(InitialInput := |cInt|);
|
||||
//if int(0)=777 then
|
||||
CheckOutput('Пароль правильный');
|
||||
//if int(0)=777 then // и без этого работает. Тёмное дело...
|
||||
CheckOutput('Пароль правильный'); // Когда по одной ветке ничего не выводится, это сложная ситуация. Это не проконтролируешь
|
||||
end;
|
||||
'If2Пароль': begin
|
||||
CheckData(Input := |cInt|);
|
||||
|
|
@ -87,7 +86,9 @@ begin
|
|||
else CheckOutput(Int(0),'Нечетное');
|
||||
end;
|
||||
'If5ЛогинПарольAnd': begin
|
||||
CancelMessagesIfInitial := False;
|
||||
CancelMessagesIfInitial := False; // Это важнейший флаг.
|
||||
// Обычно если запускается программа с Initial вводом-выводом, то подсказки не выводятся
|
||||
// А здесь выводятся - ученика сразу настраивают, что ему надо вывести
|
||||
CheckData(InitialInput := |cStr,cInt|);
|
||||
TestCount := 10;
|
||||
GenerateTestData := tnum -> begin
|
||||
|
|
@ -95,7 +96,7 @@ begin
|
|||
var p := Arr(777,666,555).RandomElement;
|
||||
if tnum = 5 then
|
||||
(a,p) := ('Angel',777);
|
||||
InputList.AddTestData(|object(a),object(p)|);
|
||||
InputList.AddTestData(|object(a),object(p)|); // Приведение к object - это приём, позволяющий записывать в тестовые данные разные типы
|
||||
end;
|
||||
if (Str(0) = 'Angel') and (Int(1) = 777) then
|
||||
CheckOutput('Вход разрешен')
|
||||
|
|
@ -197,7 +198,7 @@ begin
|
|||
end;
|
||||
'Minmax_2': begin
|
||||
CheckData(InitialOutput := |cInt|);
|
||||
CheckOutputSeq(Arr(3,5,3,5,6,6));
|
||||
CheckOutput(3,5,3,5,6,6);
|
||||
end;
|
||||
'ВложенныеIf2': begin
|
||||
CheckData(Input := |cStr,cInt|);
|
||||
|
|
@ -258,7 +259,7 @@ begin
|
|||
case Str(0) of
|
||||
'черное' : CheckOutput('белое');
|
||||
'высокий': begin
|
||||
CheckOutputSilent('низкий');
|
||||
CheckOutputSilent('низкий'); // о это прикольно. Это когда возможны несколько решений. Вначале проверяем одно, потом другое
|
||||
if TaskResult = TaskStatus.BadSolution then
|
||||
CheckOutput('невысокий');
|
||||
end;
|
||||
|
|
@ -299,7 +300,7 @@ begin
|
|||
var (d,m) := (Int(0),Int(1));
|
||||
//GenerateTests(список кортежей)
|
||||
//GenerateTests(список значений)
|
||||
GenerateTests((1,1),(23,2),(8,3),(1,5),(9,5),(12,6),(4,11),(12,12),(7,13));
|
||||
GenerateTests((1,1),(12,12),(23,2),(8,3),(1,5),(9,5),(12,6),(4,11),(7,13));
|
||||
if (d,m) = (1,1) then
|
||||
CheckOutput('Новый год')
|
||||
else if (d,m) = (23,2) then
|
||||
|
|
@ -314,11 +315,11 @@ begin
|
|||
CheckOutput('День России')
|
||||
else if (d,m) = (4,11) then
|
||||
CheckOutput('День народного единства')
|
||||
else CheckOutput('');
|
||||
//else CheckOutput('');
|
||||
end;
|
||||
'IfXSituations2': begin
|
||||
CheckData(Input := |cInt|);
|
||||
GenerateTests(-2,-1,0,1,2);
|
||||
GenerateTests(2,3,4,5,6);
|
||||
if Int(0) < 3 then
|
||||
CheckOutput('x меньше 3')
|
||||
else if Int(0) in 3..5 then
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ begin
|
|||
|
||||
case name of
|
||||
'LoopErr2': begin
|
||||
TaskResult := ErrFix;
|
||||
TaskResult := ErrFix; // Это задача на исправление ошибок. Откомпилировалась 1 раз - и внеслась в базу
|
||||
if OutputString.ToString = '*' then
|
||||
ColoredMessage('Сотри ; после do!',MsgColorGray);
|
||||
if OutputString.ToString = '*'*50 then
|
||||
|
|
@ -24,48 +24,43 @@ begin
|
|||
ColoredMessage('Молодец! Если в цикле - несколько действий, окайми их операторными скобками begin-end',MsgColorGray);
|
||||
end;
|
||||
'Loop_Arithm1': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckOutputAfterInitialSeq(ArrGen(n,1,i->i+2));
|
||||
CheckOutputAfterInitial(ArrGen(n,1,i->i+2));
|
||||
end;
|
||||
'Loop_Arithm2': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Input := Empty);
|
||||
var sq := ObjectList.New.AddArithm(10,19,-2).AddArithm(9,1.1,0.1);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'For1': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
TaskResult := InitialTask;
|
||||
ColoredMessage('Что лучше в данном случае: цикл loop или цикл for?',msgColorGray);
|
||||
end;
|
||||
'For1a': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
var sq := ObjectList.New.AddArithm(10,2,2).AddArithm(10,2,2);
|
||||
CheckOutputSeq(sq);
|
||||
var sq := ObjectList.New.AddArithm(n,2,2).AddArithm(n,2,2);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'For1b': begin
|
||||
ClearOutputListFromSpaces;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
var sq := ObjectList.New.AddArithm(10,1,2).AddArithm(10,1,2);
|
||||
CheckOutputSeq(sq);
|
||||
var sq := ObjectList.New.AddArithm(n,1,2).AddArithm(n,1,2);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'For1b_step': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
var sq := ObjectList.New.AddArithm(10,2,2).AddArithm(10,1,2);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'For1c': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
var sq := ObjectList.New.AddArithm(11,15,-1);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'For1d': begin
|
||||
ClearOutputListFromSpaces;
|
||||
|
|
@ -77,13 +72,13 @@ begin
|
|||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
var sq := ObjectList.New.AddArithm(10,5,5).AddArithm(7,40,-4);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'For1f': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
var sq := ObjectList.New.AddArithm(9,1.9,-0.1).AddArithm(9,1.9,-0.1);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'ForErr1': begin
|
||||
TaskResult := ErrFix; // Задание на исправление ошибок
|
||||
|
|
@ -121,35 +116,30 @@ begin
|
|||
'Tabl1': begin
|
||||
CheckData(InitialOutput := |cInt|*20);
|
||||
var sq := (1..10).SelectMany(x -> |x,x*x,x*x*x|);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'Tabl2': begin
|
||||
CheckData(Empty);
|
||||
var sq := (1..10).SelectMany(x -> |object(x),object(sqrt(x))|); // приводим к object поскольку типы разные
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'Tabl4': begin
|
||||
CheckData(Empty);
|
||||
var sq := PartitionPoints(1.1,1.9,8).SelectMany(x -> |x,x*x|);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'Sum1': begin
|
||||
FilterOnlyNumbers;
|
||||
// Частичные решения не проработаны. Они крайне редки конечно
|
||||
TaskResult := PartialSolution; // Решение состоит в последовательном решении нескольких родственных задач
|
||||
FilterOnlyNumbers;
|
||||
//CheckInitialOutputValues(55);
|
||||
if (OutputList.Count = 1) and OutIsInt(0) then
|
||||
begin
|
||||
var a := OutInt(0);
|
||||
if a=4905 then
|
||||
ColoredMessage('Отлично! Теперь найдите сумму квадратов всех двузначных чисел', MsgColorGray)
|
||||
else if a=328065 then
|
||||
TaskResult := Solved;
|
||||
end;
|
||||
if CompareValuesWithOutput(4905) then // CompareValuesWithOutput используется именно для частичного решения
|
||||
ColoredMessage('Отлично! Теперь найдите сумму квадратов всех двузначных чисел', MsgColorGray)
|
||||
else if CompareValuesWithOutput(328065) then
|
||||
TaskResult := Solved;
|
||||
end;
|
||||
'Sum1a': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Input := |cInt|*2);
|
||||
CheckData(Input := cInt*2);
|
||||
var (a,b) := (Int(0),Int(1));
|
||||
TestCount := 10;
|
||||
GenerateTestData := tnum -> begin
|
||||
|
|
@ -177,6 +167,8 @@ begin
|
|||
'Prod1': begin
|
||||
TaskResult := PartialSolution;
|
||||
FilterOnlyNumbers;
|
||||
// CompareValuesWithOutput - более низкоуровневая чем CheckOutput
|
||||
// Она просто сравнивает значения с выводом и возвращает True/False
|
||||
if CompareValuesWithOutput(3*3*3*3*3*3*3) then
|
||||
ColoredMessage('Вычислите 4 в степени 6', MsgColorGray)
|
||||
else if CompareValuesWithOutput(4*4*4*4*4*4) then
|
||||
|
|
@ -200,7 +192,7 @@ begin
|
|||
FilterOnlyNumbers;
|
||||
CheckData(InitialOutput := |cInt|*11);
|
||||
var sq := ObjectList.New.AddGeom(15,1,3);
|
||||
CheckOutputAfterInitialSeq(sq);
|
||||
CheckOutputAfterInitial(sq);
|
||||
end;
|
||||
'Geom2': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -209,7 +201,7 @@ begin
|
|||
sq.Add(integer.MaxValue);
|
||||
if OutputList.Count = 11 then
|
||||
ColoredMessage('Выведите integer.MaxValue - самое большое целое типа integer',MsgColorMagenta);
|
||||
CheckOutputSeqNew(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'Geom3': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -218,13 +210,13 @@ begin
|
|||
sq.Add(real.MaxValue);
|
||||
if OutputList.Count = 20 then
|
||||
ColoredMessage('Выведите real.MaxValue - самое большое целое типа real',MsgColorMagenta);
|
||||
CheckOutputSeqNew(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'Geom4': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Empty);
|
||||
var sq := ObjectList.New.AddGeom(8,1.0,0.999);
|
||||
CheckOutputSeq(sq);
|
||||
CheckOutput(sq);
|
||||
end;
|
||||
'Loop_If_1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -233,7 +225,7 @@ begin
|
|||
GenerateTests(10,tInt(1,100)*n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputSeq(a.Where(x->x.IsEven));
|
||||
CheckOutput(a.Where(x->x.IsEven));
|
||||
end;
|
||||
'Loop_If_2': begin
|
||||
var n := 10;
|
||||
|
|
@ -253,7 +245,7 @@ begin
|
|||
for var i:=0 to n-1 do
|
||||
if Int(i) in 10..99 then
|
||||
lst.Add(Int(i));
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'Loop_If_2a': begin
|
||||
var n := 10;
|
||||
|
|
@ -263,7 +255,7 @@ begin
|
|||
for var i:=0 to n-1 do
|
||||
if Int(i).Divs(3) and Int(i).NotDivs(5) then
|
||||
lst.Add(Int(i));
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'Loop_If_3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -274,7 +266,7 @@ begin
|
|||
for var i:=1 to n do
|
||||
if i.IsEven then
|
||||
lst.Add(Int(i-1));
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'Loop_If_4': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -285,7 +277,7 @@ begin
|
|||
for var i:=0 to n-1 do
|
||||
if Int(i).IsEven then
|
||||
lst.Add(i+1);
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'Loop_If_5_Count': begin
|
||||
var n := 10;
|
||||
|
|
@ -312,8 +304,8 @@ begin
|
|||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(Input := |cInt|*n);
|
||||
var c := 0;
|
||||
GenerateTests(10,tInt(1,10)*n);
|
||||
var c := 0;
|
||||
for var i:=0 to n-1 do
|
||||
if Int(i) not in 2..5 then
|
||||
c += 1;
|
||||
|
|
@ -345,7 +337,14 @@ begin
|
|||
FilterOnlyNumbersAndBools;
|
||||
var N := Int(0);
|
||||
CheckData(Input := |cInt|*(N+1));
|
||||
GenerateTests(10,tInt(1,10)*n);
|
||||
|
||||
TestCount := 5;
|
||||
GenerateTestData := tnum -> begin
|
||||
var N := Random(5, 10);
|
||||
var a := ArrRandomInteger(N,1,10);
|
||||
InputList.AddTestData(|N|+a);
|
||||
end;
|
||||
|
||||
var s := 0;
|
||||
for var i:=1 to N do
|
||||
if Int(i).IsEven then
|
||||
|
|
@ -362,7 +361,7 @@ begin
|
|||
FilterOnlyNumbers;
|
||||
CheckData(InitialOutput := |cInt|*18);
|
||||
|
||||
CheckOutputSeq(Arr(1..9)*3);
|
||||
CheckOutput(Arr(1..9)*3);
|
||||
end;
|
||||
'Wh2': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -372,7 +371,7 @@ begin
|
|||
'Wh3': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(45,99,x->x-2));
|
||||
CheckOutput(ArrGen(45,99,x->x-2));
|
||||
end;
|
||||
'Дюймы1': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -393,7 +392,6 @@ begin
|
|||
'Дюймы4': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Input := cRe * 2);
|
||||
CheckData(Input := cRe * 2);
|
||||
CheckOutput(Re(0) - Trunc(Re(0)/Re(1)));
|
||||
end;
|
||||
'Sum1W': begin
|
||||
|
|
@ -414,7 +412,7 @@ begin
|
|||
'Умножение1': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(14,1,x->x*2));
|
||||
CheckOutput(ArrGen(14,1,x->x*2));
|
||||
end;
|
||||
'Умножение2': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -424,11 +422,11 @@ begin
|
|||
'Деление1': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(6,26.5,x->x/2));
|
||||
CheckOutput(ArrGen(6,26.5,x->x/2));
|
||||
end;
|
||||
'Деление2': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckInitialOutputSeq(Arr(cInt)*0);
|
||||
CheckData(Empty);
|
||||
CheckOutput(7);
|
||||
end;
|
||||
'Digits': begin
|
||||
|
|
@ -439,7 +437,7 @@ begin
|
|||
'Bank_ForLeaders': begin
|
||||
FilterOnlyNumbers;
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(ArrGen(9,109000.0,x->x*1.09));
|
||||
CheckOutput(ArrGen(9,109000.0,x->x*1.09));
|
||||
end;
|
||||
'Digits1': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -492,7 +490,7 @@ begin
|
|||
L.Add(x mod 2);
|
||||
x := x div 2;
|
||||
end;
|
||||
CheckOutputSeq(L.ToArray);
|
||||
CheckOutput(L);
|
||||
end;
|
||||
'BinNumSystem2': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -518,23 +516,24 @@ begin
|
|||
end;
|
||||
'Min1': begin
|
||||
CheckData(InitialInput := |cRe|*2);
|
||||
Generatetests(10,tRe(1,100)*2);
|
||||
GenerateTests(10,tRe(1,100)*2);
|
||||
CheckOutput(Min(Re(0),Re(1)),Max(Re(0),Re(1)));
|
||||
end;
|
||||
'Min2': begin
|
||||
CheckData(InitialInput := |cRe|*2);
|
||||
Generatetests(10,tRe(1,100)*2);
|
||||
GenerateTests(10,tRe(1,100)*2);
|
||||
CheckOutput(Min(Re(0),Re(1)));
|
||||
end;
|
||||
'Min3': begin
|
||||
CheckData(InitialInput := |cRe|*3);
|
||||
Generatetests(10,tRe(1,100)*3);
|
||||
GenerateTests(10,tRe(1,100)*3);
|
||||
CheckOutput(Min(Re(0),Re(1),Re(2)));
|
||||
end;
|
||||
'SeriesMin2': begin
|
||||
var n := 10;
|
||||
CheckData(Input := |cInt|*n);
|
||||
GenerateTests(10,tInt(1,100)*n);
|
||||
// Лучше var a := IntArr(n)
|
||||
CheckOutput(InputListAsIntegers.Max - InputListAsIntegers.Min)
|
||||
end;
|
||||
'Break1': begin
|
||||
|
|
@ -615,9 +614,9 @@ begin
|
|||
if x < 5 then
|
||||
c += 1;
|
||||
until False;
|
||||
TestCount := 10;
|
||||
TestCount := 10; // Это немного неудобно - надо не забыть присвоить!
|
||||
GenerateTestData := tnum -> begin
|
||||
var n := Random(7,12);
|
||||
var n := Random(7,12); // Разобраться, как работает в Test mode
|
||||
var a := ArrRandomInteger(n,1,10);
|
||||
a[^1] := 0;
|
||||
InputList.AddTestData(a);
|
||||
|
|
@ -635,6 +634,7 @@ begin
|
|||
c += x;
|
||||
until False;
|
||||
TestCount := 10;
|
||||
//CheckData(Input := |cInt|*i);
|
||||
GenerateTestData := tnum -> begin
|
||||
var n := Random(7,12);
|
||||
var a := ArrRandomInteger(n,1,10);
|
||||
|
|
@ -667,6 +667,7 @@ begin
|
|||
CheckOutputString((9*'*'+#13#10) * 5);
|
||||
end;
|
||||
'сс2': begin
|
||||
// Уже можно использовать многострочную строку! Но лень переписывать. Работает.
|
||||
CheckOutputString(9*'1'+#13#10 + 9*'2'+#13#10 + 9*'3'+#13#10 + 9*'4'+#13#10 + 9*'5'+#13#10)
|
||||
end;
|
||||
'сс3': begin
|
||||
|
|
@ -762,7 +763,6 @@ begin
|
|||
CheckOutputString(sb.ToString);
|
||||
end;
|
||||
'Combinations': begin
|
||||
ClearOutputListFromSpaces;
|
||||
CheckData(Empty);
|
||||
var lst := ObjectList.New;
|
||||
for var c := 'a' to 'z' do
|
||||
|
|
@ -771,7 +771,7 @@ begin
|
|||
lst.Add(c);
|
||||
lst.Add(i);
|
||||
end;
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'Primes': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -789,12 +789,12 @@ begin
|
|||
if IsPrime then
|
||||
lst.Add(n);
|
||||
end;
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'Счастливые билеты': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Empty);
|
||||
CheckOutputNew(55252);
|
||||
CheckOutput(55252);
|
||||
end;
|
||||
'1_ПрямоугольныеТреугольники': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -805,11 +805,11 @@ begin
|
|||
for var c:=1 to 20 do
|
||||
if (a*a + b*b = c*c) and (a<b) then
|
||||
lst.AddRange(|a,b,c|);
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'2_Перебор вариантов': begin
|
||||
CheckData(Empty);
|
||||
CheckOutputSeq(Arr(4,6,12,3));
|
||||
CheckOutput(4,6,12,3);
|
||||
end;
|
||||
'ДесятичныеЧисла': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -823,7 +823,7 @@ begin
|
|||
if (d1 + d2 + d3).Divs(3) and (d1<d2) and (d2<d3) then
|
||||
lst.Add(a);
|
||||
end;
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
'ДвоичныеЧисла': begin
|
||||
FilterOnlyNumbers;
|
||||
|
|
@ -836,7 +836,7 @@ begin
|
|||
var a := d1*4 + d2*2 + d3;
|
||||
Lst.AddRange(|d1,d2,d3,a|);
|
||||
end;
|
||||
CheckOutputSeq(lst);
|
||||
CheckOutput(lst);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ var AllTaskNames: array of string;
|
|||
|
||||
procedure CheckTaskT(name: string);
|
||||
begin
|
||||
FlattenOutput; // Во всех задачах на массивы
|
||||
ClearOutputListFromSpaces; // Это чтобы a.Print работал. По идее, надо писать всегда. Яне знаю задач, где пробелы в ответе
|
||||
//FlattenOutput; // Это теперь делается автоматически до вызова CheckTask
|
||||
ClearOutputListFromSpaces; // Это чтобы a.Print работал. По идее, надо писать всегда. Я не знаю задач, где пробелы в ответе
|
||||
|
||||
case name of
|
||||
'Arr1','Arr2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(InitialOutput := |cInt|*5);
|
||||
CheckOutputSeq(|cInt|*10);
|
||||
CheckData(InitialOutput := cInt*5);
|
||||
CheckOutput(|cInt|*10); // Это еще и типы проверяет. Бывает, что только типы и надо проверить
|
||||
// Надо проверить, что Output[9] - целое ненулевое
|
||||
if OutputList.Count<10 then // чтобы не получить исключение
|
||||
if OutputList.Count<10 then // чтобы не получить исключение. Ошибки в CheckOutput кидают исключения уже после
|
||||
exit;
|
||||
if OutIsInt(9) then
|
||||
if OutIsInt(9) then // Это - редкая техника
|
||||
if OutInt(9) = 0 then
|
||||
begin
|
||||
ColoredMessage('Массив надо заполнить ненулевыми значениями');
|
||||
|
|
@ -28,23 +28,23 @@ begin
|
|||
FilterOnlyNumbersAndBools;
|
||||
TaskResult := PartialSolution; // То есть, уже начали проверять, уже под контролем
|
||||
CheckData(|cInt|*5, |cInt|*5, |cInt|*10);
|
||||
if TaskResult <> PartialSolution then
|
||||
if TaskResult <> PartialSolution then // Не знаю, зачем это
|
||||
exit;
|
||||
|
||||
CheckOutputSeq(InputList);
|
||||
CheckOutput(InputList); // Что ввели, то и вывели
|
||||
end;
|
||||
'Arr5','Arr6': begin
|
||||
// Проверка того что введено и выведено 10 значений, что ввод совпадает с выводом и что вывод в диапазоне от 2 до 5
|
||||
// Что плохо - все Check неявно меняют TaskResult, а здесь надо еще и явно
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(InitialInput := |cInt|*n, InitialOutput := |cInt|*n);
|
||||
|
||||
TaskResult := PartialSolution; // потому что если просто запустить - будет InitialSolution
|
||||
|
||||
CheckOutputSeq(InputList);
|
||||
CheckOutput(InputList); // Что ввели, то и вывели
|
||||
// Дополнительная проверка
|
||||
if TaskResult = Solved then
|
||||
if TaskResult = Solved then // То есть, после проверки решения мы проверяем еще входные данные
|
||||
begin
|
||||
// проверим на диапазон от 2 до 5
|
||||
var a := IntArr(n);
|
||||
|
|
@ -56,11 +56,11 @@ begin
|
|||
end;
|
||||
end;
|
||||
end;
|
||||
'Arr_Sum0': begin
|
||||
'Arr_Sum0': begin // Этой задачи нет
|
||||
// Это паттерн: вводится n, а потом вводится n элементов массива
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := Int;
|
||||
CheckInput(|cInt| + n*|cInt|);
|
||||
CheckData(Input := |cInt| + n*cInt);
|
||||
var a := IntArr(n);
|
||||
CheckOutput(a.Sum)
|
||||
end;
|
||||
|
|
@ -68,16 +68,16 @@ begin
|
|||
FilterOnlyNumbersAndBools;
|
||||
// Это всё надо. Начальный ввод - 10 целых, весь ввод - тоже
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*(n+1), |cInt|*n);
|
||||
CheckData(cInt*n, cInt*(n+1), cInt*n);
|
||||
|
||||
var a := IntArr(n);
|
||||
var p := integer(a.Product);
|
||||
var p := integer(a.Product); // потому что ученик будет вычислять в вещественной переменной
|
||||
CheckOutputAfterInitial(p)
|
||||
end;
|
||||
'Arr_Sum3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*(n+1), |cInt|*n);
|
||||
CheckData(cInt*n, cInt*(n+1), cInt*n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitial(a.Product)
|
||||
|
|
@ -85,11 +85,11 @@ begin
|
|||
'Arr_Sum4': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n, cInt*n);
|
||||
|
||||
var a := IntArr(n);
|
||||
var ave := a.Average;
|
||||
CheckOutputAfterInitialSeq(|ave|*2)
|
||||
CheckOutputAfterInitial(ave,ave)
|
||||
end;
|
||||
'Arr_CountA1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -100,51 +100,51 @@ begin
|
|||
CheckOutputAfterInitial(a.CountOf(3));
|
||||
end;
|
||||
'Arr_CountA2': begin
|
||||
ClearOutputListFromSpaces; // Кроме чисел тут строки
|
||||
// Кроме чисел тут строки
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var lst := ObjectList.New;
|
||||
var a := IntArr(n);
|
||||
var cnt4 := a.CountOf(4);
|
||||
var cnt5 := a.CountOf(5);
|
||||
|
||||
var lst := ObjectList.New; // Можно без списка. Наверное, думал выводить что то еще
|
||||
case cnt4.CompareTo(cnt5) of
|
||||
1: lst.Add('четвёрок больше');
|
||||
0: lst.Add('одинаково');
|
||||
-1: lst.Add('пятёрок больше');
|
||||
end;
|
||||
CheckOutputAfterInitialSeq(lst);
|
||||
CheckOutputAfterInitial(lst);
|
||||
end;
|
||||
'Arr_Replace1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var arr := IntArr(n);
|
||||
arr.Replace(2,3);
|
||||
CheckOutputAfterInitialSeq(arr);
|
||||
CheckOutputAfterInitial(arr);
|
||||
end;
|
||||
'Arr_Replace2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var arr := IntArr(n);
|
||||
arr.Replace(2,22);
|
||||
arr.Replace(5,55);
|
||||
arr.Replace(22,5);
|
||||
arr.Replace(55,2);
|
||||
CheckOutputAfterInitialSeq(arr);
|
||||
CheckOutputAfterInitial(arr);
|
||||
end;
|
||||
'Arr_Find1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 5;
|
||||
CheckData(|cInt|*n, |cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
var has2 := 2 in a;
|
||||
|
|
@ -169,7 +169,7 @@ begin
|
|||
'Arr_Find3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 5;
|
||||
CheckData(|cInt|*n, |cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n, cInt*n);
|
||||
TestCount := 10;
|
||||
GenerateTestData := tnum -> begin
|
||||
var a := ArrRandomInteger(n,1,99);
|
||||
|
|
@ -220,7 +220,7 @@ begin
|
|||
'Arr_Index2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
TestCount := 10;
|
||||
GenerateTestData := tnum -> begin
|
||||
var a := ArrRandomInteger(n,2,5);
|
||||
|
|
@ -236,17 +236,17 @@ begin
|
|||
'Arr_Index2a': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
var a := IntArr(n);
|
||||
var ind2 := a.IndexOf(2);
|
||||
var ind5 := a.IndexOf(5);
|
||||
CheckOutputAfterInitialSeq(|ind2,ind5|);
|
||||
CheckOutputAfterInitial(ind2,ind5);
|
||||
end;
|
||||
'Arr_Index3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 20;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
TestCount := 10;
|
||||
GenerateTestData := tnum -> begin
|
||||
var a := ArrRandomInteger(n,2,5);
|
||||
|
|
@ -259,13 +259,13 @@ begin
|
|||
var ind2 := arr.IndexOf(2);
|
||||
var ind5 := arr.IndexOf(5);
|
||||
Swap(arr[ind2],arr[ind5]);
|
||||
CheckOutputAfterInitialSeq(arr);
|
||||
CheckOutputAfterInitial(arr);
|
||||
end;
|
||||
'Arr_Index4': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 30;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
GenerateTests(10, tInt * n);
|
||||
var arr := IntArr(n);
|
||||
var ind := arr.IndexOf(2);
|
||||
ind := arr.IndexOf(2,ind + 1);
|
||||
|
|
@ -275,16 +275,17 @@ begin
|
|||
'Arr_MinMax1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckData(InitialOutput := cInt * n);
|
||||
|
||||
var a := OutSliceIntArr(0,n-1);
|
||||
var a := OutSliceIntArr(0,n-1); // Ввода нет, поэтому пользуемся начальным выводом
|
||||
// Вот здесь если ученик его сотрёт, то будет плохо
|
||||
var min := a.Min;
|
||||
CheckOutputAfterInitial(min);
|
||||
end;
|
||||
'Arr_MinMax2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
|
|
@ -294,7 +295,7 @@ begin
|
|||
'Arr_MinMax3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
|
|
@ -303,17 +304,17 @@ begin
|
|||
'Arr_MinMax4': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10,tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(|a.Min,a.Max|);
|
||||
CheckOutputAfterInitial(a.Min,a.Max);
|
||||
end;
|
||||
|
||||
'Arr_Neighbors1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 20;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt*n);
|
||||
|
||||
var a := IntArr(n);
|
||||
|
|
@ -325,7 +326,7 @@ begin
|
|||
end;
|
||||
'Arr_MinMaxInd1': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateAutoTests(10);
|
||||
|
||||
var a := IntArr(n);
|
||||
|
|
@ -341,40 +342,40 @@ begin
|
|||
var indmax := a.IndexMax;
|
||||
var indmin := a.IndexMin;
|
||||
Swap(a[indmax],a[indmin]);
|
||||
CheckOutputSeq(acopy + a);
|
||||
CheckOutput(acopy, a);
|
||||
end;
|
||||
|
||||
'Arr_Fill1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := nil);
|
||||
CheckData(Input := Empty);
|
||||
|
||||
CheckOutputSeq(ArrFill(10,1));
|
||||
CheckOutput(ArrFill(10,1));
|
||||
end;
|
||||
'Arr_Fill2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := nil);
|
||||
CheckData(Input := Empty);
|
||||
|
||||
CheckOutputSeq(ArrFill(10,1));
|
||||
CheckOutput(ArrFill(10,1));
|
||||
end;
|
||||
'Заполнение1','ЗаполнениеЛямбда1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := Empty);
|
||||
CheckOutputSeq(ArrGen(10,i->i*i));
|
||||
CheckOutput(ArrGen(10,i->i*i));
|
||||
end;
|
||||
'Заполнение2','ЗаполнениеЛямбда2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := Empty);
|
||||
CheckOutputSeq(ArrGen(10,1,i->i+2));
|
||||
CheckOutput(ArrGen(10,1,i->i+2));
|
||||
end;
|
||||
'ЗаполнениеПоПред1','ЗаполнениеПоПред2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := Empty);
|
||||
CheckOutputSeq(ArrGen(10,5,i->i+5));
|
||||
CheckOutput(ArrGen(10,5,i->i+5));
|
||||
end;
|
||||
'ЗаполнениеГеом1','ЗаполнениеГеом2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := Empty);
|
||||
CheckOutputSeq(ArrGen(10,1,i->i*2));
|
||||
CheckOutput(ArrGen(10,1,i->i*2));
|
||||
end;
|
||||
'ЗаполнениеСумма1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -391,49 +392,49 @@ begin
|
|||
'Arr_Transf6': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
foreach var i in a.Indices do
|
||||
if i.IsOdd then
|
||||
a[i] := 0;
|
||||
CheckOutputAfterInitialSeq(a);
|
||||
CheckOutputAfterInitial(a);
|
||||
end;
|
||||
|
||||
'Arr_Reverse1','Arr_Reverse2': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(a.Reverse);
|
||||
CheckOutputAfterInitial(a.Reverse);
|
||||
end;
|
||||
'Arr_Reverse3': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
for var i:= 0 to n div 2 - 1 do
|
||||
Swap(a[i],a[i + n div 2]);
|
||||
CheckOutputAfterInitialSeq(a);
|
||||
CheckOutputAfterInitial(a);
|
||||
end;
|
||||
|
||||
'Arr_Reverse3a': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
|
||||
var out := IntArr(n);
|
||||
var out0 := Copy(out);
|
||||
Reverse(out, 0, 5);
|
||||
Reverse(out, 5, 5);
|
||||
CheckOutputSeq(out0 + out);
|
||||
CheckOutput(out0, out);
|
||||
end;
|
||||
|
||||
'Arr_Count1','Arr_Count2': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
|
|
@ -441,7 +442,7 @@ begin
|
|||
end;
|
||||
'Arr_Count3': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
|
|
@ -449,11 +450,11 @@ begin
|
|||
end;
|
||||
'Arr_Count4': begin
|
||||
var n := 30;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(|a.CountOf(a.Min),a.CountOf(a.Max)|);
|
||||
CheckOutputAfterInitial(a.CountOf(a.Min),a.CountOf(a.Max));
|
||||
end;
|
||||
|
||||
'Arr_FindIndex1': begin
|
||||
|
|
@ -462,38 +463,38 @@ begin
|
|||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(|a.FindIndex(x-> x.IsOdd),a.FindLastIndex(x-> x.IsOdd)|);
|
||||
CheckOutputAfterInitial(a.FindIndex(x-> x.IsOdd),a.FindLastIndex(x-> x.IsOdd));
|
||||
end;
|
||||
'Arr_FindIndex2': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
var i1 := a.FindIndex(x -> x.IsEven);
|
||||
var i2 := a.FindLastIndex(x -> x.IsOdd);
|
||||
Swap(a[i1],a[i2]);
|
||||
CheckOutputAfterInitialSeq(a);
|
||||
CheckOutputAfterInitial(a);
|
||||
end;
|
||||
|
||||
'Arr_Filter1': begin
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateTests(10, tInt(1,100) * n);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(a.Where(x->x<50));
|
||||
CheckOutputAfterInitial(a.Where(x -> x < 50));
|
||||
end;
|
||||
'Arr_GenFilter1': begin
|
||||
CheckData(Input := Empty);
|
||||
var a := ArrGen(50,1,x->x+2);
|
||||
CheckOutputSeq(a.Where(x->x mod 7 = 0));
|
||||
var a := ArrGen(50, 1, x -> x+2);
|
||||
CheckOutput(a.Where(x -> x mod 7 = 0));
|
||||
end;
|
||||
'Arr_GenFilter2': begin
|
||||
var n := 40;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
var a := ArrGen(40,1,1,(x,y)->x+y);
|
||||
CheckOutputAfterInitialSeq(a.Where(x->x mod 5 = 0));
|
||||
CheckOutputAfterInitial(a.Where(x->x mod 5 = 0));
|
||||
end;
|
||||
|
||||
'Arr_Op1': begin
|
||||
|
|
@ -502,7 +503,7 @@ begin
|
|||
var b := |0| * 6 + |1| * 6;
|
||||
var c := |1,2,3|*3 + |4,5,6|*3;
|
||||
var d := |1| * 5 + |2| * 5 + |1| * 5 + |2| * 5;
|
||||
CheckOutputSeq(a+b+c+d);
|
||||
CheckOutput(a, b, c, d);
|
||||
end;
|
||||
|
||||
'Arr_Slice1': begin
|
||||
|
|
@ -510,28 +511,28 @@ begin
|
|||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
var a := Arr(0..9);
|
||||
CheckOutputSeq(a + a[2:6] + a[:4] + a[2:]);
|
||||
CheckOutput(a, a[2:6], a[:4], a[2:]);
|
||||
end;
|
||||
'Arr_Slice2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
var a := Arr(0..9);
|
||||
CheckOutputSeq(a + a[:2] + a[5:] + a[1:^1]);
|
||||
CheckOutput(a, a[:2], a[5:], a[1:^1]);
|
||||
end;
|
||||
'Arr_Slice3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt| * n + |cInt| * 2);
|
||||
CheckData(InitialOutput := cInt * n + cInt * 2);
|
||||
var a := Arr(0..9);
|
||||
CheckOutputSeq(a + |9| + |8| + |7| + a[^2:] + a[1:^1])
|
||||
CheckOutput(a, 9, 8, 7, a[^2:], a[1:^1])
|
||||
end;
|
||||
'Arr_Slice7': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
CheckData(InitialOutput := cInt * n);
|
||||
var a := Arr(0..9);
|
||||
CheckOutputSeq(a + a[4::-1] + a[9::-2])
|
||||
CheckOutput(a, a[4::-1], a[9::-2])
|
||||
end;
|
||||
'Arr_Slice10': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -556,37 +557,37 @@ begin
|
|||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
var a := Arr(0..9);
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
CheckOutputSeq(a + a[:5] + a[6:]);
|
||||
CheckData(InitialOutput := cInt * n);
|
||||
CheckOutput(a, a[:5], a[6:]);
|
||||
end;
|
||||
'Arr_InsDel2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
var a := Arr(0..9);
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
CheckOutputSeq(a + a[:5] + |333| + a[5:]);
|
||||
CheckData(InitialOutput := cInt * n);
|
||||
CheckOutput(a, a[:5], 333, a[5:]);
|
||||
end;
|
||||
'Arr_InsDel3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
var a := Arr(0..9);
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
CheckOutputSeq(a + a[:1] + |555| + a[1:^1] + |555| + a[^1:]);
|
||||
CheckData(InitialOutput := cInt * n);
|
||||
CheckOutput(a, a[:1], 555, a[1:^1], 555, a[^1:]);
|
||||
end;
|
||||
|
||||
'Arr_Shift1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
var a := Arr(0..9);
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
CheckOutputSeq(a + a[1:] + |0|);
|
||||
CheckData(InitialOutput := cInt * n);
|
||||
CheckOutput(a, a[1:], 0);
|
||||
end;
|
||||
'Arr_Shift2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
var a := Arr(0..9);
|
||||
CheckData(InitialOutput := |cInt| * n);
|
||||
CheckOutputSeq(a + |0| + a[:^1]);
|
||||
CheckOutput(a, 0, a[:^1]);
|
||||
end;
|
||||
|
||||
'List1': begin
|
||||
|
|
@ -612,61 +613,61 @@ begin
|
|||
'List5': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateAutoTests(10);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(a.Where(x->x.IsEven));
|
||||
CheckOutputAfterInitial(a.Where(x->x.IsEven));
|
||||
end;
|
||||
'List6': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(|cInt|*n, cInt*n);
|
||||
GenerateAutoTests(10);
|
||||
|
||||
var a := IntArr(n);
|
||||
CheckOutputAfterInitialSeq(a.Where(x->x.IsEven)+a.Where(x->x.IsOdd));
|
||||
CheckOutputAfterInitial(a.Where(x->x.IsEven), a.Where(x->x.IsOdd));
|
||||
end;
|
||||
'List6a': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(InitialInput := |cInt|*3);
|
||||
CheckData(InitialInput := cInt * 3);
|
||||
GenerateAutoTests(10);
|
||||
|
||||
var a := IntArr(3);
|
||||
CheckOutputSeq(|1,3,5|+a);
|
||||
CheckOutput(1,3,5,a);
|
||||
end;
|
||||
'List6b': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
CheckData(Input := Empty);
|
||||
CheckOutputSeq(|1,3,5,2,4,6,9,8,7|);
|
||||
CheckOutput(1,3,5,2,4,6,9,8,7);
|
||||
end;
|
||||
'List7': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 20;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateAutoTests(5);
|
||||
var a := IntArr(10);
|
||||
var b := IntArr(10);
|
||||
CheckOutputAfterInitialSeq(a.Interleave(b));
|
||||
CheckOutputAfterInitial(a.Interleave(b));
|
||||
end;
|
||||
'List8': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckData(InitialOutput := cInt*n);
|
||||
var a := OutSliceIntArr(0,n-1);
|
||||
var b := a.ToList;
|
||||
b.Insert(2,555);
|
||||
CheckOutputSeq(a+b);
|
||||
CheckOutput(a, b);
|
||||
end;
|
||||
'List9': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckData(InitialOutput := cInt*n);
|
||||
var a := OutSliceIntArr(0,n-1);
|
||||
var b := a.ToList;
|
||||
if b.Count>0 then
|
||||
b.RemoveAt(2);
|
||||
CheckOutputSeq(a+b);
|
||||
CheckOutput(a, b);
|
||||
end;
|
||||
'List9a': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
|
|
@ -678,52 +679,52 @@ begin
|
|||
var n := 10;
|
||||
CheckData(InitialInput := |cInt|*n);
|
||||
var a := IntArr(n);
|
||||
CheckOutputSeq(a);
|
||||
CheckOutput(a);
|
||||
end;
|
||||
|
||||
'Sort1': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateAutoTests(5);
|
||||
var a := IntArr(n);
|
||||
CheckOutputSeq(a+a.Sorted);
|
||||
CheckOutput(a, a.Sorted);
|
||||
end;
|
||||
'Sort2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(|cInt|*n, |cInt|*n);
|
||||
CheckData(cInt*n, cInt*n);
|
||||
GenerateAutoTests(5);
|
||||
var a := IntArr(n);
|
||||
CheckOutputSeq(a+a.SortedDescending);
|
||||
CheckOutput(a, a.SortedDescending);
|
||||
end;
|
||||
'Sort3': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 9;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckData(InitialOutput := cInt*n);
|
||||
|
||||
var a := OutSliceIntArr(0,n-1);
|
||||
CheckOutputSeq(a + a.Sorted);
|
||||
CheckOutput(a, a.Sorted);
|
||||
end;
|
||||
'BubbleSort': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 10;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckData(InitialOutput := cInt*n);
|
||||
|
||||
var a := OutSliceIntArr(0,n-1);
|
||||
var b := Copy(a);
|
||||
for var j:=n-1 downto 1 do
|
||||
if b[j-1] > b[j] then
|
||||
Swap(b[j-1], b[j]);
|
||||
CheckOutputSeq(a + b);
|
||||
CheckOutput(a, b);
|
||||
end;
|
||||
'BubbleSort2': begin
|
||||
FilterOnlyNumbersAndBools;
|
||||
var n := 9;
|
||||
CheckData(InitialOutput := |cInt|*n);
|
||||
CheckData(InitialOutput := cInt*n);
|
||||
|
||||
var a := OutSliceIntArr(0,n-1);
|
||||
CheckOutputSeq(a+a.Sorted);
|
||||
CheckOutput(a, a.Sorted);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue