type_to_str()

pull/3804/head
Alexander Medvednikov 2020-02-21 14:47:42 +01:00
parent 6d0a599d0c
commit b309e7d0e5
4 changed files with 9 additions and 6 deletions

View File

@ -22,7 +22,7 @@ const (
fn C.symlink(charptr, charptr) int
pub fn init_os_args(argc int, argv &byteptr) []string {
fn init_os_args(argc int, argv &byteptr) []string {
mut args := []string
for i in 0 .. argc {
args << string(argv[i])

View File

@ -20,8 +20,7 @@ pub fn (node &FnDecl) str(t &table.Table) string {
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ
f.write(arg.name)
if should_add_type {
arg_typ_sym := t.get_type_symbol(arg.typ)
f.write(' ${arg_typ_sym.name}')
f.write(' ' + t.type_to_str(arg.typ))
}
if !is_last_arg {
f.write(', ')
@ -29,8 +28,7 @@ pub fn (node &FnDecl) str(t &table.Table) string {
}
f.write(')')
if node.typ != table.void_type {
sym := t.get_type_symbol(node.typ)
f.write(' ' + sym.name)
f.write(' ' + t.type_to_str(node.typ))
}
return f.str()
}

View File

@ -40,7 +40,7 @@ pub fn doc(mod string, table &table.Table) string {
if !file.ends_with('.v') {
continue
}
if file.ends_with('_test.v') {
if file.ends_with('_test.v') || file.ends_with('_windows.v') || file.ends_with('_macos.v') {
continue
}
file_ast := parser.parse_file(filepath.join(path,file), table)

View File

@ -392,3 +392,8 @@ pub mut:
key_type Type
value_type Type
}
pub fn (table &Table) type_to_str(t Type) string {
sym := table.get_type_symbol(t)
return sym.name.replace('array_', '[]')
}