• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Ast.BlockExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



BlockExpression类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了BlockExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LeaveBlockExpression

		override public void LeaveBlockExpression(BlockExpression node)
		{
			var closureEntity = GetEntity(node) as InternalMethod;
			if (closureEntity == null)
				return;

			var collector = new ForeignReferenceCollector();
			{
				collector.CurrentMethod = closureEntity.Method;
				collector.CurrentType = (IType)closureEntity.DeclaringType;
				closureEntity.Method.Body.Accept(collector);
				
				if (collector.ContainsForeignLocalReferences)
				{
					BooClassBuilder closureClass = CreateClosureClass(collector, closureEntity);
					closureClass.ClassDefinition.LexicalInfo = node.LexicalInfo;
					collector.AdjustReferences();
					
					ReplaceCurrentNode(
						CodeBuilder.CreateMemberReference(
							collector.CreateConstructorInvocationWithReferencedEntities(
								closureClass.Entity),
							closureEntity));
				}
				else
				{
					Expression expression = CodeBuilder.CreateMemberReference(closureEntity);
					expression.LexicalInfo = node.LexicalInfo;
					TypeSystemServices.GetConcreteExpressionType(expression);
					ReplaceCurrentNode(expression);
				}
			}
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:33,代码来源:ProcessClosures.cs


示例2: evaluate

        public static Expression evaluate(BlockExpression formula)
        {
            var body = new Block(formula.LexicalInfo);
            for (int i = 0; i < formula.Body.Statements.Count; ++i)
            {
                var statement = formula.Body.Statements[i];

                if (statement is ExpressionStatement &&
                    i == formula.Body.Statements.Count - 1)
                {
                    var last = (ExpressionStatement)statement;
                    body.Statements.Add(new ReturnStatement(last.Expression));
                }
                else
                    body.Statements.Add(formula.Body.Statements[i]);
            }

            var result = new BlockExpression(body);
            result.Parameters.Add(new ParameterDeclaration("this",
                CompilerContext.Current.CodeBuilder
                    .CreateTypeReference(EvaluationContext.CurrentContext.GetType())));
            result.ReturnType = CompilerContext.Current.CodeBuilder
                .CreateTypeReference(typeof(bool));

            return new MethodInvocationExpression(
                new ReferenceExpression("SetEvaluationFunction"), result);
        }
开发者ID:JackWangCUMT,项目名称:RulesEngine,代码行数:27,代码来源:DslModel.cs


示例3: OnBlockExpression

		public override void OnBlockExpression(BlockExpression node)
		{
			if (node.LexicalInfo.Line <= resolver.CaretLine && GetEndSourceLocation(node).Line >= resolver.CaretLine - 1) {
				foreach (ParameterDeclaration param in node.Parameters) {
					DeclarationFound(param.Name, param.Type ?? (resolver.IsDucky ? new SimpleTypeReference("duck") : new SimpleTypeReference("object")), null, param.LexicalInfo);
				}
				base.OnBlockExpression(node);
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:VariableLookupVisitor.cs


示例4: when

		public static Expression when(Expression expression)
		{
			BlockExpression right = new BlockExpression();
			right.Body.Add(new ReturnStatement(expression));
			return new BinaryExpression(
				BinaryOperatorType.Assign,
				new ReferenceExpression("condition"),
				right
			);
		}
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:10,代码来源:BaseScheduler.cs


示例5: when

		public static Expression when(Expression expression, Expression action)
		{
			BlockExpression condition = new BlockExpression();
			condition.Body.Add(new ReturnStatement(expression));
			return new MethodInvocationExpression(
				new ReferenceExpression("When"),
				condition,
				action
			);
		}
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:10,代码来源:BaseOrderActionsDSL.cs


示例6: when

 public static Statement when(Expression expression)
 {
     var body = new Block(expression.LexicalInfo);
     body.Add(new ReturnStatement(expression));
     var result = new BlockExpression(body);
     result.Parameters.Add(
         new ParameterDeclaration("order",
                                  CurrentContext.CodeBuilder.CreateTypeReference(typeof(Order))));
     result.Parameters.Add(
         new ParameterDeclaration("customer",
                                  CurrentContext.CodeBuilder.CreateTypeReference(typeof(Customer))));
     return new ReturnStatement(result);
 }
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:13,代码来源:GlobalMethods.cs


示例7: CreateCallableFromMacroBody

        public static Expression CreateCallableFromMacroBody(BooCodeBuilder builder, MacroStatement macro)
        {
            // create closure for macro's body or null
            Expression macroBody = new NullLiteralExpression();
            if (macro.Block.Statements.Count > 0)
            {
                var callableExpr = new BlockExpression {Body = macro.Block};
                callableExpr.Parameters.Add(
                    new ParameterDeclaration("OutputStream",
                                             builder.CreateTypeReference(typeof(TextWriter))));

                macroBody = callableExpr;
            }
            return macroBody;
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:15,代码来源:CodeBuilderHelper.cs


示例8: exclude

        public static Expression exclude(BlockExpression action)
        {
            var arrayExpression = new ArrayLiteralExpression();

            foreach (Statement statement in action.Body.Statements)
            {
                var stringLiteral =
                    new StringLiteralExpression(
                        ((MethodInvocationExpression) (((ExpressionStatement) (statement)).Expression)).Arguments[0].ToString().Trim(new[]{'\''}));

                arrayExpression.Items.Add(stringLiteral);
            }

            return new MethodInvocationExpression(
                new ReferenceExpression("SetExcludeList"),
                arrayExpression
            );
        }
开发者ID:emmekappa,项目名称:horn_src,代码行数:18,代码来源:BooConfigReader.cs


示例9: OnBlockExpression

        public override void OnBlockExpression(BlockExpression node)
        {
            var dependencies = new ArrayLiteralExpression();

            foreach (Statement statement in node.Body.Statements)
            {
                var expressionStatement = (ExpressionStatement)statement;
                var expression = (MethodInvocationExpression)expressionStatement.Expression;

                OnMethodInvocationExpression(dependencies, expression);
            }

            if (dependencies.Items.Count == 0)
                return;

            var referenceExpression = new ReferenceExpression("AddDependencies");
            var replacementMethod = new MethodInvocationExpression(referenceExpression, dependencies);

            ReplaceCurrentNode(replacementMethod);
        }
开发者ID:emmekappa,项目名称:horn_src,代码行数:20,代码来源:RightShiftToMethodCompilerStep.cs


示例10: AddInferredClosureParameterTypes

        private void AddInferredClosureParameterTypes(BlockExpression node, ICallableType callableType)
        {
            IParameter[] parameters = (callableType == null ? null : callableType.GetSignature().Parameters);
            for (int i = 0; i < node.Parameters.Count; i++)
            {
                ParameterDeclaration pd = node.Parameters[i];
                if (pd.Type != null) continue;

                IType inferredType;
                if (parameters != null && i < parameters.Length)
                {
                    inferredType = parameters[i].Type;
                }
                else if (pd.IsParamArray)
                {
                    inferredType = TypeSystemServices.ObjectArrayType;
                }
                else
                {
                    inferredType = TypeSystemServices.ObjectType;
                }

                pd.Type = CodeBuilder.CreateTypeReference(inferredType);
            }
        }
开发者ID:stuman08,项目名称:boo,代码行数:25,代码来源:ProcessMethodBodies.cs


示例11: InferClosureSignature

 private void InferClosureSignature(BlockExpression node)
 {
     ClosureSignatureInferrer inferrer = new ClosureSignatureInferrer(node);
     ICallableType inferredCallableType = inferrer.InferCallableType();
     BindExpressionType(node, inferredCallableType);
     AddInferredClosureParameterTypes(node, inferredCallableType);
 }
开发者ID:stuman08,项目名称:boo,代码行数:7,代码来源:ProcessMethodBodies.cs


示例12: nested_function

	protected Statement  nested_function() //throws RecognitionException, TokenStreamException
{
		Statement stmt;
		
		IToken  def = null;
		IToken  id = null;
		
			stmt = null;
			BlockExpression be = null;
			Block body = null;
			TypeReference rt = null;
		
		
		try {      // for error handling
			def = LT(1);
			match(DEF);
			id = LT(1);
			match(ID);
			if (0==inputState.guessing)
			{
				
						be = new BlockExpression(ToLexicalInfo(id));
						body = be.Body;
					
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				{
					match(LPAREN);
					parameter_declaration_list(be.Parameters);
					match(RPAREN);
					{
						switch ( LA(1) )
						{
						case AS:
						{
							match(AS);
							rt=type_reference();
							if (0==inputState.guessing)
							{
								be.ReturnType = rt;
							}
							break;
						}
						case COLON:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					break;
				}
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			compound_stmt(body);
			if (0==inputState.guessing)
			{
				
						string name = id.getText();
						stmt = new DeclarationStatement(
									ToLexicalInfo(def),
									new Declaration(
										ToLexicalInfo(id),
										name),
									be);
						be[BlockExpression.ClosureNameAnnotation] = name;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "nested_function");
				recover(ex,tokenSet_84_);
			}
			else
			{
				throw ex;
			}
		}
		return stmt;
	}
开发者ID:hlizard,项目名称:boo,代码行数:97,代码来源:BooParserBase.cs


示例13: ClosureSignatureInferrer

 public ClosureSignatureInferrer(BlockExpression closure)
 {
     _closure = closure;
     InitializeInputTypes();
 }
开发者ID:BITechnologies,项目名称:boo,代码行数:5,代码来源:ClosureSignatureInferrer.cs


示例14: InferExplicits

        /// <summary>
        /// Performs inference on explicitly typed arguments.
        /// </summary>
        /// <remarks>
        /// Corresponds to the first phase in generic parameter inference according to the C# 3.0 spec.
        /// </remarks>
        private void InferExplicits()
        {
            foreach (TypedArgument typedArgument in Arguments)
            {
                _currentClosure = typedArgument.Expression as BlockExpression;

                Infer(
                    typedArgument.FormalType,
                    typedArgument.Expression.ExpressionType,
                    TypeInference.AllowCovariance);
            }
        }
开发者ID:BITechnologies,项目名称:boo,代码行数:18,代码来源:GenericParameterInferrer.cs


示例15: callable_expression

	protected Expression  callable_expression() //throws RecognitionException, TokenStreamException
{
		Expression e;
		
		IToken  doAnchor = null;
		IToken  defAnchor = null;
		
			e = null;
			Block body = null;
			BlockExpression cbe = null;
			TypeReference rt = null;
			IToken anchor = null;
		
		
		try {      // for error handling
			switch ( LA(1) )
			{
			case COLON:
			{
				{
					if (0==inputState.guessing)
					{
						body = new Block();
					}
					compound_stmt(body);
					if (0==inputState.guessing)
					{
						e = new BlockExpression(body.LexicalInfo, body);
					}
				}
				break;
			}
			case DEF:
			case DO:
			{
				{
					{
						switch ( LA(1) )
						{
						case DO:
						{
							{
								doAnchor = LT(1);
								match(DO);
								if (0==inputState.guessing)
								{
									anchor = doAnchor;
								}
							}
							break;
						}
						case DEF:
						{
							{
								defAnchor = LT(1);
								match(DEF);
								if (0==inputState.guessing)
								{
									anchor = defAnchor;
								}
							}
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					if (0==inputState.guessing)
					{
						
									e = cbe = new BlockExpression(ToLexicalInfo(anchor));
									body = cbe.Body;
								
					}
					{
						switch ( LA(1) )
						{
						case LPAREN:
						{
							match(LPAREN);
							parameter_declaration_list(cbe.Parameters);
							match(RPAREN);
							{
								switch ( LA(1) )
								{
								case AS:
								{
									match(AS);
									rt=type_reference();
									if (0==inputState.guessing)
									{
										cbe.ReturnType = rt;
									}
									break;
								}
								case COLON:
								{
									break;
//.........这里部分代码省略.........
开发者ID:hlizard,项目名称:boo,代码行数:101,代码来源:BooParserBase.cs


示例16: ShouldDeferClosureProcessing

        private bool ShouldDeferClosureProcessing(BlockExpression node)
        {
            // Defer closure processing if it's an argument in a generic method invocation
            MethodInvocationExpression methodInvocationContext = node.ParentNode as MethodInvocationExpression;
            if (methodInvocationContext == null) return false;
            if (!methodInvocationContext.Arguments.Contains(node)) return false;

            if (methodInvocationContext.Target.Entity is Ambiguous)
                return ((Ambiguous) methodInvocationContext.Target.Entity).Any(GenericsServices.IsGenericMethod);

            IMethod target = methodInvocationContext.Target.Entity as IMethod;
            return (target != null && GenericsServices.IsGenericMethod(target));
        }
开发者ID:stuman08,项目名称:boo,代码行数:13,代码来源:ProcessMethodBodies.cs


示例17: OnExtendedGeneratorExpression

        public override void OnExtendedGeneratorExpression(ExtendedGeneratorExpression node)
        {
            BlockExpression block = new BlockExpression(node.LexicalInfo);

            Block body = block.Body;
            Expression e = node.Items[0].Expression;
            foreach (GeneratorExpression ge in node.Items)
            {
                ForStatement fs = new ForStatement(ge.LexicalInfo);
                fs.Iterator = ge.Iterator;
                fs.Declarations = ge.Declarations;

                body.Add(fs);

                if (null == ge.Filter)
                {
                    body = fs.Block;
                }
                else
                {
                    fs.Block.Add(
                        NormalizeStatementModifiers.MapStatementModifier(ge.Filter, out body));
                }

            }
            body.Add(new YieldStatement(e.LexicalInfo, e));

            MethodInvocationExpression mie = new MethodInvocationExpression(node.LexicalInfo);
            mie.Target = block;

            Node parentNode = node.ParentNode;
            bool isGenerator = AstUtil.IsListMultiGenerator(parentNode);
            parentNode.Replace(node, mie);
            mie.Accept(this);

            if (isGenerator)
            {
                parentNode.ParentNode.Replace(
                    parentNode,
                    CodeBuilder.CreateConstructorInvocation(
                        TypeSystemServices.Map(ProcessGenerators.List_IEnumerableConstructor),
                        mie));
            }
        }
开发者ID:stuman08,项目名称:boo,代码行数:44,代码来源:ProcessMethodBodies.cs


示例18: RecordClosureDependency

        private void RecordClosureDependency(BlockExpression closure, IGenericParameter genericParameter)
        {
            if (!_closureDependencies.ContainsKey(closure))
            {
                _closureDependencies.Add(closure, new List<InferredType>());
            }

            _closureDependencies[closure].AddUnique(InferredTypes[genericParameter]);
        }
开发者ID:BITechnologies,项目名称:boo,代码行数:9,代码来源:GenericParameterInferrer.cs


示例19: ProcessClosureBody

        void ProcessClosureBody(BlockExpression node)
        {
            MarkVisited(node);
            if (node.ContainsAnnotation("inline"))
                AddOptionalReturnStatement(node.Body);

            var explicitClosureName = node[BlockExpression.ClosureNameAnnotation] as string;

            Method closure = CodeBuilder.CreateMethod(
                ClosureName(explicitClosureName),
                node.ReturnType ?? CodeBuilder.CreateTypeReference(Unknown.Default),
                ClosureModifiers());

            MarkVisited(closure);

            var closureEntity = (InternalMethod)closure.Entity;
            closure.LexicalInfo = node.LexicalInfo;
            closure.Parameters = node.Parameters;
            closure.Body = node.Body;

            CurrentMethod.DeclaringType.Members.Add(closure);

            CodeBuilder.BindParameterDeclarations(_currentMethod.IsStatic, closure);

            // check for invalid names and
            // resolve parameter types
            Visit(closure.Parameters);

            // Inside the closure, connect the closure method namespace with the current namespace
            var ns = new NamespaceDelegator(CurrentNamespace, closureEntity);

            // Allow closure body to reference itself using its explicit name (BOO-1085)
            if (explicitClosureName != null)
                ns.DelegateTo(new AliasedNamespace(explicitClosureName, closureEntity));

            ProcessMethodBody(closureEntity, ns);

            if (closureEntity.ReturnType is Unknown)
                TryToResolveReturnType(closureEntity);

            node.ExpressionType = closureEntity.Type;
            node.Entity = closureEntity;
        }
开发者ID:stuman08,项目名称:boo,代码行数:43,代码来源:ProcessMethodBodies.cs


示例20: prebuild

        public static Expression prebuild(BlockExpression commands)
        {
            var cmdList = new ArrayLiteralExpression();

            foreach (Statement statement in commands.Body.Statements)
            {
                var expression = (MethodInvocationExpression)((ExpressionStatement)statement).Expression;

                cmdList.Items.Add(new StringLiteralExpression(expression.Arguments[0].ToString().Trim(new char[] { '\'' })));
            }

            return new MethodInvocationExpression(new ReferenceExpression("ParseCommands"), cmdList);
        }
开发者ID:emmekappa,项目名称:horn_src,代码行数:13,代码来源:BooConfigReader.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.ClassDefinition类代码示例发布时间:2022-05-24
下一篇:
C# Ast.Block类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap