1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix enum vals, includes, in strings

This commit is contained in:
Alexander Medvednikov 2020-03-15 01:36:17 +01:00
parent a121dfd23a
commit 28fc9d332c

View File

@ -290,7 +290,7 @@ fn (g mut Gen) stmt(node ast.Stmt) {
ast.HashStmt { ast.HashStmt {
// #include etc // #include etc
typ := it.val.all_before(' ') typ := it.val.all_before(' ')
if typ in ['#include', '#define'] { if typ in ['include', 'define'] {
g.definitions.writeln('#$it.val') g.definitions.writeln('#$it.val')
} }
} }
@ -628,7 +628,8 @@ fn (g mut Gen) expr(node ast.Expr) {
} }
ast.EnumVal { ast.EnumVal {
// g.write('/*EnumVal*/${it.mod}${it.enum_name}_$it.val') // g.write('/*EnumVal*/${it.mod}${it.enum_name}_$it.val')
g.write('${it.enum_name}_$it.val') enum_name := it.enum_name.replace('.', '__')
g.write('${enum_name}_$it.val')
} }
ast.FloatLiteral { ast.FloatLiteral {
g.write(it.val) g.write(it.val)
@ -917,7 +918,7 @@ fn (g mut Gen) infix_expr(node ast.InfixExpr) {
// g.write('/*$node.left_type str*/') // g.write('/*$node.left_type str*/')
// } // }
// string + string, string == string etc // string + string, string == string etc
if node.left_type == table.string_type_idx { if node.left_type == table.string_type_idx && node.op != .key_in {
fn_name := match node.op { fn_name := match node.op {
.plus{ .plus{
'string_add(' 'string_add('