/// <summary> /// Allocates a new choice point with the current execution state /// </summary> public void TryMeElse(int nextClause) { var argumentValues = _registers.Skip(_environment.Variables.Length).Take(_environment.NumberOfArguments); var newChoice = new ChoicePoint(_choicePoint, _environment, argumentValues, new BasicTrail(), nextClause); _choicePoint = newChoice; _trail = _choicePoint.Trail; }
public ChoicePoint(ChoicePoint previousChoice, ByteCodeEnvironment environment, IEnumerable<IReferenceLiteral> arguments, ITrail trail, int nextClause) { if (arguments == null) throw new ArgumentNullException(nameof(arguments)); if (trail == null) throw new ArgumentNullException(nameof(trail)); _previousChoicePoint = previousChoice; _arguments = arguments.Select(arg => new SimpleReference(arg)).ToArray(); _trail = trail; _nextClause = nextClause; _environment = environment; }
/// <summary> /// Backtracks to the current choice point and discards it /// </summary> public void TrustMe() { BacktrackToChoicePoint(); _programCounter = _choicePoint.NextClause; _choicePoint = _choicePoint.PreviousChoicePoint; if (_choicePoint == null) { _trail = new NoTrail(); } else { _trail = _choicePoint.Trail; } }
public ChoicePoint(ChoicePoint previousChoice, ByteCodeEnvironment environment, IEnumerable <IReferenceLiteral> arguments, ITrail trail, int nextClause) { if (arguments == null) { throw new ArgumentNullException(nameof(arguments)); } if (trail == null) { throw new ArgumentNullException(nameof(trail)); } _previousChoicePoint = previousChoice; _arguments = arguments.Select(arg => new SimpleReference(arg)).ToArray(); _trail = trail; _nextClause = nextClause; _environment = environment; }