string: make left/right private
parent
b92a3544f5
commit
b38283dcf1
|
@ -384,14 +384,14 @@ pub fn (s string) split_into_lines() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'hello'.left(2) => 'he'
|
// 'hello'.left(2) => 'he'
|
||||||
pub fn (s string) left(n int) string {
|
fn (s string) left(n int) string {
|
||||||
if n >= s.len {
|
if n >= s.len {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
return s.substr(0, n)
|
return s.substr(0, n)
|
||||||
}
|
}
|
||||||
// 'hello'.right(2) => 'llo'
|
// 'hello'.right(2) => 'llo'
|
||||||
pub fn (s string) right(n int) string {
|
fn (s string) right(n int) string {
|
||||||
if n >= s.len {
|
if n >= s.len {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ fn (p mut Parser) fn_decl() {
|
||||||
is_public: is_pub || p.is_vh // functions defined in .vh are always public
|
is_public: is_pub || p.is_vh // functions defined in .vh are always public
|
||||||
is_unsafe: p.attr == 'unsafe_fn'
|
is_unsafe: p.attr == 'unsafe_fn'
|
||||||
is_deprecated: p.attr == 'deprecated'
|
is_deprecated: p.attr == 'deprecated'
|
||||||
comptime_define: if p.attr.starts_with('if ') { p.attr.right(3) } else { '' }
|
comptime_define: if p.attr.starts_with('if ') { p.attr[3..] } else { '' }
|
||||||
}
|
}
|
||||||
is_live := p.attr == 'live' && !p.pref.is_so && p.pref.is_live
|
is_live := p.attr == 'live' && !p.pref.is_so && p.pref.is_live
|
||||||
if p.attr == 'live' && p.first_pass() && !p.pref.is_live && !p.pref.is_so {
|
if p.attr == 'live' && p.first_pass() && !p.pref.is_live && !p.pref.is_so {
|
||||||
|
|
|
@ -983,11 +983,11 @@ fn (p mut Parser) get_type() string {
|
||||||
p.check(.amp)
|
p.check(.amp)
|
||||||
}
|
}
|
||||||
// generic type check
|
// generic type check
|
||||||
ti := p.cur_fn.dispatch_of.inst
|
ti := p.cur_fn.dispatch_of.inst
|
||||||
if p.lit in ti.keys() {
|
if p.lit in ti.keys() {
|
||||||
typ += ti[p.lit]
|
typ += ti[p.lit]
|
||||||
} else {
|
} else {
|
||||||
typ += p.lit
|
typ += p.lit
|
||||||
}
|
}
|
||||||
// C.Struct import
|
// C.Struct import
|
||||||
if p.lit == 'C' && p.peek() == .dot {
|
if p.lit == 'C' && p.peek() == .dot {
|
||||||
|
@ -2093,7 +2093,7 @@ fn (p mut Parser) index_expr(typ_ string, fn_ph int) string {
|
||||||
// }
|
// }
|
||||||
if is_indexer {
|
if is_indexer {
|
||||||
l := p.cgen.cur_line.trim_space()
|
l := p.cgen.cur_line.trim_space()
|
||||||
index_val := l.right(l.last_index(' ')).trim_space()
|
index_val := l[l.last_index(' ')..].trim_space()
|
||||||
p.cgen.resetln(l[..fn_ph])
|
p.cgen.resetln(l[..fn_ph])
|
||||||
p.table.varg_access << VargAccess{
|
p.table.varg_access << VargAccess{
|
||||||
fn_name: p.cur_fn.name,
|
fn_name: p.cur_fn.name,
|
||||||
|
|
|
@ -421,7 +421,7 @@ pub fn (t Time) weekday_str() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct C.timeval {
|
pub struct C.timeval {
|
||||||
tv_sec u64
|
tv_sec u64
|
||||||
tv_usec u64
|
tv_usec u64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
month := '${t.smonth()}'
|
month := '${t.smonth()}'
|
||||||
year := t.year.str().right(2)
|
year := t.year.str()[2..]
|
||||||
|
|
||||||
return match fmt_date {
|
return match fmt_date {
|
||||||
.ddmmyy { '${t.day:02d}|${t.month:02d}|$year' }
|
.ddmmyy { '${t.day:02d}|${t.month:02d}|$year' }
|
||||||
|
|
Loading…
Reference in New Issue