1
0
mirror of https://github.com/golang/go synced 2024-11-19 17:14:44 -07:00

gc: allow tags on parameters in export section of object files.

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
This commit is contained in:
Luuk van Dijk 2011-06-03 03:54:56 +02:00
parent ae5a972d9e
commit 56668283f1
2 changed files with 10 additions and 16 deletions

View 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:

View 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