/// <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); }
/// <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); }
/// <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)); }
/// <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); }
/// <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; }
/// <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; }