Exemple #1
0
        /// <summary>
        /// Creates the alias to this entry and returnes data which can be used to aliasing the target.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <returns>
        /// Alias data fro the newly created aliases.
        /// </returns>
        public AliasData CreateAliasToEntry(Snapshot snapshot)
        {
            //Collect alias indexes
            AssignCollector indexesCollector = new AssignCollector(snapshot);

            indexesCollector.ProcessPath(path);

            //Memory locations where to get data from
            ReadCollector valueCollector = new ReadCollector(snapshot);

            valueCollector.ProcessPath(path);

            //Get data from locations
            ReadWorker  worker = new ReadWorker(snapshot);
            MemoryEntry value  = worker.ReadValue(valueCollector);

            //Makes deep copy of data to prevent changes after assign alias
            TemporaryIndex            temporaryIndex = snapshot.CreateTemporary();
            MergeWithinSnapshotWorker mergeWorker    = new MergeWithinSnapshotWorker(snapshot);

            mergeWorker.MergeMemoryEntry(temporaryIndex, value);

            AliasData data = new AliasData(indexesCollector.MustIndexes, indexesCollector.MayIndexes, temporaryIndex);

            data.TemporaryIndexToRealease(temporaryIndex);

            return(data);
        }
Exemple #2
0
        /// <summary>
        /// Determine that memory represented by current snapshot entry Is already defined.
        /// If not, reading memory returns UndefinedValue. But UndefinedValue can be returned
        /// even for defined memory entries - this can be used to distinct
        /// between null/undefined semantic of PHP.
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <returns>True whether memory represented by current snapshot entry Is already defined.</returns>
        protected override bool isDefined(SnapshotBase context)
        {
            Snapshot snapshot = ToSnapshot(context);

            SnapshotLogger.append(context, "is defined:" + this.ToString());

            ReadCollector collector = new ReadCollector(snapshot);

            collector.ProcessPath(path);

            return(collector.IsDefined);
        }
Exemple #3
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, QualifiedName methodName)
        {
            Snapshot snapshot = ToSnapshot(context);

            SnapshotLogger.append(context, "resolve method - path: " + this.ToString() + " method: " + methodName);

            ReadCollector collector = new ReadCollector(snapshot);

            collector.ProcessPath(path);

            ReadWorker  worker = new ReadWorker(snapshot);
            MemoryEntry memory = worker.ReadValue(collector);

            return(snapshot.resolveMethod(memory, methodName));
        }
Exemple #4
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>
        protected override MemoryEntry readMemory(SnapshotBase context)
        {
            Snapshot snapshot = ToSnapshot(context);

            SnapshotLogger.append(context, "read: " + this.ToString());

            ReadCollector collector = new ReadCollector(snapshot);

            collector.ProcessPath(path);

            ReadWorker  worker = new ReadWorker(snapshot);
            MemoryEntry entry  = worker.ReadValue(collector);

            SnapshotLogger.appendToSameLine(" value: " + entry.ToString());

            return(entry);
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldLocationVisitor"/> class.
 /// </summary>
 /// <param name="fieldSegment">The field segment.</param>
 /// <param name="collector">The collector.</param>
 public FieldLocationVisitor(FieldPathSegment fieldSegment, ReadCollector collector)
     : base(collector.snapshot.MemoryAssistant)
 {
     this.fieldSegment = fieldSegment;
     this.collector    = collector;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexLocationVisitor"/> class.
 /// </summary>
 /// <param name="indexSegment">The index segment.</param>
 /// <param name="collector">The collector.</param>
 public IndexLocationVisitor(IndexPathSegment indexSegment, ReadCollector collector)
     : base(collector.snapshot.MemoryAssistant)
 {
     this.indexSegment = indexSegment;
     this.collector    = collector;
 }