Skip to content

Commit

Permalink
Merge pull request #149 from rokostik/fix-dump-main-context
Browse files Browse the repository at this point in the history
Fix dumping contexts
  • Loading branch information
refaktor committed Mar 4, 2024
2 parents b6b7131 + 9e5db77 commit 7076258
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ func (i RyeCtx) Equal(o Object) bool {

func (i RyeCtx) Dump(e Idxs) string {
var bu strings.Builder
bu.WriteString("context {\n")
bu.WriteString(fmt.Sprintf("doc \"%s\"\n", i.Doc))
bu.WriteString(i.DumpBare(e))
bu.WriteString("}")
return bu.String()
}

// DumpBare returns the string representation of the context without wraping it in context { ... }
func (i RyeCtx) DumpBare(e Idxs) string {
var bu strings.Builder
for j := 0; j < e.GetWordCount(); j++ {
if val, ok := i.state[j]; ok {
if val.Type() != BuiltinType {
Expand Down Expand Up @@ -299,7 +308,7 @@ func NewProgramStateNEW() *ProgramState {
}

func (ps *ProgramState) Dump() string {
return ps.Ctx.Dump(*ps.Idx)
return ps.Ctx.DumpBare(*ps.Idx)
}

func AddToProgramState(ps *ProgramState, ser TSeries, idx *Idxs) *ProgramState {
Expand Down

0 comments on commit 7076258

Please sign in to comment.