Skip to content

Commit

Permalink
libifps: allow Instruction.Create(OpCode, Operand, Operand, Operand) …
Browse files Browse the repository at this point in the history
…to be used for InlineCmpValueType too

libasm: allow generic operand to be used for InlineCmpValueType op2, as well as type
tests: refactor and fix
tests: add test for InlineCmpValueType on type and variable
  • Loading branch information
Wack0 committed Mar 31, 2023
1 parent 8aea82c commit b20d5d8
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 3,105 deletions.
17 changes: 13 additions & 4 deletions IFPSAsmLib/Assembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,20 @@ Dictionary<string, ParserElement> defines
var op1 = ParseOperandValue(next, function, types, globals, functions, aliases, defines);
if (next.Next == null) next.ThrowInvalid();
next = next.Next;
next.ExpectValidName();
next.EnsureNoNextChild();
if (!types.TryGetValue(next.Value, out var typeOp)) next.ThrowInvalid(string.Format("In function \"{0}\": Referenced unknown type", function.Name));
Operand op2 = null;
try
{
op2 = ParseOperandValue(next, function, types, globals, functions, aliases, defines);
}
catch
{
next.ExpectValidName();
next.EnsureNoNextChild();
if (!types.TryGetValue(next.Value, out var typeOp)) next.ThrowInvalid(string.Format("In function \"{0}\": Referenced unknown type", function.Name));
op2 = Operand.Create(typeOp);
}
if (next.Next != null) next.Next.ThrowInvalid();
return Instruction.Create(opcode, op0, op1, typeOp);
return Instruction.Create(opcode, op0, op1, op2);
}
case OperandType.InlineTypeVariable:
{
Expand Down
Loading

0 comments on commit b20d5d8

Please sign in to comment.