mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fix bootstrap
This commit is contained in:
parent
16380c44a8
commit
f2d174c156
3 changed files with 11 additions and 6 deletions
|
@ -607,7 +607,8 @@ pub fn (mut a array) delete_last() {
|
||||||
// Alternative: Slices can also be made with [start..end] notation
|
// Alternative: Slices can also be made with [start..end] notation
|
||||||
// Alternative: `.slice_ni()` will always return an array.
|
// Alternative: `.slice_ni()` will always return an array.
|
||||||
fn (a array) slice(start int, _end int) array {
|
fn (a array) slice(start int, _end int) array {
|
||||||
end := if _end == max_int { a.len } else { _end } // max_int
|
// WARNNING: The is a temp solution for bootstrap!
|
||||||
|
end := if _end == max_i64 || _end == max_i32 { a.len } else { _end } // max_int
|
||||||
$if !no_bounds_checking {
|
$if !no_bounds_checking {
|
||||||
if start > end {
|
if start > end {
|
||||||
panic('array.slice: invalid slice index (start>end):' + impl_i64_to_string(i64(start)) +
|
panic('array.slice: invalid slice index (start>end):' + impl_i64_to_string(i64(start)) +
|
||||||
|
@ -644,7 +645,8 @@ fn (a array) slice(start int, _end int) array {
|
||||||
// This function always return a valid array.
|
// This function always return a valid array.
|
||||||
fn (a array) slice_ni(_start int, _end int) array {
|
fn (a array) slice_ni(_start int, _end int) array {
|
||||||
// a.flags.clear(.noslices)
|
// a.flags.clear(.noslices)
|
||||||
mut end := if _end == max_int { a.len } else { _end } // max_int
|
// WARNNING: The is a temp solution for bootstrap!
|
||||||
|
mut end := if _end == max_i64 || _end == max_i32 { a.len } else { _end } // max_int
|
||||||
mut start := _start
|
mut start := _start
|
||||||
|
|
||||||
if start < 0 {
|
if start < 0 {
|
||||||
|
|
|
@ -1165,7 +1165,8 @@ pub fn (s string) split_by_space() []string {
|
||||||
// Example: assert 'ABCD'.substr(1,3) == 'BC'
|
// Example: assert 'ABCD'.substr(1,3) == 'BC'
|
||||||
@[direct_array_access]
|
@[direct_array_access]
|
||||||
pub fn (s string) substr(start int, _end int) string {
|
pub fn (s string) substr(start int, _end int) string {
|
||||||
end := if _end == max_int { s.len } else { _end } // max_int
|
// WARNNING: The is a temp solution for bootstrap!
|
||||||
|
end := if _end == max_i64 || _end == max_i32 { s.len } else { _end } // max_int
|
||||||
$if !no_bounds_checking {
|
$if !no_bounds_checking {
|
||||||
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
||||||
panic('substr(' + impl_i64_to_string(start) + ', ' + impl_i64_to_string(end) +
|
panic('substr(' + impl_i64_to_string(start) + ', ' + impl_i64_to_string(end) +
|
||||||
|
@ -1205,7 +1206,8 @@ pub fn (s string) substr_unsafe(start int, _end int) string {
|
||||||
// return an error when the index is out of range
|
// return an error when the index is out of range
|
||||||
@[direct_array_access]
|
@[direct_array_access]
|
||||||
pub fn (s string) substr_with_check(start int, _end int) !string {
|
pub fn (s string) substr_with_check(start int, _end int) !string {
|
||||||
end := if _end == max_int { s.len } else { _end } // max_int
|
// WARNNING: The is a temp solution for bootstrap!
|
||||||
|
end := if _end == max_i64 || _end == max_i32 { s.len } else { _end } // max_int
|
||||||
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
||||||
return error('substr(' + impl_i64_to_string(start) + ', ' + impl_i64_to_string(end) +
|
return error('substr(' + impl_i64_to_string(start) + ', ' + impl_i64_to_string(end) +
|
||||||
') out of bounds (len=' + impl_i64_to_string(s.len) + ')')
|
') out of bounds (len=' + impl_i64_to_string(s.len) + ')')
|
||||||
|
@ -1230,7 +1232,8 @@ pub fn (s string) substr_with_check(start int, _end int) !string {
|
||||||
@[direct_array_access]
|
@[direct_array_access]
|
||||||
pub fn (s string) substr_ni(_start int, _end int) string {
|
pub fn (s string) substr_ni(_start int, _end int) string {
|
||||||
mut start := _start
|
mut start := _start
|
||||||
mut end := if _end == max_int { s.len } else { _end } // max_int
|
// WARNNING: The is a temp solution for bootstrap!
|
||||||
|
mut end := if _end == max_i64 || _end == max_i32 { s.len } else { _end }
|
||||||
|
|
||||||
// borders math
|
// borders math
|
||||||
if start < 0 {
|
if start < 0 {
|
||||||
|
|
|
@ -152,7 +152,7 @@ fn (mut g Gen) index_range_expr(node ast.IndexExpr, range ast.RangeExpr) {
|
||||||
} else if sym.info is ast.ArrayFixed {
|
} else if sym.info is ast.ArrayFixed {
|
||||||
g.write('${sym.info.size}')
|
g.write('${sym.info.size}')
|
||||||
} else {
|
} else {
|
||||||
g.write('2147483647') // max_int
|
g.write('${max_int}')
|
||||||
}
|
}
|
||||||
g.write(')')
|
g.write(')')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue