Commit Graph

33 Commits

Author SHA1 Message Date
Rui Ueyama e0bf168041 Add long double 2020-12-07 12:00:06 +09:00
Rui Ueyama 31087f8d4b Handle inline functions as static functions 2020-12-07 12:00:06 +09:00
Rui Ueyama 9c36dd727c Make "main" to implicitly return 0 2020-12-07 12:00:06 +09:00
Rui Ueyama e0b5da3b39 Dereferencing a function shouldn't do anything
This is an oddity in the C spec, but you can apply the unary `*`
operator to a function as many times as you want. `*x` and `x`
means exactly the same, given that `x` is a function.
2020-12-07 12:00:06 +09:00
Rui Ueyama d7bad96114 Allow to define a function returning a struct 2020-12-07 12:00:06 +09:00
Rui Ueyama c72df1c9be Allow to call a fucntion returning a struct 2020-12-07 12:00:06 +09:00
Rui Ueyama d63b1f410a Allow struct argument 2020-12-07 12:00:06 +09:00
Rui Ueyama 5e0f8c47e3 Allow struct parameter 2020-12-07 12:00:06 +09:00
Rui Ueyama 9021f7f5de Support passed-on-stack parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama b29f052102 Support passed-on-stack arguments 2020-12-07 12:00:06 +09:00
Rui Ueyama 82ba010c76 [GNU] Add __FUNCTION__ 2020-12-07 12:00:06 +09:00
Rui Ueyama ba6b4b6375 Add __func__ 2020-12-07 12:00:06 +09:00
Rui Ueyama c5953ba132 Decay a function to a pointer in the func param context 2020-12-07 12:00:06 +09:00
Rui Ueyama d06a8ac6e6 Add function pointer 2020-12-07 12:00:06 +09:00
Rui Ueyama e452cf7215 Support variadic function with floating-point parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama 8b14859f63 Implement default argument promotion for float 2020-12-07 12:00:06 +09:00
Rui Ueyama c6b30568b4 Allow to define a function that takes/returns flonums 2020-12-07 12:00:06 +09:00
Rui Ueyama 8ec1ebf176 Allow to call a function that takes/returns flonums 2020-12-07 12:00:06 +09:00
Rui Ueyama 34ab83bdf4 Add unsigned integral types 2020-12-07 12:00:06 +09:00
Rui Ueyama 754a24fafc Add va_start to support variadic functions 2020-12-07 12:00:06 +09:00
Rui Ueyama 58fc86137c Allow to call a variadic function 2020-12-07 12:00:06 +09:00
Rui Ueyama dcd4579226 Handle a function returning bool, char or short
x86-64 psABI says that only the least significant 8 bits are
significant if RAX has a return value of a function returning bool.
Likewise, it looks like only the least significant 1 or 2 bytes
are guaranteed to have a correct value for char and short return
values, respectively.
2020-12-07 12:00:06 +09:00
Rui Ueyama 30b3e216cd Add return that doesn't take any value 2020-12-07 12:00:06 +09:00
Rui Ueyama 319772b42e Add static local variables 2020-12-07 12:00:06 +09:00
Rui Ueyama 7a1f816783 Accept `void` as a parameter list
`foo(void)` indicate that function foo does not take a parameter.
2020-12-07 12:00:06 +09:00
Rui Ueyama 79632219d0 Decay an array to a pointer in the func param context 2020-12-07 12:00:06 +09:00
Rui Ueyama 736232f3d6 Support file-scope functions 2020-12-07 12:00:05 +09:00
Rui Ueyama 44bba965cb Add _Bool type
_Bool isn't just a 1-bit integer because when you convert a value
to bool, the result is 1 if the original value is non-zero. This
is contrary to the other small integral types, e.g. char, as you
can see below:

  char x  = 256; // x is 0
  _Bool y = 256; // y is 1
2020-12-07 12:00:05 +09:00
Rui Ueyama fdc80bc6b5 Handle function argument type conversion 2020-12-07 12:00:05 +09:00
Rui Ueyama 818352acc0 Handle return type conversion 2020-12-07 12:00:05 +09:00
Rui Ueyama 9d48eef58b Add short type 2020-10-15 14:22:16 +09:00
Rui Ueyama 43c2f0829f Add long type 2020-10-15 14:22:16 +09:00
Rui Ueyama cd832a311e Rewrite tests in shell script in C 2020-10-15 14:22:15 +09:00