mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Oops, all IBodyItems!
This commit is contained in:
@@ -6,7 +6,7 @@ using System.Text;
|
||||
namespace Microsoft.Iris.Asm.Models;
|
||||
|
||||
[DebuggerDisplay("{Name} " + DebuggerDisplay)]
|
||||
public record Label(string Name) : BodyItem
|
||||
public record Label(string Name) : CodeItem
|
||||
{
|
||||
public override string ToString() => $"{Name}:";
|
||||
}
|
||||
@@ -25,19 +25,41 @@ public record Operand(object Value, OperandDataType DataType, string Content = n
|
||||
public override string ToString() => Content ?? Value.ToString();
|
||||
}
|
||||
|
||||
public record Program(IEnumerable<IDirective> Directives, IEnumerable<IBodyItem> Body)
|
||||
public record Program
|
||||
{
|
||||
public Program(IEnumerable<IBodyItem> body)
|
||||
{
|
||||
Body = body.Cached();
|
||||
|
||||
Directives = body.OfType<IDirective>().Cached();
|
||||
Imports = Directives.OfType<IImportDirective>().Cached();
|
||||
Exports = Directives.OfType<ExportDirective>().Cached();
|
||||
|
||||
Code = body.OfType<ICodeItem>().Cached();
|
||||
}
|
||||
|
||||
public IEnumerable<IBodyItem> Body { get; }
|
||||
|
||||
public IEnumerable<IDirective> Directives { get; }
|
||||
public IEnumerable<IImportDirective> Imports { get; }
|
||||
public IEnumerable<ExportDirective> Exports { get; }
|
||||
|
||||
public IEnumerable<ICodeItem> Code { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
const string lineEnding = "\r\n";
|
||||
const string indent = " ";
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.AppendJoin(lineEnding, Directives.Select(i => i.ToString()));
|
||||
sb.AppendJoin(lineEnding, Exports.Select(i => i.ToString()));
|
||||
sb.Append(lineEnding);
|
||||
sb.Append(lineEnding);
|
||||
sb.AppendJoin(lineEnding, Imports.Select(i => i.ToString()));
|
||||
sb.Append(lineEnding);
|
||||
sb.Append(lineEnding);
|
||||
|
||||
foreach (var bodyItem in Body)
|
||||
foreach (var bodyItem in Code)
|
||||
{
|
||||
if (bodyItem is Instruction)
|
||||
sb.Append(indent);
|
||||
|
||||
Reference in New Issue
Block a user