Skip to content

Commit

Permalink
fixed eyr builtins with no args, improved some os context
Browse files Browse the repository at this point in the history
  • Loading branch information
refaktor committed Sep 4, 2024
1 parent 3ebe85e commit c163899
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions evaldo/builtins_eyr.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ func Eyr_CallBuiltin(bi env.Builtin, ps *env.ProgramState, arg0_ env.Object, toL
var arg1 env.Object // := bi.Cur1
var arg2 env.Object

if bi.Argsn == 0 && bi.Cur0 == nil {
if checkFlagsBi(bi, ps, 0) {
return ps
}
if ps.ErrorFlag || ps.ReturnFlag {
return ps
}
if bi.Argsn == 0 {
// fmt.Println("** CALL BI")
ps.Res = bi.Fn(ps, nil, nil, nil, nil, nil)
// stack.Push(ps.Res)
}
}
if bi.Argsn > 0 && bi.Cur0 == nil {
if checkFlagsBi(bi, ps, 0) {
return ps
Expand Down
1 change: 0 additions & 1 deletion evaldo/builtins_os.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ var Builtins_os = map[string]*env.Builtin{
items[i] = *env.NewUri1(ps.Idx, "file://"+file.Name())
}
return *env.NewBlock(*env.NewTSeries(items))

},
},

Expand Down
6 changes: 5 additions & 1 deletion evaldo/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ func (r *Repl) evalLine(es *env.ProgramState, code string) string {

if !es.ErrorFlag && es.Res != nil {
r.prevResult = es.Res
output = fmt.Sprintf("\033[38;5;37m" + es.Res.Inspect(*genv) + "\x1b[0m")
resultStr := es.Res.Inspect(*genv)
if r.dialect == "eyr" {
resultStr = strings.Replace(resultStr, "Block:", "Stack:", 1) // TODO --- temp / hackish way ... make stack display itself or another approach
}
output = fmt.Sprintf("\033[38;5;37m" + resultStr + "\x1b[0m")
}

es.ReturnFlag = false
Expand Down

0 comments on commit c163899

Please sign in to comment.