diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-09-14 18:36:17 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-09-14 18:36:17 +0200 |
| commit | 43144347e05e03446052db1ba87a1c2c97072221 (patch) | |
| tree | 6545ab5ddbbda77aa8e5a5f49d8dada726dfa44b | |
| parent | 9e3ca7b83888fdcf0228e1f71a91c07317d8a73f (diff) | |
Fix new odin changes
| -rw-r--r-- | src/odin/printer/printer.odin | 1 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 46 |
2 files changed, 43 insertions, 4 deletions
diff --git a/src/odin/printer/printer.odin b/src/odin/printer/printer.odin index b033d68..930274a 100644 --- a/src/odin/printer/printer.odin +++ b/src/odin/printer/printer.odin @@ -26,6 +26,7 @@ Printer :: struct { disabled_lines: map[int]Disabled_Info, disabled_until_line: int, group_modes: map[string]Document_Group_Mode, + force_statement_fit: bool, src: string, } diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 9ad25fe..6fa4798 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -315,7 +315,15 @@ visit_decl :: proc( document, cons_with_opl(text("foreign"), visit_expr(p, v.foreign_library)), ) - document = cons_with_nopl(document, visit_stmt(p, v.body)) + + if v.body != nil && is_foreign_block_only_procedures(v.body) { + p.force_statement_fit = true + document = cons_with_nopl(document, visit_stmt(p, v.body)) + p.force_statement_fit = false + } else { + document = cons_with_nopl(document, visit_stmt(p, v.body)) + } + return document case ^Import_Decl: document := move_line(p, decl.pos) @@ -450,6 +458,25 @@ is_call_expr_nestable :: proc(list: []^ast.Expr) -> bool { } @(private) +is_foreign_block_only_procedures :: proc(stmt: ^ast.Stmt) -> bool { + + /* + if block, ok := stmt.derived.(^ast.Block_Stmt); ok { + + for stmt in block.stmts { + + + + + } + + } + */ + + return true +} + +@(private) is_value_decl_statement_ending_with_call :: proc(stmt: ^ast.Stmt) -> bool { if value_decl, ok := stmt.derived.(^ast.Value_Decl); ok { @@ -2158,7 +2185,18 @@ visit_block_stmts :: proc( if stmts[last_index].end.line == stmt.pos.line && i != 0 { document = cons(document, break_with(";")) } - document = cons(document, visit_stmt(p, stmt, .Generic, false, true)) + + if p.force_statement_fit { + document = cons( + document, + enforce_fit(visit_stmt(p, stmt, .Generic, false, true)), + ) + } else { + document = cons( + document, + visit_stmt(p, stmt, .Generic, false, true), + ) + } } return document @@ -2288,8 +2326,8 @@ visit_proc_tags :: proc(p: ^Printer, proc_tags: ast.Proc_Tags) -> ^Document { document = cons_with_opl(document, text("#optional_ok")) } - if .Optional_Second in proc_tags { - document = cons_with_opl(document, text("#optional_second")) + if .Optional_Allocator_Error in proc_tags { + document = cons_with_opl(document, text("#optional_allocator_error")) } return document |