void UpdateVariables(int newVariablesOffset, int oldVariablesOffset, int newVariableCount, int oldVariableCount, IList <EnvironmentUpdateMapEntry> variableEntries, IList <Variable> variables, Location[] newLocations) { if (variableEntries != null) { for (int i = 0; i < variableEntries.Count; i++) { EnvironmentUpdateMapEntry entry = variableEntries[i]; Fx.Assert(entry.NewOffset >= 0 && entry.NewOffset < newVariableCount, "Variable offset is out of range"); Fx.Assert(!entry.IsNewHandle, "This should have been caught in ActivityInstanceMap.UpdateRawInstance"); if (entry.IsAddition) { Variable newVariable = variables[entry.NewOffset]; Location location = newVariable.CreateLocation(); newLocations[newVariablesOffset + entry.NewOffset] = location; if (location.CanBeMapped) { ActivityUtilities.Add(ref this.locationsToRegister, newVariable); } } else { Fx.Assert(this.locations != null && this.singleLocation == null, "Caller should have copied singleLocation into locations array"); // rearrangement of existing variable // this entry here doesn't describe variable removal newLocations[newVariablesOffset + entry.NewOffset] = this.locations[oldVariablesOffset + entry.OldOffset]; } } } // copy over unchanged variable Locations for (int i = 0; i < newVariableCount; i++) { if (newLocations[newVariablesOffset + i] == null) { Fx.Assert(i < oldVariableCount, "New variable should have a location"); Fx.Assert(this.locations != null && this.locations.Length > oldVariablesOffset + i, "locations must be non-null and index i + oldVariableOffset must be within the range of locations."); newLocations[newVariablesOffset + i] = this.locations[oldVariablesOffset + i]; } } }
private static bool TryGatherSchedulableExpressions(IList <EnvironmentUpdateMapEntry> entries, out List <int> addedLocationReferenceIndexes) { addedLocationReferenceIndexes = null; for (int i = 0; i < entries.Count; i++) { EnvironmentUpdateMapEntry entry = entries[i]; if (entry.IsAddition) { if (addedLocationReferenceIndexes == null) { addedLocationReferenceIndexes = new List <int>(); } addedLocationReferenceIndexes.Add(entry.NewOffset); } } return(addedLocationReferenceIndexes != null); }
void UpdateArguments(EnvironmentUpdateMap map, Location[] newLocations) { if (map.HasArgumentEntries) { for (int i = 0; i < map.ArgumentEntries.Count; i++) { EnvironmentUpdateMapEntry entry = map.ArgumentEntries[i]; Fx.Assert(entry.NewOffset >= 0 && entry.NewOffset < map.NewArgumentCount, "Argument offset is out of range"); if (entry.IsAddition) { // Location allocation will be performed later during ResolveDynamicallyAddedArguments(). // for now, simply assign a dummy location so we know not to copy over the old value. newLocations[entry.NewOffset] = dummyLocation; } else { Fx.Assert(this.locations != null && this.singleLocation == null, "Caller should have copied singleLocation into locations array"); // rearrangement of existing arguments // this entry here doesn't describe argument removal newLocations[entry.NewOffset] = this.locations[entry.OldOffset]; } } } // copy over unchanged Locations, and null out DummyLocations for (int i = 0; i < map.NewArgumentCount; i++) { if (newLocations[i] == null) { Fx.Assert(this.locations != null && this.locations.Length > i, "locations must be non-null and index i must be within the range of locations."); newLocations[i] = this.locations[i]; } else if (newLocations[i] == dummyLocation) { newLocations[i] = null; } } }