Extend PCL support to Silverlight 5 and Windows Phone 8

This commit is contained in:
Sam Harwell 2014-04-27 16:06:17 -05:00
parent 38659d3b79
commit 4ef578ec4d
16 changed files with 56 additions and 34 deletions

View File

@ -44,9 +44,9 @@
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-cf\$Configuration$\Antlr4.Runtime.net35-cf.pdb" target="lib\net35-cf"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-cf\$Configuration$\Antlr4.Runtime.net35-cf.xml" target="lib\net35-cf"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\Portable\$Configuration$\Antlr4.Runtime.Portable.dll" target="lib\portable-net40"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\Portable\$Configuration$\Antlr4.Runtime.Portable.pdb" target="lib\portable-net40"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\Portable\$Configuration$\Antlr4.Runtime.Portable.xml" target="lib\portable-net40"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net40\$Configuration$\Antlr4.Runtime.portable-net40.dll" target="lib\portable-net40+sl50+wp80+win"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net40\$Configuration$\Antlr4.Runtime.portable-net40.pdb" target="lib\portable-net40+sl50+wp80+win"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net40\$Configuration$\Antlr4.Runtime.portable-net40.xml" target="lib\portable-net40+sl50+wp80+win"/>
<!-- Source Code -->

View File

@ -17,7 +17,7 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<BaseIntermediateOutputPath>obj\Portable\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath>obj\portable-net40\</BaseIntermediateOutputPath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
@ -25,7 +25,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Portable\Debug\</OutputPath>
<OutputPath>bin\portable-net40\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;PORTABLE;NET40;NET40PLUS;NET35PLUS;NET30PLUS;NET20PLUS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -34,7 +34,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Portable\Release\</OutputPath>
<OutputPath>bin\portable-net40\Release\</OutputPath>
<DefineConstants>TRACE;PORTABLE;NET40;NET40PLUS;NET35PLUS;NET30PLUS;NET20PLUS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -68,9 +68,9 @@
<Compile Include="TestPerformance.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Antlr4.Runtime\Antlr4.Runtime.Portable.csproj">
<ProjectReference Include="..\Antlr4.Runtime\Antlr4.Runtime.portable-net40.csproj">
<Project>{06c182c5-095c-4d43-9c33-c87e305c6bc2}</Project>
<Name>Antlr4.Runtime.Portable</Name>
<Name>Antlr4.Runtime.portable-net40</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@ -79,7 +79,7 @@
<Antlr4 Include="Java.g4" />
</ItemGroup>
<ItemGroup>
<None Include="packages.Antlr4.Runtime.Test.Portable.config" />
<None Include="packages.Antlr4.Runtime.Test.portable-net40.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr4" version="4.2.1-alpha001" targetFramework="portable-net40" />
<package id="Antlr4.Runtime" version="4.2.1-alpha001" targetFramework="portable-net40" />
<package id="Antlr4" version="4.2.1-alpha001" targetFramework="portable-net40+sl50+wp80+win" />
<package id="Antlr4.Runtime" version="4.2.1-alpha001" targetFramework="portable-net40+sl50+wp80+win" />
</packages>

View File

