/// <summary>
 /// Invoked when the fresh variable cannot be promoted to a double int, or char type.
 /// </summary>
 /// <param name="operand"></param>
 /// <returns></returns>
 public override object Exec(TypeExpression operand, object arg)
 {
     if (!operand.IsValueType())
     {
         return(null);
     }
     // * If not promotion is needed, we simply Unbox
     codeGenerator.UnboxAny(this.indent, operand);
     return(null);
 }
 /// <summary>
 /// Groups several kind of calls.
 /// Checks if the parameter passed (operand) matches with the proper argument.
 /// Finally, if the operand is a value type it perforns an unbox.any over the the operand
 /// </summary>
 /// <param name="operand">parameter to check</param>
 /// <returns></returns>
 private object MultiTypeExec(TypeExpression operand, object arg)
 {
     this.codeGenerator.dup(this.indent);
     this.codeGenerator.isinst(this.indent, operand);
     // if check fail then check nextMethod
     this.nextMethod.Add(this.codeGenerator.NewLabel);
     this.codeGenerator.brfalse(this.indent, nextMethod[nextMethod.Count - 1]);
     if (operand.IsValueType())
     {
         this.codeGenerator.UnboxAny(this.indent, operand);
     }
     return(null);
 }
 /// <summary>
 /// Checks if the parameter passed (operand) matches with the proper argument.
 /// In this method only processes non TypeValue parameters.
 /// </summary>
 /// <param name="operand">parameter to check</param>
 /// <returns></returns>
 public override object Exec(TypeExpression operand, object arg)
 {
     if (operand.IsValueType())
     {
         return(null);
     }
     this.codeGenerator.dup(this.indent);
     this.codeGenerator.isinst(this.indent, operand);
     // if check fail then check nextMethod
     this.nextMethod.Add(this.codeGenerator.NewLabel);
     this.codeGenerator.brfalse(this.indent, nextMethod[nextMethod.Count - 1]);
     return(null);
 }
        private object InvokeUnionMethod(MethodType actualMethodCalled, object arg)
        {
            List <string> nextMethod = new List <string>();
            Dictionary <MethodInvocationArgument, object> dic = (Dictionary <MethodInvocationArgument, object>)arg;

            if (this.nonValidObjectsList.Remove(actualMethodCalled.MemberInfo.Class))
            {
                this.codeGenerator.Comment("Removing..." + actualMethodCalled + " from non suitable objects");
            }
            string nextMethodLabel = this.codeGenerator.NewLabel;

            if ((actualMethodCalled.MemberInfo.ModifierMask & Modifier.Static) == 0)
            {
                // check the invocation reference
                dic[MethodInvocationArgument.Clean] = true;
                this.codeGenerator.dup(this.indent);
                this.codeGenerator.isinst(this.indent, actualMethodCalled.MemberInfo.Class);
                this.codeGenerator.brfalse(this.indent, nextMethodLabel);
                if (actualMethodCalled.MemberInfo.Class.IsValueType())
                {
                    this.codeGenerator.Unbox(this.indent, actualMethodCalled.MemberInfo.Class);
                }
            }
            InheritedAttributes ia = this.inheritedAttributes;

            this.objArgs = new InheritedAttributes(ia.CurrentMethod, ia.Assignment, ia.Reference, ia.ArrayAccessFound, actualMethodCalled, ia.IsParentNodeAnInvocation);
            // checks arguments with the parameters of the current method
            this.visitor.RuntimeCheckArguments(this.node, this.objArgs, actualMethodCalled, nextMethod);
            // call currentMethod
            TypeExpression hasReturn = this.codeGenerator.MakeCall(this.indent, this.node, dic[MethodInvocationArgument.DecorationAttributes], actualMethodCalled, (FieldAccessExpression)this.node.Identifier, arg);

            if (hasReturn.IsValueType() && (bool)dic[MethodInvocationArgument.MakeBox])
            {
                this.codeGenerator.Box(this.indent, hasReturn);
            }

            this.codeGenerator.br(this.indent, endLabel);
            // Check next method
            for (int k = nextMethod.Count - 1; k >= 0; k--)
            {
                this.codeGenerator.WriteLabel(this.indent, nextMethod[k]);
                this.codeGenerator.pop(this.indent);
            }
            if ((bool)dic[MethodInvocationArgument.Clean])
            {
                this.codeGenerator.WriteLabel(this.indent, nextMethodLabel);
            }

            return(dic[MethodInvocationArgument.DecorationAttributes]);
        }