Skip to content

Commit a3f86ee

Browse files
authored
checker,cgen: evaluate comptime $if results in checker *only* (fix #25123) (fix #25156) (#25150)
1 parent 7dd91ec commit a3f86ee

12 files changed

Lines changed: 604 additions & 460 deletions

File tree

‎cmd/tools/vast/vast.v‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,6 @@ fn (t Tree) if_branch(node ast.IfBranch) &Node {
15381538
obj.add_terse('cond', t.expr(node.cond))
15391539
obj.add('pos', t.pos(node.pos))
15401540
obj.add('body_pos', t.pos(node.body_pos))
1541-
obj.add_terse('pkg_exist', t.bool_node(node.pkg_exist))
15421541
obj.add_terse('stmts', t.array_node_stmt(node.stmts))
15431542
obj.add('scope', t.number_node(int(node.scope)))
15441543
obj.add('comments', t.array_node_comment(node.comments))

‎vlib/v/ast/ast.v‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,9 @@ pub:
12341234
body_pos token.Pos
12351235
comments []Comment
12361236
pub mut:
1237-
cond Expr
1238-
pkg_exist bool
1239-
stmts []Stmt
1240-
scope &Scope = unsafe { nil }
1237+
cond Expr
1238+
stmts []Stmt
1239+
scope &Scope = unsafe { nil }
12411240
}
12421241

12431242
pub struct UnsafeExpr {
@@ -2131,6 +2130,8 @@ pub fn (cc ComptimeCall) expr_str() string {
21312130
if arg.expr.is_pure_literal() {
21322131
str = "\$${cc.method_name}('${cc.args_var}', ${arg})"
21332132
}
2133+
} else if cc.kind == .pkgconfig {
2134+
str = "\$${cc.method_name}('${cc.args_var}')"
21342135
}
21352136
return str
21362137
}

‎vlib/v/ast/table.v‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ pub mut:
9494
anon_struct_counter int
9595
anon_union_names map[string]int // anon union name -> union sym idx
9696
anon_union_counter int
97+
comptime_is_true map[string]ComptTimeCondResult // The evaluate cond results for different generic types combination, such as `comptime_is_true['T=int,X=string|main.v|pos ...'] = {true, '!DEFINED(WINDOWS)'}`
98+
}
99+
100+
pub struct ComptTimeCondResult {
101+
pub mut:
102+
val bool
103+
c_str string
97104
}
98105

99106
// used by vls to avoid leaks

0 commit comments

Comments
 (0)