1
0
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:
Delyan Angelov
2020-05-06 19:03:44 +03:00
parent 2b0f2be18b
commit f638caef39
9 changed files with 106 additions and 63 deletions

View File

@@ -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' ]"

View File

@@ -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)