Created
May 29, 2016 17:01
-
-
Save dimiro1/4f539132a2f8a5e074002b4236535598 to your computer and use it in GitHub Desktop.
Stack Dump Shopify-Go-lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stackDump(l *lua.State) { | |
n := l.Top() | |
fmt.Println("-------------------- Stack Dump -------------------") | |
fmt.Printf("Total in stack: %d\n", n) | |
for i := 1; i <= n; i++ { | |
fmt.Printf("%d: ", i) | |
switch l.TypeOf(i) { | |
case lua.TypeString: | |
s, _ := l.ToString(i) | |
fmt.Printf("string %s", s) | |
case lua.TypeBoolean: | |
fmt.Printf("boolean %t", l.ToBoolean(i)) | |
case lua.TypeNumber: | |
f, _ := l.ToNumber(i) | |
fmt.Printf("number %f", f) | |
default: | |
fmt.Printf("%s", lua.TypeNameOf(l, i)) | |
} | |
fmt.Println() | |
} | |
fmt.Println("--------------- Stack Dump Finished ---------------") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment