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_attrs.c,1.16,1.17 cs_def


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_attrs.c,1.16,1.17 cs_defs.tc,1.10,1.11 cs_grammar.y,1.48,1.49 cs_oper.tc,1.34,1.35
Date: Thu, 20 Feb 2003 23:30:06 -0500

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

Modified Files:
        cs_attrs.c cs_defs.tc cs_grammar.y cs_oper.tc 
Log Message:


Support "MarshalTypeRef" in custom marshalling declarations.


Index: cs_attrs.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_attrs.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** cs_attrs.c  15 Feb 2003 06:30:29 -0000      1.16
--- cs_attrs.c  21 Feb 2003 04:30:03 -0000      1.17
***************
*** 242,245 ****
--- 242,246 ----
        ILNode *nameNode;
        int retry;
+       int skipConst;
  
        /* Try the attribute name without "Attribute" first */
***************
*** 365,370 ****
                        if(!CSSemExpectValue(arg, info, iter.last, &value))
                        {
!                               haveErrors = 1;
!                               evalArgs[argNum].type = ILType_Int32;
                        }
                        else
--- 366,374 ----
                        if(!CSSemExpectValue(arg, info, iter.last, &value))
                        {
!                               if(!CSSemIsType(value))
!                               {
!                                       haveErrors = 1;
!                                       evalArgs[argNum].type = ILType_Int32;
!                               }
                        }
                        else
***************
*** 377,384 ****
  
                        /* Evaluate the constant value of the argument */
!                       if(!haveErrors &&
!                          !ILNode_EvalConst(*(iter.last), info, 
&(evalValues[argNum])))
                        {
!                               haveErrors = 1;
                        }
  
--- 381,397 ----
  
                        /* Evaluate the constant value of the argument */
!                       if(CSSemIsType(value))
                        {
!                               evalValues[argNum].valueType = 
ILMachineType_Void;
!                               evalValues[argNum].un.oValue = 
CSSemGetType(value);
!                               evalArgs[argNum].type = ILFindSystemType(info, 
"Type");
!                       }
!                       else
!                       {
!                               if(!haveErrors &&
!                                  !ILNode_EvalConst(*(iter.last), info, 
&(evalValues[argNum])))
!                               {
!                                       haveErrors = 1;
!                               }
                        }
  
***************
*** 444,449 ****
                                                                 
&(((ILNode_NamedArg *)arg)->value), &value))
                        {
!                               haveErrors = 1;
!                               namedArgs[argNum].type = ILType_Int32;
                        }
                        else
--- 457,465 ----
                                                                 
&(((ILNode_NamedArg *)arg)->value), &value))
                        {
!                               if(!CSSemIsType(value))
!                               {
!                                       haveErrors = 1;
!                                       namedArgs[argNum].type = ILType_Int32;
!                               }
                        }
                        else
***************
*** 456,464 ****
  
                        /* Evaluate the constant value of the argument */
!                       if(!haveErrors &&
!                          !ILNode_EvalConst(namedArgs[argNum].node, info,
!                                                                
&(namedValues[argNum])))
                        {
!                               haveErrors = 1;
                        }
  
--- 472,491 ----
  
                        /* Evaluate the constant value of the argument */
!                       if(CSSemIsType(value))
                        {
!                               namedValues[argNum].valueType = 
ILMachineType_Void;
!                               namedValues[argNum].un.oValue = 
CSSemGetType(value);
!                               namedArgs[argNum].type = ILFindSystemType(info, 
"Type");
!                               skipConst = 1;
!                       }
!                       else
!                       {
!                               if(!haveErrors &&
!                                  !ILNode_EvalConst(namedArgs[argNum].node, 
info,
!                                                                        
&(namedValues[argNum])))
!                               {
!                                       haveErrors = 1;
!                               }
!                               skipConst = 0;
                        }
  
***************
*** 470,478 ****
                                                        namedArgs[argNum].type,
                                                        
