Add Runtime.Substring and Arrays.CopyOf

This commit is contained in:
Sam Harwell 2013-02-16 09:45:18 -06:00
parent 3ba462d403
commit 8d4c3252f5
3 changed files with 30 additions and 0 deletions

View File

@ -145,6 +145,8 @@
<Compile Include="RecognitionException.cs" />
<Compile Include="Recognizer`2.cs" />
<Compile Include="RuleContext.cs" />
<Compile Include="Sharpen\Arrays.cs" />
<Compile Include="Sharpen\Runtime.cs" />
<Compile Include="TokenStreamRewriter.cs" />
<Compile Include="Tree\AbstractParseTreeVisitor`1.cs" />
<Compile Include="Tree\ErrorNodeImpl.cs" />

View File

@ -0,0 +1,13 @@
namespace Sharpen
{
using System;
internal static class Arrays
{
public static T[] CopyOf<T>(T[] array, int newSize)
{
Array.Resize(ref array, newSize);
return array;
}
}
}

View File

@ -0,0 +1,15 @@
namespace Sharpen
{
using System;
internal static class Runtime
{
public static string Substring(string str, int beginOffset, int endOffset)
{
if (str == null)
throw new ArgumentNullException("str");
return str.Substring(beginOffset, endOffset - beginOffset);
}
}
}