39 lines
1.8 KiB
C#
39 lines
1.8 KiB
C#
using Convention.RScript.Parser;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Convention.RScript.Runner
|
|
{
|
|
public abstract class JumpRuntimePointerRunner : IRSentenceRunner
|
|
{
|
|
protected void DoJumpRuntimePointer(ExpressionParser parser, int target, RScriptContext context)
|
|
{
|
|
bool isForwardMove = target > context.CurrentRuntimePointer;
|
|
int step = isForwardMove ? 1 : -1;
|
|
for (; context.CurrentRuntimePointer != target; context.CurrentRuntimePointer += step)
|
|
{
|
|
if (context.CurrentSentence.mode == RScriptSentence.Mode.ExitNamespace)
|
|
{
|
|
if (isForwardMove)
|
|
//DoExitNamespace(parser);
|
|
context.SentenceRunners[RScriptSentence.Mode.ExitNamespace].Run(parser, context.CurrentSentence, context);
|
|
else
|
|
//DoEnterNamespace(parser);
|
|
context.SentenceRunners[RScriptSentence.Mode.EnterNamespace].Run(parser, context.CurrentSentence, context);
|
|
}
|
|
else if (context.CurrentSentence.mode == RScriptSentence.Mode.EnterNamespace)
|
|
{
|
|
if (isForwardMove)
|
|
//DoEnterNamespace(parser);
|
|
context.SentenceRunners[RScriptSentence.Mode.EnterNamespace].Run(parser, context.CurrentSentence, context);
|
|
else
|
|
//DoExitNamespace(parser);
|
|
context.SentenceRunners[RScriptSentence.Mode.ExitNamespace].Run(parser, context.CurrentSentence, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
[return: MaybeNull]
|
|
public abstract object Run(ExpressionParser parser, RScriptSentence sentence, RScriptContext context);
|
|
}
|
|
}
|