mescc: Tinycc support: Compound strings as function argument.

* module/language/c99/compiler.mes (expr->accu): Handle compound
  strings as function argument.
* module/mes/M1.mes (object->M1): Call error when string not found.
* scaffold/tests/t.c: Test it.
This commit is contained in:
Jan Nieuwenhuizen 2018-05-14 22:37:53 +02:00
parent 209f9cc599
commit 345d0d8413
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
3 changed files with 9 additions and 4 deletions

View file

@ -942,6 +942,12 @@
(info (clone info #:globals globals))) (info (clone info #:globals globals)))
(append-text info (list (i386:label->accu `(#:string ,string)))))) (append-text info (list (i386:label->accu `(#:string ,string))))))
((p-expr (string . ,strings))
(let* ((string (apply string-append strings))
(globals ((globals:add-string globals) string))
(info (clone info #:globals globals)))
(append-text info (list (i386:label->accu `(#:string ,string))))))
((p-expr (fixed ,value)) ((p-expr (fixed ,value))
(let ((value (cstring->number value))) (let ((value (cstring->number value)))
(append-text info (wrap-as (i386:value->accu value))))) (append-text info (wrap-as (i386:value->accu value)))))
@ -954,9 +960,6 @@
(let ((char (char->integer (car (string->list char))))) (let ((char (char->integer (car (string->list char)))))
(append-text info (wrap-as (i386:value->accu char))))) (append-text info (wrap-as (i386:value->accu char)))))
((p-expr (string . ,strings))
(append-text info (list (i386:label->accu `(#:string ,(apply string-append strings))))))
(,char (guard (char? char)) (append-text info (wrap-as (i386:value->accu char)))) (,char (guard (char? char)) (append-text info (wrap-as (i386:value->accu char))))
((p-expr (ident ,name)) ((p-expr (ident ,name))

View file

@ -110,7 +110,7 @@
(let ((index (list-index (lambda (s) (equal? s o)) strings))) (let ((index (list-index (lambda (s) (equal? s o)) strings)))
(if index (if index
(string-append "_string_" file-name "_" (number->string index)) (string-append "_string_" file-name "_" (number->string index))
""))) (error "no such string:" o))))
(define (text->M1 o) (define (text->M1 o)
(cond (cond
((char? o) (text->M1 (char->integer o))) ((char? o) (text->M1 (char->integer o)))

View file

@ -153,6 +153,8 @@ main (int argc, char* argv[])
if (lst[i+1] != i) if (lst[i+1] != i)
return 30 + i; return 30 + i;
} }
puts ("foo"
"bar");
return 0; return 0;
} }