Class PCodeSerializer
Serializes and parses P-Code in text form.
public static class PCodeSerializer
- Inheritance
-
PCodeSerializer
- Inherited Members
Methods
Parse(string)
Parses P-Code text into instructions.
public static IReadOnlyList<Instruction> Parse(string text)
Parameters
textstringInput text containing p-code.
Returns
- IReadOnlyList<Instruction>
Parsed instruction list.
ParseInt(string, int, string)
Parses an integer value or throws a formatted exception.
private static int ParseInt(string value, int lineNo, string partName)
Parameters
valuestringText to parse.
lineNointLine number for error reporting.
partNamestringName of the parsed part.
Returns
- int
Parsed integer.
ParseOpcode(string, int)
Parses an opcode from mnemonic or numeric form.
private static Opcode ParseOpcode(string value, int lineNo)
Parameters
Returns
- Opcode
The parsed opcode.
StripComment(string)
Removes // comments from a line.
private static string StripComment(string line)
Parameters
linestringInput line.
Returns
- string
Line content without comments.
ToAsm(IReadOnlyList<Instruction>)
Converts instructions to mnemonic assembly format.
public static string ToAsm(IReadOnlyList<Instruction> instructions)
Parameters
instructionsIReadOnlyList<Instruction>Instructions to serialize.
Returns
- string
Assembly text with one instruction per line.
ToCod(IReadOnlyList<Instruction>)
Converts instructions to numeric opcode format.
public static string ToCod(IReadOnlyList<Instruction> instructions)
Parameters
instructionsIReadOnlyList<Instruction>Instructions to serialize.
Returns
- string
Numeric opcode text with one instruction per line.
ToMnemonic(Opcode)
Converts an opcode to its mnemonic form.
private static string ToMnemonic(Opcode opcode)
Parameters
opcodeOpcodeOpcode to convert.
Returns
- string
Mnemonic string.