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_grammar.y,1.42,1.43 cs_d


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y,1.42,1.43 cs_defs.tc,1.8,1.9 cs_stmt.tc,1.30,1.31 cs_oper.tc,1.33,1.34
Date: Tue, 10 Dec 2002 18:09:01 -0500

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

Modified Files:
        cs_grammar.y cs_defs.tc cs_stmt.tc cs_oper.tc 
Log Message:
small fixes to the compiler and add some support for ILNode_Fixed


Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** cs_grammar.y        9 Dec 2002 20:33:25 -0000       1.42
--- cs_grammar.y        10 Dec 2002 23:08:59 -0000      1.43
***************
*** 2299,2303 ****
  FixedPointerDeclarators
        : FixedPointerDeclarator                {
!                               $$ = ILNode_FixedDeclList_create();
                                ILNode_List_Add($$, $1);
                        }
--- 2299,2303 ----
  FixedPointerDeclarators
        : FixedPointerDeclarator                {
!                               $$ = ILNode_List_create();
                                ILNode_List_Add($$, $1);
                        }
***************
*** 2319,2328 ****
                                if(yykind($3) == yykindof(ILNode_AddressOf))
                                {
!                                       MakeBinary(FixAddress, 
ILQualIdentName($1, 0),
!                                                          
((ILNode_UnaryExpression *)($3))->expr);
                                }
                                else
                                {
!                                       MakeBinary(FixExpr, ILQualIdentName($1, 
0), $3);
                                }
                        }
--- 2319,2327 ----
                                if(yykind($3) == yykindof(ILNode_AddressOf))
                                {
!                                       MakeBinary(FixAddress, $1,$3);
                                }
                                else
                                {
!                                       MakeBinary(FixExpr, $1, $3);
                                }
                        }
***************
*** 2408,2412 ****
  
  AttributeArguments
!       : '(' PositionalArgumentList ')'                        {
                                MakeBinary(AttrArgs, $2, 0);
                        }
--- 2407,2412 ----
  
  AttributeArguments
!       : '(' ')' {     /* empty */ }
!       | '(' PositionalArgumentList ')'                        {
                                MakeBinary(AttrArgs, $2, 0);
                        }

Index: cs_defs.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_defs.tc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** cs_defs.tc  9 Dec 2002 20:33:25 -0000       1.8
--- cs_defs.tc  10 Dec 2002 23:08:59 -0000      1.9
***************
*** 119,131 ****
        ILNode *stmt;
  }
! %node ILNode_FixedDeclList ILNode_List
! %node ILNode_FixAddress ILNode_Dummy =
  {
-       char   *name;
        ILNode *address;
  }
! %node ILNode_FixExpr ILNode_Dummy =
  {
-       char   *name;
        ILNode *expr;
  }
--- 119,132 ----
        ILNode *stmt;
  }
! %node ILNode_FixedVariable ILNode_Dummy %abstract =
! {
!       ILNode *name;
! }
! %node ILNode_FixAddress ILNode_FixedVariable =
  {
        ILNode *address;
  }
! %node ILNode_FixExpr ILNode_FixedVariable =
  {
        ILNode *expr;
  }

