当前位置: 首页>>代码示例>>C#>>正文


C# ReferenceExpression.CloneNode方法代码示例

本文整理汇总了C#中Boo.Lang.Compiler.Ast.ReferenceExpression.CloneNode方法的典型用法代码示例。如果您正苦于以下问题:C# ReferenceExpression.CloneNode方法的具体用法?C# ReferenceExpression.CloneNode怎么用?C# ReferenceExpression.CloneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Boo.Lang.Compiler.Ast.ReferenceExpression的用法示例。


在下文中一共展示了ReferenceExpression.CloneNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddResolvedNamedArgumentToEval

        protected override void AddResolvedNamedArgumentToEval(MethodInvocationExpression eval, ExpressionPair pair, ReferenceExpression instance)
        {
            if (!TypeSystemServices.IsQuackBuiltin(pair.First))
            {
                base.AddResolvedNamedArgumentToEval(eval, pair, instance);
                return;
            }

            MemberReferenceExpression memberRef = new MemberReferenceExpression(
                pair.First.LexicalInfo,
                instance.CloneNode(),
                ((ReferenceExpression)pair.First).Name);
            BindQuack(memberRef);

            eval.Arguments.Add(
                CodeBuilder.CreateAssignment(
                    pair.First.LexicalInfo,
                    memberRef,
                    pair.Second));
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:20,代码来源:ProcessMethodBodiesWithDuckTyping.cs

示例2: OnCollectionInitializationExpression

		public override void OnCollectionInitializationExpression(CollectionInitializationExpression node)
		{
			var temp = new ReferenceExpression(node.LexicalInfo, Context.GetUniqueName("collection"));

			var initialization = CodeBuilder.CreateEvalInvocation(node.LexicalInfo);

			// temp = $(node.Collection)
			initialization.Arguments.Add(new BinaryExpression(BinaryOperatorType.Assign, temp, node.Collection));

			if (node.Initializer is ListLiteralExpression)
				foreach (var item in ((ListLiteralExpression)node.Initializer).Items)
					// temp.Add(item)
					initialization.Arguments.Add(NewAddInvocation(item.LexicalInfo, temp, item));
			else
				foreach (var pair in ((HashLiteralExpression)node.Initializer).Items)
					// temp.Add(key, value)
					initialization.Arguments.Add(NewAddInvocation(pair.LexicalInfo, temp, pair.First, pair.Second));

			// return temp
			initialization.Arguments.Add(temp.CloneNode());

			ReplaceCurrentNode(initialization);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:23,代码来源:NormalizeExpressions.cs

示例3: AddResolvedNamedArgumentToEval

        protected virtual void AddResolvedNamedArgumentToEval(MethodInvocationExpression eval, ExpressionPair pair, ReferenceExpression instance)
        {
            IEntity entity = GetEntity(pair.First);
            switch (entity.EntityType)
            {
                case EntityType.Event:
                    {
                        IEvent member = (IEvent)entity;
                        eval.Arguments.Add(
                            CodeBuilder.CreateMethodInvocation(
                                pair.First.LexicalInfo,
                                instance.CloneNode(),
                                member.GetAddMethod(),
                                pair.Second));
                        break;
                    }

                case EntityType.Field:
                    {
                        eval.Arguments.Add(
                            CodeBuilder.CreateAssignment(
                                pair.First.LexicalInfo,
                                CodeBuilder.CreateMemberReference(
                                    instance.CloneNode(),
                                    (IMember)entity),
                                pair.Second));
                        break;
                    }

                case EntityType.Property:
                    {
                        IProperty property = (IProperty)entity;
                        IMethod setter = property.GetSetMethod();
                        if (null == setter)
                        {
                            Error(CompilerErrorFactory.PropertyIsReadOnly(pair.First, property));
                        }
                        else
                        {
                            //EnsureRelatedNodeWasVisited(pair.First, setter);
                            eval.Arguments.Add(
                                CodeBuilder.CreateAssignment(
                                    pair.First.LexicalInfo,
                                    CodeBuilder.CreateMemberReference(
                                        instance.CloneNode(),
                                        property),
                                    pair.Second));
                        }
                        break;
                    }
            }
        }
开发者ID:stuman08,项目名称:boo,代码行数:52,代码来源:ProcessMethodBodies.cs

示例4: ProcessTargets

		protected Expression ProcessTargets(Expression node)
		{
			// Look for safe access operators in the targets chain
			UnaryExpression ue = null;
			Expression target = node;
			Expression nextTarget = null;
			while (IsTargetable(target))
			{
				if (target is MemberReferenceExpression)
				{
					nextTarget = ((MemberReferenceExpression)target).Target;
				} 
				else if (target is SlicingExpression)
				{
					nextTarget = ((SlicingExpression)target).Target;
				}
				else
				{
					nextTarget = ((MethodInvocationExpression)target).Target;
				}

				if (IsSafeAccess(nextTarget))
				{
					ue = (UnaryExpression)nextTarget;
					break;
				}

				target = nextTarget;
			}

			// No safe access operator was found
			if (ue == null)
			{
				return null;
			}

			// Target the safe access to a temporary variable
			var tmp = new ReferenceExpression(node.LexicalInfo, Context.GetUniqueName("safe"));
			tmp.IsSynthetic = true;

			// Make sure preceding operators are processed
			MemberReferenceExpression mre = null;
			SlicingExpression se = null;
			MethodInvocationExpression mie = null;
			if (null != (mre = target as MemberReferenceExpression))
			{
				Visit(mre.Target);
				mre.Target = tmp.CloneNode();
			} 
			else if (null != (se = target as SlicingExpression))
			{
				Visit(se.Target);
				se.Target = tmp.CloneNode();
			}
			else if (null != (mie = target as MethodInvocationExpression))
			{
				Visit(mie.Target);
				mie.Target = tmp.CloneNode();
			}

			// Convert the target into a ternary operation 
			var tern = new ConditionalExpression(node.LexicalInfo);
			tern.Condition = new BinaryExpression(
				BinaryOperatorType.ReferenceInequality,
				CodeBuilder.CreateAssignment(tmp, ue.Operand),
				CodeBuilder.CreateNullLiteral()
				);
			tern.TrueValue = node;
			tern.FalseValue = CodeBuilder.CreateNullLiteral();

			return tern;
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:72,代码来源:SafeAccessOperator.cs

示例5: CreateRawArraySlicing

 private static SlicingExpression CreateRawArraySlicing(ReferenceExpression arrayRef, Expression numRef, IType elementType)
 {
     SlicingExpression expression = new SlicingExpression(arrayRef.CloneNode(), numRef.CloneNode());
     expression.ExpressionType = elementType;
     AstAnnotations.MarkRawArrayIndexing(expression);
     return expression;
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:7,代码来源:OptimizeIterationStatements.cs

示例6: NewAddInvocation

		private static MethodInvocationExpression NewAddInvocation(LexicalInfo location, ReferenceExpression target, params Expression[] args)
		{
			return new MethodInvocationExpression(location, new MemberReferenceExpression(target.CloneNode(), "Add"), args);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:4,代码来源:NormalizeExpressions.cs


注:本文中的Boo.Lang.Compiler.Ast.ReferenceExpression.CloneNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。