checker: minor changes to `Checker.hash_stmt()` (#9249)
parent
8f08795689
commit
04c4f16f75
|
@ -3486,16 +3486,17 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
|||
}
|
||||
if c.pref.backend == .js {
|
||||
if !c.file.path.ends_with('.js.v') {
|
||||
c.error('Hash statements are only allowed in backend specific files such "x.js.v"',
|
||||
c.error('hash statements are only allowed in backend specific files such "x.js.v"',
|
||||
node.pos)
|
||||
}
|
||||
if c.mod == 'main' {
|
||||
c.error('Hash statements are not allowed in the main module. Please place them in a separate module.',
|
||||
c.error('hash statements are not allowed in the main module. Please place them in a separate module.',
|
||||
node.pos)
|
||||
}
|
||||
return
|
||||
}
|
||||
if node.kind == 'include' {
|
||||
match node.kind {
|
||||
'include' {
|
||||
mut flag := node.main
|
||||
if flag.contains('@VROOT') {
|
||||
vroot := util.resolve_vroot(flag, c.file.path) or {
|
||||
|
@ -3519,7 +3520,8 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
|||
c.error('including C files should use either `"header_file.h"` or `<header_file.h>` quoting',
|
||||
node.pos)
|
||||
}
|
||||
} else if node.kind == 'pkgconfig' {
|
||||
}
|
||||
'pkgconfig' {
|
||||
args := if node.main.contains('--') {
|
||||
node.main.split(' ')
|
||||
} else {
|
||||
|
@ -3537,7 +3539,8 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
|||
c.error(err.msg, node.pos)
|
||||
return
|
||||
}
|
||||
} else if node.kind == 'flag' {
|
||||
}
|
||||
'flag' {
|
||||
// #flag linux -lm
|
||||
mut flag := node.main
|
||||
// expand `@VROOT` to its absolute path
|
||||
|
@ -3562,12 +3565,14 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
|||
c.table.parse_cflag(flag, c.mod, c.pref.compile_defines_all) or {
|
||||
c.error(err.msg, node.pos)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if node.kind != 'define' {
|
||||
c.error('expected `#define`, `#flag`, `#include` or `#pkgconfig` not $node.val',
|
||||
node.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut c Checker) import_stmt(imp ast.Import) {
|
||||
|
|
Loading…
Reference in New Issue