From 2642f6a0da452867e69ae9d684df30034812105b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 20 Apr 2020 09:04:17 +0200 Subject: [PATCH] cgen: remove _PUSH --- vlib/v/fmt/fmt.v | 3 +-- vlib/v/gen/cgen.v | 15 ++++----------- vlib/v/gen/cheaders.v | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 0e8232599f..a826261191 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -54,7 +54,7 @@ pub fn fmt(file ast.File, table &table.Table) string { // for comment in file.comments { println('$comment.line_nr $comment.text') } f.imports(f.file.imports) // now that we have all autoimports, handle them res := f.out.str().trim_space() + '\n' - return res[..f.import_pos] + f.out_imports.str() + res[f.import_pos..] + '\n' + return res[..f.import_pos] + f.out_imports.str() + res[f.import_pos..] // + '\n' } /* @@ -933,4 +933,3 @@ fn (var f Fmt) mark_module_as_used(name string) { f.used_imports << mod // println('marking module $mod as used') } - diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index ed05c7d9af..716a1d74df 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -20,9 +20,10 @@ const ( 'double' 'extern' 'float' - 'inline', 'int', 'long', 'register', 'restrict', 'short', 'signed', 'sizeof', 'static' - 'switch' - 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while'] + 'inline' + 'int', 'long', 'register', 'restrict', 'short', 'signed', 'sizeof', 'static', 'switch' + 'typedef' + 'union', 'unsigned', 'void', 'volatile', 'while'] ) fn foo(t token.Token) { @@ -1331,14 +1332,6 @@ fn (var g Gen) infix_expr(node ast.InfixExpr) { g.write('), $tmp, $styp)') } else { // push a single element - /* - elem_type_str := g.typ(info.elem_type) - g.write('_PUSH(&') - g.expr(node.left) - g.write(', (') - g.expr_with_cast(node.right, node.right_type, info.elem_type) - g.write('), $tmp, $elem_type_str)') -*/ elem_type_str := g.typ(info.elem_type) g.write('array_push(&') g.expr(node.left) diff --git a/vlib/v/gen/cheaders.v b/vlib/v/gen/cheaders.v index ca84173a31..7ec9acabc2 100644 --- a/vlib/v/gen/cheaders.v +++ b/vlib/v/gen/cheaders.v @@ -173,7 +173,6 @@ extern wchar_t **_wenviron; //============================== HELPER C MACROS =============================*/ -#define _PUSH(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array_push(arr, &tmp);} #define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array_push_many(arr, tmp.data, tmp.len);} #define _IN(typ, val, arr) array_##typ##_contains(arr, val) #define _IN_MAP(val, m) map_exists(m, val)