// public override Reference GetReference() // { // throw MyParams.GetException("should not be invoked"); // } public override ExpressionCompilationResult TryGetSetter(AbstractILCompilerParams @params, Reference referenceToAssign) { var invocationTarget = new ClassMethodTarget(new ClassMethodReference(myReference, "set_Item")); var returnedValues = new Dictionary <ParameterIndex, Reference> { { ParameterIndex.ReturnValueIndex, @params.LocalVariableIndexer.GetNextVariable() } }; var passedValues = new Dictionary <ParameterIndex, Reference> { { new ParameterIndex(1), referenceToAssign } }; if (myArgument != null) { passedValues.Add(new ParameterIndex(0), myArgument); } var statement = new InvocationStatement(GetLocation(), invocationTarget, passedValues, returnedValues); var invocationInstruction = new Instruction(statement, @params.GetNewInstructionId()); var summaryBlock = ElementCompiler.GetInstructionsConnectedSequentially(new List <IInstructionsContainer> { this, invocationInstruction }); var invocationResultReference = returnedValues[ParameterIndex.ReturnValueIndex]; return(new ExpressionCompilationResult(summaryBlock, GetLocation(), invocationResultReference)); }
public virtual ExpressionCompilationResult TryGetSetter(AbstractILCompilerParams @params, Reference referenceToAssign) { if (!(myReference is ClassPropertyReference propertyReference)) { return(null); } var invocationTarget = new ClassMethodTarget(new ClassMethodReference(propertyReference.Owner, $"set_{propertyReference.Name}")); var returnedValues = new Dictionary <ParameterIndex, Reference>(); returnedValues.Add(ParameterIndex.ReturnValueIndex, @params.LocalVariableIndexer.GetNextVariable()); var passedValues = new Dictionary <ParameterIndex, Reference> { { new ParameterIndex(0), referenceToAssign } }; var statement = new InvocationStatement(GetLocation(), invocationTarget, passedValues, returnedValues); var invocationInstruction = new Instruction(statement, @params.GetNewInstructionId()); var summaryBlock = ElementCompiler.GetInstructionsConnectedSequentially(new List <IInstructionsContainer> { this, invocationInstruction }); var invocationResultReference = returnedValues[ParameterIndex.ReturnValueIndex]; return(new ExpressionCompilationResult(summaryBlock, GetLocation(), invocationResultReference)); }