Skip to content

Commit

Permalink
String now has getIndex/setIndex for Bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMagnus committed Feb 18, 2024
1 parent d2cef9d commit b676957
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/headers/linuxAmd64/string.ph
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ header function concatenate (stringA: String, stringB: String): String;
header function getIndex (string: String, index: Int): String;
header function setIndex (string: String, index: Int, character: String);

header function getIndexByte (string: String, index: Int): Int;
header function setIndexByte (string: String, index: Int, value: Int);

header function getLength (string: String): Int;
13 changes: 13 additions & 0 deletions src/platforms/amd64/linux/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ void setIndex (const String string, const UInt index, const String character)
newDataArray[index] = character->data[0];
}

Int getIndexByte (const String string, const UInt index) asm ("\"Standard.String~getIndexByte\"");
Int getIndexByte (const String string, const UInt index)
{
return createString(string->data[index], 1);
}

void setIndexByte (const String string, const UInt index, const Int value) asm ("\"Standard.String~setIndexByte\"");
void setIndexByte (const String string, const UInt index, const Int value)
{
UInt8* newDataArray = string->data;
newDataArray[index] = value;
}

UInt getLength (const String string) asm ("\"Standard.String~getLength\"");
UInt getLength (const String string)
{
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/amd64/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ String concatenate (const String string1, const String string2);
String getIndex (const String string, const UInt index);
void setIndex (const String string, const UInt index, const String character);

Int getIndexByte (const String string, const UInt index);
void setIndexByte (const String string, const UInt index, const Int value);

UInt getLength (const String string);

0 comments on commit b676957

Please sign in to comment.