interp: don't panic in the Store method

Instead return an error, which indicates where it goes wrong. That's
less user unfriendly than panicking.
This commit is contained in:
Ayke van Laethem
2020-07-26 21:28:48 +02:00
committed by Ron Evans
parent ccb803e35d
commit 4fa1fc6e72
2 changed files with 22 additions and 15 deletions
+8 -2
View File
@@ -111,7 +111,10 @@ func (fr *frame) evalBasicBlock(bb, incoming llvm.BasicBlock, indent string) (re
if inst.IsVolatile() {
fr.builder.CreateStore(value.Value(), ptr.Value())
} else {
ptr.Store(value.Value())
err := ptr.Store(value.Value())
if err != nil {
return nil, nil, fr.errorAt(inst, err)
}
}
case !inst.IsAGetElementPtrInst().IsNil():
value := fr.getLocal(inst.Operand(0))
@@ -422,7 +425,10 @@ func (fr *frame) evalBasicBlock(bb, incoming llvm.BasicBlock, indent string) (re
if err != nil {
return nil, nil, fr.errorAt(inst, err)
}
dstArray.Store(val)
err = dstArray.Store(val)
if err != nil {
return nil, nil, fr.errorAt(inst, err)
}
// dst++
dstArrayValue, err := dstArray.GetElementPtr([]uint32{1})
if err != nil {