Return() public static method

Creates a GotoExpression representing a return statement.
public static Return ( LabelTarget target ) : GotoExpression
target LabelTarget The that the will jump to.
return GotoExpression
Ejemplo n.º 1
0
        private GotoExpression GotoExpression(
            ExpressionType nodeType, System.Type type, JObject obj)
        {
            var value      = this.Expression(this.Prop(obj, "value"));
            var kind       = this.Enum <GotoExpressionKind>(this.Prop(obj, "kind"));
            var targetType = this.Type(this.Prop(obj, "targetType"));
            var targetName = this.Prop(obj, "targetName").Value <string>();

            switch (kind)
            {
            case GotoExpressionKind.Break:
                return(Expr.Break(CreateLabelTarget(targetName, targetType), value));

            case GotoExpressionKind.Continue:
                return(Expr.Continue(CreateLabelTarget(targetName, targetType)));

            case GotoExpressionKind.Goto:
                return(Expr.Goto(CreateLabelTarget(targetName, targetType), value));

            case GotoExpressionKind.Return:
                return(Expr.Return(CreateLabelTarget(targetName, targetType), value));

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Generate a return statement.
 /// </summary>
 /// <param name="Value"></param>
 public void Return(LinqExpr Value)
 {
     // Create the return label if it doesn't already exist.
     if (ret == null)
     {
         ret = LinqExpr.Label(Value.Type, "ret");
     }
     code.Add(LinqExpr.Return(ret, Value));
 }
Ejemplo n.º 3
0
 public void Return()
 {
     // Create the return label if it doesn't already exist.
     if (ret == null)
     {
         ret = LinqExpr.Label("ret");
     }
     code.Add(LinqExpr.Return(ret));
 }
Ejemplo n.º 4
0
        public Expr CompileStatement(ParseTreeNode parseNode)
        {
            switch (parseNode.Term.Name)
            {
            case "GlobalAssignment":
            case "LocalAssignment":
            case "FunctionCall":
                throw new NotImplementedException();

            case "Label":
                return(CurrentScope.RegisterJumpTarget(parseNode.ChildNodes[0].Token.Text));

            case "Goto":
                return(Expr.Goto(CurrentScope.GetJumpLabel(parseNode.ChildNodes[0].Token.Text)));

            case "Break":
                return(Expr.Break(CurrentScope.GetExitLabel()));

            case "Scope":
                return(CompileBlock(parseNode));

            case "ForLoop_Enumerable":
            case "ForLoop_Iterable":
            case "WhileLoop":
            case "RepeatLoop":
            case "IfStatement":
            case "GlobalFunction":
                throw new NotImplementedException();

            case "LocalFunction":
                return(CompileLocalFunction(parseNode));

            case "ReturnStatement":
                return(Expr.Return(CurrentScope.GetReturnLabel(), GetMultiExpressionValue(parseNode.ChildNodes[0])));

            default:
                throw new LithiumCompilerException("Unrecognized statement terminal '{0}' at {1}", parseNode.Term.Name, parseNode.Span.Location.ToUiString());
            }
        }