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

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

[dotgnu-pnet-commits] pnet ChangeLog ilasm/ilasm_grammar.y ilasm/ilas...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog ilasm/ilasm_grammar.y ilasm/ilas...
Date: Sun, 08 Jul 2007 20:13:39 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      07/07/08 20:13:39

Modified files:
        .              : ChangeLog 
        ilasm          : ilasm_grammar.y ilasm_scanner.l 
        image          : class.c 
        samples        : Makefile.am 
Added files:
        samples        : phone.il 

Log message:
        Fix more generics stuff. Add the phone sample from the ECMA specs.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3476&r2=1.3477
http://cvs.savannah.gnu.org/viewcvs/pnet/ilasm/ilasm_grammar.y?cvsroot=dotgnu-pnet&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/pnet/ilasm/ilasm_scanner.l?cvsroot=dotgnu-pnet&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pnet/image/class.c?cvsroot=dotgnu-pnet&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/pnet/samples/Makefile.am?cvsroot=dotgnu-pnet&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pnet/samples/phone.il?cvsroot=dotgnu-pnet&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3476
retrieving revision 1.3477
diff -u -b -r1.3476 -r1.3477
--- ChangeLog   8 Jul 2007 15:41:29 -0000       1.3476
+++ ChangeLog   8 Jul 2007 20:13:38 -0000       1.3477
@@ -1,3 +1,21 @@
+2007-07-08  Klaus Treickel  <address@hidden>
+
+       * ilasm/ilasm_grammar.y: Set the abstract attribute automatically for
+       interface declarations. Change the reference for method generic 
parameters
+       from '!' '!' to "!!".
+
+       * ilasm/ilasm_scanner.l: Change the "type" keyword to IL only. Add the 
"`"
+       to the allowed characters in IL identifiers for the generic arity.
+
+       * image/class.c: Add the static metod CreateClassRef for creating a 
class
+       reference in the current image for synthetic classes to avoid a TypeRef
+       being created in the image. Call this function in ILClassImport for
+       synthetic classes.
+
+       * samples/phone.il: Add the ECMA phone sample for generics.
+
+       * samples/Makefile.am: Add the phone sample to the built samples.
+
 2007-07-08  Radek Polak  <address@hidden>
 
        * engine/debugger.c: Fix invalid xml in show_types command.

Index: ilasm/ilasm_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_grammar.y,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- ilasm/ilasm_grammar.y       3 Jul 2007 20:25:26 -0000       1.47
+++ ilasm/ilasm_grammar.y       8 Jul 2007 20:13:38 -0000       1.48
@@ -760,6 +760,7 @@
 %token COLON_COLON                     "::"
 %token DOT_DOT_DOT                     "..."
 %token DOT_DOT                         ".."
+%token EXCL_EXCL                       "!!"
 
 /*
  * Directives.
@@ -1510,7 +1511,13 @@
 
 ClassAttributes
        : /* empty */                   { $$ = 0; }
-       | ClassAttributeList    { $$ = $1; }
+       | ClassAttributeList    { 
+                               $$ = $1;
+                               if($$ & IL_META_TYPEDEF_INTERFACE)
+                               {
+                                       $$ |= IL_META_TYPEDEF_ABSTRACT;
+                               }
+                       }
        ;
 
 ClassAttributeList
@@ -3216,10 +3223,10 @@
                                $$ = ILTypeCreateVarNum
                                                (ILAsmContext, 
IL_TYPE_COMPLEX_VAR, (int)($2));
                        }
