/// <summary> /// Allocate a field of the state machine of the given type, to serve as a temporary. /// </summary> private SynthesizedFieldSymbolBase GetOrAllocateTempField(TypeSymbol type) { SynthesizedFieldSymbolBase result = null; // See if we've allocated a temp field we can reuse. Not particularly efficient, but // there should not normally be a lot of hoisted temps. for (int i = 0; i < availableTempFields.Count; i++) { SynthesizedFieldSymbolBase f = availableTempFields[i]; if (f.Type == type) { result = f; availableTempFields.RemoveAt(i); break; } } if ((object)result == null) { var fieldName = GeneratedNames.SpillTempFieldName(nextTempNumber++); result = F.StateMachineField(type, fieldName, isPublic: true); } return(result); }