Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 17, 2024
1 parent aa37cc6 commit a7c7a86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vlib/builtin/string.v
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ pub fn (s string) last_index_u8(c u8) int {
// count returns the number of occurrences of `substr` in the string.
// count returns -1 if no `substr` could be found.
@[direct_array_access]
pub fn (s &string) count(substr string) int {
pub fn (s string) count(substr string) int {
if s.len == 0 || substr.len == 0 {
return 0
}
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/token/pos.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ pub mut:
pub fn (mut p Pos) free() {
}

pub fn (p &Pos) line_str() string {
pub fn (p Pos) line_str() string {
return '{l: ${p.line_nr + 1:5}, c: ${p.col:3}, p: ${p.pos:5}, ll: ${p.last_line + 1:5}}'
}

pub fn (pos &Pos) extend(end Pos) Pos {
pub fn (pos Pos) extend(end Pos) Pos {
return Pos{
...pos
len: end.pos - pos.pos + end.len
last_line: end.last_line
}
}

pub fn (pos &Pos) extend_with_last_line(end Pos, last_line int) Pos {
pub fn (pos Pos) extend_with_last_line(end Pos, last_line int) Pos {
return Pos{
len: end.pos - pos.pos + end.len
line_nr: pos.line_nr
Expand Down
10 changes: 5 additions & 5 deletions vlib/v/token/token.v
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ pub fn (t Kind) str() string {
}

@[inline]
pub fn (t &Token) is_next_to(pre_token Token) bool {
pub fn (t Token) is_next_to(pre_token Token) bool {
return t.pos - pre_token.pos == pre_token.len
}

pub fn (t &Token) str() string {
pub fn (t Token) str() string {
mut s := t.kind.str()
if s.len == 0 {
eprintln('missing token kind string')
Expand Down Expand Up @@ -493,7 +493,7 @@ const precedences = build_precedences()

// precedence returns a tokens precedence if defined, otherwise 0
@[direct_array_access; inline]
pub fn (tok &Token) precedence() int {
pub fn (tok Token) precedence() int {
return int(precedences[tok.kind])
}

Expand All @@ -505,13 +505,13 @@ pub fn (kind Kind) precedence() int {

// is_scalar returns true if the token is a scalar
@[inline]
pub fn (tok &Token) is_scalar() bool {
pub fn (tok Token) is_scalar() bool {
return tok.kind in [.number, .string]
}

// is_unary returns true if the token can be in a unary expression
@[inline]
pub fn (tok &Token) is_unary() bool {
pub fn (tok Token) is_unary() bool {
// `+` | `-` | `!` | `~` | `*` | `&` | `<-`
return tok.kind in [.plus, .minus, .not, .bit_not, .mul, .amp, .arrow]
}
Expand Down

0 comments on commit a7c7a86

Please sign in to comment.