Open cayhorstmann opened 1 year ago
We need to capture the type of the C function, not just its name. Right now, Language.java has a functionName
method that finds the name. We'd like functionType
. But not all functions have types (e.g. in Python, JavaScript, etc.) So the default in Language
should return null
, but in CLanguage
override to produce a type. The type is everything before the name, with spaces and modifiers (const
, static
, extern
) removed, e.g. int
, double
, bool
, char
, char*
.
Modify Calls.Call
to have a String type
field. Set it in addCall
to the result of calling functionName
. It will be null
for all languages other than C. That's ok.
In CLanguage.writeTester
, ask for the type
of the Call
object and produce calls to print_int
, print_double
, print_char_pointer
, print_bool
, print_char
. Those are the only supported ones. Otherwise call print_unsupported
.
Define those functions in a file codecheck_c.h that you include like the C++ language does. They just call printf
. Or skip the functions and call printf
directly.
Make a progfileCodeCheck.c with the contents
where T is derived from the return type (
print_int
,print_double
,print_char_pointer
,print_bool
,print_char
, ...). If the return type is something else, the instructor/student code must contain a function print_T.