GetAttrFieldType(namedFields[argNum]),1) &&
!                                  ILGenCastConst
                                                (info, &(namedValues[argNum]),
                                                 namedValues[argNum].valueType,
                                                 ILTypeToMachineType
!                                                               
(GetAttrFieldType(namedFields[argNum]))))
                                {
                                        namedArgs[argNum].node = 
*(namedArgs[argNum].parent);
--- 497,505 ----
                                                        namedArgs[argNum].type,
                                                        
GetAttrFieldType(namedFields[argNum]),1) &&
!                                  (skipConst || ILGenCastConst
                                                (info, &(namedValues[argNum]),
                                                 namedValues[argNum].valueType,
                                                 ILTypeToMachineType
!                                                               
(GetAttrFieldType(namedFields[argNum])))))
                                {
                                        namedArgs[argNum].node = 
*(namedArgs[argNum].parent);
***************
*** 572,592 ****
        {
                paramType = ILTypeGetParam(signature, argNum + 1);
!               if(!ILGenCastConst(info, &(evalValues[argNum]),
!                                                  evalValues[argNum].valueType,
!                                                  
ILTypeToMachineType(paramType)))
!               {
!                       CCErrorOnLine(yygetfilename(evalArgs[argNum].node),
!                                                 
yygetlinenum(evalArgs[argNum].node),
!                                                 _("could not coerce constant 
argument %d"),
!                                                 argNum + 1);
!                       haveErrors = 1;
!               }
!               else if(ILSerializeGetType(paramType) == -1)
!               {
!                       CCErrorOnLine(yygetfilename(evalArgs[argNum].node),
!                                                 
yygetlinenum(evalArgs[argNum].node),
!                                                 _("attribute argument %d is 
not serializable"),
!                                                 argNum + 1);
!                       haveErrors = 1;
                }
        }
--- 599,622 ----
        {
                paramType = ILTypeGetParam(signature, argNum + 1);
!               if(evalValues[argNum].valueType != ILMachineType_Void)
!               {
!                       if(!ILGenCastConst(info, &(evalValues[argNum]),
!                                                          
evalValues[argNum].valueType,
!                                                          
ILTypeToMachineType(paramType)))
!                       {
!                               
CCErrorOnLine(yygetfilename(evalArgs[argNum].node),
!                                                         
yygetlinenum(evalArgs[argNum].node),
!                                                         _("could not coerce 
constant argument %d"),
!                                                         argNum + 1);
!                               haveErrors = 1;
!                       }
!                       else if(ILSerializeGetType(paramType) == -1)
!                       {
!                               
CCErrorOnLine(yygetfilename(evalArgs[argNum].node),
!                                                         
yygetlinenum(evalArgs[argNum].node),
!                                                         _("attribute argument 
%d is not serializable"),
!                                                         argNum + 1);
!                               haveErrors = 1;
!                       }
                }
        }
***************
*** 649,655 ****
                        break;
  
                        default:
                        {
!                               /* TODO: types and arrays */
                        }
                        break;
--- 679,693 ----
                        break;
  
+                       case IL_META_SERIALTYPE_TYPE:
+                       {
+                               const char *name = CSTypeToName
+                                       ((ILType *)(argValue->un.strValue.str));
+                               ILSerializeWriterSetString(writer, name, 
strlen(name));
+                       }
+                       break;
+ 
                        default:
                        {
!                               /* TODO: arrays and implicit coercions to 
Object */
                        }
                        break;
***************
*** 660,665 ****
        {
                argValue = &(namedValues[argNum]);
!               paramType = ILValueTypeToType(info, argValue->valueType);
!               serialType = ILSerializeGetType(paramType);
                if(ILMember_IsField(((ILMember *)(namedFields[argNum]))))
                {
--- 698,710 ----
        {
                argValue = &(namedValues[argNum]);
!               if(argValue->valueType == ILMachineType_Void)
!               {
!                       serialType = IL_META_SERIALTYPE_TYPE;
!               }
!               else
!               {
!                       paramType = ILValueTypeToType(info, 
argValue->valueType);
!                       serialType = ILSerializeGetType(paramType);
!               }
                if(ILMember_IsField(((ILMember *)(namedFields[argNum]))))
                {
***************
*** 716,722 ****
                        break;
  
                        default:
                        {
!                               /* TODO: types and arrays */
                        }
                        break;
--- 761,775 ----
                        break;
  
+                       case IL_META_SERIALTYPE_TYPE:
+                       {
+                               const char *name = CSTypeToName
+                                       ((ILType *)(argValue->un.strValue.str));
+                               ILSerializeWriterSetString(writer, name, 
strlen(name));
+                       }
+                       break;
+ 
                        default:
                        {
!                               /* TODO: arrays and implicit coercions to 
Object */
                        }
                        break;

Index: cs_defs.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_defs.tc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** cs_defs.tc  12 Dec 2002 16:59:54 -0000      1.10
--- cs_defs.tc  21 Feb 2003 04:30:03 -0000      1.11
***************
*** 109,112 ****
--- 109,113 ----
        CSSemValue      value;
  }
+ %node ILNode_ToAttrConst ILNode_ToConst
  
  /*

Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** cs_grammar.y        21 Feb 2003 02:00:00 -0000      1.48
--- cs_grammar.y        21 Feb 2003 04:30:03 -0000      1.49
***************
*** 2504,2508 ****
  
  AttributeArgumentExpression
!       : ConstantExpression                    { $$ = $1; }
        ;
  
--- 2504,2508 ----
  
  AttributeArgumentExpression
!       : Expression                    { $$ = ILNode_ToAttrConst_create($1); }
        ;
  

Index: cs_oper.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_oper.tc,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** cs_oper.tc  10 Dec 2002 23:08:59 -0000      1.34
--- cs_oper.tc  21 Feb 2003 04:30:03 -0000      1.35
***************
*** 1374,1377 ****
--- 1374,1444 ----
  
  /*
+  * Perform semantic analysis for the "ToAttrConst" operator.
+  */
+ ILNode_SemAnalysis(ILNode_ToAttrConst)
+ {
+       CSSemValue value;
+       ILNode_TypeOf *typeofNode;
+ 
+       /* Special case: types can be used as attribute constants */
+       if(yyisa(node->expr, ILNode_TypeOf))
+       {
+               /* Get the semantic value for the typeof sub-expression */
+               typeofNode = (ILNode_TypeOf *)(node->expr);
+               value = ILNode_SemAnalysisType
+                       (typeofNode->expr, info, &(typeofNode->expr));
+ 
+               /* Check that the argument is of the correct kind */
+               if(CSSemIsType(value))
+               {
+                       if(ILType_IsPrimitive(CSSemGetType(value)))
+                       {
+                               typeofNode->type = ILType_FromClass
+                                       (ILTypeToClass(info, 
CSSemGetType(value)));
+                       }
+                       else
+                       {
+                               typeofNode->type = CSSemGetType(value);
+                       }
+               }
+               else
+               {
+                       CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
+                                                 "invalid argument to `typeof' 
operator");
+                       typeofNode->type = ILFindSystemType(info, "Int32");
+               }
+               CSSemSetType(value, typeofNode->type);
+               return value;
+       }
+ 
+       /* Perform semantic analysis on the sub-expression */
+       value = ILNode_SemAnalysis(node->expr, info, &(node->expr));
+ 
+       /* Types can be used as constants in attributes */
+       if(CSSemIsType(value))
+       {
+               return value;
+       }
+ 
+       /* Determine if the sub-expression evaluates to a constant */
+       if(!CSSemIsConstant(value) || CSSemIsDynConstant(value))
+       {
+               CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
+                                         "constant value required");
+               if(!CSSemIsValue(value))
+               {
+                       CSSemSetDynConstant(value, ILType_Int32);
+               }
+               else
+               {
+                       CSSemSetDynConstant(value, CSSemGetType(value));
+               }
+       }
+ 
+       /* Return the semantic information to the caller */
+       return value;
+ }
+ 
+ /*
   * Perform semantic analysis for the logical NOT operator.
   */





reply via email to

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