summaryrefslogtreecommitdiff
path: root/usr/austin/eval/compiler.go
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-07-29 11:57:46 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-07-29 11:57:46 -0700
commit6a1530c6ecdc3610889367b75ca275d84604b1c5 (patch)
treeeea7019f7e07a3a6e3f801510489ef285050a586 /usr/austin/eval/compiler.go
parent261d6437b8a7a1e7c85f9c83dd4a72446a9234a5 (diff)
downloadgolang-6a1530c6ecdc3610889367b75ca275d84604b1c5.tar.gz
Flatten the Frame tree. Now each function call produces a
single frame and non-overlapping variables reuse frame slots. As a result, entering and exiting blocks no longer requires code execution, which means jumps across block boundaries should be doable now. Frame slot initialization happens at definition time now, instead of at frame creation time. As an added bonus, Scope's are now exclusively compile-time objects and we no longer need to specially track the function activation frame for access to out vars. R=rsc APPROVED=rsc DELTA=313 (102 added, 90 deleted, 121 changed) OCL=32416 CL=32420
Diffstat (limited to 'usr/austin/eval/compiler.go')
-rw-r--r--usr/austin/eval/compiler.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/usr/austin/eval/compiler.go b/usr/austin/eval/compiler.go
index 6dd6437e1..641e6a293 100644
--- a/usr/austin/eval/compiler.go
+++ b/usr/austin/eval/compiler.go
@@ -32,16 +32,16 @@ func (a *compiler) diagAt(pos positioned, format string, args ...) {
}
type FuncDecl struct
-func (a *compiler) compileFunc(scope *Scope, decl *FuncDecl, body *ast.BlockStmt) (func (f *Frame) Func)
+func (a *compiler) compileFunc(b *block, decl *FuncDecl, body *ast.BlockStmt) (func (f *Frame) Func)
type exprCompiler struct
-func (a *compiler) compileExpr(scope *Scope, expr ast.Expr, constant bool) *exprCompiler
+func (a *compiler) compileExpr(b *block, expr ast.Expr, constant bool) *exprCompiler
type assignCompiler struct
func (a *compiler) checkAssign(pos token.Position, rs []*exprCompiler, errOp, errPosName string) (*assignCompiler, bool)
func (a *compiler) compileAssign(pos token.Position, lt Type, rs []*exprCompiler, errOp, errPosName string) (func(lv Value, f *Frame))
-func (a *compiler) compileType(scope *Scope, typ ast.Expr) Type
-func (a *compiler) compileFuncType(scope *Scope, typ *ast.FuncType) *FuncDecl
+func (a *compiler) compileType(b *block, typ ast.Expr) Type
+func (a *compiler) compileFuncType(b *block, typ *ast.FuncType) *FuncDecl
-func (a *compiler) compileArrayLen(scope *Scope, expr ast.Expr) (int64, bool)
+func (a *compiler) compileArrayLen(b *block, expr ast.Expr) (int64, bool)
type codeBuf struct
@@ -63,7 +63,7 @@ type funcCompiler struct {
// of a single block within a function.
type blockCompiler struct {
*funcCompiler;
- scope *Scope;
+ block *block;
returned bool;
// The PC break statements should jump to, or nil if a break
// statement is invalid.
@@ -74,9 +74,6 @@ type blockCompiler struct {
// 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) compileStmt(s ast.Stmt)
@@ -92,6 +89,6 @@ func (a *blockCompiler) exit()
// this to exprCompiler.
type exprContext struct {
*compiler;
- scope *Scope;
+ block *block;
constant bool;
}