public WorkspaceDocumentUpdatedEventArgs(string filePath, SnapshotBase snapshot)
 {
     this.FilePath = filePath
                     ?? throw new ArgumentNullException(nameof(filePath));
     this.Snapshot = snapshot
                     ?? throw new ArgumentNullException(nameof(snapshot));
 }
示例#2
0
        /// <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);
        }
示例#3
0
        public static void append(SnapshotBase snapshotBase, String message)
        {
#if COPY_SNAPSHOT_LOG
            Snapshot snapshot = SnapshotEntry.ToSnapshot(snapshotBase);
            append(snapshot, message);
#endif
        }
示例#4
0
 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);
 }
示例#5
0
        /// <inheritdoc />
        protected override void setAliases(SnapshotBase context, ReadSnapshotEntryBase aliasedEntry)
        {
            var snapshot     = C(context);
            var aliasEntries = aliasedEntry.Aliases(context);

            snapshot.SetAliases(Storages, aliasEntries);
        }
示例#6
0
        /// <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);
                }
            }
        }
示例#7
0
 /// <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>();
 }
示例#8
0
        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));
        }
    }
示例#9
0
        /// <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);
            }
        }
示例#10
0
        /// <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()));
        }
示例#11
0
        /// <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()));
        }
示例#12
0
        /// <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);
            }
        }
示例#13
0
        /// <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));
        }
示例#14
0
        internal static IEnumerable <FunctionValue> ResolveMethods(TypeValue type, SnapshotBase snapshot)
        {
            var resolver = new TypeMethodResolver(snapshot);

            type.Accept(resolver);

            return(resolver._methods);
        }
示例#15
0
文件: Snapshot.cs 项目: zz110/Ray
 public Snapshot(PrimaryKey stateId)
 {
     Base = new SnapshotBase <PrimaryKey>
     {
         StateId = stateId
     };
     State = new StateType();
 }
示例#16
0
 private MemoryEntry getUndefinedMemoryEntry(SnapshotBase snapshot)
 {
     if (UndefinedEntry == null)
     {
         UndefinedEntry = new MemoryEntry(snapshot.UndefinedValue);
     }
     return(UndefinedEntry);
 }
示例#17
0
        /// <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);
        }
示例#18
0
 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;
 }
示例#19
0
 /// <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();
     }
 }
示例#20
0
        /// <inheritdoc />
        protected override ReadWriteSnapshotEntryBase readIndex(SnapshotBase context, MemberIdentifier index)
        {
            var snapshot = C(context);

            var indexVisitor = new IndexStorageVisitor(this, snapshot, index);

            return(indexVisitor.IndexedValue);
        }
示例#21
0
        /// <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));
        }
示例#22
0
 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;
 }
示例#23
0
 public Snapshot(K stateId)
 {
     Base = new SnapshotBase <K>
     {
         StateId = stateId
     };
     State = new S();
 }
示例#24
0
        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);
        }
示例#25
0
        /// <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);
        }
示例#26
0
        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)}");
        }
示例#27
0
 /// <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));
 }
示例#28
0
 /// <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);
     }
 }
示例#29
0
 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;
 }
示例#30
0
        /// <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));
        }