diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-21 23:22:56 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-21 23:22:56 +0200 |
| commit | 0ff1e12ce89cf5d97625a73d1240b352e32400f2 (patch) | |
| tree | a5480ec46633af27340ccaad26779d23721ed903 | |
| parent | 6070844d69cab5b4a5bb50473bd6ccc2343ff7dd (diff) | |
| parent | f814d3e9791c9ef6dc3c002017f0d949224e6b44 (diff) | |
Merge branch 'master' of github.com:DanielGavin/ols
| -rw-r--r-- | odinfmt.bat | 2 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 21 | ||||
| -rw-r--r-- | tools/odinfmt/flag/flag.odin | 2 |
3 files changed, 14 insertions, 11 deletions
diff --git a/odinfmt.bat b/odinfmt.bat index a50406c..19c0202 100644 --- a/odinfmt.bat +++ b/odinfmt.bat @@ -1 +1 @@ -odin build tools/odinfmt -show-timings -collection:shared=src -out:odinfmt -opt:2
\ No newline at end of file +odin build tools/odinfmt -show-timings -collection:shared=src -out:odinfmt.exe -o:minimal
\ No newline at end of file diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index f0d718b..9a22c8b 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1200,18 +1200,21 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, called_from: Expr_Called_Type = if v.type != nil { document = cons_with_nopl(document, visit_expr(p, v.type)) - } - - if matrix_type, ok := v.type.derived.(^ast.Matrix_Type); ok && is_matrix_type_constant(matrix_type) { - document = cons_with_opl(document, visit_begin_brace(p, v.pos, .Generic)) - set_source_position(p, v.open) - document = cons(document, nest(p.indentation_count, cons(newline_position(p, 1, v.elems[0].pos), visit_matrix_comp_lit(p, v, matrix_type)))) - set_source_position(p, v.end) + if matrix_type, ok := v.type.derived.(^ast.Matrix_Type); ok && is_matrix_type_constant(matrix_type) { + document = cons_with_opl(document, visit_begin_brace(p, v.pos, .Generic)) + + set_source_position(p, v.open) + document = cons(document, nest(p.indentation_count, cons(newline_position(p, 1, v.elems[0].pos), visit_matrix_comp_lit(p, v, matrix_type)))) + set_source_position(p, v.end) - document = cons(document, cons(newline(1), text_position(p, "}", v.end))) + document = cons(document, cons(newline(1), text_position(p, "}", v.end))) + + break + } } - else if (should_align_comp_lit(p, v^) || contains_comments_in_range(p, v.pos, v.end)) && (called_from == .Value_Decl || called_from == .Assignment_Stmt) && len(v.elems) != 0 { + + if (should_align_comp_lit(p, v^) || contains_comments_in_range(p, v.pos, v.end)) && (called_from == .Value_Decl || called_from == .Assignment_Stmt) && len(v.elems) != 0 { document = cons_with_opl(document, visit_begin_brace(p, v.pos, .Generic)) set_source_position(p, v.open) diff --git a/tools/odinfmt/flag/flag.odin b/tools/odinfmt/flag/flag.odin index 8d57a06..010a48b 100644 --- a/tools/odinfmt/flag/flag.odin +++ b/tools/odinfmt/flag/flag.odin @@ -146,7 +146,7 @@ reflect_args_structure :: proc(ctx: ^Flag_Context, v: any) -> Flag_Error { type := types[i]; if named_type, ok := type.variant.(Type_Info_Named); ok { - if union_type, ok := named_type.base.variant.(Type_Info_Union); ok && union_type.maybe && len(union_type.variants) == 1 { + if union_type, ok := named_type.base.variant.(Type_Info_Union); ok && len(union_type.variants) == 1 { flag.optional = true; flag.tag_ptr = rawptr(uintptr(union_type.tag_offset) + uintptr(v.data) + uintptr(offsets[i])); type = union_type.variants[0]; |