compiler: allow to inline global variables

This commit is contained in:
Evgeniy Stratonikov 2021-02-08 17:25:42 +03:00
parent 6e560c6c9f
commit cf459002f7
3 changed files with 36 additions and 0 deletions

View file

@ -53,6 +53,10 @@ func (c *codegen) inlineCall(f *funcScope, n *ast.CallExpr) {
c.scope.vars.locals = newScope
c.scope.vars.addAlias(name, varLocal, unspecifiedVarIndex, types.TypeAndValue{})
continue
} else if index, ok := c.globals[c.getIdentName("", arg.Name)]; ok {
c.scope.vars.locals = newScope
c.scope.vars.addAlias(name, varGlobal, index, types.TypeAndValue{})
continue
}
}
ast.Walk(c, n.Args[i])