1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: add [..2] & [2..] support for slices

This commit is contained in:
joe-conigliaro
2019-10-27 17:36:04 +11:00
committed by Alexander Medvednikov
parent e80cf185b9
commit a075ce160e
6 changed files with 47 additions and 10 deletions

View File

@@ -197,7 +197,7 @@ fn (p mut Parser) index_get(typ string, fn_ph int, cfg IndexConfig) {
else {
ref := if cfg.is_ptr { '*' } else { '' }
if cfg.is_slice {
p.gen(' array_slice($ref $index_expr) ')
p.gen(' array_slice2($ref $index_expr) ')
}
else {
p.gen('( *($typ*) array_get($ref $index_expr) )')
@@ -206,7 +206,7 @@ fn (p mut Parser) index_get(typ string, fn_ph int, cfg IndexConfig) {
}
else if cfg.is_str && !p.builtin_mod {
if cfg.is_slice {
p.gen('string_substr($index_expr)')
p.gen('string_substr2($index_expr)')
} else {
p.gen('string_at($index_expr)')
}