public Value[] CollectRecursiveValues() { HashSet <Value> visitedValues = new HashSet <Value>(); List <Value> values = new List <Value>(); ValueTable currentTable = TopTable; while (currentTable != null) { foreach (var currentValue in currentTable.Values) { if (currentValue.IsConstant || visitedValues.Contains(currentValue)) { continue; } if (currentValue.IsLocal || currentValue.UsedRecursively || currentValue.HasCOWReferences()) { values.Add(currentValue); visitedValues.Add(currentValue); } } currentTable = currentTable.ParentTable; } // values.AddRange(GetMethodLinkage(CurrentEmitMethod, false).ParameterValues); values.AddRange(_openCows.Where(e => e.Value != null && e.ReferenceCount > 0 && !e.Value.IsConstant && !visitedValues.Contains(e.Value)).Select(e => e.Value)); return(values.ToArray()); }
private void OpenScope() { #if UDONSHARP_DEBUG _scopeDepth += 1; #endif ValueTable newTable = new ValueTable(Module, TopTable); TopTable.AddChildTable(newTable); _valueTableStack.Push(newTable); }
public Value(ValueTable parentTable, string uniqueID, TypeSymbol userType, ValueFlags flags) { #if UDONSHARP_DEBUG if (parentTable == null) { throw new NullReferenceException(); } #endif _parentTable = parentTable; UserType = userType; Flags = flags; UniqueID = uniqueID; }
public void DirtyAllValues() { ValueTable currentTable = this; while (currentTable != null) { if (currentTable._values != null) { Value[] iterationArray = currentTable._values.ToArray(); // Needed since dirtying can modify the _values list foreach (Value val in iterationArray) { if (val.IsConstant || val.IsLocal || val.IsInternal) { continue; } val.MarkDirty(); } } currentTable = currentTable.ParentTable; } }
public void AddChildTable(ValueTable child) { LazyInitTable(); _childTables.Add(child); }
public ValueTable(AssemblyModule module, ValueTable parent) { Module = module; ParentTable = parent; _nameCollisionCheckSet = ParentTable != null ? new HashSet <string>(ParentTable._nameCollisionCheckSet) : new HashSet <string>(); }