///

    public static bool SetGlobalVar(
        this NeuInterpreter interpreter,
        String name,
        NeuOperation newValue)
    {
        var ops = interpreter.GetOperations(name, null, null, null);

        ///

        var op = ops.SingleOrDefault();

        if (op == null)
        {
            return(false);
        }

        ///

        var v = op as NeuVar;

        if (v == null)
        {
            throw new Exception();
        }

        ///

        v.Value = newValue;

        ///

        return(true);
    }
    public static NeuOperation CallVTable(
        this NeuInterpreter interpreter,
        String name,
        IEnumerable <Node> rawArgs,
        IList <NeuArgument> evalArguments)
    {
        ///

        var ops = interpreter.GetOperations(name, null, null, null);

        ///

        var callee = ops.SingleOrDefault() as NeuOperation;

        if (callee == null)
        {
            throw new Exception();
        }

        ///

        var calleeeParamClause = callee.GetParamClause();

        if (calleeeParamClause == null)
        {
            throw new Exception();
        }

        ///

        var calleeParamList = calleeeParamClause.GetFuncParamList();

        if (calleeParamList == null)
        {
            throw new Exception();
        }

        ///

        switch (true)
        {
        case var _ when rawArgs.Count() == 0 && calleeParamList.Count() == 0:

            break;

        ///

        default:

            throw new Exception();
        }

        ///

        return(interpreter.Execute(callee, evalArguments));
    }
    ///

    public static NeuVar?GetGlobalVar(
        this NeuInterpreter interpreter,
        String name)
    {
        var ops = interpreter.GetOperations(name, null, null, null);

        ///

        var op = ops.SingleOrDefault();

        if (op == null)
        {
            return(null);
        }

        ///

        return(op as NeuVar);
    }
    public static NeuOperation Execute(
        this NeuInterpreter interpreter,
        NeuSource source,
        IEnumerable <IArgument> arguments)
    {
        var codeBlockItemList = source.GetCodeBlockItemList();

        if (codeBlockItemList == null)
        {
            throw new Exception();
        }

        ///

        if (codeBlockItemList.Children.Count() == 0)
        {
            return(NeuOperation.Void);
        }

        ///

        var hasMainFunction = false;

        ///

        var stackOperations = new List <Node>();

        ///

        foreach (var item in codeBlockItemList.Children)
        {
            switch (item)
            {
            case NeuDeclaration decl:

                var result = interpreter.Execute(decl);

                if (result == null)
                {
                    throw new Exception();
                }

                ///

                if (result is NeuFunc func && func.Name == "main")
                {
                    hasMainFunction = true;
                }

                ///

                break;

            ///

            case Node n:

                stackOperations.Add(n);

                break;

            ///

            case var i:

                throw new Exception($"Unexpected: {i}");
            }
        }

        ///

        var lastValue = NeuOperation.Void;

        ///

        foreach (var stackOp in stackOperations)
        {
            lastValue = interpreter.Execute(stackOp);

            ///

            interpreter.SourceOutput.Add(lastValue);
        }

        ///

        if (hasMainFunction)
        {
            var mainCandidates = interpreter.GetOperations("main", null, null, null);

            if (mainCandidates.Count() != 1)
            {
                throw new Exception();
            }

            ///

            var mainFunc = mainCandidates.FirstOrDefault() as NeuFunc;

            if (mainFunc == null)
            {
                throw new Exception();
            }

            ///

            lastValue = interpreter.Execute(mainFunc, Empty <NeuArgument>());

            ///

            interpreter.SourceOutput.Add(lastValue);
        }

        ///

        return(lastValue);
    }