Skip to content

Commit 6db904f

Browse files
authored
cgen: correct comments and cleanup in comptime_for() (#17964)
1 parent d3de7ad commit 6db904f

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

vlib/v/gen/c/comptime.v

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -727,15 +727,12 @@ fn (mut g Gen) resolve_comptime_type(node ast.Expr, default_type ast.Type) ast.T
727727
return default_type
728728
}
729729

730-
//
731-
732730
fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
733731
sym := g.table.final_sym(g.unwrap_generic(node.typ))
734-
g.writeln('/* \$for ${node.val_var} in ${sym.name}(${node.kind.str()}) */ {')
732+
g.writeln('/* \$for ${node.val_var} in ${sym.name}.${node.kind.str()} */ {')
735733
g.indent++
736-
// vweb_result_type := ast.new_type(g.table.find_type_idx('vweb.Result'))
737734
mut i := 0
738-
// g.writeln('string method = _SLIT("");')
735+
739736
if node.kind == .methods {
740737
mut methods := sym.methods.filter(it.attrs.len == 0) // methods without attrs first
741738
methods_with_attrs := sym.methods.filter(it.attrs.len > 0) // methods with attrs second
@@ -809,7 +806,7 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
809806
ret_typ := method.return_type.idx()
810807
g.writeln('\t${node.val_var}.typ = ${styp};')
811808
g.writeln('\t${node.val_var}.return_type = ${ret_typ};')
812-
//
809+
813810
g.comptime_var_type_map['${node.val_var}.return_type'] = ret_typ
814811
g.comptime_var_type_map['${node.val_var}.typ'] = styp
815812
g.stmts(node.stmts)
@@ -818,7 +815,6 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
818815
g.pop_existing_comptime_values()
819816
}
820817
} else if node.kind == .fields {
821-
// TODO add fields
822818
if sym.kind in [.struct_, .interface_] {
823819
fields := match sym.info {
824820
ast.Struct {
@@ -853,28 +849,27 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
853849
attrs.join(', ') + '}));\n')
854850
}
855851
field_sym := g.table.sym(field.typ)
856-
// g.writeln('\t${node.val_var}.typ = _SLIT("$field_sym.name");')
857852
styp := field.typ
858853
unaliased_styp := g.table.unaliased_type(styp)
859854

860855
g.writeln('\t${node.val_var}.typ = ${styp.idx()};')
861856
g.writeln('\t${node.val_var}.unaliased_typ = ${unaliased_styp.idx()};')
862857
g.writeln('\t${node.val_var}.is_pub = ${field.is_pub};')
863858
g.writeln('\t${node.val_var}.is_mut = ${field.is_mut};')
864-
//
859+
865860
g.writeln('\t${node.val_var}.is_shared = ${field.typ.has_flag(.shared_f)};')
866861
g.writeln('\t${node.val_var}.is_atomic = ${field.typ.has_flag(.atomic_f)};')
867862
g.writeln('\t${node.val_var}.is_option = ${field.typ.has_flag(.option)};')
868-
//
863+
869864
g.writeln('\t${node.val_var}.is_array = ${field_sym.kind in [.array, .array_fixed]};')
870865
g.writeln('\t${node.val_var}.is_map = ${field_sym.kind == .map};')
871866
g.writeln('\t${node.val_var}.is_chan = ${field_sym.kind == .chan};')
872867
g.writeln('\t${node.val_var}.is_struct = ${field_sym.kind == .struct_};')
873868
g.writeln('\t${node.val_var}.is_alias = ${field_sym.kind == .alias};')
874869
g.writeln('\t${node.val_var}.is_enum = ${field_sym.kind == .enum_};')
875-
//
870+
876871
g.writeln('\t${node.val_var}.indirections = ${field.typ.nr_muls()};')
877-
//
872+
878873
g.comptime_var_type_map['${node.val_var}.typ'] = styp
879874
g.comptime_var_type_map['${node.val_var}.unaliased_typ'] = unaliased_styp
880875
g.stmts(node.stmts)

0 commit comments

Comments
 (0)