Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
8 changes: 8 additions & 0 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ type Config struct {

// Outline = true means to skip compiling function bodies.
Outline bool

// AddMarkStmt = true means to add const __gop_autogen__ = true.
AddMarkStmt bool
}

type nodeInterp struct {
Expand Down Expand Up @@ -498,6 +501,11 @@ func NewPackage(pkgPath string, pkg *ast.Package, conf *Config) (p *gox.Package,
}()
}
p = gox.NewPackage(pkgPath, pkg.Name, confGox)

if conf.AddMarkStmt {
p.CB().NewConstStart(nil, "__gop_autogen__").Val(true).EndInit(1)
}

ctx.cpkgs = cpackages.NewImporter(&cpackages.Config{
Pkg: p, LookupPub: conf.LookupPub,
})
Expand Down
2 changes: 2 additions & 0 deletions load.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func LoadDir(dir string, conf *Config, genTestPkg bool, promptGenGo ...bool) (ou
Importer: imp,
LookupClass: mod.LookupClass,
LookupPub: c2go.LookupPub(mod),
AddMarkStmt: true,
}

for name, pkg := range pkgs {
Expand Down Expand Up @@ -277,6 +278,7 @@ func LoadFiles(dir string, files []string, conf *Config) (out *gox.Package, err
Importer: imp,
LookupClass: mod.LookupClass,
LookupPub: c2go.LookupPub(mod),
AddMarkStmt: true,
}
out, err = cl.NewPackage("", pkg, clConf)
if err != nil {
Expand Down