diff --git a/Assets/Cryville/Common/IdentifierManager.cs b/Assets/Cryville/Common/IdentifierManager.cs
new file mode 100644
index 0000000..106a771
--- /dev/null
+++ b/Assets/Cryville/Common/IdentifierManager.cs
@@ -0,0 +1,45 @@
+using System.Collections.Generic;
+
+namespace Cryville.Common {
+ ///
+ /// A manager that assigns each given identifiers a unique integer ID.
+ ///
+ public class IdentifierManager {
+ ///
+ /// A shared instance of the class.
+ ///
+ public static IdentifierManager SharedInstance = new IdentifierManager();
+
+ Dictionary _idents = new Dictionary();
+ List _ids = new List();
+
+ object _syncRoot = new object();
+
+ ///
+ /// Requests an integer ID for an identifier.
+ ///
+ /// The identifier.
+ /// The integer ID.
+ public int Request(object ident) {
+ lock (_syncRoot) {
+ int id;
+ if (!_idents.TryGetValue(ident, out id)) {
+ _idents.Add(ident, id = _idents.Count);
+ _ids.Add(ident);
+ }
+ return id;
+ }
+ }
+
+ ///
+ /// Retrieves the identifier assigned with an integer ID.
+ ///
+ /// The integer ID.
+ /// The identifier.
+ public object Retrieve(int id) {
+ lock (_syncRoot) {
+ return _ids[id];
+ }
+ }
+ }
+}
diff --git a/Assets/Cryville/Common/IdentifierManager.cs.meta b/Assets/Cryville/Common/IdentifierManager.cs.meta
new file mode 100644
index 0000000..8198deb
--- /dev/null
+++ b/Assets/Cryville/Common/IdentifierManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 478086496f56eaf46be4df4e2ad37fee
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs b/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs
index 0aac98c..c6f3629 100644
--- a/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs
+++ b/Assets/Cryville/Common/Pdt/PdtEvaluatorBase.cs
@@ -47,7 +47,7 @@ namespace Cryville.Common.Pdt {
var i = _rip.Value;
if (i is PdtInstruction.Operate) {
int fc0 = _framecount;
- int fc1 = ((PdtInstruction.Operate)i).ParamCount;
+ int fc1 = ((PdtInstruction.Operate)i).Signature.ParamCount;
try { i.Execute(this); } catch (Exception) { }
if (fc0 - _framecount == fc1) {
unsafe {
@@ -137,7 +137,7 @@ namespace Cryville.Common.Pdt {
_goffset += value.Length;
}
}
- internal unsafe void PushVariable(ref string name) {
+ internal unsafe void PushVariable(int name) {
fixed (StackFrame* frame = &_stack[_framecount++]) {
byte[] value;
GetVariable(name, out frame->Type, out value);
@@ -153,12 +153,12 @@ namespace Cryville.Common.Pdt {
/// The name of the variable.
/// The type of the variable.
/// The value of the variable.
- protected abstract void GetVariable(string name, out int type, out byte[] value);
- internal void Operate(ref string name, int pc) {
+ protected abstract void GetVariable(int name, out int type, out byte[] value);
+ internal void Operate(PdtOperatorSignature sig) {
PdtOperator op;
- try { op = GetOperator(name, pc); }
- catch (Exception) { _framecount -= pc; return; }
- Operate(op, pc);
+ try { op = GetOperator(sig); }
+ catch (Exception) { _framecount -= sig.ParamCount; return; }
+ Operate(op, sig.ParamCount);
}
///
/// Gets an operator of the specified name and the suggested parameter count.
@@ -167,7 +167,7 @@ namespace Cryville.Common.Pdt {
/// Suggested parameter count.
/// An operator of the specific name.
/// The parameter count of the returned operator does not necessarily equal to .
- protected abstract PdtOperator GetOperator(string name, int pc);
+ protected abstract PdtOperator GetOperator(PdtOperatorSignature sig);
unsafe void Operate(PdtOperator op, int pc, bool noset = false) {
fixed (byte* pmem = _mem) {
op.Begin(this);
@@ -179,7 +179,7 @@ namespace Cryville.Common.Pdt {
op.Call(pmem + _goffset, noset);
}
}
- internal unsafe void Collapse(ref string name, LinkedListNode target) {
+ internal unsafe void Collapse(int name, LinkedListNode target) {
fixed (byte* pmem = _mem) {
var frame = _stack[--_framecount];
if (Collapse(name, new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length))) {
@@ -194,7 +194,7 @@ namespace Cryville.Common.Pdt {
/// The name of the collapse operator.
/// The top frame in the stack as the parameter.
/// Whether to jump to the target of the collapse instruction.
- protected abstract bool Collapse(string name, PdtVariableMemory param);
+ protected abstract bool Collapse(int name, PdtVariableMemory param);
internal unsafe PdtVariableMemory StackAlloc(int type, byte* ptr, int len) {
fixed (StackFrame* frame = &_stack[_framecount++]) {
frame->Type = type;
diff --git a/Assets/Cryville/Common/Pdt/PdtExpression.cs b/Assets/Cryville/Common/Pdt/PdtExpression.cs
index 2750e00..4d52be4 100644
--- a/Assets/Cryville/Common/Pdt/PdtExpression.cs
+++ b/Assets/Cryville/Common/Pdt/PdtExpression.cs
@@ -50,43 +50,38 @@ namespace Cryville.Common.Pdt {
}
}
public class PushVariable : PdtInstruction {
- private string m_name;
- public string Name { get { return m_name; } }
+ public int Name { get; private set; }
public PushVariable(string name) {
- m_name = name;
+ Name = IdentifierManager.SharedInstance.Request(name);
}
internal override void Execute(PdtEvaluatorBase etor) {
- etor.PushVariable(ref m_name);
+ etor.PushVariable(Name);
}
public override string ToString() {
return string.Format("pushv {0}", Name);
}
}
public class Operate : PdtInstruction {
- private string m_name;
- public string Name { get { return m_name; } }
- public int ParamCount { get; private set; }
+ public PdtOperatorSignature Signature { get; private set; }
public Operate(string name, int paramCount) {
- m_name = name;
- ParamCount = paramCount;
+ Signature = new PdtOperatorSignature(name, paramCount);
}
internal override void Execute(PdtEvaluatorBase etor) {
- etor.Operate(ref m_name, ParamCount);
+ etor.Operate(Signature);
}
public override string ToString() {
- return string.Format("op {0}({1})", Name, ParamCount);
+ return string.Format("op {0}", Signature);
}
}
public class Collapse : PdtInstruction {
- private string m_name;
- public string Name { get { return m_name; } }
+ public int Name { get; private set; }
public LinkedListNode Target { get; internal set; }
public Collapse(string name, LinkedListNode target) {
- m_name = name;
+ Name = IdentifierManager.SharedInstance.Request(name);
Target = target;
}
internal override void Execute(PdtEvaluatorBase etor) {
- etor.Collapse(ref m_name, Target);
+ etor.Collapse(Name, Target);
}
public override string ToString() {
return string.Format("col {0}{{{1}}}", Name, Target.Value);
diff --git a/Assets/Cryville/Common/Pdt/PdtOperator.cs b/Assets/Cryville/Common/Pdt/PdtOperator.cs
index a1ae7d9..05de7bc 100644
--- a/Assets/Cryville/Common/Pdt/PdtOperator.cs
+++ b/Assets/Cryville/Common/Pdt/PdtOperator.cs
@@ -74,4 +74,48 @@ namespace Cryville.Common.Pdt {
return _etor.StackAlloc(type, _prmem, len);
}
}
+ ///
+ /// The signature of a .
+ ///
+ public struct PdtOperatorSignature : IEquatable {
+ ///
+ /// The name of the operator.
+ ///
+ public int Name { get; private set; }
+ ///
+ /// The parameter count.
+ ///
+ public int ParamCount { get; private set; }
+ readonly int _hash;
+ ///
+ /// Creates an operator signature.
+ ///
+ /// The name of the operator.
+ /// The parameter count.
+ public PdtOperatorSignature(string name, int paramCount)
+ : this(IdentifierManager.SharedInstance.Request(name), paramCount) { }
+ ///
+ /// Creates an operator signature.
+ ///
+ /// The identifier of the operator.
+ /// The parameter count.
+ public PdtOperatorSignature(int name, int paramCount) {
+ Name = name;
+ ParamCount = paramCount;
+ _hash = Name ^ ((ParamCount << 16) | (ParamCount >> 16));
+ }
+ public override bool Equals(object obj) {
+ if (!(obj is PdtOperatorSignature)) return false;
+ return Equals((PdtOperatorSignature)obj);
+ }
+ public bool Equals(PdtOperatorSignature other) {
+ return Name == other.Name && ParamCount == other.ParamCount;
+ }
+ public override int GetHashCode() {
+ return _hash;
+ }
+ public override string ToString() {
+ return string.Format("{0}({1})", Name, ParamCount);
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs b/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs
index 8eacff3..34bc867 100644
--- a/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs
+++ b/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs
@@ -101,11 +101,10 @@ namespace Cryville.Common.Pdt {
/// The offset on the span to start reading from.
/// The name of an undefined identifier.
/// The span does not represent an undefined identifier.
- public string AsIdentifier(int offset = 0) {
+ public int AsIdentifier(int offset = 0) {
if (Type != PdtInternalType.Undefined && Type != PdtInternalType.Array)
throw new InvalidCastException("Not an identifier");
- var len = *(int*)(_ptr + offset);
- return new string((char*)(_ptr + offset + sizeof(int)), 0, len);
+ return *(int*)(_ptr + offset);
}
internal void* TrustedAsOfLength(int len) {
if (Length < len)
diff --git a/Assets/Cryville/Crtr/Chart.cs b/Assets/Cryville/Crtr/Chart.cs
index 8031bcc..c27f841 100644
--- a/Assets/Cryville/Crtr/Chart.cs
+++ b/Assets/Cryville/Crtr/Chart.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using Cryville.Common;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -112,19 +113,19 @@ namespace Cryville.Crtr {
}
[JsonIgnore]
- public Dictionary PropSrcs { get; private set; }
+ public Dictionary PropSrcs { get; private set; }
protected void SubmitPropSrc(string name, PropSrc property) {
- PropSrcs.Add(name, property);
+ PropSrcs.Add(IdentifierManager.SharedInstance.Request(name), property);
}
[JsonIgnore]
- public Dictionary PropOps { get; private set; }
+ public Dictionary PropOps { get; private set; }
protected void SubmitPropOp(string name, PropOp property) {
- PropOps.Add(name, property);
+ PropOps.Add(IdentifierManager.SharedInstance.Request(name), property);
}
protected ChartEvent() {
- PropSrcs = new Dictionary();
- PropOps = new Dictionary();
+ PropSrcs = new Dictionary();
+ PropOps = new Dictionary();
SubmitPropSrc("long", new PropSrc.Boolean(() => IsLong));
SubmitPropSrc("time", new PropSrc.BeatTime(() => time.Value));
SubmitPropSrc("endtime", new PropSrc.BeatTime(() => endtime.Value));
diff --git a/Assets/Cryville/Crtr/ChartPlayer.cs b/Assets/Cryville/Crtr/ChartPlayer.cs
index aca86c9..9913330 100644
--- a/Assets/Cryville/Crtr/ChartPlayer.cs
+++ b/Assets/Cryville/Crtr/ChartPlayer.cs
@@ -115,12 +115,12 @@ namespace Cryville.Crtr {
cbus.ForwardByTime(dt);
bbus.ForwardByTime(dt);
UnityEngine.Profiling.Profiler.BeginSample("ChartPlayer.FeedJudge");
- judge.StartFrame();
+ /*judge.StartFrame();
Game.InputManager.EnumerateEvents(ev => {
// Logger.Log("main", 0, "Input", ev.ToString());
judge.Feed(ev);
});
- judge.EndFrame();
+ judge.EndFrame();*/
UnityEngine.Profiling.Profiler.EndSample();
UnityEngine.Profiling.Profiler.BeginSample("ChartPlayer.Forward");
UnityEngine.Profiling.Profiler.BeginSample("EventBus.Copy");
diff --git a/Assets/Cryville/Crtr/Judge.cs b/Assets/Cryville/Crtr/Judge.cs
index c94fbbb..40afd6f 100644
--- a/Assets/Cryville/Crtr/Judge.cs
+++ b/Assets/Cryville/Crtr/Judge.cs
@@ -1,3 +1,4 @@
+using Cryville.Common;
using Cryville.Common.Pdt;
using Cryville.Common.Unity.Input;
using System.Collections.Generic;
@@ -7,24 +8,22 @@ namespace Cryville.Crtr {
readonly PdtRuleset _rs;
public Judge(PdtRuleset rs) {
_rs = rs;
- foreach (var s in rs.scores)
- scores.Add(s.Key, s.Value.init);
- }
- public void StartFrame() {
-
+ foreach (var s in rs.scores) {
+ var name = IdentifierManager.SharedInstance.Request(s.Key);
+ scoreDefs.Add(name, s.Value);
+ scores.Add(name, s.Value.init);
+ }
}
public void Feed(InputEvent ev) {
}
- public void EndFrame() {
-
- }
- public readonly Dictionary scores = new Dictionary();
- readonly Dictionary ScoreCache = new Dictionary();
- public Dictionary GetFormattedScoreStrings() {
+ public readonly Dictionary scoreDefs = new Dictionary();
+ public readonly Dictionary scores = new Dictionary();
+ readonly Dictionary ScoreCache = new Dictionary();
+ public Dictionary GetFormattedScoreStrings() {
if (ScoreCache.Count == 0) {
foreach (var s in scores)
- ScoreCache.Add(s.Key, s.Value.ToString(_rs.scores[s.Key].format));
+ ScoreCache.Add(s.Key, s.Value.ToString(scoreDefs[s.Key].format));
}
return ScoreCache;
}
@@ -51,7 +50,7 @@ namespace Cryville.Crtr {
public Dictionary scores;
}
public class ScoreOperation {
- public string name;
+ public int name;
public PdtOperator op;
}
public class ScoreDefinition {
diff --git a/Assets/Cryville/Crtr/PdtEvaluator.cs b/Assets/Cryville/Crtr/PdtEvaluator.cs
index 93feef4..7b7eaa9 100644
--- a/Assets/Cryville/Crtr/PdtEvaluator.cs
+++ b/Assets/Cryville/Crtr/PdtEvaluator.cs
@@ -1,66 +1,54 @@
-using Cryville.Common.Pdt;
+using Cryville.Common;
+using Cryville.Common.Pdt;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Cryville.Crtr {
public class PdtEvaluator : PdtEvaluatorBase {
- static readonly Dictionary _shortops = new Dictionary();
- static readonly Dictionary _longops = new Dictionary();
- readonly Dictionary _ctxops = new Dictionary();
- struct OperatorSignature : IEquatable {
- public string Name { get; private set; }
- public int ParamCount { get; private set; }
- readonly int _hash;
- public OperatorSignature(string name, int paramCount) {
- Name = name;
- ParamCount = paramCount;
- _hash = name.GetHashCode() ^ paramCount;
- }
- public override bool Equals(object obj) {
- if (!(obj is OperatorSignature)) return false;
- return Equals((OperatorSignature)obj);
- }
- public bool Equals(OperatorSignature other) {
- return Name == other.Name && ParamCount == other.ParamCount;
- }
- public override int GetHashCode() {
- return _hash;
- }
- }
+ static readonly Dictionary _shortops = new Dictionary();
+ static readonly Dictionary _longops = new Dictionary();
+ readonly Dictionary _ctxops = new Dictionary();
readonly byte[] _numbuf = new byte[4];
- protected override void GetVariable(string name, out int type, out byte[] value) {
- switch (name) {
- case "w": LoadNum(ChartPlayer.hitRect.width); type = PdtInternalType.Number; value = _numbuf; return;
- case "h": LoadNum(ChartPlayer.hitRect.height); type = PdtInternalType.Number; value = _numbuf; return;
- case "true": LoadNum(1); type = PdtInternalType.Number; value = _numbuf; return;
- case "false": LoadNum(0); type = PdtInternalType.Number; value = _numbuf; return;
- default:
- PropSrc prop;
- string str;
- if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) {
- prop.Get(out type, out value);
- }
- else if (ContextJudge != null && ContextJudge.GetFormattedScoreStrings().TryGetValue(name, out str)) {
- type = PdtInternalType.String;
- value = GetBytes(str);
- RevokePotentialConstant();
- }
- else {
- PropSrc.Arbitrary result;
- foreach (var cas in ContextCascade) {
- if (cas.TryGetValue(name, out result)) {
- result.Get(out type, out value);
- return;
- }
+ static int _var_w = IdentifierManager.SharedInstance.Request("w");
+ static int _var_h = IdentifierManager.SharedInstance.Request("h");
+ static int _var_true = IdentifierManager.SharedInstance.Request("true");
+ static int _var_false = IdentifierManager.SharedInstance.Request("false");
+ protected override void GetVariable(int name, out int type, out byte[] value) {
+ if (name == _var_w) { LoadNum(ChartPlayer.hitRect.width); type = PdtInternalType.Number; value = _numbuf; }
+ else if (name == _var_h) { LoadNum(ChartPlayer.hitRect.height); type = PdtInternalType.Number; value = _numbuf; }
+ else if (name == _var_true) { LoadNum(1); type = PdtInternalType.Number; value = _numbuf; }
+ else if (name == _var_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
+ else {
+ PropSrc prop;
+ string str;
+ if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) {
+ prop.Get(out type, out value);
+ }
+ else if (ContextJudge != null && ContextJudge.GetFormattedScoreStrings().TryGetValue(name, out str)) {
+ type = PdtInternalType.String;
+ value = GetBytes(str);
+ RevokePotentialConstant();
+ }
+ else {
+ PropSrc.Arbitrary result;
+ foreach (var cas in ContextCascade) {
+ if (cas.TryGetValue(name, out result)) {
+ result.Get(out type, out value);
+ return;
}
- type = PdtInternalType.Undefined;
- value = GetBytes(name);
}
- return;
+ type = PdtInternalType.Undefined;
+ LoadNum(name);
+ value = _numbuf;
+ }
+ return;
}
}
+ unsafe void LoadNum(int value) {
+ fixed (byte* ptr = _numbuf) *(int*)ptr = value;
+ }
unsafe void LoadNum(float value) {
fixed (byte* ptr = _numbuf) *(float*)ptr = value;
}
@@ -75,31 +63,32 @@ namespace Cryville.Crtr {
}
return result;
}
- protected override PdtOperator GetOperator(string name, int pc) {
+ static int _op_sep = IdentifierManager.SharedInstance.Request(",");
+ protected override PdtOperator GetOperator(PdtOperatorSignature sig) {
PdtOperator result;
- if (name.Length == 1 && _shortops.TryGetValue(new OperatorSignature(name, pc), out result)) {
+ if (_shortops.TryGetValue(sig, out result)) {
return result;
}
- else if (name == ",") {
- result = new op_arr(pc);
- _shortops.Add(new OperatorSignature(",", pc), result);
+ else if (sig.Name == _op_sep) {
+ result = new op_arr(sig.ParamCount);
+ _shortops.Add(new PdtOperatorSignature(",", sig.ParamCount), result);
return result;
}
- else if (_longops.TryGetValue(name, out result)) {
+ else if (_longops.TryGetValue(sig.Name, out result)) {
return result;
}
- else if (_ctxops.TryGetValue(name, out result)) {
+ else if (_ctxops.TryGetValue(sig.Name, out result)) {
return result;
}
- else throw new KeyNotFoundException(string.Format("Undefined operator {0}({1})", name, pc));
+ else throw new KeyNotFoundException(string.Format("Undefined operator {0}", sig));
}
- protected override bool Collapse(string name, PdtVariableMemory param) {
- switch (name) {
- case "&": return param.AsNumber() == 0;
- case "|": return param.AsNumber() != 0;
- default: throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
- }
+ static int _colop_and = IdentifierManager.SharedInstance.Request("&");
+ static int _colop_or = IdentifierManager.SharedInstance.Request("|");
+ protected override bool Collapse(int name, PdtVariableMemory param) {
+ if (name == _colop_and) return param.AsNumber() == 0;
+ else if(name == _colop_or) return param.AsNumber() != 0;
+ else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
}
public ChartEvent ContextEvent { private get; set; }
@@ -107,11 +96,11 @@ namespace Cryville.Crtr {
public Judge ContextJudge { private get; set; }
public PropSrc ContextSelfValue { private get; set; }
- readonly List> ContextCascade = new List>();
+ readonly List> ContextCascade = new List>();
public void ContextCascadeInsert() {
- ContextCascade.Add(new Dictionary());
+ ContextCascade.Add(new Dictionary());
}
- public void ContextCascadeUpdate(string key, PropSrc.Arbitrary value) {
+ public void ContextCascadeUpdate(int key, PropSrc.Arbitrary value) {
ContextCascade[ContextCascade.Count - 1][key] = value;
}
public void ContextCascadeDiscard() {
@@ -119,29 +108,29 @@ namespace Cryville.Crtr {
}
public PdtEvaluator() {
- _ctxops.Add("screen_edge", new func_screen_edge(() => ContextTransform));
- _ctxops.Add("int", new func_int(() => ContextSelfValue));
- _ctxops.Add("clamp", new func_clamp(() => ContextSelfValue));
- _ctxops.Add("min", new func_min(() => ContextSelfValue));
- _ctxops.Add("max", new func_max(() => ContextSelfValue));
+ _ctxops.Add(IdentifierManager.SharedInstance.Request("screen_edge"), new func_screen_edge(() => ContextTransform));
+ _ctxops.Add(IdentifierManager.SharedInstance.Request("int"), new func_int(() => ContextSelfValue));
+ _ctxops.Add(IdentifierManager.SharedInstance.Request("clamp"), new func_clamp(() => ContextSelfValue));
+ _ctxops.Add(IdentifierManager.SharedInstance.Request("min"), new func_min(() => ContextSelfValue));
+ _ctxops.Add(IdentifierManager.SharedInstance.Request("max"), new func_max(() => ContextSelfValue));
}
static PdtEvaluator() {
- _shortops.Add(new OperatorSignature("*", 2), new op_mul_2());
- _shortops.Add(new OperatorSignature("/", 2), new op_div_2());
- _shortops.Add(new OperatorSignature("%", 2), new op_mod_2());
+ _shortops.Add(new PdtOperatorSignature("*", 2), new op_mul_2());
+ _shortops.Add(new PdtOperatorSignature("/", 2), new op_div_2());
+ _shortops.Add(new PdtOperatorSignature("%", 2), new op_mod_2());
- _shortops.Add(new OperatorSignature("+", 1), new op_add_1());
- _shortops.Add(new OperatorSignature("+", 2), new op_add_2());
- _shortops.Add(new OperatorSignature("-", 1), new op_sub_1());
- _shortops.Add(new OperatorSignature("-", 2), new op_sub_2());
+ _shortops.Add(new PdtOperatorSignature("+", 1), new op_add_1());
+ _shortops.Add(new PdtOperatorSignature("+", 2), new op_add_2());
+ _shortops.Add(new PdtOperatorSignature("-", 1), new op_sub_1());
+ _shortops.Add(new PdtOperatorSignature("-", 2), new op_sub_2());
- _shortops.Add(new OperatorSignature("=", 2), new op_eq_2());
- _shortops.Add(new OperatorSignature("<", 2), new op_lt_2());
- _shortops.Add(new OperatorSignature(">", 2), new op_gt_2());
+ _shortops.Add(new PdtOperatorSignature("=", 2), new op_eq_2());
+ _shortops.Add(new PdtOperatorSignature("<", 2), new op_lt_2());
+ _shortops.Add(new PdtOperatorSignature(">", 2), new op_gt_2());
- _shortops.Add(new OperatorSignature("!", 1), new op_not_1());
+ _shortops.Add(new PdtOperatorSignature("!", 1), new op_not_1());
- _longops.Add("frame_seq", new func_frame_seq());
+ _longops.Add(IdentifierManager.SharedInstance.Request("frame_seq"), new func_frame_seq());
}
#region Operators
#pragma warning disable IDE1006
diff --git a/Assets/Cryville/Crtr/PropOp.cs b/Assets/Cryville/Crtr/PropOp.cs
index 071208a..6142f4b 100644
--- a/Assets/Cryville/Crtr/PropOp.cs
+++ b/Assets/Cryville/Crtr/PropOp.cs
@@ -1,4 +1,5 @@
-using Cryville.Common.Pdt;
+using Cryville.Common;
+using Cryville.Common.Pdt;
using System;
using System.Collections.Generic;
using System.Reflection;
@@ -36,14 +37,14 @@ namespace Cryville.Crtr {
}
}
public class Enum : PropOp {
- readonly static Dictionary _cache = new Dictionary();
+ readonly static Dictionary _cache = new Dictionary();
readonly Action _cb;
public Enum(Action cb) {
if (!typeof(T).IsEnum)
throw new ArgumentException("Type is not enum");
var names = typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static);
for (int i = 0; i < names.Length; i++)
- _cache[names[i].Name] = Convert.ToInt32(names[i].GetValue(null));
+ _cache[IdentifierManager.SharedInstance.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null));
_cb = cb;
}
protected override void Execute() {
diff --git a/Assets/Cryville/Crtr/Ruleset.cs b/Assets/Cryville/Crtr/Ruleset.cs
index 5cb7677..f83abfe 100644
--- a/Assets/Cryville/Crtr/Ruleset.cs
+++ b/Assets/Cryville/Crtr/Ruleset.cs
@@ -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 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);
}