perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

[Cleanup] Move opcode data initialization from headers into dedicated C file

Open happy-barney opened this issue 1 year ago • 4 comments

Planned follow-ups (long run, this PR has been waiting almost 2 years):

  1. -use designated array initializers (should not make problems in internal C-files)-
  2. extend data with "not supported" message, moving for example usage of PL_no_dir_func from pp_sys.c into single PL_not_supported function
  3. provide accessor functions instead of direct data access
  • allows introduction of custom op codes, may be interesting for some grammar extension
  1. merge data into single structure
  • allows unified handling of unavailable op, see for example difference between read (handled in opcode.h) and readdir / open_dir (handled in pp_sys.c)

Example of structure declaration (here using designated initializers for readability)

#define PL_no_dir_func  "Unsupported directory function \"%s\" called"

#if defined(Direntry_t) && defined(HAS_READDIR)
#  define PL_PLATFORM_PP_READDIR Perl_pp_readdir
#else
#  define PL_PLATFORM_PP_READDIR Perl_pp_unsupported
#endif

  [OP_READDIR] = {
    .op_name = "readdir",
    .op_desc  = "readdir",
    .op_ppaddr = PL_PLATFORM_PP_READDIR,
    .op_check = Perl_ck_fun,
    .op_opargs = 0x00006b00,
    .op_private_labels = 'U',
    .op_private_bitdef_ix = 0,
    .op_unsupported = PL_no_dir_func,
  }

happy-barney avatar Aug 25 '24 16:08 happy-barney

Can you address the porting test failures reported in https://github.com/Perl/perl5/actions/runs/10548400876/job/29222271299?pr=22540, then re-push?

Issuing a pull request that is going to fail multiple tests (porting or otherwise) is not helpful to potential code reviewers.

jkeenan avatar Aug 25 '24 23:08 jkeenan

Can you address the porting test failures reported in https://github.com/Perl/perl5/actions/runs/10548400876/job/29222271299?pr=22540, then re-push?

just re-pushed ... had to rethink my approach due tests relying in symbols defined in globals.o

happy-barney avatar Aug 26 '24 03:08 happy-barney

  1. use designated array initializers (should not make problems in internal C-files)

We have developers who build perl with C++ compilers, and designated array initializers aren't in any C++ standard (g++ allows it anyway, MSVC doesn't).

tonycoz avatar Aug 28 '24 03:08 tonycoz

  1. use designated array initializers (should not make problems in internal C-files)

We have developers who build perl with C++ compilers, and designated array initializers aren't in any C++ standard (g++ allows it anyway, MSVC doesn't).

shame, such a nice feature improving readability of code :-( updating PR comment

happy-barney avatar Aug 28 '24 04:08 happy-barney