正在新增编译缓存功能,用于加速与加密
This commit is contained in:
@@ -5,6 +5,11 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class BackpointRunner : JumpRuntimePointerRunner
|
||||
{
|
||||
public override void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public override object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -5,6 +5,11 @@ namespace Convention.RScript
|
||||
{
|
||||
public class BreakpointRunner : IRSentenceRunner
|
||||
{
|
||||
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
parser.Compile<bool>(sentence.content);
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
@@ -18,7 +23,6 @@ namespace Convention.RScript
|
||||
else if (context.NamespaceLayer.TryGetValue(context.RuntimePointerStack.Peek(), out var exitPointer))
|
||||
{
|
||||
context.CurrentRuntimePointer = exitPointer;
|
||||
//DoExitNamespace(parser);
|
||||
context.SentenceRunners[RScriptSentence.Mode.ExitNamespace].Run(parser, context.CurrentSentence, context);
|
||||
}
|
||||
else
|
||||
|
@@ -6,6 +6,66 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class DefineVariableRunner : IRSentenceRunner
|
||||
{
|
||||
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
var varTypeName = sentence.info[0];
|
||||
var varName = sentence.info[1];
|
||||
var varInitExpression = sentence.info[2];
|
||||
Type varType;
|
||||
object varDefaultValue;
|
||||
{
|
||||
if (varTypeName == "string")
|
||||
{
|
||||
varType = typeof(string);
|
||||
varDefaultValue = "";
|
||||
}
|
||||
else if (varTypeName == "int")
|
||||
{
|
||||
varType = typeof(int);
|
||||
if (varInitExpression != null) parser.Compile<int>(varInitExpression);
|
||||
varDefaultValue = 0;
|
||||
}
|
||||
else if (varTypeName == "double")
|
||||
{
|
||||
varType = typeof(double);
|
||||
if (varInitExpression != null) parser.Compile<double>(varInitExpression);
|
||||
varDefaultValue = 0.0;
|
||||
}
|
||||
else if (varTypeName == "float")
|
||||
{
|
||||
varType = typeof(float);
|
||||
if (varInitExpression != null) parser.Compile<float>(varInitExpression);
|
||||
varDefaultValue = 0.0f;
|
||||
}
|
||||
else if (varTypeName == "bool")
|
||||
{
|
||||
varType = typeof(bool);
|
||||
if (varInitExpression != null) parser.Compile<bool>(varInitExpression);
|
||||
varDefaultValue = false;
|
||||
}
|
||||
else if (varTypeName == "var")
|
||||
{
|
||||
varType = typeof(object);
|
||||
if (varInitExpression != null) parser.Compile(varInitExpression);
|
||||
varDefaultValue = new object();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RScriptRuntimeException($"Unsupported variable type '{varTypeName}'.", context.CurrentRuntimePointer);
|
||||
}
|
||||
}
|
||||
if (context.CurrentLocalSpaceVariableNames.Peek().Contains(varName) == false)
|
||||
{
|
||||
context.Variables.Add(varName, new(varType, default));
|
||||
parser.context.Variables[varName] = varDefaultValue;
|
||||
context.CurrentLocalSpaceVariableNames.Peek().Add(varName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RScriptRuntimeException($"Variable '{varName}' already defined on this namespace.", context.CurrentRuntimePointer);
|
||||
}
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -5,6 +5,11 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class EnterNamedSpaceRunner : IRSentenceRunner
|
||||
{
|
||||
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -5,6 +5,11 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class EnterNamespaceRunner : IRSentenceRunner
|
||||
{
|
||||
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -5,6 +5,11 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class ExitNamespaceRunner : IRSentenceRunner
|
||||
{
|
||||
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -5,6 +5,11 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class ExpressionRunner : IRSentenceRunner
|
||||
{
|
||||
public void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
parser.Compile(sentence.content);
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -5,6 +5,11 @@ namespace Convention.RScript.Runner
|
||||
{
|
||||
public class GoToRunner : JumpRuntimePointerRunner
|
||||
{
|
||||
public override void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
parser.Compile<bool>(sentence.info[0]);
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
public override object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context)
|
||||
{
|
||||
|
@@ -59,6 +59,7 @@ namespace Convention.RScript.Runner
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Compile(ExpressionParser parser, RScriptSentence sentence, RScriptContext context);
|
||||
[return: MaybeNull]
|
||||
public abstract object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context);
|
||||
}
|
||||
|
Reference in New Issue
Block a user