interp: error location for "unknown GEP" error

This commit removes a panic and replaces it with a proper source
location. The message still isn't very helpful, but at least it points
to a location in the source code.

I'm not very happy with all the `err.Error()` calls, but that's the way
to fit this in a `scanner.Error`. Eventually we should make a
replacement for `scanner.Error` that does proper wrapping of the
original error message.
This commit is contained in:
Ayke van Laethem
2019-12-31 19:59:34 +01:00
committed by Ron Evans
parent ec467da83c
commit 25cff20117
3 changed files with 49 additions and 20 deletions
+5 -1
View File
@@ -24,7 +24,11 @@ func getStringBytes(strPtr Value, strLen llvm.Value) []byte {
}
buf := make([]byte, strLen.ZExtValue())
for i := range buf {
c := strPtr.GetElementPtr([]uint32{uint32(i)}).Load()
gep, err := strPtr.GetElementPtr([]uint32{uint32(i)})
if err != nil {
panic(err) // TODO
}
c := gep.Load()
buf[i] = byte(c.ZExtValue())
}
return buf