新增UndefinedIdentifiersAsStrings
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
private PropertyDescriptor _myPropertyDescriptor;
|
||||
private Type _myVariableType;
|
||||
private Type _myCalcEngineReferenceType;
|
||||
private bool _isStringLiteral;
|
||||
public IdentifierElement(string name)
|
||||
{
|
||||
this.MyName = name;
|
||||
@@ -60,6 +61,13 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
|
||||
if (MyPrevious == null)
|
||||
{
|
||||
// 检查是否启用了未定义标识符作为字符串的选项
|
||||
if (MyOptions.UndefinedIdentifiersAsStrings)
|
||||
{
|
||||
// 将此标识符标记为字符串字面量
|
||||
_isStringLiteral = true;
|
||||
return;
|
||||
}
|
||||
base.ThrowCompileException("NoIdentifierWithName", CompileExceptionReason.UndefinedName, MyName);
|
||||
}
|
||||
else
|
||||
@@ -140,6 +148,13 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
base.Emit(ilg, services);
|
||||
|
||||
// 如果是字符串字面量,直接发出字符串加载指令
|
||||
if (_isStringLiteral)
|
||||
{
|
||||
ilg.Emit(OpCodes.Ldstr, MyName);
|
||||
return;
|
||||
}
|
||||
|
||||
this.EmitFirst(ilg);
|
||||
|
||||
if ((_myCalcEngineReferenceType != null))
|
||||
@@ -354,6 +369,12 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
get
|
||||
{
|
||||
// 如果是字符串字面量,返回 string 类型
|
||||
if (_isStringLiteral)
|
||||
{
|
||||
return typeof(string);
|
||||
}
|
||||
|
||||
if ((_myCalcEngineReferenceType != null))
|
||||
{
|
||||
return _myCalcEngineReferenceType;
|
||||
|
||||
Reference in New Issue
Block a user