cgen: c2v enum fix
parent
9c24d09dc3
commit
5a14748e7c
|
@ -2853,10 +2853,7 @@ fn (mut g Gen) expr(node ast.Expr) {
|
|||
g.dump_expr(node)
|
||||
}
|
||||
ast.EnumVal {
|
||||
// g.write('${it.mod}${it.enum_name}_$it.val')
|
||||
// g.enum_expr(node)
|
||||
styp := g.typ(g.table.unaliased_type(node.typ))
|
||||
g.write('${styp}__$node.val')
|
||||
g.enum_val(node)
|
||||
}
|
||||
ast.FloatLiteral {
|
||||
if g.pref.nofloat {
|
||||
|
@ -5051,6 +5048,17 @@ fn (mut g Gen) size_of(node ast.SizeOf) {
|
|||
g.write('sizeof(${util.no_dots(styp)})')
|
||||
}
|
||||
|
||||
fn (mut g Gen) enum_val(node ast.EnumVal) {
|
||||
// g.write('${it.mod}${it.enum_name}_$it.val')
|
||||
// g.enum_expr(node)
|
||||
styp := g.typ(g.table.unaliased_type(node.typ))
|
||||
if node.typ.is_number() {
|
||||
// Mostly in translated code, when C enums are used as ints in switches
|
||||
// g.write('/*enum val is_number $node.mod styp=$styp*/')
|
||||
}
|
||||
g.write('${styp}__$node.val')
|
||||
}
|
||||
|
||||
fn (mut g Gen) go_expr(node ast.GoExpr) {
|
||||
line := g.go_before_stmt(0)
|
||||
mut handle := ''
|
||||
|
|
|
@ -419,7 +419,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
|||
} else {
|
||||
name = p.prepend_mod(name)
|
||||
}
|
||||
if language == .v {
|
||||
if !p.pref.translated && language == .v {
|
||||
if existing := p.table.fns[name] {
|
||||
if existing.name != '' {
|
||||
if file_mode == .v && existing.file_mode != .v {
|
||||
|
|
Loading…
Reference in New Issue