Exemplo n.º 1
0
        //// <summary>
        /// Returns an int value encapsulated in an object item that indicates a promotion level.
        /// </summary>
        /// <param name="firstOperand">An array to promote.</param>
        /// <returns>Returns a promotion value.</returns>
        public override object Exec(ArrayType firstOperand, object arg)
        {
            // * Array and bounded type variable
            ArrayType array = TypeExpression.As <ArrayType>(this.secondOperand);

            if (array != null)
            {
                return(firstOperand.ArrayTypeExpression.Equals(array.ArrayTypeExpression) ? 0 : -1);
            }
            // * A free variable is a complete promotion
            TypeVariable typeVariable = this.secondOperand as TypeVariable;

            if (typeVariable != null && typeVariable.Substitution == null)
            {
                return(0);
            }
            // * Union type and bounded type variable
            UnionType unionType = TypeExpression.As <UnionType>(this.secondOperand);

            if (unionType != null)
            {
                return(unionType.SuperType(firstOperand));
            }
            // * Field type and bounded type variable
            FieldType fieldType = TypeExpression.As <FieldType>(this.secondOperand);

            if (fieldType != null)
            {
                return(firstOperand.AcceptOperation(new PromotionLevelOperation(fieldType.FieldTypeExpression), arg));
            }
            // * Use the BCL object oriented approach
            return(firstOperand.AsClassType().AcceptOperation(this, arg));
        }
Exemplo n.º 2
0
 public override object Exec(ArrayType d, object arg)
 {
     return(d.AsClassType().AcceptOperation(new UnconstrainedDotOperation(this.memberName, this.previousDot), arg));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Delegate its behaviour to the BCLClassType, chaining its message to the later.
        /// </summary>
        /// <param name="d">An array WriteType to pass the message member</param>
        /// <returns>A typeExpression result of the operation</returns>

        public override object Exec(ArrayType d, object arg)
        {
            return(d.AsClassType().AcceptOperation(this, arg));
        }