From d2d3289a2a54d69f006b1bda5890f03f5efd5c76 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 6 Oct 2020 06:24:50 +0200 Subject: [PATCH] all: mark pref.Preferences field as immutable --- vlib/v/builder/builder.v | 2 +- vlib/v/checker/checker.v | 2 +- vlib/v/doc/doc.v | 23 ++++++++++++++--------- vlib/v/parser/parser.v | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index 427a1c11fd..b32890268d 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -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 diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index c3c5e96cbd..948c7ec959 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 diff --git a/vlib/v/doc/doc.v b/vlib/v/doc/doc.v index 5534c061bb..ae6f691668 100644 --- a/vlib/v/doc/doc.v +++ b/vlib/v/doc/doc.v @@ -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 } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 212fde68af..dd38c22d8f 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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