From 95c3ef3a6a8bd29f08ca223d0eeb573103c7762b Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 10 Feb 2021 06:00:43 +0800 Subject: [PATCH] cgen: minor cleanup in stmt() (#8659) --- vlib/v/gen/c/cgen.v | 2 +- vlib/v/gen/js/js.v | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index deff9a6fc0dd60..645a3ea879098e 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1042,7 +1042,7 @@ fn (mut g Gen) stmt(node ast.Stmt) { // if af { // g.autofree_call_postgen() // } - if g.inside_ternary == 0 && !node.is_expr && !(node.expr is ast.IfExpr) { + if g.inside_ternary == 0 && !node.is_expr && node.expr !is ast.IfExpr { g.writeln(';') } } diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index eaec7f04485f9d..69e1c09f420a03 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -1039,7 +1039,7 @@ fn (mut g JsGen) gen_struct_decl(node ast.StructDecl) { } // gen toString method fn_names := fns.map(it.name) - if !('toString' in fn_names) { + if 'toString' !in fn_names { g.writeln('toString() {') g.inc_indent() g.write('return `$js_name {') @@ -1569,13 +1569,13 @@ fn (mut g JsGen) gen_type_cast_expr(it ast.CastExpr) { || (it.expr is ast.FloatLiteral && it.typ in table.float_type_idxs)) typ := g.typ(it.typ) if !is_literal { - if !(typ in js.v_types) || g.ns.name == 'builtin' { + if typ !in js.v_types || g.ns.name == 'builtin' { g.write('new ') } g.write('${typ}(') } g.expr(it.expr) - if typ == 'string' && !(it.expr is ast.StringLiteral) { + if typ == 'string' && it.expr !is ast.StringLiteral { g.write('.toString()') } if !is_literal {