private void generateAssignInto(LValueProvider lValue) { if (_storage != null) { //value is already created, reassign it lValue.Assign(_storage, _newOperator); return; } var storageProvider = lValue as IStorageReadProvider; if (storageProvider == null) { var temporary = new TemporaryVariableValue(_objectType, Context); _storage = temporary.Storage; temporary.AssignNewObject(_objectType, _newOperator); lValue.Assign(_storage, _newOperator); } else { _storage = storageProvider.Storage; lValue.AssignNewObject(_objectType, _newOperator); } _ctorCall.Generate(); if (_initializerArguments.Length > 0) { generateInitializer(); } }
/// <inheritdoc /> public override string GenerateStorage() { var tmp = new TemporaryVariableValue(MethodInfo.ReturnType, Context); GenerateAssignInto(tmp); return(tmp.Storage); }
/// <summary> /// Get storage with computed result. Consider current state of computation. /// </summary> /// <returns>Storage where computation is stored</returns> private string getStorage() { if (_storage == null) { var tmp = new TemporaryVariableValue(_type, Context); generateAssignToStorage(tmp); } var storageProvider = _storage as IStorageReadProvider; return(storageProvider.Storage); }