mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: v -autofree can now compile itself
This commit is contained in:
@@ -212,6 +212,12 @@ fn (a array) slice2(start, _end int, end_max bool) array {
|
||||
return a.slice(start, end)
|
||||
}
|
||||
|
||||
// array.clone_static returns an independent copy of a given array
|
||||
// It should be used only in -autofree generated code.
|
||||
fn (a array) clone_static() array {
|
||||
return a.clone()
|
||||
}
|
||||
|
||||
// array.clone returns an independent copy of a given array
|
||||
pub fn (a &array) clone() array {
|
||||
mut size := a.cap * a.element_size
|
||||
@@ -304,7 +310,7 @@ pub fn (a array) reverse() array {
|
||||
|
||||
// pub fn (a []int) free() {
|
||||
[unsafe_fn]
|
||||
pub fn (a array) free() {
|
||||
pub fn (a &array) free() {
|
||||
// if a.is_slice {
|
||||
// return
|
||||
// }
|
||||
|
@@ -98,11 +98,17 @@ pub fn (a array) reverse() array {
|
||||
return a
|
||||
}
|
||||
|
||||
// array.clone_static returns an independent copy of a given array
|
||||
// It should be used only in -autofree generated code.
|
||||
fn (a array) clone_static() array {
|
||||
return a.clone()
|
||||
}
|
||||
|
||||
pub fn (a array) clone() array {
|
||||
return a
|
||||
}
|
||||
|
||||
pub fn (a array) free() {
|
||||
pub fn (a &array) free() {
|
||||
}
|
||||
|
||||
// "[ 'a', 'b', 'c' ]"
|
||||
|
@@ -26,6 +26,11 @@ pub fn tos(s byteptr) string {
|
||||
}
|
||||
}
|
||||
|
||||
// string.clone_static returns an independent copy of a given array
|
||||
// It should be used only in -autofree generated code.
|
||||
fn (a string) clone_static() string {
|
||||
return a.clone()
|
||||
}
|
||||
|
||||
pub fn (a string) clone() string {
|
||||
return a
|
||||
@@ -241,18 +246,9 @@ pub fn (c byte) is_letter() bool {
|
||||
return (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`)
|
||||
}
|
||||
|
||||
pub fn (s string) free() {
|
||||
pub fn (s &string) free() {
|
||||
}
|
||||
|
||||
/*
|
||||
fn (arr []string) free() {
|
||||
for s in arr {
|
||||
s.free()
|
||||
}
|
||||
C.free(arr.data)
|
||||
}
|
||||
*/
|
||||
|
||||
// all_before('23:34:45.234', '.') == '23:34:45'
|
||||
pub fn (s string) all_before(dot string) string {
|
||||
pos := s.index(dot)
|
||||
|
@@ -413,7 +413,7 @@ pub fn (m &map) keys() []string {
|
||||
}
|
||||
|
||||
[unsafe_fn]
|
||||
pub fn (m map) free() {
|
||||
pub fn (m &map) free() {
|
||||
free(m.metas)
|
||||
for i := u32(0); i < m.key_values.size; i++ {
|
||||
if m.key_values.keys[i].str == 0 {
|
||||
|
@@ -104,6 +104,12 @@ pub fn tos3(s charptr) string {
|
||||
}
|
||||
}
|
||||
|
||||
// string.clone_static returns an independent copy of a given array
|
||||
// It should be used only in -autofree generated code.
|
||||
fn (a string) clone_static() string {
|
||||
return a.clone()
|
||||
}
|
||||
|
||||
pub fn (a string) clone() string {
|
||||
mut b := string{
|
||||
len: a.len
|
||||
@@ -1141,7 +1147,7 @@ pub fn (u ustring) at(idx int) string {
|
||||
return u.substr(idx, idx + 1)
|
||||
}
|
||||
|
||||
fn (u ustring) free() {
|
||||
fn (u &ustring) free() {
|
||||
u.runes.free()
|
||||
}
|
||||
|
||||
@@ -1165,19 +1171,10 @@ pub fn (c byte) is_letter() bool {
|
||||
return (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`)
|
||||
}
|
||||
|
||||
pub fn (s string) free() {
|
||||
pub fn (s &string) free() {
|
||||
free(s.str)
|
||||
}
|
||||
|
||||
/*
|
||||
fn (arr []string) free() {
|
||||
for s in arr {
|
||||
s.free()
|
||||
}
|
||||
C.free(arr.data)
|
||||
}
|
||||
*/
|
||||
|
||||
// all_before('23:34:45.234', '.') == '23:34:45'
|
||||
pub fn (s string) all_before(dot string) string {
|
||||
pos := s.index(dot) or {
|
||||
|
Reference in New Issue
Block a user