Skip to content
Permalink
Browse files

fixed stack. added string functions (#723)

  • Loading branch information...
arakis authored and tgiphil committed Oct 7, 2019
1 parent 6ca4bb8 commit 435af4ff7fe69f138e245ca37610fae8c5cda988
Showing with 41 additions and 1 deletion.
  1. +40 −0 Source/Mosa.Korlib/System/String.cs
  2. +1 −1 Source/Mosa.Runtime/SimpleStackTraceEntry.cs
@@ -508,6 +508,46 @@ public unsafe string Substring(int startIndex, int length)
return result;
}

public unsafe bool StartsWith(string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));

if (value.length > length)
return false;

var thisChar = first_char;
var cmpChar = value.first_char;
for (var i = 0; i < value.length; i++)
{
if (*thisChar != *cmpChar)
return false;
thisChar++;
cmpChar++;
}
return true;
}

public unsafe bool EndsWith(string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));

if (value.length > length)
return false;

var thisChar = first_char + (length - value.length);
var cmpChar = value.first_char;
for (var i = 0; i < value.length; i++)
{
if (*thisChar != *cmpChar)
return false;
thisChar++;
cmpChar++;
}
return true;
}

public static bool IsNullOrEmpty(string value)
{
return (value == null) || (value.Length == 0);
@@ -22,7 +22,7 @@ public struct SimpleStackTraceEntry
public override string ToString()
{
string methodAddress = MethodDefinition.IsNull ? "[NULL]" : MethodDefinition.Method.ToInt32().ToString("x");
string methodName = MethodName == null ? "(unknown method)" : MethodName.Substring(MethodName.IndexOf(' ') + 1);
string methodName = MethodName == null ? "(unknown method)" : MethodName;

return "0x" + methodAddress + "+0x" + Offset.ToString("x") + " " + methodName;
}

0 comments on commit 435af4f

Please sign in to comment.
You can’t perform that action at this time.