/// <summary> /// Generates CIL for an assignment expression. /// </summary> /// <param name="generator"> The generator to output the CIL to. </param> /// <param name="optimizationInfo"> Information about any optimizations that should be performed. </param> /// <param name="target"> The target to modify. </param> private void GenerateAssignment(ILGenerator generator, OptimizationInfo optimizationInfo, IReferenceExpression target) { // Load the value to assign. var rhs = this.GetOperand(1); rhs.GenerateCode(generator, optimizationInfo); // Support the inferred function displayName property. var expression = rhs as FunctionExpression; if (expression != null) { expression.GenerateDisplayName(generator, optimizationInfo, target.ToString(), false); } // Duplicate the value so it remains on the stack afterwards. //if (optimizationInfo.SuppressReturnValue == false) generator.Duplicate(); // Store the value. target.GenerateSet(generator, optimizationInfo, rhs.ResultType, optimizationInfo.StrictMode); }
/// <summary> /// Generates CIL for an assignment expression. /// </summary> /// <param name="generator"> The generator to output the CIL to. </param> /// <param name="optimizationInfo"> Information about any optimizations that should be performed. </param> /// <param name="target"> The target to modify. </param> private void GenerateAssignment(ILGenerator generator, OptimizationInfo optimizationInfo, IReferenceExpression target) { // Evaluate the left hand side first! target.GenerateReference(generator, optimizationInfo); // Load the value to assign. var rhs = this.GetOperand(1); rhs.GenerateCode(generator, optimizationInfo); // Support the inferred function displayName property. if (rhs is FunctionExpression) { ((FunctionExpression)rhs).GenerateDisplayName(generator, optimizationInfo, target.ToString(), false); } // Store the RHS value so we can return it as the result of the expression. var result = generator.CreateTemporaryVariable(rhs.ResultType); generator.Duplicate(); generator.StoreVariable(result); // Store the value. target.GenerateSet(generator, optimizationInfo, rhs.ResultType, optimizationInfo.StrictMode); // Restore the RHS value. generator.LoadVariable(result); generator.ReleaseTemporaryVariable(result); }
/// <summary> /// Generates CIL for an assignment expression. /// </summary> /// <param name="generator"> The generator to output the CIL to. </param> /// <param name="optimizationInfo"> Information about any optimizations that should be performed. </param> /// <param name="target"> The target to modify. </param> private void GenerateAssignment(ILGenerator generator, OptimizationInfo optimizationInfo, IReferenceExpression target) { // Evaluate the left hand side first! target.GenerateReference(generator, optimizationInfo); // Load the value to assign. var rhs = this.GetOperand(1); rhs.GenerateCode(generator, optimizationInfo); // Support the inferred function displayName property. if (rhs is FunctionExpression) ((FunctionExpression)rhs).GenerateDisplayName(generator, optimizationInfo, target.ToString(), false); // Store the RHS value so we can return it as the result of the expression. var result = generator.CreateTemporaryVariable(rhs.ResultType); generator.Duplicate(); generator.StoreVariable(result); // Store the value. target.GenerateSet(generator, optimizationInfo, rhs.ResultType, optimizationInfo.StrictMode); // Restore the RHS value. generator.LoadVariable(result); generator.ReleaseTemporaryVariable(result); }
/// <summary> /// Generates CIL for an assignment expression. /// </summary> /// <param name="generator"> The generator to output the CIL to. </param> /// <param name="optimizationInfo"> Information about any optimizations that should be performed. </param> /// <param name="target"> The target to modify. </param> private void GenerateAssignment(ILGenerator generator, OptimizationInfo optimizationInfo, IReferenceExpression target) { // Load the value to assign. var rhs = this.GetOperand(1); rhs.GenerateCode(generator, optimizationInfo); // Support the inferred function displayName property. if (rhs is FunctionExpression) ((FunctionExpression)rhs).GenerateDisplayName(generator, optimizationInfo, target.ToString(), false); // Duplicate the value so it remains on the stack afterwards. //if (optimizationInfo.SuppressReturnValue == false) generator.Duplicate(); // Store the value. target.GenerateSet(generator, optimizationInfo, rhs.ResultType, optimizationInfo.StrictMode); }