diff --git a/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs b/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs
index 6b277f3..faedc5a 100644
--- a/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs
+++ b/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs
@@ -34,6 +34,16 @@ namespace Cryville.Common.Pdt {
}
}
///
+ /// Patches an expression with a lefthand variable and a compound operator.
+ ///
+ /// The name of the lefthand variable.
+ /// The name of the compound operator.
+ /// The expression.
+ public void PatchCompound(int target, int op, PdtExpression exp) {
+ exp.Instructions.AddFirst(new PdtInstruction.PushVariable(target));
+ exp.Instructions.AddLast(new PdtInstruction.Operate(op, 2));
+ }
+ ///
/// Optimizes an expression by merging its instructions.
///
/// The expression to optimize.
diff --git a/Assets/Cryville/Common/Pdt/PdtExpression.cs b/Assets/Cryville/Common/Pdt/PdtExpression.cs
index 6c8507a..5d1351d 100644
--- a/Assets/Cryville/Common/Pdt/PdtExpression.cs
+++ b/Assets/Cryville/Common/Pdt/PdtExpression.cs
@@ -51,9 +51,8 @@ namespace Cryville.Common.Pdt {
}
public class PushVariable : PdtInstruction {
public int Name { get; private set; }
- public PushVariable(string name) {
- Name = IdentifierManager.SharedInstance.Request(name);
- }
+ public PushVariable(int name) { Name = name; }
+ public PushVariable(string name) : this(IdentifierManager.SharedInstance.Request(name)) { }
internal override void Execute(PdtEvaluatorBase etor) {
etor.PushVariable(Name);
}
@@ -63,6 +62,9 @@ namespace Cryville.Common.Pdt {
}
public class Operate : PdtInstruction {
public PdtOperatorSignature Signature { get; private set; }
+ public Operate(int name, int paramCount) {
+ Signature = new PdtOperatorSignature(name, paramCount);
+ }
public Operate(string name, int paramCount) {
Signature = new PdtOperatorSignature(name, paramCount);
}