summaryrefslogtreecommitdiff
path: root/usr/austin/eval/expr.go
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-07-30 14:39:27 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-07-30 14:39:27 -0700
commit96e1969da9cb424435bd31f2c912b15ce6e89fa1 (patch)
tree2fe900def247d1d92afe550b73763aeacf10a07f /usr/austin/eval/expr.go
parent6a40b7b0896e5de398a9e1af52d244621a1a56e4 (diff)
downloadgolang-96e1969da9cb424435bd31f2c912b15ce6e89fa1.tar.gz
Implement labels, goto, labeled break, and labeled continue.
Return checking is now done as a general flow check at the end of function compilation, since break and goto complicated the way I was doing return checking before. Goto-over-declaration checking is also done as a final flow check. Temporary variables used for effect extraction are now actually temporary. Otherwise "op=", "++", and "--" appear as declarations that cannot be jumped over. R=rsc APPROVED=rsc DELTA=421 (344 added, 38 deleted, 39 changed) OCL=32527 CL=32535
Diffstat (limited to 'usr/austin/eval/expr.go')
-rw-r--r--usr/austin/eval/expr.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr/austin/eval/expr.go b/usr/austin/eval/expr.go
index fbd4b5ac4..1231e2258 100644
--- a/usr/austin/eval/expr.go
+++ b/usr/austin/eval/expr.go
@@ -1324,7 +1324,10 @@ func (a *compiler) compileExpr(b *block, expr ast.Expr, constant bool) *exprComp
// extractEffect separates out any effects that the expression may
// have, returning a function that will perform those effects and a
// new exprCompiler that is guaranteed to be side-effect free. These
-// are the moral equivalents of "temp := &expr" and "*temp".
+// are the moral equivalents of "temp := &expr" and "*temp". Because
+// this creates a temporary variable, the caller should create a
+// temporary block for the compilation of this expression and the
+// evaluation of the results.
//
// Implementation limit: The expression must be addressable.
func (a *exprCompiler) extractEffect() (func(f *Frame), *exprCompiler) {
@@ -1337,9 +1340,7 @@ func (a *exprCompiler) extractEffect() (func(f *Frame), *exprCompiler) {
// Create temporary
tempBlock := a.block;
tempType := NewPtrType(a.t);
- // TODO(austin) These temporaries accumulate in the scope. We
- // could enter a temporary block, but the caller has to exit it.
- temp := tempBlock.DefineTemp(tempType);
+ temp := tempBlock.DefineSlot(tempType);
tempIdx := temp.Index;
// Generate "temp := &e"