type #t, an enum's constants and the bitwise names
None had a rule. A constant is typed as its enum, where C says int, so that the enum's ops are found through it. And bit-and, bit-not and the rest were respelled bit_and before fmt-c could see them, and called.
This commit is contained in:
@@ -360,7 +360,14 @@ whitespace aside, THEN?"
|
||||
(test-assert "c-or is still accepted"
|
||||
(emits? (in-fn "(var x int (c-or a b))") "a || b"))
|
||||
(test-assert "c-bit-or is still accepted"
|
||||
(emits? (in-fn "(var x int (c-bit-or a b))") "a | b")))
|
||||
(emits? (in-fn "(var x int (c-bit-or a b))") "a | b"))
|
||||
;; the names fmt-c has cases for were respelled bit_and before it
|
||||
;; saw them, and called as functions
|
||||
(test-assert "and so are the named ones"
|
||||
(emits? (in-fn "(var x _ (bit-and a b)) (var y _ (bit-or a b)) (var z _ (bit-xor a b))")
|
||||
"int z = a ^ b"))
|
||||
(test-assert "bit-not among them"
|
||||
(emits? (in-fn "(var x _ (bit-not a))") "int x = ~a")))
|
||||
|
||||
;; A `;' comment is a form. In a macro body `comment' is a no-op
|
||||
;; that swallows the comment itself. Inside a quasiquoted payload
|
||||
@@ -823,6 +830,15 @@ whitespace aside, THEN?"
|
||||
"a function's types are written out"))
|
||||
;; a call was typed by asking the global table what a function of
|
||||
;; that name returns, which a local pointer is not
|
||||
;; none of these had a rule
|
||||
(test-assert "#t is a bool, as true is"
|
||||
(emits? (in-fn "(var t _ #t)") "bool t = 1"))
|
||||
(test-assert "an enum's constant is the enum, whose ops it can call"
|
||||
(emits? "(enum color (red green)) (fn f () void (var c _ green))" "enum color c = green"))
|
||||
(test-assert "a bit-not is its operand, promoted"
|
||||
(emits? (in-fn "(var u (unsigned int) 1) (var v _ (~ u))") "unsigned int v = ~u"))
|
||||
(test-assert "a char's to an int"
|
||||
(emits? (in-fn "(var c char 1) (var w _ (bit-not c))") "int w = ~c"))
|
||||
(test-assert "a call through a local function pointer"
|
||||
(emits? (string-append "(fn area ((w int) (h int)) int (return (* w h)))"
|
||||
"(fn f () void (var p (fn ((int) (int)) int) area) (var r _ (p 3 4)))")
|
||||
|
||||
Reference in New Issue
Block a user