コード例 #1
0
ファイル: Phrase.cs プロジェクト: hwacha/LanguageProject
    public Phrase(Expression function, params Expression[] inputs) : base(null)
    {
        if (inputs.Length > function.GetNumFreeArgs())
        {
            throw new ArgumentException("Too many arguments passed to a function expression");
        }

        Expression newExpression = function;

        int counter = 0;

        for (int i = 0; i < inputs.Length; i++)
        {
            if (inputs[i] == null)
            {
                counter++;
            }
            newExpression = new Phrase(newExpression, inputs[i], counter);
        }

        this.type       = newExpression.type;
        this.headString = newExpression.headString;
        this.headType   = newExpression.headType;
        this.args       = new Expression[newExpression.GetNumArgs()];

        for (int i = 0; i < newExpression.GetNumArgs(); i++)
        {
            this.args[i] = newExpression.GetArg(i);
        }
    }