public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount , Slot reservedSlot) { if (slotChangeCount > 0) { var transactionLogSlot = SlotLongEnoughForLog(slotChangeCount, reservedSlot) ? reservedSlot : AllocateSlot(true, slotChangeCount); var buffer = new StatefulBuffer(_container.SystemTransaction(), transactionLogSlot ); buffer.WriteInt(transactionLogSlot.Length()); buffer.WriteInt(slotChangeCount); AppendSlotChanges(buffer, slotChangeTree); buffer.Write(); var commitHook = _container.CommitHook(); FlushDatabaseFile(); _container.WriteTransactionPointer(transactionLogSlot.Address()); FlushDatabaseFile(); if (WriteSlots(slotChangeTree)) { FlushDatabaseFile(); } _container.WriteTransactionPointer(0); commitHook.Run(); FlushDatabaseFile(); if (transactionLogSlot != reservedSlot) { FreeSlot(transactionLogSlot); } } FreeSlot(reservedSlot); }
// throws VisitFailure public virtual IVisitable visit(IVisitable x) { Object state = v.getState(); IVisitable result = v.visit(x); v.setState(state); return result; }
internal override void Visit(IVisitable visitable) { var item = visitable as EFContainer; if (item == null) { return; } if (item.State != EFElementState.Normalized) { return; } try { item.Resolve(_artifactSet); } catch (Exception e) { // reset element state item.State = EFElementState.ResolveAttempted; string name = null; var nameable = item as EFNameableItem; if (nameable != null) { name = nameable.LocalName.Value; } else { var element = item.XObject as XElement; if (element != null) { name = element.Name.LocalName; } else { name = item.SemanticName; } } var message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorResolvingItem, name, e.Message); var errorInfo = new ErrorInfo( ErrorInfo.Severity.ERROR, message, item, ErrorCodes.FATAL_RESOLVE_ERROR, ErrorClass.ResolveError); _artifactSet.AddError(errorInfo); } if (item.State != EFElementState.Resolved) { var efElement = item as EFElement; if (efElement != null) { _missedCount++; if (!_missed.Contains(efElement)) { _missed.Add(efElement); } } } }
/** * Create a new Logger, which has as initial trace a sequence of * visiting events where the visitor <code>v</code> visits each of * the <code>nodes</code> */ public Logger(IVisitor v, IVisitable[] nodes) { for (int i = 0; i < nodes.Length; i++) { log( new Event(v, nodes[i]) ); } }
// throws VisitFailure public virtual IVisitable visit(IVisitable x) { if (visitables.Contains(x)) { throw (new VisitFailure()); } return x; }
public void Visit(IVisitable pVisitable) { if (pVisitable is PriceChangeMessage) { PriceChangeMessage lMsg = pVisitable as PriceChangeMessage; Result = new TradeItem() { Change = lMsg.Change, Name = lMsg.Item, Price = lMsg.Price }; } }
public void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter) { Slot reservedSlot = _transactionLogHandler.AllocateSlot(false, CountSlotChanges(slotChanges )); freespaceCommitter.Commit(); _transactionLogHandler.ApplySlotChanges(slotChanges, CountSlotChanges(slotChanges ), reservedSlot); }
public override void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter ) { if (TriggersException()) { _exceptionFactory.ThrowException(); } base.Commit(slotChanges, freespaceCommitter); }
public void AddElement(IVisitable element) { this.codeElements.Add(element); if (element is ClassModel) { ClassModel @class = (ClassModel)element; this.classes[@class.Name] = @class; this.classes[@class.MetaClass.Name] = @class.MetaClass; } }
internal override void Visit(IVisitable visitable) { base.Visit(visitable); var ib = visitable as ItemBinding; if (ib != null) { ib.Unbind(); } }
// throws VisitFailure public virtual IVisitable visit(IVisitable any) { int childCount = any.getChildCount(); IVisitable result = any; for (int i = 0; i < childCount; i++) { result.setChildAt(i, v.visit(result.getChildAt(i))); } return result; }
public virtual IVisitable visit(IVisitable x) { try { Thread.Sleep(sleepTime); } catch (System.Threading.ThreadInterruptedException) { } return x; }
/* Visit the current visitable with the argument visitor v, * and turn any VisitFailure that might occur into a * RuntimeException. */ public virtual IVisitable visit(IVisitable visitable) { try { return v.visit(visitable); } catch (VisitFailure f) { throw new Exception(f.Message); } }
public virtual IVisitable visit(IVisitable visitable) { try { return first.visit(visitable); } catch (VisitFailure) { return then.visit(visitable); } }
internal virtual bool countingShouldContinue(IVisitable x) { bool goOn = false; try { goOnWhileSuccess.visit(x); goOn = true; } catch (VisitFailure) { goOn = false; } return goOn; }
public virtual IVisitable visit(IVisitable any) { IVisitable result; if (any is Node) { result = ((Node) any).accept(this); } else { throw new VisitFailure(); } return result; }
public virtual IVisitable visit(IVisitable visitable) { if(visitable is ATermVisitable) { ((ATermVisitable)visitable).accept(this); return visitable; } else { throw new VisitFailure(); } }
public ReListener(IVisitable bidirectionalMapper, FullListenerRegister fullListenerRegister, Action onDispose) { _Visitable = bidirectionalMapper; _FullListenerRegister = fullListenerRegister; _OnDisposeOk = onDispose; _DeltaProperty = DeltaListener.GetDeltaListener(_FullListenerRegister.Property); _DeltaCollection = DeltaListener.GetDeltaListener(_FullListenerRegister.Collection); _DeltaCommand = DeltaListener.GetDeltaListener(_FullListenerRegister.Command); Visit(_DeltaProperty.VisitOld, _DeltaCollection.VisitOld, _DeltaCommand.VisitOld); }
// throws VisitFailure public virtual IVisitable visit(IVisitable x) { try { v.visit(x); } catch (VisitFailure) { return x; } throw new VisitFailure(); }
// do nothing public virtual void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter ) { Slot oldSlot = _slot; Slot reservedSlot = AllocateSlot(false, EstimatedSlotLength(EstimateMappingCount( slotChanges))); // No more operations against the FreespaceManager. // Time to free old slots. freespaceCommitter.Commit(); slotChanges.Accept(new _IVisitor4_69(this)); WriteThis(reservedSlot); FreeSlot(oldSlot); }
public virtual IVisitable visit(IVisitable x) { try { action.visit(x); success++; } catch (VisitFailure) { failure++; } return x; }
public virtual IVisitable visit(IVisitable any) // throws VisitFailure { int childCount = any.getChildCount(); for (int i = 0; i < childCount; i++) { try { return any.setChildAt(i,v.visit(any.getChildAt(i))); } catch(VisitFailure) {} } throw new VisitFailure(); }
internal override void Visit(IVisitable visitable) { var item = visitable as EFElement; // if this is an EFElement and it is a higher state than // what we want to set it to, set it if (item != null && item.State > _state) { item.State = _state; } }
internal override void Visit(IVisitable visitable) { var efElement = visitable as EFElement; // search all EFElements if (null != efElement) { var stringToSearch = _elementTextToSearch(efElement); if (StringToSearchContainsTargetString(stringToSearch, _targetString)) { _objectsSatisfyingSearch.Add(efElement); } } }
// throws VisitFailure /** Apply the nesting depth counter to a given visitable. */ public virtual IVisitable visit(IVisitable x) { if (countingShouldContinue(x)) { if (isNestingConstruct(x)) { maxNestingDepth = restart().apply(x).getDepth(); } else { this.apply(x); } } return x; }
// throws VisitFailure public virtual void testTrueFailingThen() { Fail failingThen = new Fail(); Logger expected = new Logger(); expected.log( new Event( failingThen, n0 ) ); try { nodeReturned = new IfThenElse( new Identity(), logVisitor(failingThen), logVisitor(idFalse)).visit(n0); Assertion.Fail(); } catch(VisitFailure) { Assertion.AssertEquals("trace", expected, logger); Assertion.AssertNull("returned node", nodeReturned); } }
internal override void Visit(IVisitable visitable) { var item = visitable as EFContainer; if (item == null) { return; } if (item.State == EFElementState.None || item.State == EFElementState.Normalized || item.State == EFElementState.Resolved) { return; } try { item.Normalize(); } catch (Exception e) { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, "Error normalizing item {0}", item.SemanticName ), e); } if (item.State != EFElementState.Normalized) { // only do this for elements var efElement = item as EFElement; if (efElement != null) { _missedCount++; if (!_missed.Contains(efElement)) { _missed.Add(efElement); } } } }
// throws VisitFailure public override IVisitable visit(IVisitable visitable) { long startTime = DateTime.Now.Ticks; if (firstInvocationTimeStamp == 0) { firstInvocationTimeStamp = startTime; } logger.log( new Event(visitor,visitable) ); IVisitable result = visitor.visit( visitable ); long endTime = DateTime.Now.Ticks; lastReturnTimeStamp = endTime; consumedTime = consumedTime + (endTime - startTime); return result; }
// throws VisitFailure public virtual IVisitable visit(IVisitable x) { IVisitable result = v.visit(x); int childCount = result.getChildCount(); for (int i = 0; i < childCount; i++) { pending.Enqueue(result.getChildAt(i)); } if (pending.Count != 0) { IVisitable next = (IVisitable) pending.Dequeue(); next = this.visit(next); } return result; }
/// <summary> /// Performs a breadth-first traversal across the metadata tree starting at "item". /// The traversal calls Accept on each node. Each node can override the Accept to /// determine if they want to allow the Visitor to visit. Their Accept method should /// return the child nodes to be processed next. /// </summary> /// <param name="item"></param> internal void Traverse(IVisitable visitable) { // do a BFS across the metadata graph starting from item. var toVisit = new Queue<IVisitable>(); toVisit.Enqueue(visitable); while (toVisit.Count > 0) { var i = toVisit.Dequeue(); var newNodes = i.Accept(this); if (newNodes != null) { foreach (var v in newNodes) { toVisit.Enqueue(v); } } } }
public virtual void ReturnUnusedIds(IVisitable visitable) { visitable.Accept(new _IVisitor4_167(this)); }
void IApplicationBindingVisitor.VisitReferencedApplicationBinding(IVisitable <IApplicationBindingVisitor> referencedApplicationBinding) { // skip ReferencedApplicationBinding }
/// <summary> /// Wraps and accepts the specified visitor. /// </summary> /// <param name="subject">The subject.</param> /// <param name="visitor">The visitor.</param> /// <returns> /// <c>true</c> if the subject was visited; <c>false</c> otherwise. /// </returns> public static bool AcceptVisitor(this IVisitable subject, object visitor) => subject.AcceptVisitor(new Visitor(visitor));
/// <summary> /// Wraps and accepts the specified visitor. /// </summary> /// <param name="subject">The subject.</param> /// <param name="visitor">The visitor.</param> /// <returns> /// A <see cref="Task" /> object representing the async visit operation. /// </returns> /// <seealso cref="Visitor" /> public static Task <bool> AcceptVisitorAsync(this IVisitable subject, object visitor) => subject.AcceptVisitorAsync(new Visitor(visitor));
public Between(IVisitable value, IVisitable min, IVisitable max) { this.value = value; this.min = min; this.max = max; }
public virtual void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter ) { _delegate.Commit(slotChanges, freespaceCommitter); }
public virtual void ReturnUnusedIds(IVisitable visitable) { _delegate.ReturnUnusedIds(visitable); }
private static Expression GetVisitableExpression(object value) { IVisitable <IGenericVisitor> visitable = value as IVisitable <IGenericVisitor>; return(visitable == null ? null : new CodeGenerationTreeBuilder(visitable).Expression); }
void IQueryVisitor.Visit(IVisitable node) { node.Visit(this); }
public When(IVisitable condition, IVisitable value) { this.condition = condition; this.value = value; }
public virtual void Start(IVisitable visitable) { switch (visitable) { case Program program: Visit(program); break; case BinaryExpression bin: Visit(bin); break; case ConditionalBranch branch: Visit(branch); break; case DoWhileLoop doWhile: Visit(doWhile); break; case ForLoop forLoop: Visit(forLoop); break; case FunctionCall funcCall: Visit(funcCall); break; case FunctionDefinition funcDef: Visit(funcDef); break; case Literal lit: Visit(lit); break; case ReturnExpression ret: Visit(ret); break; case Scope scope: Visit(scope); break; case AST.Type type: Visit(type); break; case UnaryExpression un: Visit(un); break; case Variable var: Visit(var); break; case VariableDeclaration decl: Visit(decl); break; case WhileLoop whileLoop: Visit(whileLoop); break; case Break brk: Visit(brk); break; case Continue cont: Visit(cont); break; default: throw new InvalidOperationException($"Visitor doesn't support visitables of type {visitable.GetType()}"); } }
public abstract void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount , Slot reservedSlot);
protected void AppendSlotChanges(ByteArrayBuffer writer, IVisitable slotChangeVisitable ) { slotChangeVisitable.Accept(new _IVisitor4_30(writer)); }