Implement int_map function. Remove "long operator" concept.
This commit is contained in:
@@ -7,7 +7,6 @@ using UnityEngine;
|
|||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class PdtEvaluator : PdtEvaluatorBase {
|
public class PdtEvaluator : PdtEvaluatorBase {
|
||||||
static readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new Dictionary<PdtOperatorSignature, PdtOperator>();
|
static readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new Dictionary<PdtOperatorSignature, PdtOperator>();
|
||||||
static readonly Dictionary<int, PdtOperator> _longops = new Dictionary<int, PdtOperator>();
|
|
||||||
readonly Dictionary<int, PdtOperator> _ctxops = new Dictionary<int, PdtOperator>();
|
readonly Dictionary<int, PdtOperator> _ctxops = new Dictionary<int, PdtOperator>();
|
||||||
|
|
||||||
readonly byte[] _numbuf = new byte[4];
|
readonly byte[] _numbuf = new byte[4];
|
||||||
@@ -63,6 +62,7 @@ namespace Cryville.Crtr {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static readonly int _op_sep = IdentifierManager.SharedInstance.Request(",");
|
static readonly int _op_sep = IdentifierManager.SharedInstance.Request(",");
|
||||||
|
static readonly int _func_int_map = IdentifierManager.SharedInstance.Request("int_map");
|
||||||
protected override PdtOperator GetOperator(PdtOperatorSignature sig) {
|
protected override PdtOperator GetOperator(PdtOperatorSignature sig) {
|
||||||
PdtOperator result;
|
PdtOperator result;
|
||||||
if (_shortops.TryGetValue(sig, out result)) {
|
if (_shortops.TryGetValue(sig, out result)) {
|
||||||
@@ -73,7 +73,9 @@ namespace Cryville.Crtr {
|
|||||||
_shortops.Add(new PdtOperatorSignature(_op_sep, sig.ParamCount), result);
|
_shortops.Add(new PdtOperatorSignature(_op_sep, sig.ParamCount), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (_longops.TryGetValue(sig.Name, out result)) {
|
else if (sig.Name == _func_int_map) {
|
||||||
|
result = new func_int_map(sig.ParamCount);
|
||||||
|
_shortops.Add(new PdtOperatorSignature(_func_int_map, sig.ParamCount), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (_ctxops.TryGetValue(sig.Name, out result)) {
|
else if (_ctxops.TryGetValue(sig.Name, out result)) {
|
||||||
@@ -145,8 +147,8 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
_shortops.Add(new PdtOperatorSignature("!", 1), new op_not_1());
|
_shortops.Add(new PdtOperatorSignature("!", 1), new op_not_1());
|
||||||
|
|
||||||
_longops.Add(IdentifierManager.SharedInstance.Request("frame_seq"), new func_frame_seq());
|
_shortops.Add(new PdtOperatorSignature("frame_seq", 3), new func_frame_seq());
|
||||||
_longops.Add(IdentifierManager.SharedInstance.Request("in_area"), new func_in_area());
|
_shortops.Add(new PdtOperatorSignature("in_area", 1), new func_in_area());
|
||||||
}
|
}
|
||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
@@ -411,6 +413,21 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class func_int_map : PdtOperator {
|
||||||
|
public func_int_map(int pc) : base(pc) {
|
||||||
|
if (pc < 4) throw new ArgumentOutOfRangeException("Too few parameters for int_map");
|
||||||
|
}
|
||||||
|
protected override unsafe void Execute() {
|
||||||
|
var value = GetOperand(0).AsNumber();
|
||||||
|
var offset = GetOperand(1).AsNumber();
|
||||||
|
var step = GetOperand(2).AsNumber();
|
||||||
|
var index = (int)((value - offset) / step);
|
||||||
|
if (index < 0 || index >= LoadedOperandCount - 3) index = 0;
|
||||||
|
var hit = GetOperand(index + 3);
|
||||||
|
var ret = GetReturnFrame(hit.Type, hit.Length);
|
||||||
|
hit.CopyTo(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
unsafe static class oputil {
|
unsafe static class oputil {
|
||||||
public static float AsNumber(PropSrc src) {
|
public static float AsNumber(PropSrc src) {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
|
Reference in New Issue
Block a user