parser: skip $if windows etc blocks on a different os

pull/2759/head
Alexander Medvednikov 2019-11-13 21:14:37 +03:00
parent 3b929cdd03
commit 861f2d4bc0
2 changed files with 5 additions and 2 deletions

View File

@ -85,7 +85,7 @@ pub fn (_rune string) utf32_code() int {
for i := 1; i < _rune.len; i++ {
c := int(_rune[i])
res = res << shift
res |= c & 63 /* 0x3f */
res |= c & 63 // 0x3f
shift = 6
}
return res

View File

@ -31,12 +31,15 @@ fn (p mut Parser) comp_time() {
}
p.check(.lcbr)
os := os_from_string(name)
if false && p.fileis('runtime.v') && os != p.os {
if (!not && os != p.os) || (not && os == p.os) {
// `$if os {` for a different target, skip everything inside
// to avoid compilation errors (like including <windows.h>
// on non-Windows systems)
mut stack := 1
for {
if p.tok == .key_return {
p.returns = true
}
if p.tok == .lcbr {
stack++
} else if p.tok == .rcbr {