mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "e6563fbd8bdbe6243185089e23c5c0d5a628a1e8" and "50f703d9b3ca940aa8068ba92696a7fc97ea0467" have entirely different histories.
e6563fbd8b
...
50f703d9b3
12
util/util.go
12
util/util.go
|
@ -42,7 +42,7 @@ func SetField(rtm *rt.Runtime, module *rt.Table, field string, value rt.Value, d
|
|||
|
||||
// DoString runs the code string in the Lua runtime.
|
||||
func DoString(rtm *rt.Runtime, code string) error {
|
||||
chunk, err := rtm.CompileAndLoadLuaChunk("<string>", []byte(code), rt.TableValue(rtm.GlobalEnv()))
|
||||
chunk, err := rtm.CompileAndLoadLuaChunk("", []byte(code), rt.TableValue(rtm.GlobalEnv()))
|
||||
if chunk != nil {
|
||||
_, err = rt.Call1(rtm.MainThread(), rt.FunctionValue(chunk))
|
||||
}
|
||||
|
@ -71,16 +71,15 @@ func DoFile(rtm *rt.Runtime, path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
var buf []byte
|
||||
if c == byte('#') {
|
||||
// shebang - skip that line
|
||||
_, err := reader.ReadBytes('\n')
|
||||
if err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
buf = []byte{'\n'}
|
||||
}
|
||||
|
||||
var buf []byte
|
||||
for {
|
||||
line, err := reader.ReadBytes('\n')
|
||||
if err != nil {
|
||||
|
@ -93,12 +92,7 @@ func DoFile(rtm *rt.Runtime, path string) error {
|
|||
buf = append(buf, line...)
|
||||
}
|
||||
|
||||
chunk, err := rtm.CompileAndLoadLuaChunk(path, buf, rt.TableValue(rtm.GlobalEnv()))
|
||||
if chunk != nil {
|
||||
_, err = rt.Call1(rtm.MainThread(), rt.FunctionValue(chunk))
|
||||
}
|
||||
|
||||
return err
|
||||
return DoString(rtm, string(buf))
|
||||
}
|
||||
|
||||
// HandleStrCallback handles function parameters for Go functions which take
|
||||
|
|
Loading…
Reference in New Issue