Implement compound operator patching.

This commit is contained in:
2022-11-14 16:03:35 +08:00
parent 1f57c299a2
commit d5d6465806
2 changed files with 15 additions and 3 deletions

View File

@@ -34,6 +34,16 @@ namespace Cryville.Common.Pdt {
}
}
/// <summary>
/// Patches an expression with a lefthand variable and a compound operator.
/// </summary>
/// <param name="target">The name of the lefthand variable.</param>
/// <param name="op">The name of the compound operator.</param>
/// <param name="exp">The expression.</param>
public void PatchCompound(int target, int op, PdtExpression exp) {
exp.Instructions.AddFirst(new PdtInstruction.PushVariable(target));
exp.Instructions.AddLast(new PdtInstruction.Operate(op, 2));
}
/// <summary>
/// Optimizes an expression by merging its instructions.
/// </summary>
/// <param name="exp">The expression to optimize.</param>