public WorkspaceDocumentUpdatedEventArgs(string filePath, SnapshotBase snapshot) { this.FilePath = filePath ?? throw new ArgumentNullException(nameof(filePath)); this.Snapshot = snapshot ?? throw new ArgumentNullException(nameof(snapshot)); }
/// <summary> /// Set aliases to current snapshot entry. Aliases can be set even to those entries /// that doesn't belongs to any variable, field,.. /// </summary> /// <param name="context">Context snapshot where operation is proceeded</param> /// <param name="aliasedEntry">Snapshot entry which will be aliased from current entry</param> protected override void setAliases(SnapshotBase context, ReadSnapshotEntryBase aliasedEntry) { Snapshot snapshot = ToSnapshot(context); SnapshotLogger.append(context, "set alias: " + this.ToString() + " from: " + aliasedEntry.ToString()); if (snapshot.CurrentMode == SnapshotMode.InfoLevel) { return; } ICopyModelSnapshotEntry entry = ToEntry(aliasedEntry); AliasData data = entry.CreateAliasToEntry(snapshot); AssignCollector collector = new AssignCollector(snapshot); collector.AliasesProcessing = AliasesProcessing.BeforeCollecting; collector.ProcessPath(path); AssignAliasWorker worker = new AssignAliasWorker(snapshot); worker.AssignAlias(collector, data); data.Release(snapshot); }
public static void append(SnapshotBase snapshotBase, String message) { #if COPY_SNAPSHOT_LOG Snapshot snapshot = SnapshotEntry.ToSnapshot(snapshotBase); append(snapshot, message); #endif }
public WorkspaceDocument(WorkspaceBase <TKey> workspace, TKey key) { this.workspace = workspace ?? throw new ArgumentNullException(nameof(workspace)); this.Key = key; this.utf8Key = Encoding.UTF8.GetBytes(this.workspace.KeyToString(key)); this.CurrentSnapshot = workspace.GetCurrentSnapshot(this); }
/// <inheritdoc /> protected override void setAliases(SnapshotBase context, ReadSnapshotEntryBase aliasedEntry) { var snapshot = C(context); var aliasEntries = aliasedEntry.Aliases(context); snapshot.SetAliases(Storages, aliasEntries); }
/// <summary> /// Read memory represented by current snapshot entry /// </summary> /// <param name="context">Context snapshot where operation is proceeded</param> /// <returns> /// Memory represented by current snapshot entry /// </returns> /// <exception cref="System.NotSupportedException">Current mode: + snapshot.CurrentMode</exception> protected override MemoryEntry readMemory(SnapshotBase context) { SnapshotLogger.append(context, "read memory - " + this.ToString()); if (isTemporarySet(context)) { SnapshotLogger.append(context, "read from temporary location - " + this.ToString()); return(temporaryLocation.ReadMemory(context)); } else { SnapshotLogger.append(context, "read just value - " + this.ToString()); Snapshot snapshot = SnapshotEntry.ToSnapshot(context); switch (snapshot.CurrentMode) { case SnapshotMode.MemoryLevel: return(dataEntry); case SnapshotMode.InfoLevel: return(infoEntry); default: throw new NotSupportedException("Current mode: " + snapshot.CurrentMode); } } }
/// <summary> /// Creates new instance of Simplifier /// </summary> /// <param name="context">SnapshotBase</param> public Simplifier(SnapshotBase context) { this.context = context; result = new HashSet <Value>(); booleans = new HashSet <Value>(); strings = new HashSet <Value>(); }
public static InteropSnapshot FromSnapshot(SnapshotBase snapshotBase) { // TODO: can this memory alternatively be addressed with Memory<T>? unsafe int CopyChars(byte *buffer, int offset, int count) { var chars = stackalloc char[count]; for (int i = 0; i < count && (i + offset) < snapshotBase.Length; i++) { chars[i] = snapshotBase[i + offset]; } // TODO: this might have issues with encoding conversions of multi-char characters // at array boundaries. return(Encoding.UTF8.GetBytes(chars, count, buffer, count)); } ReadCallback callback = CopyChars; // Ensure that the callback can't be GC-ed. // TODO: free? GCHandle.Alloc(callback); return(new InteropSnapshot(callback, snapshotBase.Length)); } }
/// <summary> /// Write given value at memory represented by snapshot entry /// </summary> /// <param name="context">Context snapshot where operation is proceeded</param> /// <param name="value">Written value</param> /// <param name="forceStrongWrite">Determine that current write should be processed as strong</param> /// <exception cref="System.NotSupportedException">Current mode: + snapshot.CurrentMode</exception> protected override void writeMemory(SnapshotBase context, MemoryEntry value, bool forceStrongWrite) { SnapshotLogger.append(context, "write memory - " + this.ToString()); Snapshot snapshot = SnapshotEntry.ToSnapshot(context); switch (snapshot.CurrentMode) { case SnapshotMode.MemoryLevel: getTemporary(context).WriteMemory(context, value, forceStrongWrite); break; case SnapshotMode.InfoLevel: if (isTemporarySet(context)) { getTemporary(context).WriteMemory(context, value, forceStrongWrite); } else { infoEntry = value; } break; default: throw new NotSupportedException("Current mode: " + snapshot.CurrentMode); } }
/// <inheritdoc /> protected override ReadWriteSnapshotEntryBase readField(SnapshotBase context, VariableIdentifier field) { // TODO: The method should return SnapshotMemoryEntry of read fields var snapshot = C(context); var allKeys = new List <Memory.VariableKeyBase>(); foreach (var value in WrappedEntry.PossibleValues) { var objectValue = value as ObjectValue; if (objectValue != null) { var keys = snapshot.FieldStorages(objectValue, field); // TODO: Use snapshot.ReadValue to read values of every variable key allKeys.AddRange(keys); } else { // TODO: If it is not object, what to do? throw new NotSupportedException("Reading fields on non-arrays is not supported in SnapshotMemoryEntry yet"); } } return(new SnapshotStorageEntry(null, ForceStrong, allKeys.ToArray())); }
/// <inheritdoc /> protected override ReadWriteSnapshotEntryBase readIndex(SnapshotBase context, MemberIdentifier index) { // TODO: The method should return SnapshotMemoryEntry of read indices var snapshot = C(context); var allKeys = new List <Memory.VariableKeyBase>(); foreach (var value in WrappedEntry.PossibleValues) { var array = value as AssociativeArray; if (array != null) { var keys = snapshot.IndexStorages(array, index); // TODO: Use snapshot.ReadValue to read values of every variable key allKeys.AddRange(keys); } else { // TODO: If it is not array, what to do? throw new NotSupportedException("Reading indices on non-arrays is not supported in SnapshotMemoryEntry yet"); } } return(new SnapshotStorageEntry(null, ForceStrong, allKeys.ToArray())); }
/// <summary> /// Resolve method on current snapshot entry with given methodName /// </summary> /// <param name="context">Context where methods are resolved</param> /// <param name="methodName">Name of resolved method</param> /// <returns> /// Resolved methods /// </returns> protected override IEnumerable <FunctionValue> resolveMethod(SnapshotBase context, PHP.Core.QualifiedName methodName) { Snapshot snapshot = SnapshotEntry.ToSnapshot(context); snapshot.Factories.Logger.Log(context, "resolve method - " + this.ToString() + " method: " + methodName); if (isTemporarySet(context)) { return(getTemporary(context).ResolveMethod(context, methodName)); } else { snapshot.Factories.Logger.Log(snapshot, "iterate fields: " + this.ToString()); MemoryEntry values = readMemory(snapshot); snapshot.Factories.Benchmark.StartOperation(snapshot); snapshot.Factories.Benchmark.StartAlgorithm(snapshot, AlgorithmType.RESOLVE_METHOD); var methods = snapshot.Algorithms.ReadAlgorithm.GetMethod(snapshot, values, methodName); snapshot.Factories.Benchmark.FinishAlgorithm(snapshot, AlgorithmType.RESOLVE_METHOD); snapshot.Factories.Benchmark.FinishOperation(snapshot); return(methods); } }
/// <summary> /// Read memory represented by given field identifier resolved on current /// snapshot entry (resulting snapshot entry can encapsulate merging, alias resolving and /// other stuff based on nondeterminism of identifier and current snapshot entry) /// </summary> /// <param name="context">Context snapshot where operation is proceeded</param> /// <param name="field">Identifier of an field</param> /// <returns> /// Snapshot entry representing field resolving on current entry /// </returns> protected override ReadWriteSnapshotEntryBase readField(SnapshotBase context, AnalysisFramework.VariableIdentifier field) { Snapshot snapshot = SnapshotEntry.ToSnapshot(context); snapshot.Factories.Logger.Log(context, "read index - " + this.ToString()); return(getTemporary(context).ReadField(context, field)); }
internal static IEnumerable <FunctionValue> ResolveMethods(TypeValue type, SnapshotBase snapshot) { var resolver = new TypeMethodResolver(snapshot); type.Accept(resolver); return(resolver._methods); }
public Snapshot(PrimaryKey stateId) { Base = new SnapshotBase <PrimaryKey> { StateId = stateId }; State = new StateType(); }
private MemoryEntry getUndefinedMemoryEntry(SnapshotBase snapshot) { if (UndefinedEntry == null) { UndefinedEntry = new MemoryEntry(snapshot.UndefinedValue); } return(UndefinedEntry); }
/// <summary> /// Set aliases to current snapshot entry. Aliases can be set even to those entries /// that doesn't belongs to any variable, field,.. /// </summary> /// <param name="context">Context snapshot where operation is proceeded</param> /// <param name="aliasedEntry">Snapshot entry which will be aliased from current entry</param> protected override void setAliases(SnapshotBase context, ReadSnapshotEntryBase aliasedEntry) { Snapshot snapshot = SnapshotEntry.ToSnapshot(context); snapshot.Factories.Logger.Log(context, "set aliases - " + this.ToString()); getTemporary(context).SetAliases(context, aliasedEntry); }
public static void IncrementDoingVersion <PrimaryKey>(this SnapshotBase <PrimaryKey> snapshot, Type grainType) { if (snapshot.DoingVersion != snapshot.Version) { throw new StateInsecurityException(snapshot.StateId.ToString(), grainType, snapshot.DoingVersion, snapshot.Version); } snapshot.DoingVersion += 1; }
/// <summary> /// Stores one item /// </summary> /// <param name="item">The item</param> public void Store(SnapshotBase item) { using (var session = _store.OpenSession()) { session.Store(item); session.SaveChanges(); } }
/// <inheritdoc /> protected override ReadWriteSnapshotEntryBase readIndex(SnapshotBase context, MemberIdentifier index) { var snapshot = C(context); var indexVisitor = new IndexStorageVisitor(this, snapshot, index); return(indexVisitor.IndexedValue); }
/// <summary> /// Read memory represented by given index identifier resolved on current /// snapshot entry (resulting snapshot entry can encapsulate merging, alias resolving and /// other stuff based on nondeterminism of identifier and current snapshot entry) /// </summary> /// <param name="context">Context snapshot where operation is proceeded</param> /// <param name="index">Identifier of an index</param> /// <returns> /// Snapshot entry representing index resolving on current entry /// </returns> protected override ReadWriteSnapshotEntryBase readIndex(SnapshotBase context, MemberIdentifier index) { Snapshot snapshot = SnapshotEntry.ToSnapshot(context); snapshot.Factories.Logger.Log(context, "read index - " + this.ToString()); return(getTemporary(context).ReadIndex(context, index)); }
internal FlowOutputSet(SnapshotBase snapshot, int widenLimit = int.MaxValue, int simplifyLimit = int.MaxValue) : base(snapshot) { //because new snapshot has been initialized HasChanges = true; _widenLimit = widenLimit; _simplifyLimit = simplifyLimit; }
public Snapshot(K stateId) { Base = new SnapshotBase <K> { StateId = stateId }; State = new S(); }
private void extendAsCallInfo(SnapshotBase callerContext, MemoryEntry thisObject, MemoryEntry[] arguments) { //TODO semantic about this object and arguments ? var input = callerContext as Snapshot; _infoData.ExtendBy(input._infoData, true); }
/// <summary> /// Read warnings from <see cref="FlowOutputSet" /> /// </summary> /// <typeparam name="T">The type of read warnings</typeparam> /// <param name="flowOutSet">The flow out set.</param> /// <returns> List of warnings read </returns> public static IEnumerable <Value> ReadWarnings <T>(SnapshotBase flowOutSet) where T : AnalysisWarning { var snapshotEntry = flowOutSet.ReadControlVariable(getStorage <T>()); var resultEntry = snapshotEntry.ReadMemory(flowOutSet); var result = resultEntry.PossibleValues; return(from value in result where !(value is UndefinedValue) select value); }
public static ITextSnapshot ToTextSnapshot(this SnapshotBase snapshot) { if (snapshot is TextSnapshot textSnapshot) { return(textSnapshot.Snapshot); } throw new ArgumentException($"{nameof(snapshot)} must be of type {nameof(TextSnapshot)}"); }
/// <summary> /// Widens given values /// </summary> /// <param name="values">input values</param> /// <param name="Context">Snapshot</param> /// <returns>Memory entry with widen values</returns> public MemoryEntry Widen(IEnumerable <Value> values, SnapshotBase Context) { flags = FlagsHandler.GetFlags(values); foreach (var value in values) { value.Accept(this); } return(GetResult(Context)); }
/// <summary> /// Assigns the variable values held in this class to the flowOutputSet. /// </summary> /// <param name="flowOutputSet">The flow output set where the values will be assigned.</param> public void AssignToSnapshot(SnapshotBase flowOutputSet) { foreach (var variableValue in variableValues) { var variableInfo = flowOutputSet.GetVariable(new VariableIdentifier(variableValue.Key)); MemoryEntry values = new MemoryEntry(variableValue.Value.ToArray()); variableInfo.WriteMemory(flowOutputSet, values); } }
public TxSnapshotBase(SnapshotBase <PrimaryKey> snapshotBase) { StateId = snapshotBase.StateId; DoingVersion = snapshotBase.DoingVersion; Version = snapshotBase.Version; StartTimestamp = snapshotBase.StartTimestamp; LatestMinEventTimestamp = snapshotBase.LatestMinEventTimestamp; IsLatest = snapshotBase.IsLatest; IsOver = snapshotBase.IsOver; }
/// <summary> /// Iterates the indexes of PHP array in entry. /// </summary> /// <param name="context">The context.</param> /// <param name="snapshotEntry">The snapshot entry.</param> /// <returns>The list of indexes in the given snapshot entry.</returns> public static IEnumerable <MemberIdentifier> IterateIndexes(SnapshotBase context, ICopyModelSnapshotEntry snapshotEntry) { Snapshot snapshot = SnapshotEntry.ToSnapshot(context); MemoryEntry entry = snapshotEntry.ReadMemory(snapshot); CollectComposedValuesVisitor visitor = new CollectComposedValuesVisitor(); visitor.VisitMemoryEntry(entry); return(visitor.CollectIndexes(snapshot)); }