forked from jasder/antlr
Added Antlr4.Runtime.CF3.5 assembly for .NET Compact Framework 3.5 (requires Visual Studio 2008 to build)
This commit is contained in:
parent
785585199c
commit
6b0890a510
|
@ -36,6 +36,10 @@ using File = System.IO.File;
|
|||
|
||||
namespace Antlr4.Runtime
|
||||
{
|
||||
#if NET_CF
|
||||
using StreamReader = System.IO.StreamReader;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// This is an ANTLRInputStream that is loaded from a file
|
||||
/// all at once when you construct the object.
|
||||
|
@ -71,10 +75,17 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
|
||||
string text;
|
||||
#if !NET_CF
|
||||
if (encoding != null)
|
||||
text = File.ReadAllText(fileName, encoding);
|
||||
else
|
||||
text = File.ReadAllText(fileName);
|
||||
#else
|
||||
if (encoding != null)
|
||||
text = ReadAllText(fileName, encoding);
|
||||
else
|
||||
text = ReadAllText(fileName);
|
||||
#endif
|
||||
|
||||
data = text.ToCharArray();
|
||||
n = data.Length;
|
||||
|
@ -87,6 +98,24 @@ namespace Antlr4.Runtime
|
|||
return fileName;
|
||||
}
|
||||
}
|
||||
|
||||
#if NET_CF
|
||||
private static string ReadAllText(string path)
|
||||
{
|
||||
using (var reader = new StreamReader(path))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private static string ReadAllText(string path, Encoding encoding)
|
||||
{
|
||||
using (var reader = new StreamReader(path, encoding ?? Encoding.Default))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{C5F9C476-200F-4440-9524-C5C3F9BE16D7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Antlr4.Runtime</RootNamespace>
|
||||
<AssemblyName>Antlr4.Runtime.CF3.5</AssemblyName>
|
||||
<ProjectTypeGuids>{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
||||
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
|
||||
<OSVersion>5.0</OSVersion>
|
||||
<DeployDirSuffix>Antlr4.Runtime.CF3.5</DeployDirSuffix>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<NativePlatformName>Windows CE</NativePlatformName>
|
||||
<FormFactorID>
|
||||
</FormFactorID>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<BaseIntermediateOutputPath>obj\CF3.5\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\CF3.5\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;$(PlatformFamilyName);NET_CF;NET_2_0;NET_3_0;NET_3_5</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\CF2.0\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;$(PlatformFamilyName);NET_CF;NET_2_0;NET_3_0;NET_3_5</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>..\..\..\..\..\..\keys\antlr\Key.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AntlrFileStream.cs" />
|
||||
<Compile Include="AntlrInputStream.cs" />
|
||||
<Compile Include="Atn\AbstractPredicateTransition.cs" />
|
||||
<Compile Include="Atn\ActionTransition.cs" />
|
||||
<Compile Include="Atn\ArrayPredictionContext.cs" />
|
||||
<Compile Include="Atn\ATN.cs" />
|
||||
<Compile Include="Atn\ATNConfig.cs" />
|
||||
<Compile Include="Atn\ATNConfigSet.cs" />
|
||||
<Compile Include="Atn\ATNSimulator.cs" />
|
||||
<Compile Include="Atn\ATNState.cs" />
|
||||
<Compile Include="Atn\AtomTransition.cs" />
|
||||
<Compile Include="Atn\BasicBlockStartState.cs" />
|
||||
<Compile Include="Atn\BasicState.cs" />
|
||||
<Compile Include="Atn\BlockEndState.cs" />
|
||||
<Compile Include="Atn\BlockStartState.cs" />
|
||||
<Compile Include="Atn\DecisionState.cs" />
|
||||
<Compile Include="Atn\EmptyPredictionContext.cs" />
|
||||
<Compile Include="Atn\EpsilonTransition.cs" />
|
||||
<Compile Include="Atn\LexerATNSimulator.cs" />
|
||||
<Compile Include="Atn\LL1Analyzer.cs" />
|
||||
<Compile Include="Atn\LoopEndState.cs" />
|
||||
<Compile Include="Atn\NotSetTransition.cs" />
|
||||
<Compile Include="Atn\OrderedATNConfigSet.cs" />
|
||||
<Compile Include="Atn\ParserATNPathFinder.cs" />
|
||||
<Compile Include="Atn\ParserATNSimulator.cs" />
|
||||
<Compile Include="Atn\PlusBlockStartState.cs" />
|
||||
<Compile Include="Atn\PlusLoopbackState.cs" />
|
||||
<Compile Include="Atn\PrecedencePredicateTransition.cs" />
|
||||
<Compile Include="Atn\PredicateTransition.cs" />
|
||||
<Compile Include="Atn\PredictionContext.cs" />
|
||||
<Compile Include="Atn\PredictionContextCache.cs" />
|
||||
<Compile Include="Atn\PredictionMode.cs" />
|
||||
<Compile Include="Atn\RangeTransition.cs" />
|
||||
<Compile Include="Atn\RuleStartState.cs" />
|
||||
<Compile Include="Atn\RuleStopState.cs" />
|
||||
<Compile Include="Atn\RuleTransition.cs" />
|
||||
<Compile Include="Atn\SemanticContext.cs" />
|
||||
<Compile Include="Atn\SetTransition.cs" />
|
||||
<Compile Include="Atn\SimulatorState.cs" />
|
||||
<Compile Include="Atn\SingletonPredictionContext.cs" />
|
||||
<Compile Include="Atn\StarBlockStartState.cs" />
|
||||
<Compile Include="Atn\StarLoopbackState.cs" />
|
||||
<Compile Include="Atn\StarLoopEntryState.cs" />
|
||||
<Compile Include="Atn\StateType.cs" />
|
||||
<Compile Include="Atn\TokensStartState.cs" />
|
||||
<Compile Include="Atn\Transition.cs" />
|
||||
<Compile Include="Atn\TransitionType.cs" />
|
||||
<Compile Include="Atn\WildcardTransition.cs" />
|
||||
<Compile Include="BailErrorStrategy.cs" />
|
||||
<Compile Include="BaseErrorListener.cs" />
|
||||
<Compile Include="BufferedTokenStream.cs" />
|
||||
<Compile Include="CommonToken.cs" />
|
||||
<Compile Include="CommonTokenFactory.cs" />
|
||||
<Compile Include="CommonTokenStream.cs" />
|
||||
<Compile Include="ConsoleErrorListener.cs" />
|
||||
<Compile Include="DefaultErrorStrategy.cs" />
|
||||
<Compile Include="Dependents.cs" />
|
||||
<Compile Include="Dfa\AbstractEdgeMap`1.cs" />
|
||||
<Compile Include="Dfa\ArrayEdgeMap`1.cs" />
|
||||
<Compile Include="Dfa\DFA.cs" />
|
||||
<Compile Include="Dfa\DFASerializer.cs" />
|
||||
<Compile Include="Dfa\DFAState.cs" />
|
||||
<Compile Include="Dfa\IEdgeMap`1.cs" />
|
||||
<Compile Include="Dfa\LexerDFASerializer.cs" />
|
||||
<Compile Include="Dfa\SingletonEdgeMap`1.cs" />
|
||||
<Compile Include="Dfa\SparseEdgeMap`1.cs" />
|
||||
<Compile Include="DiagnosticErrorListener.cs" />
|
||||
<Compile Include="FailedPredicateException.cs" />
|
||||
<Compile Include="IAntlrErrorListener`1.cs" />
|
||||
<Compile Include="IAntlrErrorStrategy.cs" />
|
||||
<Compile Include="ICharStream.cs" />
|
||||
<Compile Include="IIntStream.cs" />
|
||||
<Compile Include="InputMismatchException.cs" />
|
||||
<Compile Include="IParserErrorListener.cs" />
|
||||
<Compile Include="IRecognizer.cs" />
|
||||
<Compile Include="IToken.cs" />
|
||||
<Compile Include="ITokenFactory.cs" />
|
||||
<Compile Include="ITokenSource.cs" />
|
||||
<Compile Include="ITokenStream.cs" />
|
||||
<Compile Include="IWritableToken.cs" />
|
||||
<Compile Include="Lexer.cs" />
|
||||
<Compile Include="LexerNoViableAltException.cs" />
|
||||
<Compile Include="Misc\Args.cs" />
|
||||
<None Include="..\..\..\..\..\..\keys\antlr\Key.snk">
|
||||
<Link>Key.snk</Link>
|
||||
</None>
|
||||
<None Include="Misc\Array2DHashSet`1.cs" />
|
||||
<Compile Include="Misc\NullableAttribute.cs" />
|
||||
<None Include="Misc\DoubleKeyMap`3.cs" />
|
||||
<Compile Include="Misc\IIntSet.cs" />
|
||||
<Compile Include="Misc\Interval.cs" />
|
||||
<Compile Include="Misc\IntervalSet.cs" />
|
||||
<None Include="Misc\MultiMap`2.cs" />
|
||||
<Compile Include="Misc\NotNullAttribute.cs" />
|
||||
<None Include="Misc\OrderedHashSet`1.cs" />
|
||||
<Compile Include="Misc\ParseCanceledException.cs" />
|
||||
<Compile Include="Misc\RuleDependencyChecker.cs" />
|
||||
<None Include="Misc\RuleDependencyProcessor.cs" />
|
||||
<None Include="Misc\TestRig.cs" />
|
||||
<Compile Include="Misc\Utils.cs" />
|
||||
<Compile Include="NoViableAltException.cs" />
|
||||
<Compile Include="Parser.cs" />
|
||||
<Compile Include="ParserRuleContext.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProxyErrorListener`1.cs" />
|
||||
<Compile Include="ProxyParserErrorListener.cs" />
|
||||
<Compile Include="RecognitionException.cs" />
|
||||
<Compile Include="Recognizer`2.cs" />
|
||||
<Compile Include="RuleContext.cs" />
|
||||
<Compile Include="RuleDependencyAttribute.cs" />
|
||||
<Compile Include="RuleVersionAttribute.cs" />
|
||||
<Compile Include="Sharpen\Arrays.cs" />
|
||||
<Compile Include="Sharpen\AtomicReference`1.cs" />
|
||||
<Compile Include="Sharpen\BitSet.cs" />
|
||||
<Compile Include="Sharpen\Checksum.cs" />
|
||||
<Compile Include="Sharpen\Collections.cs" />
|
||||
<Compile Include="Sharpen\Compat\CollectionDebuggerView`2.cs" />
|
||||
<Compile Include="Sharpen\Compat\ConcurrentDictionary`2.cs" />
|
||||
<Compile Include="Sharpen\Compat\Enumerable.cs" />
|
||||
<Compile Include="Sharpen\Compat\ExtensionAttribute.cs" />
|
||||
<Compile Include="Sharpen\Compat\Funcs.cs" />
|
||||
<Compile Include="Sharpen\Compat\HashSet`1.cs" />
|
||||
<Compile Include="Sharpen\Compat\IStructuralComparable.cs" />
|
||||
<Compile Include="Sharpen\Compat\IStructuralEquatable.cs" />
|
||||
<Compile Include="Sharpen\Compat\SplitOrderedList`2.cs" />
|
||||
<Compile Include="Sharpen\Compat\Tuple.cs" />
|
||||
<Compile Include="Sharpen\Compat\Tuples.cs" />
|
||||
<Compile Include="Sharpen\CRC32.cs" />
|
||||
<Compile Include="Sharpen\DictionaryExtensions.cs" />
|
||||
<Compile Include="Sharpen\ListExtensions.cs" />
|
||||
<Compile Include="Sharpen\Runtime.cs" />
|
||||
<Compile Include="Sharpen\SequenceEqualityComparer`1.cs" />
|
||||
<Compile Include="TokenStreamRewriter.cs" />
|
||||
<Compile Include="TokenTypes.cs" />
|
||||
<Compile Include="Tree\AbstractParseTreeVisitor`1.cs" />
|
||||
<Compile Include="Tree\ErrorNodeImpl.cs" />
|
||||
<Compile Include="Tree\IErrorNode.cs" />
|
||||
<Compile Include="Tree\IParseTree.cs" />
|
||||
<Compile Include="Tree\IParseTreeListener.cs" />
|
||||
<Compile Include="Tree\IParseTreeVisitor`1.cs" />
|
||||
<Compile Include="Tree\IRuleNode.cs" />
|
||||
<Compile Include="Tree\ISyntaxTree.cs" />
|
||||
<Compile Include="Tree\ITerminalNode.cs" />
|
||||
<Compile Include="Tree\ITree.cs" />
|
||||
<Compile Include="Tree\ParseTreeProperty`1.cs" />
|
||||
<Compile Include="Tree\ParseTreeWalker.cs" />
|
||||
<Compile Include="Tree\TerminalNodeImpl.cs" />
|
||||
<Compile Include="Tree\Trees.cs" />
|
||||
<Compile Include="UnbufferedCharStream.cs" />
|
||||
<Compile Include="UnbufferedTokenStream.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
|
||||
<HostingProcess disable="1" />
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -400,6 +400,9 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
public virtual string ToDotString()
|
||||
{
|
||||
#if NET_CF
|
||||
throw new NotImplementedException("The current platform does not provide RuntimeHelpers.GetHashCode(object).");
|
||||
#else
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append("digraph G {\n");
|
||||
builder.Append("rankdir=LR;\n");
|
||||
|
@ -426,6 +429,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
builder.Append("}\n");
|
||||
return builder.ToString();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -178,7 +178,12 @@ namespace Antlr4.Runtime.Dfa
|
|||
{
|
||||
return Sharpen.Collections.EmptyMap<int, T>();
|
||||
}
|
||||
|
||||
#if NET_CF
|
||||
IDictionary<int, T> result = new SortedList<int, T>();
|
||||
#else
|
||||
IDictionary<int, T> result = new SortedDictionary<int, T>();
|
||||
#endif
|
||||
for (int i = 0; i < arrayData.Length; i++)
|
||||
{
|
||||
if (arrayData[i] == null)
|
||||
|
|
|
@ -299,6 +299,8 @@ namespace Antlr4.Runtime.Dfa
|
|||
result.Remove(-1);
|
||||
#if NET_4_5
|
||||
map = new ReadOnlyDictionary<int, DFAState>(new SortedDictionary<int, DFAState>(result));
|
||||
#elif NET_CF
|
||||
map = new SortedList<int, DFAState>(result);
|
||||
#else
|
||||
map = new SortedDictionary<int, DFAState>(result);
|
||||
#endif
|
||||
|
|
|
@ -211,7 +211,12 @@ namespace Antlr4.Runtime.Dfa
|
|||
{
|
||||
return Sharpen.Collections.EmptyMap<int, T>();
|
||||
}
|
||||
|
||||
#if NET_CF
|
||||
IDictionary<int, T> result = new SortedList<int, T>();
|
||||
#else
|
||||
IDictionary<int, T> result = new SortedDictionary<int, T>();
|
||||
#endif
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
result[keys[i]] = values[i];
|
||||
|
|
|
@ -33,7 +33,11 @@ using Sharpen;
|
|||
namespace Antlr4.Runtime
|
||||
{
|
||||
/// <summary>How to emit recognition errors</summary>
|
||||
#if NET_CF
|
||||
public interface IAntlrErrorListener<TSymbol>
|
||||
#else
|
||||
public interface IAntlrErrorListener<in TSymbol>
|
||||
#endif
|
||||
{
|
||||
/// <summary>Upon syntax error, notify any interested parties.</summary>
|
||||
/// <remarks>
|
||||
|
|
|
@ -48,7 +48,12 @@ namespace Antlr4.Runtime.Misc
|
|||
#if !PORTABLE
|
||||
[System.Serializable]
|
||||
#endif
|
||||
public class ParseCanceledException : OperationCanceledException
|
||||
public class ParseCanceledException
|
||||
#if NET_CF
|
||||
: Exception
|
||||
#else
|
||||
: OperationCanceledException
|
||||
#endif
|
||||
{
|
||||
public ParseCanceledException()
|
||||
{
|
||||
|
|
|
@ -374,8 +374,13 @@ namespace Antlr4.Runtime.Misc
|
|||
foreach (MethodInfo method in clazz.GetMethods(AllDeclaredMembers))
|
||||
{
|
||||
GetElementDependencies(AsCustomAttributeProvider(method), result);
|
||||
#if NET_CF
|
||||
if (method.ReturnTypeCustomAttributes != null)
|
||||
GetElementDependencies(AsCustomAttributeProvider(method.ReturnTypeCustomAttributes), result);
|
||||
#else
|
||||
if (method.ReturnParameter != null)
|
||||
GetElementDependencies(AsCustomAttributeProvider(method.ReturnParameter), result);
|
||||
#endif
|
||||
|
||||
foreach (ParameterInfo parameter in method.GetParameters())
|
||||
GetElementDependencies(AsCustomAttributeProvider(parameter), result);
|
||||
|
|
|
@ -78,4 +78,6 @@ using System.Runtime.InteropServices;
|
|||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
#if !NET_CF
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,9 @@ namespace Sharpen
|
|||
this.c = col;
|
||||
}
|
||||
|
||||
#if !NET_CF
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||
#endif
|
||||
public T[] Items {
|
||||
get {
|
||||
var o = new T [c.Count];
|
||||
|
@ -65,7 +67,9 @@ namespace Sharpen
|
|||
this.c = col;
|
||||
}
|
||||
|
||||
#if !NET_CF
|
||||
[DebuggerBrowsable (DebuggerBrowsableState.RootHidden)]
|
||||
#endif
|
||||
public KeyValuePair<T, U>[] Items {
|
||||
get {
|
||||
var o = new KeyValuePair<T, U> [c.Count];
|
||||
|
|
|
@ -38,8 +38,10 @@ namespace System.Collections.Concurrent
|
|||
|
||||
namespace Sharpen
|
||||
{
|
||||
#if !NET_CF
|
||||
[DebuggerDisplay ("Count={Count}")]
|
||||
[DebuggerTypeProxy (typeof (CollectionDebuggerView<,>))]
|
||||
#endif
|
||||
public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>,
|
||||
ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>,
|
||||
IDictionary, ICollection, IEnumerable
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !NET_3_5
|
||||
#if !NET_3_5 || NET_CF
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -42,9 +42,14 @@ using System.Diagnostics;
|
|||
namespace Sharpen {
|
||||
|
||||
[Serializable]
|
||||
#if !NET_CF
|
||||
[DebuggerDisplay ("Count={Count}")]
|
||||
[DebuggerTypeProxy (typeof (CollectionDebuggerView<,>))]
|
||||
public class HashSet<T> : ICollection<T>, ISerializable, IDeserializationCallback
|
||||
#endif
|
||||
public class HashSet<T> : ICollection<T>
|
||||
#if !NET_CF
|
||||
, ISerializable, IDeserializationCallback
|
||||
#endif
|
||||
{
|
||||
const int INITIAL_SIZE = 10;
|
||||
const float DEFAULT_LOAD_FACTOR = (90f / 100);
|
||||
|
@ -81,7 +86,9 @@ namespace Sharpen {
|
|||
int threshold;
|
||||
|
||||
IEqualityComparer<T> comparer;
|
||||
#if !NET_CF
|
||||
SerializationInfo si;
|
||||
#endif
|
||||
|
||||
// The number of changes made to this set. Used by enumerators
|
||||
// to detect changes and invalidate themselves.
|
||||
|
@ -120,10 +127,12 @@ namespace Sharpen {
|
|||
Add (item);
|
||||
}
|
||||
|
||||
#if !NET_CF
|
||||
protected HashSet (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
si = info;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Init (int capacity, IEqualityComparer<T> comparer)
|
||||
{
|
||||
|
@ -570,6 +579,7 @@ namespace Sharpen {
|
|||
return setComparer;
|
||||
}
|
||||
|
||||
#if !NET_CF
|
||||
[SecurityPermission (SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
|
||||
public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
|
@ -613,7 +623,7 @@ namespace Sharpen {
|
|||
si = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator ()
|
||||
{
|
||||
|
|
|
@ -438,16 +438,27 @@ namespace Sharpen
|
|||
while ((rwlock & (RwWrite | RwWait)) > 0)
|
||||
sw.SpinOnce ();
|
||||
|
||||
#if NET_CF
|
||||
if ((InterlockedAdd (ref rwlock, RwRead) & (RwWait | RwWait)) == 0)
|
||||
return;
|
||||
|
||||
InterlockedAdd (ref rwlock, -RwRead);
|
||||
#else
|
||||
if ((Interlocked.Add (ref rwlock, RwRead) & (RwWait | RwWait)) == 0)
|
||||
return;
|
||||
|
||||
Interlocked.Add (ref rwlock, -RwRead);
|
||||
#endif
|
||||
} while (true);
|
||||
}
|
||||
|
||||
public void ExitReadLock ()
|
||||
{
|
||||
#if NET_CF
|
||||
InterlockedAdd (ref rwlock, -RwRead);
|
||||
#else
|
||||
Interlocked.Add (ref rwlock, -RwRead);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void EnterWriteLock ()
|
||||
|
@ -471,8 +482,37 @@ namespace Sharpen
|
|||
|
||||
public void ExitWriteLock ()
|
||||
{
|
||||
#if NET_CF
|
||||
InterlockedAdd (ref rwlock, -RwWrite);
|
||||
#else
|
||||
Interlocked.Add (ref rwlock, -RwWrite);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NET_CF
|
||||
/// <summary>
|
||||
/// Adds two 32-bit integers and replaces the first integer with the sum, as an atomic operation.
|
||||
/// </summary>
|
||||
/// <param name="location1">A variable containing the first value to be added. The sum of the two values is stored in <paramref name="location1"/>.</param>
|
||||
/// <param name="value">The value to be added to the integer at <paramref name="location1"/>.</param>
|
||||
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
|
||||
private static int InterlockedAdd(ref int location1, int value)
|
||||
{
|
||||
#if false // the code calling this private method will never make use of this optimization
|
||||
if (value == 1)
|
||||
return Interlocked.Increment(ref location1);
|
||||
else if (value == -1)
|
||||
return Interlocked.Decrement(ref location1);
|
||||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
int previous = location1;
|
||||
if (Interlocked.CompareExchange(ref location1, previous + value, previous) == previous)
|
||||
return previous + value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,14 +521,18 @@ namespace Sharpen
|
|||
// The number of step until SpinOnce yield on multicore machine
|
||||
const int step = 10;
|
||||
const int maxTime = 200;
|
||||
#if !NET_CF
|
||||
static readonly bool isSingleCpu = (Environment.ProcessorCount == 1);
|
||||
#endif
|
||||
|
||||
int ntime;
|
||||
|
||||
public void SpinOnce ()
|
||||
{
|
||||
ntime += 1;
|
||||
|
||||
#if NET_CF
|
||||
Thread.Sleep(0);
|
||||
#else
|
||||
if (isSingleCpu) {
|
||||
// On a single-CPU system, spinning does no good
|
||||
Thread.Sleep (0);
|
||||
|
@ -499,6 +543,7 @@ namespace Sharpen
|
|||
// Multi-CPU system might be hyper-threaded, let other thread run
|
||||
Thread.SpinWait (Math.Min (ntime, maxTime) << 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,11 @@ namespace Antlr4.Runtime.Tree
|
|||
/// </remarks>
|
||||
/// <author>Sam Harwell</author>
|
||||
/// <?></?>
|
||||
#if NET_CF
|
||||
public interface IParseTreeVisitor<Result>
|
||||
#else
|
||||
public interface IParseTreeVisitor<out Result>
|
||||
#endif
|
||||
{
|
||||
/// <summary>Visit a parse tree, and return a user-defined result of the operation.</summary>
|
||||
/// <remarks>Visit a parse tree, and return a user-defined result of the operation.</remarks>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.CF3.5", "Antlr4.Runtime\Antlr4.Runtime.CF3.5.csproj", "{C5F9C476-200F-4440-9524-C5C3F9BE16D7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C5F9C476-200F-4440-9524-C5C3F9BE16D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C5F9C476-200F-4440-9524-C5C3F9BE16D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C5F9C476-200F-4440-9524-C5C3F9BE16D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C5F9C476-200F-4440-9524-C5C3F9BE16D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Loading…
Reference in New Issue