diff options
author | Austin Clements <aclements@csail.mit.edu> | 2009-07-28 14:37:06 -0700 |
---|---|---|
committer | Austin Clements <aclements@csail.mit.edu> | 2009-07-28 14:37:06 -0700 |
commit | 1d9855bd39cd04f70d17aa9bbf57245ef98c9d85 (patch) | |
tree | fd4c5541b8e38e8af07ff5f0cd9cb348f7c1031d /usr/austin/eval/compiler.go | |
parent | 7160983267c034dbe78e040a3b67f06e7cc9bdc2 (diff) | |
download | golang-1d9855bd39cd04f70d17aa9bbf57245ef98c9d85.tar.gz |
Implement if, for (modulo ranges), break, continue, increment,
and decrement. blockCompilers now form a tree the mimics the
nesting of scopes and provide convenient ways to enter and
exit scopes. blockCompilers also track the break and continue
PC for the current block. The statement testing interface now
works in lists of statements, which simplifies a bunch of
things.
R=rsc
APPROVED=rsc
DELTA=401 (335 added, 44 deleted, 22 changed)
OCL=32308
CL=32317
Diffstat (limited to 'usr/austin/eval/compiler.go')
-rw-r--r-- | usr/austin/eval/compiler.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/usr/austin/eval/compiler.go b/usr/austin/eval/compiler.go index 47ff12f36..6dd6437e1 100644 --- a/usr/austin/eval/compiler.go +++ b/usr/austin/eval/compiler.go @@ -65,10 +65,24 @@ type blockCompiler struct { *funcCompiler; scope *Scope; returned bool; + // The PC break statements should jump to, or nil if a break + // statement is invalid. + breakPC *uint; + // The PC continue statements should jump to, or nil if a + // continue statement is invalid. + continuePC *uint; + // The blockCompiler for the block enclosing this one, or nil + // for a function-level block. + parent *blockCompiler; + // The blockCompiler for the nested block currently being + // compiled, or nil if compilation is not in a nested block. + child *blockCompiler; } -func (a *blockCompiler) compileBlock(body *ast.BlockStmt) - +func (a *blockCompiler) compileStmt(s ast.Stmt) +func (a *blockCompiler) compileStmts(body *ast.BlockStmt) +func (a *blockCompiler) enterChild() *blockCompiler +func (a *blockCompiler) exit() // An exprContext stores information used throughout the compilation // of a single expression. It does not embed funcCompiler because |