private ResultRef GetResults(Track track) { var results = new ResultRef(); results.Initialize(track.MaxLaps, track.MaxSpots, track.MaxTurnCount, 15, 8, 8, 8, 6); return(results); }
/// <summary> /// Evaluates the function. /// </summary> /// <param name="Arguments">Function arguments.</param> /// <param name="Variables">Variables collection.</param> /// <returns>Function result.</returns> public override IElement Evaluate(IElement[] Arguments, Variables Variables) { int i, c = Arguments.Length; IElement ResultRef = Arguments[0]; IElement Ref; ISet ResultSet = ResultRef.AssociatedSet; ISet Set; for (i = 1; i < c; i++) { Ref = Arguments[i]; Set = Arguments[i].AssociatedSet; if (!ResultSet.Equals(Set)) { if (Expression.Upgrade(ref ResultRef, ref ResultSet, ref Ref, ref Set, this)) { Arguments[0] = ResultRef; Arguments[i] = Ref; } else { ResultRef = new ObjectVector(ResultRef.ChildElements); ResultSet = ResultRef.AssociatedSet; Arguments[0] = ResultRef; Ref = new ObjectVector(Ref.ChildElements); Arguments[i] = Ref; } } } List <IElement> Elements = new List <IElement>(); Elements.AddRange(ResultRef.ChildElements); for (i = 1; i < c; i++) { Ref = Arguments[i]; Set = Arguments[i].AssociatedSet; if (!ResultSet.Equals(Set)) { if (!Expression.Upgrade(ref ResultRef, ref ResultSet, ref Ref, ref Set, this)) { Ref = new ObjectVector(Ref.ChildElements); } } Elements.AddRange(Ref.ChildElements); } return(ResultRef.Encapsulate(Elements, this)); }
public InterpretResult Interpret(string moduleName, string sourcePath, string source) { var resultRef = new ResultRef(); var interpreter = InterpretCoroutines(moduleName, sourcePath, source, resultRef); // var result = InterpretResult.Running; while (interpreter.MoveNext()) { } return(resultRef.value); }
// Execute [source] in the context of the core module. private IEnumerator LoadIntoCore(string source, ResultRef resultRef) { ObjModule coreModule = GetCoreModule(); ObjFn fn = Compiler.Compile(this, coreModule, "", source, true); if (fn == null) { resultRef.value = InterpretResult.CompileError; yield break; } Fiber = new ObjFiber(fn); var succeeded = new SuccessRef(); var interpreter = RunInterpreter(succeeded); while (interpreter.MoveNext()) { yield return(interpreter.Current); } resultRef.value = succeeded.value ? InterpretResult.Success : InterpretResult.RuntimeError; }
private ModifyPresidentialResultsCommand DefaultModifyPresidentialResultsCommand(int executionOrder, ResultRef result, PollingCentreRef pollingCentre, UserRef user) { var fixture = new Fixture(); ModifyPresidentialResultsCommand cmd = fixture .Build <ModifyPresidentialResultsCommand>() .With(n => n.ApplyToResult, result) .With(n => n.CommandGeneratedByUser, user) .With(n => n.OriginatingPollingCentre, pollingCentre) .Create(); cmd.CommandId = Guid.NewGuid(); cmd.ApplyToResult = result; CandidateRef candidate = new CandidateRef(Guid.NewGuid(), "Pombe Magufuli", CandidateType.PartyBacked); var res = new ResultDetail { Candidate = candidate, Result = 1000 }; var resList = new List <ResultDetail>(); resList.Add(res); cmd.ResultDetail = resList; cmd.OriginatingPollingCentre = pollingCentre; cmd.CommandGeneratedByUser = user; cmd.CommandExecutionOrder = executionOrder; return(cmd); }
private ConfirmPresidentialResultsCommand DefaultConfirmPresidentalResultsCommand(int executionOrder, ResultRef result, PollingCentreRef pollingCentre, UserRef user) { return(new ConfirmPresidentialResultsCommand { CommandId = Guid.NewGuid(), ApplyToResult = result, CommandGeneratedByUser = user, CommandExecutionOrder = executionOrder, OriginatingPollingCentre = pollingCentre }); }
private AddWomenRepLineItemsCommand DefaultAddWomenRepLineItemsCommand(int executionOrder, ResultRef result, PollingCentreRef pollingCentre, UserRef user) { var fixture = new Fixture(); AddWomenRepLineItemsCommand cmd = fixture .Build <AddWomenRepLineItemsCommand>() .With(n => n.ApplyToResult, result) .Create(); cmd.CommandId = Guid.NewGuid(); cmd.ApplyToResult = result; CandidateRef candidate = new CandidateRef(Guid.NewGuid(), "Rachel Shebesh", CandidateType.PartyBacked); var res = new ResultDetail { Candidate = candidate, Result = 1000 }; var resList = new List <ResultDetail>(); resList.Add(res); cmd.ResultDetail = resList; cmd.OriginatingPollingCentre = pollingCentre; cmd.CommandGeneratedByUser = user; cmd.CommandExecutionOrder = executionOrder; return(cmd); }
public IEnumerator InterpretCoroutines(string moduleName, string sourcePath, string source, ResultRef resultRef) { if (sourcePath.Length == 0) { var loader = LoadIntoCore(source, resultRef); while (loader.MoveNext()) { yield return(loader.Current); } yield break; } // TODO: Better module name. Obj name = Obj.MakeString(moduleName); ObjFiber f = LoadModule(name, source); if (f == null) { resultRef.value = InterpretResult.CompileError; yield break; } Fiber = f; var succeeded = new SuccessRef(); var interpreter = RunInterpreter(succeeded); while (interpreter.MoveNext()) { yield return(interpreter.Current); } resultRef.value = succeeded.value ? InterpretResult.Success : InterpretResult.RuntimeError; }
public ActionBuildResults(RollRef rolls, ResultRef results, Track track) { _rolls = rolls; _results = results; _track = track; }