Skip to content

Commit

Permalink
修复 REPL 报错
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Oct 25, 2022
1 parent bc852a2 commit e969ec7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions state/api_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ import (
"git.lolli.tech/lollipopkit/lk/binchunk"
"git.lolli.tech/lollipopkit/lk/compiler"
"git.lolli.tech/lollipopkit/lk/logger"
"git.lolli.tech/lollipopkit/lk/term"
"git.lolli.tech/lollipopkit/lk/vm"
)

// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_load
func (self *luaState) Load(chunk []byte, chunkName, mode string) int {
var proto *binchunk.Prototype
prot, err := binchunk.Verify(chunk, []byte{})
logger.I("[state.Load] Using compiled chunk: %v", err)
if err == nil {
proto = prot
} else if strings.HasSuffix(chunkName, ".lk") {
if chunkName == "stdin" {
proto = compiler.Compile(string(chunk), chunkName)
} else {
prot, err := binchunk.Verify(chunk, []byte{})
logger.I("[state.Load] Using compiled chunk: %v", err)
if err == nil {
proto = prot
} else if strings.HasSuffix(chunkName, ".lkc") {
term.Error("[state.Load] can't recompile '.lkc' file: " + chunkName)
}
}

c := newLuaClosure(proto)
Expand Down

0 comments on commit e969ec7

Please sign in to comment.