aboutsummaryrefslogtreecommitdiff
path: root/Spv.Generator/LiteralString.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Spv.Generator/LiteralString.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'Spv.Generator/LiteralString.cs')
-rw-r--r--Spv.Generator/LiteralString.cs54
1 files changed, 0 insertions, 54 deletions
diff --git a/Spv.Generator/LiteralString.cs b/Spv.Generator/LiteralString.cs
deleted file mode 100644
index 629ff7bf..00000000
--- a/Spv.Generator/LiteralString.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-
-namespace Spv.Generator
-{
- public class LiteralString : Operand, IEquatable<LiteralString>
- {
- public OperandType Type => OperandType.String;
-
- private string _value;
-
- public LiteralString(string value)
- {
- _value = value;
- }
-
- public ushort WordCount => (ushort)(_value.Length / 4 + 1);
-
- public void WriteOperand(BinaryWriter writer)
- {
- writer.Write(_value.AsSpan());
-
- // String must be padded to the word size (which is 4 bytes).
- int paddingSize = 4 - (Encoding.ASCII.GetByteCount(_value) % 4);
-
- Span<byte> padding = stackalloc byte[paddingSize];
-
- writer.Write(padding);
- }
-
- public override bool Equals(object obj)
- {
- return obj is LiteralString literalString && Equals(literalString);
- }
-
- public bool Equals(LiteralString cmpObj)
- {
- return Type == cmpObj.Type && _value.Equals(cmpObj._value);
- }
-
- public override int GetHashCode()
- {
- return DeterministicHashCode.Combine(Type, DeterministicHashCode.GetHashCode(_value));
- }
-
- public bool Equals(Operand obj)
- {
- return obj is LiteralString literalString && Equals(literalString);
- }
-
- public override string ToString() => _value;
- }
-}