dotgnu-general
[Top][All Lists]
Advanced

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

[DotGNU]The type coercion for operators


From: Gopal V
Subject: [DotGNU]The type coercion for operators
Date: Sun, 1 Sep 2002 22:06:19 +0530
User-agent: Mutt/1.2.5i

uint x=0;
uint y=x+1;

Does not compile on pnet ... and is a reported bug (and the major
reason why pnetlib does not compile ...)

I had a peek at cs_oper.tc and tried to hack the addition operator
to make this work ... I wanted to confirm if I was on the right
track with this ..


--- /opt/cvs/dotgnu/pnet/cscc/csharp/cs_oper.tc Fri Aug  9 19:17:52 2002
+++ /tmp/dotgnu/pnet/cscc/csharp/cs_oper.tc     Sun Sep  1 22:01:29 2002
@@ -230,6 +230,8 @@
        CSSemValue value1;
        CSSemValue value2;
        ILType *resultType;
+       //additional
+       ILEvalValue evalue;
 
        /* Perform semantic analysis on the arguments */
        value1 = ILNode_SemAnalysis(node->expr1, info, &(node->expr1));
@@ -241,6 +243,26 @@
                goto error;
        }
 
+       if(ILNode_EvalConst(node->expr2,info,&evalue))
+       {
+               if(ILCanCoerce(info,value1.type,value2.type))
+               {
+                       
if(ILCoerce(info,node->expr2,&(node->expr2),value2.type,value1.type))
+                       {
+                               value2.type=value1.type;
+                       }
+               
+               }
+               else if(ILCanCast(info,value1.type,value2.type))
+               {
+                       
if(ILCast(info,node->expr2,&(node->expr2),value2.type,value1.type))
+                       {
+                               value2.type=value1.type;
+                       }
+               }
+               fprintf(stderr,"<%s: %s>\n",yykindname(node->expr2),
+               CSTypeToName(value2.type));//check switch
+       }
        /* Look for a builtin operator */
        oper = ILFindBinaryOperator
                                (ILOp_Add, value1.type, value2.type, 
&resultType);

I would like some comments on the above code and some help ... Also would
someone like to typecast all operators in pnetlib to make it compilable
with cscc ? Or are we going to fix up cscc first ?

Gopal
-- 
The difference between insanity and genius is measured by success


reply via email to

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