diff options
author | Austin Clements <aclements@csail.mit.edu> | 2009-07-27 17:32:35 -0700 |
---|---|---|
committer | Austin Clements <aclements@csail.mit.edu> | 2009-07-27 17:32:35 -0700 |
commit | 9373126645c1900bcf5b48ef0baaac2f4c91e96a (patch) | |
tree | db50a9cbb6d538f2949388fbec09b77ba5fb0e3f /usr/austin/eval/compiler.go | |
parent | 754ca000573feaaf13064f2813330378336cd3f7 (diff) | |
download | golang-9373126645c1900bcf5b48ef0baaac2f4c91e96a.tar.gz |
Implement multi-valued functions, multi-valued return, and
unpacking for assignments, call arguments, and returns. This
change revamps the whole assignment compilation system to be
multi-valued, using the new MultiType type and multiV value.
Function calls, returns, and assignments now share a lot of
code and produce very consistent error messages.
R=rsc
APPROVED=rsc
DELTA=510 (335 added, 74 deleted, 101 changed)
OCL=32248
CL=32258
Diffstat (limited to 'usr/austin/eval/compiler.go')
-rw-r--r-- | usr/austin/eval/compiler.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr/austin/eval/compiler.go b/usr/austin/eval/compiler.go index ab505dec1..47ff12f36 100644 --- a/usr/austin/eval/compiler.go +++ b/usr/austin/eval/compiler.go @@ -35,6 +35,9 @@ type FuncDecl struct func (a *compiler) compileFunc(scope *Scope, decl *FuncDecl, body *ast.BlockStmt) (func (f *Frame) Func) type exprCompiler struct func (a *compiler) compileExpr(scope *Scope, 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 @@ -42,11 +45,12 @@ func (a *compiler) compileArrayLen(scope *Scope, expr ast.Expr) (int64, bool) type codeBuf struct +type FuncType struct // A funcCompiler captures information used throughout the compilation // of a single function body. type funcCompiler struct { *compiler; - outVars []*Variable; + fnType *FuncType; // Whether the out variables are named. This affects what // kinds of return statements are legal. outVarsNamed bool; |