interp: support GEP on fixed (MMIO) addresses

GetElementPtr would not work on values that weren't pointers. Because
fixed addresses (often used in memory-mapped I/O) are integers rather
than pointers in interp, it would return an error.

This resulted in the teensy40 target not compiling correctly since the
interp package rewrite. This commit should fix that.
This commit is contained in:
Ayke van Laethem
2021-02-22 20:49:02 +01:00
parent 5917b8baa2
commit f50758ca5a
4 changed files with 21 additions and 8 deletions
+2 -2
View File
@@ -348,7 +348,7 @@ func (v literalValue) clone() value {
}
func (v literalValue) asPointer(r *runner) (pointerValue, error) {
return pointerValue{}, errLiteralToPointer
return pointerValue{}, errIntegerAsPointer
}
func (v literalValue) asRawValue(r *runner) rawValue {
@@ -949,7 +949,7 @@ func (v rawValue) clone() value {
func (v rawValue) asPointer(r *runner) (pointerValue, error) {
if v.buf[0] <= 255 {
// Probably a null pointer or memory-mapped I/O.
return pointerValue{}, errExpectedPointer
return pointerValue{}, errIntegerAsPointer
}
return pointerValue{v.buf[0]}, nil
}