private ExecutionState <GroupState> Run(string code, InstructionExecutor <GroupState> executor = null) { (Synfron.Staxe.Matcher.Data.IMatchData matchData, bool success, int _, int?_, string _) = LanguageMatchEngine.Match(code); Assert.True(success); InstructionGenerator generator = new InstructionGenerator(); IList <Instruction <GroupState> > instructions = generator.Generate(matchData); InstructionOptimizer <GroupState> optimizer = new InstructionOptimizer <GroupState>(); instructions = optimizer.Optimize(instructions).ToArray(); GroupState groupState = new GroupState(); groupState.Group.Instructions = instructions.ToArray(); ExecutionState <GroupState> executionState = new ExecutionState <GroupState>(groupState); executor = executor ?? new InstructionExecutor <GroupState>() { ExternalDynamicPointers = NativeLocator.GetNativePointer, ValueProvider = new ValueProvider() }; PrintDiagnostics.EnableDiagnostics(code, executor, executionState, true); executor.Execute(executionState); return(executionState); }
public void BooleanTests(string expression, bool expectedResult) { (Synfron.Staxe.Matcher.Data.IMatchData matchData, bool success, int _, int?_, string _) = LanguageMatchEngine.Match(expression); Assert.True(success); InstructionGenerator generator = new InstructionGenerator(); IList <Instruction <GroupState> > instructions = generator.Generate(matchData); InstructionOptimizer <GroupState> optimizer = new InstructionOptimizer <GroupState>(); instructions = optimizer.Optimize(instructions); GroupState groupState = new GroupState(); groupState.Group.Instructions = instructions.ToArray(); ExecutionState <GroupState> executionState = new ExecutionState <GroupState>(groupState); InstructionExecutor <GroupState> executor = new InstructionExecutor <GroupState>(); executor.Execute(executionState); Assert.Equal(expectedResult, ((DefaultBooleanValue <GroupState>)executionState.ListRegister.Last().Value).Data); }