Compare commits

...

3 Commits

4 changed files with 17 additions and 5 deletions

View File

@@ -84,22 +84,22 @@ namespace Convention.RScript.Runner
else if (varTypeName == "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")
{
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")
{
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")
{
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")
{

View File

@@ -17,6 +17,7 @@ namespace Convention.RScript.Runner
{
depth = jumpResult.Item1;
lastLayer = jumpResult.Item2;
context.CurrentRuntimePointer = target;
}
else
{

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System;
using System.Linq;
using System.Diagnostics;
namespace Convention.RScript
{
@@ -121,7 +122,10 @@ namespace Convention.RScript.Parser
{
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();
}

View File

@@ -267,9 +267,16 @@ namespace Convention.RScript
public int StepCount { get; private set; }
#if DEBUG
public List<RScriptSentence> StepStack = new();
#endif
internal object RunNextStep(ExpressionParser parser)
{
StepCount++;
#if DEBUG
StepStack.Add(CurrentSentence);
#endif
var sentence = CurrentSentence;
try
{