fix: warnings for 'c-run-time.c'
Creates different arities for DFLN.
typedef dylan_value (*DLFN0)(void); typedef dylan_value (*DLFN1)(dylan_value); typedef dylan_value (*DLFN2)(dylan_value, dylan_value); ... etc
Changing DLFN to a union
typedef union { void* raw; DLFN0 mep0; DLFN1 mep1; DLFN2 mep2; DLFN3 mep3; DLFN4 mep4; DLFN5 mep5; DLFN6 mep6; DLFN7 mep7; DLFN8 mep8; DLFN9 mep9; DLFN10 mep10; DLFN64 mep64; } DLFN;
Then rewrite the call logic using the correct type per arity.
switch (teb->argument_count) { case 0: return (mep.mep0)(); case 1: return (mep.mep1)(v[0]); ...
Closes #1650
If the premise isn't valid, please suggest an alternative and I'll start over. There are parts where I'm not sure it's correct, so I think it needs more work.
This passes 3-stage bootstrap and make check on my machine, with only these two warnings in the run-time code:
posix-threads.c:1682:12: warning: unused function 'priority_map' [-Wunused-function]
static int priority_map(int dylan_priority)
^
posix-threads.c:235:35: warning: unused function 'get_current_thread_handle' [-Wunused-function]
PURE_FUNCTION static inline void *get_current_thread_handle(void)
^
@cgay
The warnings of posix-threads.c are easier to solve, but it requires to know what is the purpose of the code. Is not needed and can be deleted? The code stay but this warnings should be suppressed?
Setting the default backend compiler to C and doing bootstrap, in the stage-2, it shows this errors:
Internal error: Link failed: Link failed: In file included from command-line.c:1:
command-line.c: In function ‘Kdo_execute_commandVcommandsMdylan_compilerM0I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:2882:21: note: in expansion of macro ‘CONGRUENT_CALL1’
2882 | serverF31 = CONGRUENT_CALL1(context_);
| ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:2922:27: note: in expansion of macro ‘CONGRUENT_CALL1’
2922 | serverF37 = CONGRUENT_CALL1(context_);
| ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:2941:27: note: in expansion of macro ‘CONGRUENT_CALL1’
2941 | serverF40 = CONGRUENT_CALL1(context_);
| ^~~~~~~~~~~~~~~
command-line.c: In function ‘Kanonymous_of_do_execute_commandF250I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3049:15: note: in expansion of macro ‘CONGRUENT_CALL1’
3049 | server_ = CONGRUENT_CALL1(CREF(2));
| ^~~~~~~~~~~~~~~
command-line.c: In function ‘KrunF245I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:827:37: error: called object is not a function or function pointer
827 | ((((ENGINE*)get_teb()->function)->entry_point)((a1),(a2)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3087:15: note: in expansion of macro ‘CONGRUENT_CALL2’
3087 | filename_ = CONGRUENT_CALL2(&KLfile_locatorGYlocatorsVsystem, T5);
| ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3092:8: note: in expansion of macro ‘CONGRUENT_CALL1’
3092 | T8 = CONGRUENT_CALL1(T7);
| ^~~~~~~~~~~~~~~
command-line.c: In function ‘Kexecute_main_commandYconsole_environmentVdylan_compilerMM0I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:827:37: error: called object is not a function or function pointer
827 | ((((ENGINE*)get_teb()->function)->entry_point)((a1),(a2)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3153:14: note: in expansion of macro ‘CONGRUENT_CALL2’
3153 | parts_ = CONGRUENT_CALL2(&KLlistGVKd, T13);
| ^~~~~~~~~~~~~~~
command-line.c: In function ‘Kexecute_main_loopYconsole_environmentVdylan_compilerMM0I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3352:13: note: in expansion of macro ‘CONGRUENT_CALL1’
3352 | server_ = CONGRUENT_CALL1(context_);
| ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
825 | ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3367:8: note: in expansion of macro ‘CONGRUENT_CALL1’
3367 | T4 = CONGRUENT_CALL1(context_);
| ^~~~~~~~~~~~~~~
Exiting with return code 9