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

C# Ast.ReturnStatement类代码示例

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

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



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

示例1: CreateGetter

		Method CreateGetter(Field f)
		{
			Method m = new Method();
			m.Name = "get";

			// value = ViewState["<f.Name>"]
			m.Body.Statements.Add(
				new ExpressionStatement(
					new BinaryExpression(
						BinaryOperatorType.Assign,
						new ReferenceExpression("value"),
						CreateViewStateSlice(f)
						)
					)
				);

			if (null != _default)
			{
				// return <_default> unless value
				ReturnStatement rs = new ReturnStatement(_default);
				rs.Modifier = new StatementModifier(StatementModifierType.Unless, new ReferenceExpression("value"));
				m.Body.Statements.Add(rs);
			}

			// return value
			m.Body.Statements.Add(
				new ReturnStatement(
					new ReferenceExpression("value")
					)
				);

			return m;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:33,代码来源:ViewStateAttribute.cs


示例2: LeaveReturnStatement

		public override void LeaveReturnStatement(ReturnStatement node)
		{
			if (node.Expression == null)
				return;

			TryToReify(node.Expression, _currentMethod.ReturnType);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:ReifyTypes.cs


示例3: OnReturnStatement

			public override void OnReturnStatement(ReturnStatement node)
			{
				noReturnStatement = false;
				if (node.Expression == null) {
					result = ParserService.CurrentProjectContent.SystemTypes.Void;
				} else {
					result = new BooResolver().GetTypeOfExpression(node.Expression, context);
				}
			}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:InferredReturnType.cs


示例4: ForCoverage

        public void ForCoverage()
        {
            var block = new Block();
            var statement = new ReturnStatement(new StringLiteralExpression("literal"));
            block.Statements.Add(statement);

            var visitor = new ReturnValueVisitor();
            bool found = visitor.Found;
            visitor.OnReturnStatement(statement);
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:10,代码来源:ReturnValueVisitorTester.cs


示例5: CheckForEmptyCoroutine

 public void CheckForEmptyCoroutine(Method node)
 {
     if (this.IsEmptyCoroutine(node))
     {
         ReturnStatement statement;
         ReturnStatement statement1 = statement = new ReturnStatement(LexicalInfo.Empty);
         statement.set_Expression(Expression.Lift(this.EmptyEnumeratorReference));
         node.get_Body().Add(statement);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:10,代码来源:ProcessUnityScriptMethods.cs


示例6: LeaveReturnStatement

		override public void LeaveReturnStatement(ReturnStatement node)
		{
			Expression expression = node.Expression;
			if (null == expression)
				return;

			if (!HasReturnType(_current))
				return;

			Expression newExpression = Convert(_current.ReturnType, expression);
			if (null == newExpression)
				return;

			node.Expression = newExpression;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:15,代码来源:InjectCallableConversions.cs


示例7: OnReturnStatement

		public override void OnReturnStatement(ReturnStatement stmt)
		{
			// First normalize the statement
			normalizer.Visit(stmt);
			//empty return, so error
			if (stmt.Expression == null)
				throw new MonoRailException("An empty return statement on a method with output attribute");
			found = true;
			Block block = (Block) stmt.ParentNode;
			int index = 0;
			while(block.Statements[index] != stmt)
			{
				index ++;
			}

			MethodInvocationExpression invocation = mie.CloneNode();
			invocation.Arguments.Add(stmt.Expression);

			stmt.Expression = invocation;
		}
开发者ID:ralescano,项目名称:castle,代码行数:20,代码来源:ReturnValueVisitor.cs


示例8: return_expression_stmt

	protected ReturnStatement  return_expression_stmt() //throws RecognitionException, TokenStreamException
{
		ReturnStatement s;
		
		IToken  r = null;
		
				s = null;
				Expression e = null;
				StatementModifier modifier = null;
			
		
		try {      // for error handling
			r = LT(1);
			match(RETURN);
			{
				switch ( LA(1) )
				{
				case ESEPARATOR:
				case CAST:
				case CHAR:
				case FALSE:
				case NOT:
				case NULL:
				case SELF:
				case SUPER:
				case THEN:
				case TRUE:
				case TYPEOF:
				case TRIPLE_QUOTED_STRING:
				case LPAREN:
				case DOUBLE_QUOTED_STRING:
				case SINGLE_QUOTED_STRING:
				case ID:
				case MULTIPLY:
				case LBRACK:
				case COMMA:
				case SPLICE_BEGIN:
				case DOT:
				case LBRACE:
				case QQ_BEGIN:
				case SUBTRACT:
				case LONG:
				case INCREMENT:
				case DECREMENT:
				case ONES_COMPLEMENT:
				case INT:
				case BACKTICK_QUOTED_STRING:
				case RE_LITERAL:
				case DOUBLE:
				case FLOAT:
				case TIMESPAN:
				{
					e=array_or_expression();
					break;
				}
				case EOL:
				case IF:
				case UNLESS:
				case WHILE:
				case EOS:
				case RBRACE:
				case QQ_END:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			{
				if (((LA(1)==IF||LA(1)==UNLESS||LA(1)==WHILE))&&(!_compact))
				{
					modifier=stmt_modifier();
				}
				else if ((tokenSet_98_.member(LA(1)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
			if (0==inputState.guessing)
			{
				
						s = new ReturnStatement(ToLexicalInfo(r));
						s.Modifier = modifier;
						s.Expression = e;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "return_expression_stmt");
				recover(ex,tokenSet_98_);
			}
//.........这里部分代码省略.........
开发者ID:hlizard,项目名称:boo,代码行数:101,代码来源:BooParserBase.cs


示例9: AddOptionalReturnStatement

        private static void AddOptionalReturnStatement(Block body)
        {
            if (body.Statements.Count != 1) return;
            var stmt = body.FirstStatement as ExpressionStatement;
            if (null == stmt) return;

            var rs = new ReturnStatement(stmt.LexicalInfo, stmt.Expression, null);
            rs.Annotate(OptionalReturnStatementAnnotation);
            body.Replace(stmt, rs);
        }
开发者ID:stuman08,项目名称:boo,代码行数:10,代码来源:ProcessMethodBodies.cs


示例10: return_stmt

        //throws RecognitionException, TokenStreamException
        protected ReturnStatement return_stmt()
        {
            ReturnStatement s;

            IToken  r = null;

                s = null;
                Expression e = null;
                StatementModifier modifier = null;

            try {      // for error handling
            r = LT(1);
            match(RETURN);
            {
                switch ( LA(1) )
                {
                case ESEPARATOR:
                case CAST:
                case CHAR:
                case FALSE:
                case NOT:
                case NULL:
                case SELF:
                case SUPER:
                case TRUE:
                case TYPEOF:
                case ID:
                case TRIPLE_QUOTED_STRING:
                case LPAREN:
                case DOUBLE_QUOTED_STRING:
                case SINGLE_QUOTED_STRING:
                case LBRACK:
                case SUBTRACT:
                case COMMA:
                case SPLICE_BEGIN:
                case DOT:
                case MULTIPLY:
                case LBRACE:
                case QQ_BEGIN:
                case LONG:
                case INCREMENT:
                case DECREMENT:
                case ONES_COMPLEMENT:
                case INT:
                case RE_LITERAL:
                case DOUBLE:
                case FLOAT:
                case TIMESPAN:
                {
                    {
                        e=array_or_expression();
                        {
                            switch ( LA(1) )
                            {
                            case DEF:
                            case DO:
                            case COLON:
                            {
                                e=method_invocation_block(e);
                                break;
                            }
                            case EOF:
                            case IF:
                            case UNLESS:
                            case WHILE:
                            case EOS:
                            case NEWLINE:
                            {
                                {
                                    {
                                        switch ( LA(1) )
                                        {
                                        case IF:
                                        case UNLESS:
                                        case WHILE:
                                        {
                                            modifier=stmt_modifier();
                                            break;
                                        }
                                        case EOF:
                                        case EOS:
                                        case NEWLINE:
                                        {
                                            break;
                                        }
                                        default:
                                        {
                                            throw new NoViableAltException(LT(1), getFilename());
                                        }
                                         }
                                    }
                                    eos();
                                }
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
//.........这里部分代码省略.........
开发者ID:0xb1dd1e,项目名称:boo,代码行数:101,代码来源:WSABooParserBase.cs


示例11: OnReturnStatement

        public override void OnReturnStatement(ReturnStatement node)
        {
            EmitDebugInfo(node);
            OpCode retOpCode = _tryBlock > 0 ? OpCodes.Leave : OpCodes.Br;
            Label label = _returnLabel;

            if (null != node.Expression)
            {
                ++_returnStatements;

                Visit(node.Expression);
                EmitCastIfNeeded(_returnType, PopType());

                if (retOpCode == OpCodes.Leave)
                {
                    //`leave' clears the stack, so we have to store return value temporarily
                    //we can use a default value holder for that since it won't be read afterwards
                    //of course this is necessary only if return type is not void
                    LocalBuilder temp = GetDefaultValueHolder(_returnType);
                    _il.Emit(OpCodes.Stloc, temp);
                    label = _leaveLabel;
                    _hasLeaveWithStoredValue = true;
                }
            }
            else if (_returnType != TypeSystemServices.VoidType)
            {
                _returnImplicit = true;
                label = _implicitLabel;
            }

            if (_method.Body.LastStatement != node)
                _il.Emit(retOpCode, label);
            else if (null != node.Expression)
                _returnStatements = -1; //instruct epilogue to branch last ret only if necessary
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:35,代码来源:EmitAssembly.cs


示例12: OnReturnStatement

 public override void OnReturnStatement(ReturnStatement r)
 {
     WriteIndented();
     WriteKeyword("return ");
     Visit(r.Expression);
     Visit(r.Modifier);
     WriteLine();
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:8,代码来源:BooPrinterVisitor.cs


示例13: LeaveReturnStatement

 public override void LeaveReturnStatement(ReturnStatement node)
 {
     if (HasReturnType(_current))
     {
         Expression expression = node.Expression;
         if (null != expression)
         {
             Expression newExpression = Convert(_current.ReturnType, expression);
             if (null != newExpression)
             {
                 node.Expression = newExpression;
             }
         }
     }
 }
开发者ID:boo,项目名称:boo-lang,代码行数:15,代码来源:InjectCallableConversions.cs


示例14: OnReturnStatement

		public override void OnReturnStatement(ReturnStatement node)
		{
			_expression = null;
			if (node.Expression != null)
				node.Expression.Accept(this);
			_statements.Add(new CodeMethodReturnStatement(_expression));
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:CodeDomVisitor.cs


示例15: Clone

		override public object Clone()
		{
		
			ReturnStatement clone = new ReturnStatement();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			if (null != _modifier)
			{
				clone._modifier = _modifier.Clone() as StatementModifier;
				clone._modifier.InitializeParent(clone);
			}
			if (null != _expression)
			{
				clone._expression = _expression.Clone() as Expression;
				clone._expression.InitializeParent(clone);
			}
			return clone;


		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:24,代码来源:ReturnStatementImpl.cs


示例16: return_statement

 public void return_statement(Block b)
 {
     IToken token = null;
     try
     {
         Expression expression;
         token = this.LT(1);
         this.match(30);
         if (tokenSet_16_.member(this.LA(1)) && tokenSet_49_.member(this.LA(2)))
         {
             expression = this.expression();
         }
         else if (!tokenSet_15_.member(this.LA(1)) || !tokenSet_20_.member(this.LA(2)))
         {
             throw new NoViableAltException(this.LT(1), this.getFilename());
         }
         if (base.inputState.guessing == 0)
         {
             ReturnStatement statement;
             ReturnStatement statement1 = statement = new ReturnStatement(ToLexicalInfo(token));
             statement.set_Expression(expression);
             b.Add(statement);
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_15_);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:34,代码来源:UnityScriptParser.cs


示例17: OnReturnStatement

		override public void OnReturnStatement(ReturnStatement node)
		{
			RemoveUnreachableCode(node);
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:4,代码来源:RemoveDeadCode.cs


示例18: LeaveReturnStatement

        public override void LeaveReturnStatement(ReturnStatement node)
        {
            if (null == node.Expression)
                return;

            // forces anonymous types to be correctly
            // instantiated
            IType expressionType = GetConcreteExpressionType(node.Expression);
            if (TypeSystemServices.VoidType == expressionType
                && node.ContainsAnnotation(OptionalReturnStatementAnnotation))
            {
                node.ParentNode.Replace(
                    node,
                    new ExpressionStatement(node.Expression));
                return;
            }

            IType returnType = _currentMethod.ReturnType;
            if (TypeSystemServices.IsUnknown(returnType))
                _currentMethod.AddReturnExpression(node.Expression);
            else
                AssertTypeCompatibility(node.Expression, returnType, expressionType);

            //bind to nullable Value if needed
            if (TypeSystemServices.IsNullable(expressionType) && !TypeSystemServices.IsNullable(returnType))
            {
                // TODO: move to later steps or introduce an implicit conversion operator
                var mre = new MemberReferenceExpression(node.Expression.LexicalInfo, node.Expression, "Value");
                Visit(mre);
                node.Replace(node.Expression, mre);
            }
        }
开发者ID:stuman08,项目名称:boo,代码行数:32,代码来源:ProcessMethodBodies.cs


示例19: LeaveReturnStatement

        public override void LeaveReturnStatement(ReturnStatement node)
        {
            if (null == node.Expression) return;

            // forces anonymous types to be correctly
            // instantiated
            IType expressionType = GetConcreteExpressionType(node.Expression);
            if (TypeSystemServices.VoidType == expressionType
                && node.ContainsAnnotation(OptionalReturnStatementAnnotation))
            {
                node.ParentNode.Replace(
                    node,
                    new ExpressionStatement(node.Expression));
                return;
            }

            IType returnType = _currentMethod.ReturnType;
            if (TypeSystemServices.IsUnknown(returnType))
            {
                _currentMethod.AddReturnExpression(node.Expression);
            }
            else
            {
                AssertTypeCompatibility(node.Expression, returnType, expressionType);
            }
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:26,代码来源:ProcessMethodBodies.cs


示例20: LeaveReturnStatement

 public override void LeaveReturnStatement(ReturnStatement node)
 {
     if (InsideEnsure)
     {
         Error(CompilerErrorFactory.CantReturnFromEnsure(node));
     }
     if (null == node.Expression) return;
     CheckExpressionType(node.Expression);
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:9,代码来源:StricterErrorChecking.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Ast.SlicingExpression类代码示例发布时间:2022-05-24
下一篇:
C# Ast.ReferenceExpression类代码示例发布时间: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