Make PdtExpression.Empty public.

This commit is contained in:
2023-05-18 13:28:46 +08:00
parent bc083541aa
commit 3d09ec8c94
2 changed files with 13 additions and 10 deletions

View File

@@ -7,6 +7,18 @@ namespace Cryville.Common.Pdt {
/// PDT expression.
/// </summary>
public class PdtExpression {
/// <summary>
/// The empty expression.
/// </summary>
public static readonly PdtExpression Empty;
static PdtExpression() {
var ins = new LinkedList<PdtInstruction>();
ins.AddLast(new PdtInstruction.PushConstant(
PdtInternalType.Number, BitConverter.GetBytes(1f)
));
Empty = new PdtExpression(ins);
}
internal LinkedList<PdtInstruction> Instructions;
/// <summary>
/// Whether the value of this expression is constant.
@@ -125,15 +137,6 @@ namespace Cryville.Common.Pdt {
{ '$', -1 },
};
static readonly PdtExpression _emptyexp;
static PdtInterpreter() {
var ins = new LinkedList<PdtInstruction>();
ins.AddLast(new PdtInstruction.PushConstant(
PdtInternalType.Number, BitConverter.GetBytes(1f)
));
_emptyexp = new PdtExpression(ins);
}
PdtExpToken GetToken() {
ws();
var result = new PdtExpToken {

View File

@@ -247,7 +247,7 @@ namespace Cryville.Common.Pdt {
break;
case ':':
case ';':
var exp = c == ';' ? _emptyexp : GetExp();
var exp = c == ';' ? PdtExpression.Empty : GetExp();
InterpretObjectInternal<PropertyListAttribute>(pcflag, type, pkey, result, type => _binder.ChangeType(exp, type, null));
break;
default: