compiler: support implicit type in function arguments

Go supports declaring multiple arguments of the same type without
duplicating type name. Now we support this too.
This commit is contained in:
Evgenii Stratonikov 2020-05-06 18:20:12 +03:00
parent d3f1ccd518
commit 7ac15a7557
2 changed files with 15 additions and 3 deletions

View file

@ -251,9 +251,10 @@ func (c *codegen) convertFuncDecl(file ast.Node, decl *ast.FuncDecl) {
// Load the arguments in scope.
for _, arg := range decl.Type.Params.List {
name := arg.Names[0].Name // for now.
l := c.scope.newLocal(name)
c.emitStoreLocal(l)
for _, id := range arg.Names {
l := c.scope.newLocal(id.Name)
c.emitStoreLocal(l)
}
}
// Load in all the global variables in to the scope of the function.
// This is not necessary for syscalls.