Ejemplo n.º 1
0
    public static Node?GetArgument(
        this NeuReturnStatement retStmt)
    {
        foreach (var child in retStmt.Children)
        {
            switch (child)
            {
            case NeuExpression expr:

                return(expr);

            ///

            case NeuLiteral lit:

                return(lit);

            ///

            case NeuIdentifier id:

                return(id);

            ///

            default:

                break;
            }
        }

        ///

        return(null);
    }
    public static NeuOperation Execute(
        this NeuInterpreter interpreter,
        NeuReturnStatement retStmt)
    {
        var argument = retStmt.GetArgument();

        if (argument == null)
        {
            return(new NeuReturnResult(NeuOperation.Void));
        }

        ///

        var result = interpreter.Execute(argument);

        ///

        return(new NeuReturnResult(result));
    }