mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: allow to use exported variables
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
b8d7e93459
commit
6df019913d
5 changed files with 124 additions and 23 deletions
|
@ -21,10 +21,19 @@ var (
|
|||
)
|
||||
|
||||
// newGlobal creates new global variable.
|
||||
func (c *codegen) newGlobal(name string) {
|
||||
func (c *codegen) newGlobal(pkg string, name string) {
|
||||
name = c.getIdentName(pkg, name)
|
||||
c.globals[name] = len(c.globals)
|
||||
}
|
||||
|
||||
// getIdentName returns fully-qualified name for a variable.
|
||||
func (c *codegen) getIdentName(pkg string, name string) string {
|
||||
if fullName, ok := c.importMap[pkg]; ok {
|
||||
pkg = fullName
|
||||
}
|
||||
return pkg + "." + name
|
||||
}
|
||||
|
||||
// traverseGlobals visits and initializes global variables.
|
||||
// and returns number of variables initialized.
|
||||
func (c *codegen) traverseGlobals() int {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue