Introduce IdentifierManager to improve PDT evaluator performance.

This commit is contained in:
2022-11-01 13:47:04 +08:00
parent 3bfc7eb643
commit 2c9be2ef1e
12 changed files with 229 additions and 145 deletions

View File

@@ -59,7 +59,7 @@ namespace Cryville.Crtr {
}
public class Constraint {
class ArbitraryOp : PropOp {
public string name;
public int name;
protected override void Execute() {
var op = GetOperand(0);
var value = new byte[op.Length];
@@ -114,15 +114,15 @@ namespace Cryville.Crtr {
}
public class PropertyKey {
public PropertyType Type { get; private set; }
public string Name { get; private set; }
public int Name { get; private set; }
public PropertyKey(PropertyType type, string name) {
Type = type;
Name = name;
Name = IdentifierManager.SharedInstance.Request(name);
}
public override string ToString() {
switch (Type) {
case PropertyType.Property: return Name;
case PropertyType.Variable: return "@var " + Name;
case PropertyType.Property: return Name.ToString();
case PropertyType.Variable: return string.Format("@var {0}", Name);
default: return string.Format("<{0}> {1}", Type, Name);
}
}
@@ -169,7 +169,7 @@ namespace Cryville.Crtr {
public pop_identstr(Action<string> cb) { _cb = cb; }
protected override void Execute() {
var op = GetOperand(0);
if (op.Type == PdtInternalType.Undefined) _cb(op.AsIdentifier());
if (op.Type == PdtInternalType.Undefined) _cb((string)IdentifierManager.SharedInstance.Retrieve(op.AsIdentifier()));
else if (op.Type == PdtInternalType.String) _cb(op.AsString());
else throw new InvalidCastException("Not an identifier or string");
}
@@ -183,7 +183,7 @@ namespace Cryville.Crtr {
var op = GetOperand(i);
if (op.Type != PdtInternalType.Undefined)
throw new InvalidCastException("Not an identifier");
result[i] = op.AsIdentifier();
result[i] = (string)IdentifierManager.SharedInstance.Retrieve(op.AsIdentifier());
}
_cb(result);
}