Пример #1
0
        /// <summary>
        /// Combines two types to create a new one
        /// </summary>
        /// <param name="right"></param>
        /// <param name="Operator"></param>
        /// <returns></returns>
        public override Types.Type CombineType(Types.Type right, Interpreter.BinaryExpression.OPERATOR Operator)
        {
            Types.Type retVal = null;

            Function function = right as Function;
            if (function != null)
            {
                if (this.ReturnType == function.ReturnType)
                {
                    if (this.FormalParameters.Count >= function.FormalParameters.Count)
                    {
                        retVal = this;
                    }
                    else
                    {
                        retVal = function;
                    }
                }
                else
                {
                    AddError("Cannot combine types " + this.ReturnType.Name + " and " + function.ReturnType.Name);
                }
            }
            else if (right.IsDouble())
            {
                retVal = this;
            }
            else
            {
                AddError("Cannot combine types " + this.ReturnType.Name + " and " + right.Name);
            }

            return retVal;
        }