shithub: mc

Download patch

ref: 077743e60829979ec6d86760e8806e1d599419bc
parent: 224a25f16463b31a8f36f266d34d09e83175f170
author: Ori Bernstein <[email protected]>
date: Wed Feb 19 15:02:52 EST 2014

Install trait funcs to symbol tables.

--- a/parse/gram.y
+++ b/parse/gram.y
@@ -194,7 +194,12 @@
 
 toplev  : package
         | use {lappend(&file->file.uses, &file->file.nuses, $1);}
-        | traitdef {puttrait(file->file.globls, $1->name, $1);}
+        | traitdef {
+                size_t i;
+                puttrait(file->file.globls, $1->name, $1);
+                for (i = 0; i < $1->nfuncs; i++)
+                    putdcl(file->file.exports, $1->funcs[i]);
+            }
         | implstmt {lappend(&file->file.stmts, &file->file.nstmts, $1);}
         | tydef {
                 puttype(file->file.globls, mkname($1.line, $1.name), $1.type);
@@ -287,6 +292,7 @@
             }
         | traitdef {
                 size_t i;
+                puttrait(file->file.exports, $1->name, $1);
                 for (i = 0; i < $1->nfuncs; i++)
                     putdcl(file->file.exports, $1->funcs[i]);
             }
@@ -339,8 +345,12 @@
 traitbody
         : optendlns {$$.nl = NULL; $$.nn = 0;}
         | traitbody Tident Tcolon type optendlns {
+                Node *d;
                 $$ = $1;
-                lappend(&$$.nl, &$$.nn, mkdecl($2->line, mkname($2->line, $2->str), $4));
+                d = mkdecl($2->line, mkname($2->line, $2->str), $4);
+                d->decl.isgeneric = 1;
+                d->decl.istraitfn = 1;
+                lappend(&$$.nl, &$$.nn, d);
             }
         ;
 
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -256,6 +256,12 @@
             char  isglobl;
             char  isconst;
             char  isgeneric;
+            /* 
+               specializations should only look up these, not generate
+               specialized versions. In fact, these should never have
+               initializers.
+            */
+            char  istraitfn;
             char  isextern;
             char  ishidden;
         } decl;