@ -10,11 +10,11 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Antlr4.Runtime</RootNamespace>
<AssemblyName>Antlr4.Runtime.Portable</AssemblyName>
<AssemblyName>Antlr4.Runtime.portable-net40</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile5</TargetFrameworkProfile>
<TargetFrameworkProfile>Profile136</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<BaseIntermediateOutputPath>obj\Portable\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath>obj\portable-net40\</BaseIntermediateOutputPath>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
@ -23,9 +23,9 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Portable\Debug\</OutputPath>
<OutputPath>bin\portable-net40\Debug\</OutputPath>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
<DefineConstants>TRACE;DEBUG;NET_2_0;NET_3_0;NET_3_5;NET_4_0;PORTABLE</DefineConstants>
<DefineConstants>TRACE;DEBUG;PORTABLE;NET40;NET40PLUS;NET35PLUS;NET30PLUS;NET20PLUS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>1591</NoWarn>
@ -33,9 +33,9 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Portable\Release\</OutputPath>
<OutputPath>bin\portable-net40\Release\</OutputPath>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
<DefineConstants>TRACE;NET_2_0;NET_3_0;NET_3_5;NET_4_0;PORTABLE</DefineConstants>
<DefineConstants>TRACE;PORTABLE;NET40;NET40PLUS;NET35PLUS;NET30PLUS;NET20PLUS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>1591</NoWarn>
@ -46,9 +46,6 @@
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\..\..\..\keys\antlr\Key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<Compile Include="AntlrFileStream.cs" />
<Compile Include="AntlrInputStream.cs" />
@ -194,6 +191,9 @@
<Compile Include="Sharpen\AtomicReference`1.cs" />
<Compile Include="Sharpen\BitSet.cs" />
<Compile Include="Sharpen\Collections.cs" />
<Compile Include="Sharpen\Compat\CollectionDebuggerView`2.cs" />
<Compile Include="Sharpen\Compat\ConcurrentDictionary`2.cs" />
<Compile Include="Sharpen\Compat\SplitOrderedList`2.cs" />
<Compile Include="Sharpen\DictionaryExtensions.cs" />
<Compile Include="Sharpen\ListExtensions.cs" />
<Compile Include="Sharpen\Runtime.cs" />
@ -233,7 +233,7 @@
<Compile Include="Tree\Xpath\XPathWildcardElement.cs" />
<Compile Include="UnbufferedCharStream.cs" />
<Compile Include="UnbufferedTokenStream.cs" />
<None Include="packages.Antlr4.Runtime.Portable.config" />
<None Include="packages.Antlr4.Runtime.portable-net40.config" />
<Antlr4 Include="Tree\Xpath\XPathLexer.g4">
<Generator>MSBuild:Compile</Generator>
<CustomToolNamespace>Antlr4.Runtime.Tree.Xpath</CustomToolNamespace>

View File

@ -31,7 +31,9 @@ using System.Collections.Generic;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
using Antlr4.Runtime.Sharpen;
#if !PORTABLE || NET45PLUS
using Stopwatch = System.Diagnostics.Stopwatch;
#endif
namespace Antlr4.Runtime.Atn
{
@ -64,6 +66,7 @@ namespace Antlr4.Runtime.Atn
/// </summary>
public long invocations;
#if !PORTABLE || NET45PLUS
/// <summary>
/// The total time spent in
/// <see cref="ParserATNSimulator.AdaptivePredict(ITokenStream, int, ParserRuleContext)"/>
@ -79,6 +82,7 @@ namespace Antlr4.Runtime.Atn
/// state before starting the profiling measurement pass.</p>
/// </summary>
public long timeInPrediction;
#endif
/// <summary>The sum of the lookahead required for SLL prediction for this decision.</summary>
/// <remarks>

View File

@ -104,6 +104,7 @@ namespace Antlr4.Runtime.Atn
return Ll;
}
#if !PORTABLE || NET45PLUS
/// <summary>
/// Gets the total time spent during prediction across all decisions made
/// during parsing.
@ -124,6 +125,7 @@ namespace Antlr4.Runtime.Atn
}
return t;
}
#endif
/// <summary>
/// Gets the total number of SLL lookahead operations across all decisions

View File

@ -32,7 +32,9 @@ using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
using Antlr4.Runtime.Sharpen;
#if !PORTABLE || NET45PLUS
using Stopwatch = System.Diagnostics.Stopwatch;
#endif
namespace Antlr4.Runtime.Atn
{
@ -97,10 +99,14 @@ namespace Antlr4.Runtime.Atn
this.currentDecision = decision;
this.currentState = null;
this.conflictingAltResolvedBySLL = ATN.InvalidAltNumber;
#if !PORTABLE || NET45PLUS
Stopwatch stopwatch = Stopwatch.StartNew();
#endif
// expensive but useful info
int alt = base.AdaptivePredict(input, decision, outerContext);
#if !PORTABLE || NET45PLUS
decisions[decision].timeInPrediction += stopwatch.ElapsedTicks * 100;
#endif
decisions[decision].invocations++;
int SLL_k = _sllStopIndex - _startIndex + 1;
decisions[decision].SLL_TotalLook += SLL_k;

View File

@ -180,6 +180,8 @@ namespace Antlr4.Runtime.Dfa
#if COMPACT
IDictionary<int, T> result = new SortedList<int, T>();
#elif PORTABLE && !NET45PLUS
IDictionary<int, T> result = new Dictionary<int, T>();
#else
IDictionary<int, T> result = new SortedDictionary<int, T>();
#endif

View File

@ -288,6 +288,8 @@ namespace Antlr4.Runtime.Dfa
map = new ReadOnlyDictionary<int, DFAState>(new SortedDictionary<int, DFAState>(result));
#elif COMPACT
map = new SortedList<int, DFAState>(result);
#elif PORTABLE && !NET45PLUS
map = new Dictionary<int, DFAState>(result);
#else
map = new SortedDictionary<int, DFAState>(result);
#endif

View File

@ -218,6 +218,8 @@ namespace Antlr4.Runtime.Dfa
#if COMPACT
IDictionary<int, T> result = new SortedList<int, T>();
#elif PORTABLE && !NET45PLUS
IDictionary<int, T> result = new Dictionary<int, T>();
#else
IDictionary<int, T> result = new SortedDictionary<int, T>();
#endif

View File

@ -57,15 +57,17 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © Sam Harwell 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(false)]
#if !PORTABLE || NET45PLUS
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bc228eb9-e79c-4e5a-a1b9-0434ea566bab")]
#endif
// Version information for an assembly consists of the following four values:
//

