Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gnovm): revert "top sort var/const globals (#1854)" #1956

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions gnovm/pkg/gnolang/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,6 @@ type Attributes struct {
data map[interface{}]interface{} // not persisted
}

func (attr *Attributes) Copy() Attributes {
if attr == nil {
return Attributes{}
}

data := make(map[interface{}]interface{})
for k, v := range attr.data {
data[k] = v
}

return Attributes{
Line: attr.Line,
Label: attr.Label,
data: data,
}
}

func (attr *Attributes) GetLine() int {
return attr.Line
}
Expand Down Expand Up @@ -1631,7 +1614,7 @@ func (sb *StaticBlock) GetPathForName(store Store, n Name) ValuePath {
bp = bp.GetParentNode(store)
gen++
if 0xff < gen {
panic("GetPathForName: value path depth overflow")
panic("value path depth overflow")
}
}
}
Expand Down
35 changes: 19 additions & 16 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,11 @@ import (
// Anything predefined or preprocessed here get skipped during the Preprocess
// phase.
func PredefineFileSet(store Store, pn *PackageNode, fset *FileSet) {
for _, fn := range fset.Files {
decls, err := sortValueDeps(fn.Decls)
if err != nil {
panic(err)
}

fn.Decls = decls
}

// First, initialize all file nodes and connect to package node.
for _, fn := range fset.Files {
SetNodeLocations(pn.PkgPath, string(fn.Name), fn)
fn.InitStaticBlock(fn, pn)
}

// NOTE: much of what follows is duplicated for a single *FileNode
// in the main Preprocess translation function. Keep synced.

Expand All @@ -40,22 +30,29 @@ func PredefineFileSet(store Store, pn *PackageNode, fset *FileSet) {
d := fn.Decls[i]
switch d.(type) {
case *ImportDecl:
if d.GetAttribute(ATTR_PREDEFINED) != true {
if d.GetAttribute(ATTR_PREDEFINED) == true {
// skip declarations already predefined
// (e.g. through recursion for a
// dependent)
} else {
// recursively predefine dependencies.
d2, _ := predefineNow(store, fn, d)
fn.Decls[i] = d2
}
}
}
}

// Predefine all type decls decls.
for _, fn := range fset.Files {
for i := 0; i < len(fn.Decls); i++ {
d := fn.Decls[i]
switch d.(type) {
case *TypeDecl:
if d.GetAttribute(ATTR_PREDEFINED) != true {
if d.GetAttribute(ATTR_PREDEFINED) == true {
// skip declarations already predefined
// (e.g. through recursion for a
// dependent)
} else {
// recursively predefine dependencies.
d2, _ := predefineNow(store, fn, d)
fn.Decls[i] = d2
Expand All @@ -69,21 +66,27 @@ func PredefineFileSet(store Store, pn *PackageNode, fset *FileSet) {
d := fn.Decls[i]
switch d.(type) {
case *FuncDecl:
if d.GetAttribute(ATTR_PREDEFINED) != true {
if d.GetAttribute(ATTR_PREDEFINED) == true {
// skip declarations already predefined
// (e.g. through recursion for a
// dependent)
} else {
// recursively predefine dependencies.
d2, _ := predefineNow(store, fn, d)
fn.Decls[i] = d2
}
}
}
}

// Finally, predefine other decls and
// preprocess ValueDecls..
for _, fn := range fset.Files {
for i := 0; i < len(fn.Decls); i++ {
d := fn.Decls[i]
if d.GetAttribute(ATTR_PREDEFINED) != true {
if d.GetAttribute(ATTR_PREDEFINED) == true {
// skip declarations already predefined (e.g.
// through recursion for a dependent)
} else {
// recursively predefine dependencies.
d2, _ := predefineNow(store, fn, d)
fn.Decls[i] = d2
Expand Down
245 changes: 0 additions & 245 deletions gnovm/pkg/gnolang/value_decl_dep_graph.go

This file was deleted.

14 changes: 0 additions & 14 deletions gnovm/tests/files/var18.gno

This file was deleted.

14 changes: 0 additions & 14 deletions gnovm/tests/files/var19.gno

This file was deleted.

Loading
Loading