dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_oper.tc,1.24,1.25


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_oper.tc,1.24,1.25
Date: Thu, 14 Nov 2002 02:19:21 -0500

Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv15896/cscc/csharp

Modified Files:
        cs_oper.tc 
Log Message:
parameter coercion for user binary operators


Index: cs_oper.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_oper.tc,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** cs_oper.tc  9 Nov 2002 21:24:13 -0000       1.24
--- cs_oper.tc  14 Nov 2002 07:19:16 -0000      1.25
***************
*** 59,62 ****
--- 59,112 ----
  }
  
+ /* 
+  * process UserBinaryOperator
+  */
+ static void ApplyUserBinaryOperator(ILGenInfo *info, ILMethod *method,
+                                                                       
ILNode_BinaryExpression *node,
+                                                                       ILNode 
**parent,CSSemValue *value1,
+                                                                       
CSSemValue *value2)
+ {
+       ILType *returnType;
+       ILType *sig;
+       ILType *argType1, *argType2;
+       
+       method = (ILMethod *)ILMemberImport(info->image, (ILMember *)method);
+       if(!method)
+       {
+               CCOutOfMemory();
+               return; /* fall back */
+       }
+       
+       sig= ILMethod_Signature(method);
+       
+       returnType = ILTypeGetReturn(sig);
+       
+       /* NOTE: this is valid even for non-static operators */
+       argType1=ILTypeGetParam(sig,0); 
+       argType2=ILTypeGetParam(sig,1);
+       
+       if(ILCanCoerce(info,CSSemGetType(*value1),argType1))
+       {
+               ILCoerce(info,node->expr1,
+                                       &(node->expr1),
+                                       CSSemGetType(*value1),
+                                       argType1);
+               /* CSSemSetRValue(*value1, argType1); *//* not needed */
+       }
+       if(ILCanCoerce(info,CSSemGetType(*value2),argType2))
+       {
+               ILCoerce(info,node->expr2,
+                                       &(node->expr2),
+                                       CSSemGetType(*value2),
+                                       argType2);
+               CSSemSetRValue(*value2, argType2);
+       }
+       *parent = ILNode_UserBinaryOp_create
+                                               
(((ILNode_BinaryExpression*)(node))->expr1, 
+                                               
((ILNode_BinaryExpression*)(node))->expr2,
+                                                
ILTypeToMachineType(returnType), method);
+       CSSemSetRValue(*value1, returnType);
+ }
+ 
  /*
   * Perform constant evaluation on an operator node.
***************
*** 107,111 ****
        const ILOperator *oper;
        ILMethod *method;
-       ILType *returnType;
        CSSemValue value1;
        CSSemValue value2;
--- 157,160 ----
***************
*** 163,178 ****
        if(method)
        {
!               method = (ILMethod *)ILMemberImport(info->image, (ILMember 
*)method);
!               if(!method)
!               {
!                       CCOutOfMemory();
!               }
!               returnType = ILTypeGetReturn(ILMethod_Signature(method));
!               *parent = ILNode_UserBinaryOp_create
!                                               (node->expr1, node->expr2,
!                                                
ILTypeToMachineType(returnType), method);
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
-               CSSemSetRValue(value1, returnType);
                return value1;
        }
--- 212,219 ----
        if(method)
        {
!               
ApplyUserBinaryOperator(info,method,(ILNode_BinaryExpression*)node,
!                                                               
parent,&(value1),&(value2));
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
                return value1;
        }
***************
*** 321,325 ****
        const ILOperator *oper;
        ILMethod *method;
-       ILType *returnType;
        CSSemValue value1;
        CSSemValue value2;
--- 362,365 ----
***************
*** 377,387 ****
        if(method)
        {
!               returnType = ILTypeGetReturn(ILMethod_Signature(method));
!               *parent = ILNode_UserBinaryOp_create
!                                               (node->expr1, node->expr2,
!                                                
ILTypeToMachineType(returnType), method);
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
-               CSSemSetRValue(value1, returnType);
                return value1;
        }
--- 417,424 ----
        if(method)
        {
!               
ApplyUserBinaryOperator(info,method,(ILNode_BinaryExpression*)node,
!                                                               
parent,&(value1),&(value2));
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
                return value1;
        }
***************
*** 475,479 ****
        const ILOperator *oper;
        ILMethod *method;
-       ILType *returnType;
        CSSemValue value1;
        CSSemValue value2;
--- 512,515 ----
***************
*** 532,542 ****
        if(method)
        {
!               returnType = ILTypeGetReturn(ILMethod_Signature(method));
!               *parent = ILNode_UserBinaryOp_create
!                                               (node->expr1, node->expr2,
!                                                
ILTypeToMachineType(returnType), method);
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
-               CSSemSetRValue(value1, returnType);
                return value1;
        }
--- 568,575 ----
        if(method)
        {
!               
ApplyUserBinaryOperator(info,method,(ILNode_BinaryExpression*)node,
!                                                               
parent,&(value1),&(value2));
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
                return value1;
        }
***************
*** 846,850 ****
        const ILOperator *oper;
        ILMethod *method;
-       ILType *returnType;
        CSSemValue value1;
        CSSemValue value2;
--- 879,882 ----
***************
*** 931,941 ****
        if(method)
        {
!               returnType = ILTypeGetReturn(ILMethod_Signature(method));
!               *parent = ILNode_UserBinaryOp_create
!                                               (node->expr1, node->expr2,
!                                                
ILTypeToMachineType(returnType), method);
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
-               CSSemSetRValue(value1, returnType);
                return value1;
        }
--- 963,970 ----
        if(method)
        {
!               
ApplyUserBinaryOperator(info,method,(ILNode_BinaryExpression*)node,
!                                                               
parent,&(value1),&(value2));
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
                return value1;
        }
***************
*** 1585,1589 ****
        const ILOperator *oper;
        ILMethod *method;
-       ILType *returnType;
        CSSemValue value1;
        CSSemValue value2;
--- 1614,1617 ----
***************
*** 1654,1664 ****
        if(method)
        {
!               returnType = ILTypeGetReturn(ILMethod_Signature(method));
!               *parent = ILNode_UserBinaryOp_create
!                                               (node->expr1, node->expr2,
!                                                
ILTypeToMachineType(returnType), method);
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
-               CSSemSetRValue(value1, returnType);
                return value1;
        }
--- 1682,1689 ----
        if(method)
        {
!               
ApplyUserBinaryOperator(info,method,(ILNode_BinaryExpression*)node,
!                                                               
parent,&(value1),&(value2));
                yysetfilename(*parent, yygetfilename(node));
                yysetlinenum(*parent, yygetlinenum(node));
                return value1;
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]