diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 9a2e120b..3193c266 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -1455,40 +1455,18 @@ ;; Hmm? ((expr-stmt (cond-expr ,test ,then ,else)) - (let* ((text-length (length text)) - - (test-jump->info ((test->jump->info info) test)) - (test+jump-info (test-jump->info 0)) - (test-length (length (.text test+jump-info))) - - (then-info ((ast->info test+jump-info) then)) - (text-then-info (.text then-info)) - (then-text (list-tail text-then-info test-length)) - (then-length (length (object->list then-text))) - - (jump-text (wrap-as (i386:Xjump 0))) - (jump-length (length (object->list jump-text))) - - (test+then+jump-info - (clone then-info - #:text (append (.text then-info) jump-text))) - - (else-info ((ast->info test+then+jump-info) else)) - (text-else-info (.text else-info)) - (else-text (list-tail text-else-info (length (.text test+then+jump-info)))) - (else-length (length (object->list else-text))) - - (text+test-text (.text (test-jump->info (+ then-length jump-length)))) - (test-text (list-tail text+test-text text-length)) - (jump-text (wrap-as (i386:Xjump else-length)))) - - (clone info #:text - (append text - test-text - then-text - jump-text - else-text) - #:globals (.globals else-info)))) + (let* ((source (with-output-to-string (lambda () (pretty-print-c99 `(cond-expr ,test (ellipsis) (ellipsis)))))) + (info (append-text info (wrap-as `(#:comment ,source)))) + (here (number->string (length text))) + (else-label (string-append (.function info) "_else_" here)) + (break-label (string-append (.function info) "_break_" here)) + (info ((test-jump-label->info info else-label) test)) + (info ((ast->info info) then)) + (info (append-text info (wrap-as (i386:jump-label `(#:local ,break-label))))) + (info (append-text info (wrap-as `(#:label ,else-label)))) + (info ((ast->info info) else)) + (info (append-text info (wrap-as `(#:label ,break-label))))) + info)) ((switch ,expr (compd-stmt (block-item-list . ,statements))) (let* ((clauses (statements->clauses statements))