-       | '!' '!' Integer32                                     {
+       | EXCL_EXCL Integer32                                   {
                                /* Reference to a method generic parameter */
                                $$ = ILTypeCreateVarNum
-                                               (ILAsmContext, 
IL_TYPE_COMPLEX_MVAR, (int)($3));
+                                               (ILAsmContext, 
IL_TYPE_COMPLEX_MVAR, (int)($2));
                        }
        | Type '<' ActualGenericParams '>'      {
                                /* Reference to a generic type instantiation */

Index: ilasm/ilasm_scanner.l
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_scanner.l,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ilasm/ilasm_scanner.l       3 Jul 2007 20:25:26 -0000       1.15
+++ ilasm/ilasm_scanner.l       8 Jul 2007 20:13:39 -0000       1.16
@@ -511,11 +511,12 @@
 <INITIAL,JAVAMODE>"false"                              { return K_FALSE; }
 <INITIAL,JAVAMODE>"java"                               { return K_JAVA; }
 <INITIAL,JAVAMODE>"nullref"                            { return K_NULLREF; }
-<INITIAL,JAVAMODE>"type"                               { return K_TYPE; }
+"type"                                                                 { 
return K_TYPE; }
 
 <INITIAL,JAVAMODE>"::"                                 { return COLON_COLON; }
 <INITIAL,JAVAMODE>"..."                                        { return 
DOT_DOT_DOT; }
 <INITIAL,JAVAMODE>".."                                 { return DOT_DOT; }
+"!!"                                                                   { 
return EXCL_EXCL; }
 
 "add"                                  { OPCODE_NONE(ADD); }   /* Opcodes with 
no args */
 "add.ovf"                              { OPCODE_NONE(ADD_OVF); }
@@ -1023,12 +1024,22 @@
 <JAVAMODE>"multianewarray"     { yylval.opcode = JAVA_OP_MULTIANEWARRAY;
                                                      return I_MULTINEWARRAY; }
 
-<INITIAL,JAVAMODE>{IDALPHA}({DIGIT}|{IDALPHA})*        {
+{IDALPHA}({DIGIT}|{IDALPHA}|"`")*      {
                        yylval.strValue = ILInternString(yytext, 
strlen(yytext));
                        return IDENTIFIER;
                }
 
-<INITIAL,JAVAMODE>"."{IDALPHA}({DIGIT}|{IDALPHA})*     {
+"."{IDALPHA}({DIGIT}|{IDALPHA}|"`")*   {
+                       yylval.strValue = ILInternString(yytext, 
strlen(yytext));
+                       return DOT_IDENTIFIER;
+               }
+
+<JAVAMODE>{IDALPHA}({DIGIT}|{IDALPHA})*        {
+                       yylval.strValue = ILInternString(yytext, 
strlen(yytext));
+                       return IDENTIFIER;
+               }
+
+<JAVAMODE>"."{IDALPHA}({DIGIT}|{IDALPHA})*     {
                        yylval.strValue = ILInternString(yytext, 
strlen(yytext));
                        return DOT_IDENTIFIER;
                }

Index: image/class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/class.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- image/class.c       17 Jul 2006 20:18:53 -0000      1.34
+++ image/class.c       8 Jul 2007 20:13:39 -0000       1.35
@@ -280,6 +280,32 @@
        return info;
 }
 
+/*
+ * Create a reference to a synthetic class in the current image.
+ */
+static ILClass *CreateClassRef(ILProgramItem *scope,
+                                                          const char *name,
+                                                          const char 
*namespace,
+                                                          ILType *synthetic)
+{
+       ILClass *info;
+
+       /* Create a new class information block */
+       info = CreateClass(scope->image, name, namespace, 0, scope);
+       if(!info)
+       {
+               return 0;
+       }
+
+       /* Mark the class as a reference */
+       info->attributes |= IL_META_TYPEDEF_REFERENCE;
+
+       /* set the synthetic type. */
+       info->synthetic = synthetic;
+
+       return info;
+}
+
 ILClass *ILClassCreate(ILProgramItem *scope, ILToken token, const char *name,
                                           const char *namespace, ILClass 
*parent)
 {
@@ -493,8 +519,17 @@
        }
 
        /* Create a new reference */
+       if(info->synthetic)
+       {
+               newInfo = CreateClassRef(scope, info->className->name,
+                                                                
info->className->namespace,
+                                                                
info->synthetic);
+       }
+       else
+       {
        newInfo = ILClassCreateRef(scope, 0, info->className->name,
                                                           
info->className->namespace);
+       }
        if(!newInfo)
        {
                return 0;

Index: samples/Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/samples/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- samples/Makefile.am 6 Feb 2007 20:54:53 -0000       1.14
+++ samples/Makefile.am 8 Jul 2007 20:13:39 -0000       1.15
@@ -1,8 +1,8 @@
 ## Build the example programs.
 
-noinst_DATA = evenodd.exe hello.exe
+noinst_DATA = evenodd.exe hello.exe phone.exe
 
-EXTRA_DIST = evenodd.il hello.il
+EXTRA_DIST = evenodd.il hello.il phone.il
 
 evenodd.exe: evenodd.il
        $(ILASM) -o evenodd.exe $(srcdir)/evenodd.il
@@ -10,4 +10,7 @@
 hello.exe: hello.il
        $(ILASM) -o hello.exe $(srcdir)/hello.il
 
+phone.exe: phone.il
+       $(ILASM) -o phone.exe $(srcdir)/phone.il
+
 CLEANFILES = $(noinst_DATA)

Index: samples/phone.il
===================================================================
RCS file: samples/phone.il
diff -N samples/phone.il
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ samples/phone.il    8 Jul 2007 20:13:39 -0000       1.1
@@ -0,0 +1,52 @@
+.assembly extern mscorlib {}
+.assembly Phone {}
+ 
+.class private Phone`2<([mscorlib]System.Object) K,
+([mscorlib]System.Object) V>
+extends [mscorlib]System.Object {
+.field private int32 hi
+.field private !0[] keys
+.field private !1[] vals
+.method public instance void Add(!0 k, !1 v) {
+.maxstack 4
+.locals init (int32 temp)
+ldarg.0
+ldfld !0[] class Phone`2<!0,!1>::keys
+ldarg.0
+dup
+ldfld int32 class Phone`2<!0,!1>::hi
+ldc.i4.1
+add
+dup
+stloc.0
+stfld int32 class Phone`2<!0,!1>::hi
+ldloc.0
+ldarg.1
+stelem !0
+ldarg.0
+ldfld !1[] class Phone`2<!0,!1>::vals
+ldarg.0
+ldfld int32 class Phone`2<!0,!1>::hi
+ldarg.2
+stelem !1
+ret
+} // end of Method Add
+} // end of class Phone
+.class App extends [mscorlib]System.Object {
+.method static void Main() {
+.entrypoint
+.maxstack 3
+.locals init (class Phone`2<string,int32> temp)
+.locals init (class Phone`2<string,int32> temp)
+newobj instance void class
+Phone`2<string,int32>::.ctor()
+stloc.0
+ldloc.0
+ldstr "Jim"
+ldc.i4.7
+callvirt instance void class
+Phone`2<string,int32>::Add(!0, !1)
+ret
+} // end of method Main
+} // end of class App
+




reply via email to

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