Skip to content

Commit

Permalink
Merge pull request #1647 from visualfc/mark
Browse files Browse the repository at this point in the history
cl.Config add field AddMarkStmt
  • Loading branch information
xushiwei committed Jan 20, 2024
2 parents 676fd45 + eb006ec commit bd63885
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit bd63885

Please sign in to comment.