Index: cs_stmt.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_stmt.tc,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** cs_stmt.tc  9 Dec 2002 22:29:22 -0000       1.30
--- cs_stmt.tc  10 Dec 2002 23:08:59 -0000      1.31
***************
*** 1638,1641 ****
--- 1638,1653 ----
  ILNode_SemAnalysis(ILNode_Fixed)
  {
+       ILType *type;
+       char *name;
+       ILNode_MethodDeclaration *method;
+       ILNode *errorNode;
+       ILNode_ListIter iter;
+       ILNode *varNode;
+       ILNode *nameNode;
+       ILScopeData *data;
+ 
+       /* Locate the method that this local is declared within */
+       method = (ILNode_MethodDeclaration *)(info->currentMethod);
+ 
        /* TODO */
        CCUnsafeMessage(info, (ILNode *)node, "unsafe `fixed' statement");
***************
*** 1644,1648 ****
--- 1656,1714 ----
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                          "`fixed' disallowed when compiling to 
Java bytecode");
+               return CSSemValueDefault;
+       }
+ 
+       /* Perform semantic analysis on the local variable type */
+       type = CSSemType(node->type, info, &(node->type));
+ 
+       /* Scan through the variable names and declare them in the current 
scope */
+       ILNode_ListIter_Init(&iter, node->decls);
+       while((varNode = ILNode_ListIter_Next(&iter)) != 0)
+       {
+               nameNode=((ILNode_FixedVariable*)varNode)->name;
+               name = ILQualIdentName(nameNode,0);
+               data = ILScopeLookup(info->currentScope, name, 0);
+               if(data)
+               {
+                       /* The name is already declared in this scope */
+                       CCErrorOnLine(yygetfilename(nameNode), 
yygetlinenum(nameNode),
+                                                 "`%s' is already declared in 
this scope", name);
+                       errorNode = ILScopeDataGetNode(data);
+                       if(errorNode)
+                       {
+                               CCErrorOnLine(yygetfilename(errorNode), 
yygetlinenum(errorNode),
+                                                         "previous declaration 
here");
+                       }
+               }
+               else
+               {
+                       /* Add the type to the local variable signature for 
this method */
+                       if(!(method->localVarSig))
+                       {
+                               method->localVarSig = 
ILTypeCreateLocalList(info->context);
+                               if(!(method->localVarSig))
+                               {
+                                       CCOutOfMemory();
+                               }
+                       }
+                       
+                       if(yyisa(varNode,ILNode_FixAddress))
+                       {
+                               /* TODO : figure the right way to pin variables 
*/
+                       }
+                       
+                       if(!ILTypeAddLocal(info->context, method->localVarSig, 
type))
+                       {
+                               CCOutOfMemory();
+                       }
+ 
+                       /* Create a local variable entry in the current scope */
+                       ILScopeDeclareLocal(info->currentScope, name,
+                                                               
ILTypeNumLocals(method->localVarSig) - 1,
+                                                               
((ILNode_FixedVariable*)varNode)->name);
+                       ILNode_SemAnalysis(varNode,info,iter.last);
+               }
        }
+       ILNode_SemAnalysis(node->stmt,info,&(node->stmt));
        return CSSemValueDefault;
  }
***************
*** 1653,1657 ****
  ILNode_GenDiscard(ILNode_Fixed)
  {
!       /* TODO */
  }
  
--- 1719,1724 ----
  ILNode_GenDiscard(ILNode_Fixed)
  {
!       ILNode_GenDiscard(node->decls,info);
!       ILNode_GenDiscard(node->stmt,info);
  }
  
***************
*** 1673,1689 ****
  
  /*
-  * Perform semantic analysis for "fixed declarator" lists.
-  */
- ILNode_SemAnalysis(ILNode_FixedDeclList)
- {
-       return CSSemValueDefault;
- }
- 
- /*
   * Perform semantic analysis for the "fix address" node.
   */
  ILNode_SemAnalysis(ILNode_FixAddress)
  {
!       /* TODO */
        return CSSemValueDefault;
  }
--- 1740,1751 ----
  
  /*
   * Perform semantic analysis for the "fix address" node.
   */
  ILNode_SemAnalysis(ILNode_FixAddress)
  {
!       *parent=ILNode_Assign_create(node->name,node->address);
!       yysetfilename(*parent, yygetfilename(node));
!       yysetlinenum(*parent, yygetlinenum(node));
!       ILNode_SemAnalysis(*parent,info,parent);
        return CSSemValueDefault;
  }
***************
*** 1694,1698 ****
  ILNode_SemAnalysis(ILNode_FixExpr)
  {
!       /* TODO */
        return CSSemValueDefault;
  }
--- 1756,1764 ----
  ILNode_SemAnalysis(ILNode_FixExpr)
  {
!       /* TODO : Convert the types array T[] into T* */
!       *parent=ILNode_Assign_create(node->name,node->expr);
!       yysetfilename(*parent, yygetfilename(node));
!       yysetlinenum(*parent, yygetlinenum(node));
!       ILNode_SemAnalysis(*parent,info,parent);
        return CSSemValueDefault;
  }

Index: cs_oper.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_oper.tc,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** cs_oper.tc  10 Dec 2002 21:40:26 -0000      1.33
--- cs_oper.tc  10 Dec 2002 23:08:59 -0000      1.34
***************
*** 1841,1847 ****
  {
        CSSemValue value;
        CCUnsafeMessage(info, (ILNode *)node, "unsafe pointer dereference");
!       /* TODO */
!       CSSemSetRValue(value, ILType_Int32);
        return value;
  }
--- 1841,1866 ----
  {
        CSSemValue value;
+       ILType *type;
        CCUnsafeMessage(info, (ILNode *)node, "unsafe pointer dereference");
!       value=ILNode_SemAnalysis(node->expr,info,&(node->expr));
!       if(!CSSemIsValue(value) || !CSSemGetType(value))
!       {
!               
CCErrorOnLine(yygetfilename(node->expr),yygetlinenum(node->expr),
!                               "invalid argument for dereference operator");
!               CSSemSetLValue(value,ILType_Int32);
!               return value;
!       }
!       type=CSSemGetType(value);
!       if(ILType_IsComplex(type) && (ILType_Kind(type) == IL_TYPE_COMPLEX_PTR))
!       {
!               CSSemSetLValue(value,ILType_Ref(CSSemGetType(value)));
!               return value;
!       }
!       else
!       {
!               
CCErrorOnLine(yygetfilename(node->expr),yygetlinenum(node->expr),
!                       "cannot deference '%s' 
type",CSTypeToName(CSSemGetType(value)));
!       }
!       CSSemSetLValue(value, ILType_Int32);
        return value;
  }




reply via email to

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