diff options
author | Austin Clements <aclements@csail.mit.edu> | 2009-07-28 16:38:41 -0700 |
---|---|---|
committer | Austin Clements <aclements@csail.mit.edu> | 2009-07-28 16:38:41 -0700 |
commit | 226a4a12a567226e455b89e74b12ab35f20aa01b (patch) | |
tree | f7426a8638b80b9bbbb0ac7387edf0b521547c2e | |
parent | 7d466b578d2ec7cdd93ec81cc012cd3b275475d2 (diff) | |
download | golang-226a4a12a567226e455b89e74b12ab35f20aa01b.tar.gz |
Fix segfault on unnamed function arguments. Make continue
jump to the post statement instead of the condition check.
R=rsc
APPROVED=rsc
DELTA=10 (6 added, 1 deleted, 3 changed)
OCL=32359
CL=32379
-rw-r--r-- | usr/austin/eval/stmt.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr/austin/eval/stmt.go b/usr/austin/eval/stmt.go index 68b593824..f769d29a2 100644 --- a/usr/austin/eval/stmt.go +++ b/usr/austin/eval/stmt.go @@ -588,7 +588,7 @@ func (a *stmtCompiler) DoForStmt(s *ast.ForStmt) { bc.compileStmt(s.Init); } - var bodyPC, checkPC, endPC uint; + var bodyPC, postPC, checkPC, endPC uint; // Jump to condition check. We generate slightly less code by // placing the condition check after the body. @@ -598,11 +598,12 @@ func (a *stmtCompiler) DoForStmt(s *ast.ForStmt) { bodyPC = a.nextPC(); body := bc.enterChild(); body.breakPC = &endPC; - body.continuePC = &checkPC; + body.continuePC = &postPC; body.compileStmts(s.Body); body.exit(); // Compile post, if any + postPC = a.nextPC(); if s.Post != nil { // TODO(austin) Does the parser disallow short // declarations in s.Post? @@ -711,13 +712,17 @@ func (a *compiler) compileFunc(scope *Scope, decl *FuncDecl, body *ast.BlockStmt // corresponding function. bodyScope := scope.Fork(); for i, t := range decl.Type.In { - bodyScope.DefineVar(decl.InNames[i].Value, t); + if decl.InNames[i] != nil { + bodyScope.DefineVar(decl.InNames[i].Value, t); + } else { + // TODO(austin) Not technically a temp + bodyScope.DefineTemp(t); + } } for i, t := range decl.Type.Out { if decl.OutNames[i] != nil { bodyScope.DefineVar(decl.OutNames[i].Value, t); } else { - // TODO(austin) Not technically a temp bodyScope.DefineTemp(t); } } |