cgen: remove _PUSH

pull/4518/head
Alexander Medvednikov 2020-04-20 09:04:17 +02:00
parent e006da7259
commit 2642f6a0da
3 changed files with 5 additions and 14 deletions

View File

@ -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')
}

View File

@ -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)

View File

@ -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)