瀏覽代碼

lua 框架

zhangjinkun 9 年之前
父節點
當前提交
bf0fc92f9c
共有 2 個文件被更改,包括 16 次插入11 次删除
  1. 7 3
      common/src/github.com/yuin/gopher-lua/state.go
  2. 9 8
      common/src/github.com/yuin/gopher-lua/value.go

+ 7 - 3
common/src/github.com/yuin/gopher-lua/state.go

@@ -6,14 +6,16 @@ package lua
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"github.com/yuin/gopher-lua/parse"
 	"io"
 	"io"
+	"log"
 	"math"
 	"math"
 	"os"
 	"os"
 	"runtime"
 	"runtime"
 	"strings"
 	"strings"
 	"sync/atomic"
 	"sync/atomic"
 	"time"
 	"time"
+
+	"github.com/yuin/gopher-lua/parse"
 )
 )
 
 
 const MultRet = -1
 const MultRet = -1
@@ -1147,8 +1149,9 @@ func (ls *LState) Pop(n int) {
 	for i := 0; i < n; i++ {
 	for i := 0; i < n; i++ {
 		if ls.GetTop() == 0 {
 		if ls.GetTop() == 0 {
 			ls.RaiseError("register underflow")
 			ls.RaiseError("register underflow")
+		} else {
+			ls.reg.Pop()
 		}
 		}
-		ls.reg.Pop()
 	}
 	}
 }
 }
 
 
@@ -1302,7 +1305,8 @@ func (ls *LState) ToThread(n int) *LState {
 
 
 // This function is equivalent to luaL_error( http://www.lua.org/manual/5.1/manual.html#luaL_error ).
 // This function is equivalent to luaL_error( http://www.lua.org/manual/5.1/manual.html#luaL_error ).
 func (ls *LState) RaiseError(format string, args ...interface{}) {
 func (ls *LState) RaiseError(format string, args ...interface{}) {
-	ls.raiseError(1, format, args...)
+	log.Println("Pop 出错,脚本名称", ls.ScriptFileName)
+	//ls.raiseError(1, format, args...)
 }
 }
 
 
 // This function is equivalent to lua_error( http://www.lua.org/manual/5.1/manual.html#lua_error ).
 // This function is equivalent to lua_error( http://www.lua.org/manual/5.1/manual.html#lua_error ).

+ 9 - 8
common/src/github.com/yuin/gopher-lua/value.go

@@ -207,14 +207,15 @@ type LState struct {
 	Dead    bool
 	Dead    bool
 	Options Options
 	Options Options
 
 
-	stop         int32
-	reg          *registry
-	stack        *callFrameStack
-	alloc        *allocator
-	currentFrame *callFrame
-	wrapped      bool
-	uvcache      *Upvalue
-	hasErrorFunc bool
+	stop           int32
+	reg            *registry
+	stack          *callFrameStack
+	alloc          *allocator
+	currentFrame   *callFrame
+	wrapped        bool
+	uvcache        *Upvalue
+	hasErrorFunc   bool
+	ScriptFileName string
 }
 }
 
 
 func (ls *LState) String() string                     { return fmt.Sprintf("thread: %p", ls) }
 func (ls *LState) String() string                     { return fmt.Sprintf("thread: %p", ls) }