compiler: fix indexing of strings on AVR

Extract directly from the string instead of calling the len() builtin.
This is both cleaner and avoids a zero-extension to an integer on AVR,
which led to a LLVM verification error.
Этот коммит содержится в:
Ayke van Laethem 2019-01-25 13:15:08 +01:00
родитель 589569fc35
коммит 85108514df
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -1995,10 +1995,7 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
// Bounds check.
// LLVM optimizes this away in most cases.
length, err := c.parseBuiltin(frame, []ssa.Value{expr.X}, "len", expr.Pos())
if err != nil {
return llvm.Value{}, err // shouldn't happen
}
length := c.builder.CreateExtractValue(value, 1, "len")
c.emitBoundsCheck(frame, length, index, expr.Index.Type())
// Lookup byte