View File

@ -26,7 +26,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET40PLUS
#if !NET40PLUS || (PORTABLE && !NET45PLUS)
using System;
using System.Collections.Generic;

View File

@ -22,12 +22,13 @@
//
//
#if !NET40PLUS
#if !NET40PLUS || (PORTABLE && !NET45PLUS)
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Diagnostics;
@ -340,7 +341,7 @@ namespace Antlr4.Runtime.Sharpen
foreach (KeyValuePair<TKey, TValue> kvp in this)
temp.Add (extractor (kvp));
return temp.AsReadOnly ();
return new ReadOnlyCollection<T>(temp);
}
void ICollection.CopyTo (Array array, int startIndex)

View File

@ -22,7 +22,7 @@
//
//
#if !NET40PLUS
#if !NET40PLUS || (PORTABLE && !NET45PLUS)
using System;
using System.Threading;
@ -533,15 +533,16 @@ namespace Antlr4.Runtime.Sharpen
#if COMPACT
Thread.Sleep(0);
#else
ManualResetEvent mre = new ManualResetEvent (false);
if (isSingleCpu) {
// On a single-CPU system, spinning does no good
Thread.Sleep (0);
mre.WaitOne (0);
} else {
if (ntime % step == 0)
Thread.Sleep (0);
mre.WaitOne (0);
else
// Multi-CPU system might be hyper-threaded, let other thread run
Thread.SpinWait (Math.Min (ntime, maxTime) << 1);
mre.WaitOne (Math.Min (ntime, maxTime) << 1);
}
#endif
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr4" version="4.2.1-alpha001" targetFramework="portable-net40" />
<package id="Antlr4.Runtime" version="4.2.1-alpha001" targetFramework="portable-net40" />
<package id="Antlr4" version="4.2.1-alpha001" targetFramework="portable-net40+sl50+win+wp80" />
<package id="Antlr4.Runtime" version="4.2.1-alpha001" targetFramework="portable-net40+sl50+win+wp80" />
</packages>

View File

@ -36,9 +36,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.Test.net30",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.Test.net20", "Antlr4.Runtime.Test\Antlr4.Runtime.Test.net20.csproj", "{0A4681C4-1248-4ACD-B59F-D6CC17CC2B4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.Portable", "Antlr4.Runtime\Antlr4.Runtime.Portable.csproj", "{06C182C5-095C-4D43-9C33-C87E305C6BC2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.portable-net40", "Antlr4.Runtime\Antlr4.Runtime.portable-net40.csproj", "{06C182C5-095C-4D43-9C33-C87E305C6BC2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.Test.Portable", "Antlr4.Runtime.Test\Antlr4.Runtime.Test.Portable.csproj", "{97C32E42-51B2-4A29-B005-769B63CFEFCA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.Test.portable-net40", "Antlr4.Runtime.Test\Antlr4.Runtime.Test.portable-net40.csproj", "{97C32E42-51B2-4A29-B005-769B63CFEFCA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4BuildTasks.net35", "Antlr4BuildTasks\Antlr4BuildTasks.net35.csproj", "{0D3D20E9-3341-4449-80E7-76A4534F0E55}"
EndProject