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

vfmt fixes

This commit is contained in:
Alexander Medvednikov
2019-07-16 17:59:07 +02:00
parent 7bbaf432e6
commit c35adbea91
18 changed files with 136 additions and 96 deletions

View File

@@ -5,6 +5,7 @@
module main
import os
import strings
struct CGen {
out os.File
@@ -20,6 +21,7 @@ struct CGen {
so_fns []string
consts_init []string
lines []string
//buf strings.Builder
is_user bool
mut:
run Pass
@@ -37,11 +39,11 @@ fn new_cgen(out_name_c string) *CGen {
out := os.create(path) or {
println('failed to create $path')
return &CGen{}
}
}
gen := &CGen {
out_path: path
out: out
//buf: strings.new_builder(10000)
lines: _make(0, 1000, sizeof(string))
}
return gen
@@ -144,7 +146,8 @@ fn (g mut CGen) set_placeholder2(pos int, val string) {
}
fn (g mut CGen) insert_before(val string) {
g.lines.insert(g.lines.len - 1, val)
prev := g.lines[g.lines.len - 1]
g.lines[g.lines.len - 1] = '$prev \n $val \n'
}
fn (g mut CGen) register_thread_fn(wrapper_name, wrapper_text, struct_text string) {