compiler: support exporting method variables in debug info

This commit is contained in:
Evgenii Stratonikov 2020-04-02 16:36:11 +03:00
parent 5bdee683e6
commit 457e7e006a
4 changed files with 31 additions and 0 deletions

View file

@ -12,6 +12,8 @@ import (
func TestCodeGen_DebugInfo(t *testing.T) {
src := `package foo
func Main(op string) bool {
var s string
_ = s
res := methodInt(op)
_ = methodString()
_ = methodByteArray()
@ -56,6 +58,18 @@ func methodStruct() struct{} { return struct{}{} }
}
})
t.Run("variables", func(t *testing.T) {
vars := map[string][]string{
"Main": {"s,String", "res,Integer"},
}
for i := range d.Methods {
v, ok := vars[d.Methods[i].Name.Name]
if ok {
require.Equal(t, v, d.Methods[i].Variables)
}
}
})
// basic check that last instruction of every method is indeed RET
for i := range d.Methods {
index := d.Methods[i].Range.End