diff --git a/vlib/v/ast/cflags.v b/vlib/v/ast/cflags.v index b8975abad7..a91ff04883 100644 --- a/vlib/v/ast/cflags.v +++ b/vlib/v/ast/cflags.v @@ -4,7 +4,6 @@ module ast import v.cflag -import v.checker.constants // check if cflag is in table pub fn (t &Table) has_cflag(flag cflag.CFlag) bool { @@ -27,7 +26,7 @@ pub fn (mut t Table) parse_cflag(cflg string, mod string, ctimedefines []string) } mut fos := '' mut allowed_os_overrides := []string{} - allowed_os_overrides << constants.valid_comptime_not_user_defined + allowed_os_overrides << valid_comptime_not_user_defined allowed_os_overrides << ctimedefines for os_override in allowed_os_overrides { if !flag.starts_with(os_override) { diff --git a/vlib/v/checker/constants/constants.v b/vlib/v/ast/comptime_valid_idents.v similarity index 80% rename from vlib/v/checker/constants/constants.v rename to vlib/v/ast/comptime_valid_idents.v index b50c1158d4..d5b50193ad 100644 --- a/vlib/v/checker/constants/constants.v +++ b/vlib/v/ast/comptime_valid_idents.v @@ -1,4 +1,4 @@ -module constants +module ast pub const ( valid_comptime_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', @@ -16,10 +16,10 @@ pub const ( fn all_valid_comptime_idents() []string { mut res := []string{} - res << constants.valid_comptime_if_os - res << constants.valid_comptime_if_compilers - res << constants.valid_comptime_if_platforms - res << constants.valid_comptime_if_cpu_features - res << constants.valid_comptime_if_other + res << ast.valid_comptime_if_os + res << ast.valid_comptime_if_compilers + res << ast.valid_comptime_if_platforms + res << ast.valid_comptime_if_cpu_features + res << ast.valid_comptime_if_other return res } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 4970266260..ae68b0ece8 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -12,7 +12,6 @@ import v.util import v.util.version import v.errors import v.pkgconfig -import v.checker.constants const ( int_min = int(0x80000000) @@ -1822,7 +1821,7 @@ fn (mut c Checker) stmt(node_ ast.Stmt) { for i, ident in node.defer_vars { mut id := ident if mut id.info is ast.IdentVar { - if id.comptime && id.name in constants.valid_comptime_not_user_defined { + if id.comptime && id.name in ast.valid_comptime_not_user_defined { node.defer_vars[i] = ast.Ident{ scope: 0 name: '' diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index 94c2b17b88..53938a6411 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -8,7 +8,6 @@ import v.pref import v.token import v.util import v.pkgconfig -import v.checker.constants [inline] fn (mut c Checker) get_comptime_var_type(node ast.Expr) ast.Type { @@ -101,8 +100,8 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) ast.Type { node.embed_file.apath = escaped_path } // c.file.embedded_files << node.embed_file - if node.embed_file.compression_type !in constants.valid_comptime_compression_types { - supported := constants.valid_comptime_compression_types.map('.${it}').join(', ') + if node.embed_file.compression_type !in ast.valid_comptime_compression_types { + supported := ast.valid_comptime_compression_types.map('.${it}').join(', ') c.error('not supported compression type: .${node.embed_file.compression_type}. supported: ${supported}', node.pos) } @@ -526,7 +525,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool { } if node.ct_expr is ast.Ident { if node.ct_opt { - if node.ct_expr.name in constants.valid_comptime_not_user_defined { + if node.ct_expr.name in ast.valid_comptime_not_user_defined { c.error('option `[if expression ?]` tags, can be used only for user defined identifiers', node.pos) node.ct_skip = true @@ -536,7 +535,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool { node.ct_evaled = true return node.ct_skip } else { - if node.ct_expr.name !in constants.valid_comptime_not_user_defined { + if node.ct_expr.name !in ast.valid_comptime_not_user_defined { c.note('`[if ${node.ct_expr.name}]` is deprecated. Use `[if ${node.ct_expr.name} ?]` instead', node.pos) node.ct_skip = node.ct_expr.name !in c.pref.compile_defines @@ -729,20 +728,20 @@ fn (mut c Checker) comptime_if_branch(cond ast.Expr, pos token.Pos) ComptimeBran } ast.Ident { cname := cond.name - if cname in constants.valid_comptime_if_os { + if cname in ast.valid_comptime_if_os { mut is_os_target_equal := true if !c.pref.output_cross_c { target_os := c.pref.os.str().to_lower() is_os_target_equal = cname == target_os } return if is_os_target_equal { .eval } else { .skip } - } else if cname in constants.valid_comptime_if_compilers { + } else if cname in ast.valid_comptime_if_compilers { return if pref.cc_from_string(cname) == c.pref.ccompiler_type { .eval } else { .skip } - } else if cname in constants.valid_comptime_if_platforms { + } else if cname in ast.valid_comptime_if_platforms { if cname == 'aarch64' { c.note('use `arm64` instead of `aarch64`', pos) } @@ -756,9 +755,9 @@ fn (mut c Checker) comptime_if_branch(cond ast.Expr, pos token.Pos) ComptimeBran 'rv32' { return if c.pref.arch == .rv32 { .eval } else { .skip } } else { return .unknown } } - } else if cname in constants.valid_comptime_if_cpu_features { + } else if cname in ast.valid_comptime_if_cpu_features { return .unknown - } else if cname in constants.valid_comptime_if_other { + } else if cname in ast.valid_comptime_if_other { match cname { 'apk' { return if c.pref.is_apk { .eval } else { .skip } diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 9f89efe464..11ce9f3b62 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -7,7 +7,6 @@ import strings import v.ast import v.util import v.pref -import v.checker.constants const ( bs = '\\' @@ -2009,7 +2008,7 @@ pub fn (mut f Fmt) enum_val(node ast.EnumVal) { pub fn (mut f Fmt) ident(node ast.Ident) { if node.info is ast.IdentVar { - if node.comptime && node.name in constants.valid_comptime_not_user_defined { + if node.comptime && node.name in ast.valid_comptime_not_user_defined { f.write(node.name) return }