修复了一些bug
This commit is contained in:
@@ -79,7 +79,7 @@ namespace Convention.RScript.Runner
|
||||
if (varTypeName == "string")
|
||||
{
|
||||
varType = typeof(string);
|
||||
varDefaultValue = varInitExpression == null ? string.Empty : varInitExpression;
|
||||
varDefaultValue = varInitExpression == null ? string.Empty : varInitExpression.Trim('\"');
|
||||
}
|
||||
else if (varTypeName == "int")
|
||||
{
|
||||
|
||||
@@ -22,7 +22,14 @@ namespace Convention.RScript.Runner
|
||||
// 还原上层命名空间的变量
|
||||
foreach (var local in context.CurrentLocalSpaceVariableNames.Peek())
|
||||
{
|
||||
parser.context.Variables[local] = context.Variables[local].data;
|
||||
if (context.Variables.ContainsKey(local))
|
||||
{
|
||||
parser.context.Variables[local] = context.Variables[local].data;
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.context.Variables.Remove(local);
|
||||
}
|
||||
}
|
||||
context.CurrentLocalSpaceVariableNames.Pop();
|
||||
// 弹栈
|
||||
|
||||
@@ -97,6 +97,14 @@ namespace Convention.RScript.Parser
|
||||
this.context = context;
|
||||
// 默认启用未定义标识符作为字符串的功能
|
||||
this.context.Options.UndefinedIdentifiersAsStrings = true;
|
||||
// 启用大小写敏感
|
||||
this.context.Options.CaseSensitive = true;
|
||||
// 启用溢出检查
|
||||
this.context.Options.Checked = true;
|
||||
#if UNITY_EDITOR
|
||||
// 浮点数使用float而非double(Unity性能优化)
|
||||
this.context.Options.RealLiteralDataType = RealLiteralDataType.Single;
|
||||
#endif
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, Type> CompileGenericExpressionTypen = new();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Convention.RScript
|
||||
else
|
||||
internalData = Activator.CreateInstance(type);
|
||||
}
|
||||
else if (type == typeof(object) || type == value.GetType())
|
||||
else if (type == typeof(object) || type.IsAssignableFrom(value.GetType()))
|
||||
internalData = value;
|
||||
else
|
||||
internalData = Convert.ChangeType(value, type);
|
||||
|
||||
Reference in New Issue
Block a user