Ticket #701 (closed bug: invalid)
PAST: Parameter Var in viviself causes duplicate parameter allocation
| Reported by: | Austin_Hastings | Owned by: | pmichaud |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | PCT | Version: | 1.2.0 |
| Severity: | high | Keywords: | past,parameter,variable |
| Cc: | Language: | ||
| Patch status: | Platform: | linux |
Description (last modified by bacek) (diff)
Creating a PAST tree containing a parameter variable and a second variable that uses the parameter in viviself for initialization causes the generation of code that allocates the parameter (at least) twice.
As best as I can tell, the problem is pretty straightforward. The viviself code calls the 'as_post'(_, Var) multimethod, which when it sees a scope of parameter jumps to a method that outputs the declaration a second time (the first time was because I put a node in the block). I suspect checking isdecl() in the viviself would fix it, but maybe it should be in 'parameter'?
Details:
This code (written in 'close'):
extern void demo(pmc args) {
lexical pmc list = args;
}
Produces this PIR:
.namespace []
.sub "demo" :subid("12_1243147960")
.param pmc param_22
.param pmc param_23
.annotate "line", 21
.lex "args", param_22
.annotate "line", 22
.lex "args", param_23
.lex "list", param_23
.annotate "line", 21
.return (param_23)
.end
By way of this PAST:
[2] => PMC 'PAST;Block' {
<blocktype> => "declaration"
<name> => "demo"
<source> => \past
<pos> => 347
<symtable> => Hash {
"args" => Hash {
"decl" => PMC 'PAST;Var' {
<isdecl> => 1
<source> => \past
<pos> => 364
<pirflags> => ""
<scope> => "parameter"
<rtype> => "P"
<name> => "args"
}
},
"list" => Hash {
"decl" => PMC 'PAST;Var' {
<isdecl> => 1
<source> => \past
<pos> => 380
<pirflags> => ""
<scope> => "lexical"
<rtype> => "P"
<name> => "list"
<viviself> => PMC 'PAST;Var' {
<source> => \past
<pos> => 399
<name> => "args"
<scope> => \past["args"]["decl"]
}
}
}
}
<params> => null
<namespace> => undef
<pirflags> => ""
<rtype> => "v"
[0] => \past["args"]["decl"]
[1] => PMC 'PAST;Stmts' {
<name> => "compound_stmt"
<rtype> => undef
[0] => \past["list"]["decl"]
}
}
