feat(core/asm): add assembler token, operand, and statement primitives
This commit is contained in:
1 parent
8c516cccbf
commit
77e45f92f6
4 files changed
+212
No files matched your search
@@ -0,0 +1,79 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Chip8.Core.Assembly;
|
||||
|
||||
public abstract class Statement
|
||||
{
|
||||
protected Statement(SourcePosition position)
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public SourcePosition position { get; }
|
||||
}
|
||||
|
||||
public sealed class LabelStatement : Statement
|
||||
{
|
||||
public LabelStatement(string name, SourcePosition position) : base(position)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public string name { get; }
|
||||
}
|
||||
|
||||
public sealed class ConstantStatement : Statement
|
||||
{
|
||||
public ConstantStatement(string name, IReadOnlyList<Token> expression, SourcePosition position) : base(position)
|
||||
{
|
||||
this.name = name;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public string name { get; }
|
||||
public IReadOnlyList<Token> expression { get; }
|
||||
}
|
||||
|
||||
public sealed class OrgStatement : Statement
|
||||
{
|
||||
public OrgStatement(IReadOnlyList<Token> expression, SourcePosition position) : base(position)
|
||||
{
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public IReadOnlyList<Token> expression { get; }
|
||||
}
|
||||
|
||||
public sealed class AlignStatement : Statement
|
||||
{
|
||||
public AlignStatement(IReadOnlyList<Token> expression, SourcePosition position) : base(position)
|
||||
{
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public IReadOnlyList<Token> expression { get; }
|
||||
}
|
||||
|
||||
public sealed class DataStatement : Statement
|
||||
{
|
||||
public DataStatement(bool word, IReadOnlyList<IReadOnlyList<Token>> items, SourcePosition position) : base(position)
|
||||
{
|
||||
this.word = word;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public bool word { get; }
|
||||
public IReadOnlyList<IReadOnlyList<Token>> items { get; }
|
||||
}
|
||||
|
||||
public sealed class InstructionStatement : Statement
|
||||
{
|
||||
public InstructionStatement(string mnemonic, IReadOnlyList<Operand> operands, SourcePosition position) : base(position)
|
||||
{
|
||||
this.mnemonic = mnemonic;
|
||||
this.operands = operands;
|
||||
}
|
||||
|
||||
public string mnemonic { get; }
|
||||
public IReadOnlyList<Operand> operands { get; }
|
||||
}
|
||||
Reference in new issue
Block a user