]> Cypherpunks repositories - gostls13.git/commitdiff
gc: allow tags on parameters in export section of object files.
authorLuuk van Dijk <lvd@golang.org>
Fri, 3 Jun 2011 01:54:56 +0000 (03:54 +0200)
committerLuuk van Dijk <lvd@golang.org>
Fri, 3 Jun 2011 01:54:56 +0000 (03:54 +0200)
This is in preparation of escape analysis; function parameters
can now be tagged with interesting bits by the compiler by
assigning to n->note.

tested by having typecheck put a fake tag on all parameters of
pointer type and compiling the tree.

R=rsc
CC=golang-dev
https://golang.org/cl/4524092

src/cmd/gc/go.y
src/pkg/go/types/gcimporter.go

index fdaab4fa4671c74a0d2d45e8c8874b57eb05c339..1278c25863fe1fdf082b8b01b98c34d8d948a458 100644 (file)
@@ -1792,24 +1792,12 @@ hidden_opt_sym:
        }
 
 hidden_dcl:
-       hidden_opt_sym hidden_type
+       hidden_opt_sym hidden_type hidden_tag
        {
                $$ = nod(ODCLFIELD, $1, typenod($2));
+               $$->val = $3;
        }
-|      hidden_opt_sym LDDD
-       {
-               Type *t;
-
-               yyerror("invalid variadic function type in import - recompile import");
-               
-               t = typ(TARRAY);
-               t->bound = -1;
-               t->type = typ(TINTER);
-               $$ = nod(ODCLFIELD, $1, typenod(t));
-               $$->isddd = 1;
-       }
-
-|      hidden_opt_sym LDDD hidden_type
+|      hidden_opt_sym LDDD hidden_type hidden_tag
        {
                Type *t;
                
@@ -1818,6 +1806,7 @@ hidden_dcl:
                t->type = $3;
                $$ = nod(ODCLFIELD, $1, typenod(t));
                $$->isddd = 1;
+               $$->val = $4;
        }
 
 hidden_structdcl:
index 377c45ad655fa28b22a1d4f3be1098ea4755d1e6..2cfed7726ae4cfb9ecd0495daa5a6387444950ea 100644 (file)
@@ -403,7 +403,7 @@ func (p *gcParser) parseStructType() Type {
 }
 
 
-// Parameter = ( identifier | "?" ) [ "..." ] Type .
+// Parameter = ( identifier | "?" ) [ "..." ] Type [ ":" string_lit ] .
 //
 func (p *gcParser) parseParameter() (par *ast.Object, isVariadic bool) {
        name := p.parseName()
@@ -415,6 +415,11 @@ func (p *gcParser) parseParameter() (par *ast.Object, isVariadic bool) {
                isVariadic = true
        }
        ptyp := p.parseType()
+       // ignore argument tag
+       if p.tok == ':' {
+               p.next()
+               p.expect(scanner.String)
+       }
        par = ast.NewObj(ast.Var, name)
        par.Type = ptyp
        return