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:
committed by
Alexander Medvednikov
parent
e80cf185b9
commit
a075ce160e
@@ -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)')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user