tlang-runtime-compiler/TLang.Common/JumpUnconditional.cs

29 lines
653 B
C#

using System;
using System.IO;
namespace TLang.Common
{
public class JumpUnconditional : Instruction, ILabelable
{
public string Key {get;set;}
public int Value {get;set;} =0;
public JumpUnconditional(string key)
{
Key = key;
}
public override int CalculateLength()
{
return 5;
}
public override void WriteData(Stream strm)
{
strm.WriteByte(JMP);
var data=BitConverter.GetBytes(Value);
if(BitConverter.IsLittleEndian) Array.Reverse(data);
strm.Write(data,0,data.Length);
}
}
}