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.pref.backend == .js {
|
||||||
if !c.file.path.ends_with('.js.v') {
|
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)
|
node.pos)
|
||||||
}
|
}
|
||||||
if c.mod == 'main' {
|
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)
|
node.pos)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if node.kind == 'include' {
|
match node.kind {
|
||||||
|
'include' {
|
||||||
mut flag := node.main
|
mut flag := node.main
|
||||||
if flag.contains('@VROOT') {
|
if flag.contains('@VROOT') {
|
||||||
vroot := util.resolve_vroot(flag, c.file.path) or {
|
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',
|
c.error('including C files should use either `"header_file.h"` or `<header_file.h>` quoting',
|
||||||
node.pos)
|
node.pos)
|
||||||
}
|
}
|
||||||
} else if node.kind == 'pkgconfig' {
|
}
|
||||||
|
'pkgconfig' {
|
||||||
args := if node.main.contains('--') {
|
args := if node.main.contains('--') {
|
||||||
node.main.split(' ')
|
node.main.split(' ')
|
||||||
} else {
|
} else {
|
||||||
|
@ -3537,7 +3539,8 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
||||||
c.error(err.msg, node.pos)
|
c.error(err.msg, node.pos)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if node.kind == 'flag' {
|
}
|
||||||
|
'flag' {
|
||||||
// #flag linux -lm
|
// #flag linux -lm
|
||||||
mut flag := node.main
|
mut flag := node.main
|
||||||
// expand `@VROOT` to its absolute path
|
// expand `@VROOT` to its absolute path
|
||||||
|
@ -3562,13 +3565,15 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
||||||
c.table.parse_cflag(flag, c.mod, c.pref.compile_defines_all) or {
|
c.table.parse_cflag(flag, c.mod, c.pref.compile_defines_all) or {
|
||||||
c.error(err.msg, node.pos)
|
c.error(err.msg, node.pos)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if node.kind != 'define' {
|
if node.kind != 'define' {
|
||||||
c.error('expected `#define`, `#flag`, `#include` or `#pkgconfig` not $node.val',
|
c.error('expected `#define`, `#flag`, `#include` or `#pkgconfig` not $node.val',
|
||||||
node.pos)
|
node.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn (mut c Checker) import_stmt(imp ast.Import) {
|
fn (mut c Checker) import_stmt(imp ast.Import) {
|
||||||
for sym in imp.syms {
|
for sym in imp.syms {
|
||||||
|
|
Loading…
Reference in New Issue