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 .` 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 module_path string
mut: mut:
checker checker.Checker
pref &pref.Preferences pref &pref.Preferences
checker checker.Checker
global_scope &ast.Scope global_scope &ast.Scope
out_name_c string out_name_c string
out_name_js string out_name_js string

View File

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

View File

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

View File

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