Merge branch 'main' of http://www.liubai.site:3000/ninemine/RScript
This commit is contained in:
@@ -84,22 +84,22 @@ namespace Convention.RScript.Runner
|
|||||||
else if (varTypeName == "int")
|
else if (varTypeName == "int")
|
||||||
{
|
{
|
||||||
varType = typeof(int);
|
varType = typeof(int);
|
||||||
varDefaultValue = varInitExpression == null ? 0 : parser.Evaluate<int>(varInitExpression);
|
varDefaultValue = varInitExpression == null ? 0 : Convert.ChangeType(parser.Evaluate(varInitExpression), typeof(int));
|
||||||
}
|
}
|
||||||
else if (varTypeName == "double")
|
else if (varTypeName == "double")
|
||||||
{
|
{
|
||||||
varType = typeof(double);
|
varType = typeof(double);
|
||||||
varDefaultValue = varInitExpression == null ? 0.0 : parser.Evaluate<double>(varInitExpression);
|
varDefaultValue = varInitExpression == null ? 0.0 : Convert.ChangeType(parser.Evaluate(varInitExpression), typeof(double));
|
||||||
}
|
}
|
||||||
else if (varTypeName == "float")
|
else if (varTypeName == "float")
|
||||||
{
|
{
|
||||||
varType = typeof(float);
|
varType = typeof(float);
|
||||||
varDefaultValue = varInitExpression == null ? 0.0f : parser.Evaluate<float>(varInitExpression);
|
varDefaultValue = varInitExpression == null ? 0.0f : Convert.ChangeType(parser.Evaluate(varInitExpression), typeof(float));
|
||||||
}
|
}
|
||||||
else if (varTypeName == "bool")
|
else if (varTypeName == "bool")
|
||||||
{
|
{
|
||||||
varType = typeof(bool);
|
varType = typeof(bool);
|
||||||
varDefaultValue = varInitExpression == null ? false : parser.Evaluate<bool>(varInitExpression);
|
varDefaultValue = varInitExpression == null ? false : Convert.ChangeType(parser.Evaluate(varInitExpression), typeof(bool));
|
||||||
}
|
}
|
||||||
else if (varTypeName == "var")
|
else if (varTypeName == "var")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Convention.RScript
|
namespace Convention.RScript
|
||||||
{
|
{
|
||||||
@@ -121,7 +122,10 @@ namespace Convention.RScript.Parser
|
|||||||
{
|
{
|
||||||
if (CompileGenericExpression.TryGetValue(expression, out var result))
|
if (CompileGenericExpression.TryGetValue(expression, out var result))
|
||||||
{
|
{
|
||||||
return (result as IGenericExpression<T>).Evaluate();
|
if (result is IGenericExpression<T> genericExpression)
|
||||||
|
return genericExpression.Evaluate();
|
||||||
|
else
|
||||||
|
return context.CompileGeneric<T>(expression).Evaluate();
|
||||||
}
|
}
|
||||||
return Compile<T>(expression).Evaluate();
|
return Compile<T>(expression).Evaluate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user