Exemple #1
0
        private IAstNode ProcessDestWriteOperation(DestWriteOperation destWriteOperation, int operationId)
        {
            LocalBuilder locValueToWrite = null;

            locValueToWrite = this.compilationContext.ilGenerator.DeclareLocal(destWriteOperation.Getter.GetMethodInfo().ReturnType);

            var cmdValue = new AstWriteLocal(
                locValueToWrite,
                AstBuildHelper.CallMethod(
                    destWriteOperation.Getter.GetType().GetMethod("Invoke"),
                    new AstCastclassRef(
                        (IAstRef)AstBuildHelper.ReadMemberRV(
                            GetStoredObject(operationId, typeof(DestWriteOperation)),
                            typeof(DestWriteOperation).GetProperty("Getter")
                            ),
                        destWriteOperation.Getter.GetType()
                        ),
                    new List <IAstStackItem>
            {
                AstBuildHelper.ReadLocalRV(locFrom),
                AstBuildHelper.ReadLocalRV(locState)
            }
                    )
                );

            return
                (new AstComplexNode
            {
                nodes = new List <IAstNode>
                {
                    cmdValue,
                    new AstIf()
                    {
                        condition = new AstExprEquals(
                            (IAstValue)AstBuildHelper.ReadMembersChain(
                                AstBuildHelper.ReadLocalRA(locValueToWrite),
                                new[] { (MemberInfo)locValueToWrite.LocalType.GetField("action") }
                                ),
                            new AstConstantInt32()
                        {
                            value = 0
                        }
                            ),
                        trueBranch = new AstComplexNode
                        {
                            nodes = new List <IAstNode>
                            {
                                AstBuildHelper.WriteMembersChain(
                                    destWriteOperation.Destination.MembersChain,
                                    AstBuildHelper.ReadLocalRA(locTo),
                                    AstBuildHelper.ReadMembersChain(
                                        AstBuildHelper.ReadLocalRA(locValueToWrite),
                                        new[] { (MemberInfo)locValueToWrite.LocalType.GetField("value") }
                                        )
                                    )
                            }
                        }
                    }
                }
            });
        }
		private IAstNode ProcessDestWriteOperation(DestWriteOperation destWriteOperation, int operationId)
		{
			LocalBuilder locValueToWrite = null;
			locValueToWrite = this.compilationContext.ilGenerator.DeclareLocal(destWriteOperation.Getter.Method.ReturnType);

			var cmdValue = new AstWriteLocal(
				locValueToWrite,
				AstBuildHelper.CallMethod(
					destWriteOperation.Getter.GetType().GetMethod("Invoke"),
                    new AstCastclassRef(
					    (IAstRef)AstBuildHelper.ReadMemberRV(
						    GetStoredObject(operationId, typeof(DestWriteOperation)),
						    typeof(DestWriteOperation).GetProperty("Getter")
					    ),
                        destWriteOperation.Getter.GetType()
                    ),
                    new List<IAstStackItem>
					{
						AstBuildHelper.ReadLocalRV(locFrom),
						AstBuildHelper.ReadLocalRV(locState)
					}
				)
			);

			return
				new AstComplexNode
				{
					nodes = new List<IAstNode> 
					{ 
						cmdValue,
						new AstIf()
						{
							condition = new AstExprEquals(
								(IAstValue)AstBuildHelper.ReadMembersChain(
									AstBuildHelper.ReadLocalRA(locValueToWrite),
									new[] { (MemberInfo)locValueToWrite.LocalType.GetField("action") }
								),
								new AstConstantInt32() { value = 0 }
							),
							trueBranch = new AstComplexNode
							{
								nodes = new List<IAstNode>
								{
									 AstBuildHelper.WriteMembersChain(
										destWriteOperation.Destination.MembersChain,
										AstBuildHelper.ReadLocalRA(locTo),
										AstBuildHelper.ReadMembersChain(
											AstBuildHelper.ReadLocalRA(locValueToWrite),
											new[] { (MemberInfo)locValueToWrite.LocalType.GetField("value") }
										)
									)
								}
							}
						}
					}
				};
		}