all: mark pref.Preferences field as immutable

pull/6298/head
Alexander Medvednikov 2020-10-06 06:24:50 +02:00
parent 06a02c41c3
commit d2d3289a2a
4 changed files with 17 additions and 12 deletions

View File

@ -15,8 +15,8 @@ pub:
compiled_dir string // contains os.real_path() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
module_path string
mut:
checker checker.Checker
pref &pref.Preferences
checker checker.Checker
global_scope &ast.Scope
out_name_c string
out_name_js string

View File

@ -25,6 +25,7 @@ const (
)
pub struct Checker {
pref &pref.Preferences // Preferences shared from V struct
pub mut:
table &table.Table
file ast.File
@ -41,7 +42,6 @@ pub mut:
global_names []string
locked_names []string // vars that are currently locked
rlocked_names []string // vars that are currently read-locked
pref &pref.Preferences // Preferences shared from V struct
in_for_count int // if checker is currently in an for loop
// checked_ident string // to avoid infinit checker loops
returns bool

View File

@ -14,9 +14,9 @@ import v.token
import v.util
pub struct Doc {
prefs &pref.Preferences
pub mut:
input_path string
prefs &pref.Preferences = &pref.Preferences{}
table &table.Table = &table.Table{}
checker checker.Checker = checker.Checker{
table: 0
@ -380,10 +380,18 @@ pub fn (mut d Doc) generate_from_ast(file_ast ast.File, orig_mod_name string) []
}
node.attrs['category'] = 'Constants'
}
ast.EnumDecl { node.attrs['category'] = 'Enums' }
ast.InterfaceDecl { node.attrs['category'] = 'Interfaces' }
ast.StructDecl { node.attrs['category'] = 'Structs' }
ast.TypeDecl { node.attrs['category'] = 'Typedefs' }
ast.EnumDecl {
node.attrs['category'] = 'Enums'
}
ast.InterfaceDecl {
node.attrs['category'] = 'Interfaces'
}
ast.StructDecl {
node.attrs['category'] = 'Structs'
}
ast.TypeDecl {
node.attrs['category'] = 'Typedefs'
}
ast.FnDecl {
if stmt.is_deprecated {
continue
@ -402,8 +410,7 @@ pub fn (mut d Doc) generate_from_ast(file_ast ast.File, orig_mod_name string) []
}
}
}
node.attrs['category'] = if node.attrs['parent'] in ['void', ''] ||
!node.attrs.exists('parent') { 'Functions' } else { 'Methods' }
node.attrs['category'] = if node.attrs['parent'] in ['void', ''] || !node.attrs.exists('parent') { 'Functions' } else { 'Methods' }
}
else {}
}
@ -415,7 +422,6 @@ pub fn (mut d Doc) generate_from_ast(file_ast ast.File, orig_mod_name string) []
}
prev_comments = []
}
return contents
}
@ -442,7 +448,6 @@ pub fn (mut d Doc) generate_from_ast_with_pos(file_ast ast.File, pos int) []DocN
}
contents << l_node
}
return contents
}

View File

@ -17,6 +17,7 @@ import time
pub struct Parser {
file_name string // "/home/user/hello.v"
file_name_dir string // "/home/user"
pref &pref.Preferences
mut:
scanner &scanner.Scanner
comments_mode scanner.CommentsMode = .skip_comments // see comment in parse_file
@ -34,7 +35,6 @@ mut:
inside_for bool
inside_fn bool
inside_str_interp bool
pref &pref.Preferences
builtin_mod bool // are we in the `builtin` module?
mod string // current module name
attrs []table.Attr // attributes before next decl stmt