summaryrefslogtreecommitdiff
path: root/op.c
Commit message (Collapse)AuthorAgeFilesLines
* Ensure that forbidden control flow messages about finally blocks say ↵Paul "LeoNerd" Evans2022-01-201-4/+5
| | | | "finally" and not "defer"
* Add op_wrap_finally() convenience functionPaul "LeoNerd" Evans2022-01-201-0/+26
|
* Make sure to rpeep() the body of catch {} blocksPaul "LeoNerd" Evans2022-01-201-0/+6
|
* make a sort with zero args a compile-time errDavid Mitchell2022-01-191-0/+3
| | | | | | | | | | | | | @a = sort @empty; # unaffected @a = sort; # now a compile-time error the main motivation for this is to potentially be able to treat a colon following the 'sort' keyword as part of the sort expression, to then be able to add sort attributes at some point, e.g. @a = sort :num, 1,2,3; rather than the colon being seen as part of a ?: conditional. See http://nntp.perl.org/group/perl.perl5.porters/262425.
* Give blessed() the same TRUEBOOL optimisation that ref() has in boolean contextsPaul "LeoNerd" Evans2021-12-081-1/+4
|
* newSVpvn_flags().. is more efficient than sv_2mortal(newSVpvn(..))Richard Leach2021-11-291-3/+3
| | | | The same holds for newSVpvs* wrappers around newSVpvn* functions.
* Add CopFILEAVn() and use it when cleaning up COP pointersTony Cook2021-11-151-1/+1
| | | | | | | | | | | | | | On threaded builds CopFILEAV() calls gv_fetchfile(), which always created the *{"::_<filenamehere"} glob, so the attempted clean up here could recreate the glob, even if it has already been removed when cleaning up a string eval. To avoid this, add CopFILEAVn() that never creates the glob, nor the AV so that the clean up never adds new objects. This change makes the check for PL_phase unnecessary, but that check is much cheaper than the call for gv_fetchfile_flags() that the macro hides, so retain the check.
* don't try to clean up the COP pointer during global destructionTony Cook2021-11-151-1/+5
| | | | | | | | | | At this point there should be no further debugging code trying to use the COP pointer. On threaded builds the call to CopFILEAV() could cause a segmentation fault, since during late destruction gv_fetchfile() could return NULL, which the threaded version of CopFILEAV() would blindly call GvAV() on.
* remove cop addressed from saved lines when the cop is freedTony Cook2021-11-151-0/+14
| | | | | | | This could cause a bad read and write when the debugger tried to set a breakpoint on the line. Fixed #19198
* op.c: use %zd to format PADOFFSET valuesDagfinn Ilmari Mannsåker2021-10-201-2/+2
| | | | | PADOFFSET is SSize_t, so %lu is wrong even if long and SSize_t are the same size.
* Generate the optree for n-at-a-time for loops.Nicholas Clark2021-10-151-4/+63
| | | | | | Perl_newFOROP can now also take an OP_LIST corresponding to two or more lexicals to iterate over n-at-a-time, where those lexicals are all declared in the for statement, and occupy consecutive pad slots.
* Remove NetWare supportDagfinn Ilmari Mannsåker2021-10-081-7/+0
| | | | The build has been broken since 2009.
* add OPpUSEINT op_private flag bitDavid Mitchell2021-10-071-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | The bitwise ops, such as a '<<', have an op_private flag that is set when compiled within the scope of 'use integer;'. Unfortunately, due to historical reasons, the defined flag that indicates this bit (bit 0) is HINT_INTEGER rather than an OPpfoo define. But HINT_INTEGER is supposed to represent a bit within PL_hints, not a bit within op_private. If someone reorganised the flags in PL_hints at some point, it would mess up bitwise ops. So this commit: 1) adds a new flag, OPpUSEINT, to indicate the bit within op_private. 2) Changes this flag's value from 0x1 to 0x4 to force it to be different than HINT_INTEGER - thus potentially flushing out any misuse of this flag anywhere (in core or XS code). 3) tells regen/op_private that the lower two bits of op_private in bitwise ops don't contain the argument count. They never did, but not specifying that in regen/op_private meant that the debugging code in op_free() never spotted the unknown bit 0 sometimes being set. 4) Also tell that debugging code to skip the test if the op is banned. This fixes a new fail in dist/Safe/t/safeops.t which was croaking about a banned op having an unrecognised op_private flag bit set before ck_bitop() had a chance to delete the arg count in op_private.
* Prefix "unexpected constant lvalue entersub" with "panic: "Nicholas Clark2021-09-181-1/+1
| | | | | | | | | | | | In Sep 1999 commit cd06dffe59d6 added various "internal error" croak()s: initial implementation of lvalue subroutines (slightly fixed version of patch suggested by Ilya Zakharevich, which in turn is based on the one suggested by Tuomas J. Lukka <lukka@iki.fi>) One was "panic: unexpected lvalue entersub entry via type/targ %ld:%ld" Another "Unexpected constant lvalue entersub entry via type/targ %ld:%ld" Prefix the latter with "panic: " to make it consistent.
* Second arg to force_list() is bool, so it should be written TRUE or FALSEPaul "LeoNerd" Evans2021-09-151-12/+12
|
* Create `defer` syntax and `OP_PUSHDEFER` opcodePaul "LeoNerd" Evans2021-08-251-0/+38
| | | | | | | | | | | | | | | Adds syntax `defer { BLOCK }` to create a deferred block; code that is deferred until the scope exits. This syntax is guarded by use feature 'defer'; Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field gives the start of an optree to be deferred until scope exit. That op pointer will be stored on the save stack and invoked as part of scope unwind. Included is support for `B::Deparse` to deparse the optree back into syntax.
* Enable warnings on «use v5.35»Leon Timmermans2021-08-151-0/+3
|
* Remove the flags OPpSORT_STABLE and OPpSORT_UNSTABLE.Nicholas Clark2021-07-311-13/+0
| | | | | | Remove the code in Perl_ck_sort() that reads from PL_hintgv that sets these, and the code in pp_sort that reads them and sets SORTf_STABLE and SORTf_UNSTABLE (which were no longer read. Remove these too.)
* Where the key is an SV, replace some hv_* calls with hv_*_ent equivalents.Nicholas Clark2021-07-261-6/+4
| | | | | This avoids the SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr) code dance.
* op.c: Remove leading tabKarl Williamson2021-07-251-1/+1
| | | | | This was the only remaining, non-generated base-level leading tab, and so resolves GH #18792
* warn when using each on an anonymous hash or arrayTony Cook2021-07-061-1/+67
| | | | | | | We've had three tickets over the years where the user has been confused by the behaviour of each on an anonymous array or hash, there's no way to tell if other users have been struck by the same issue, so make it easier to diagnose by producing a warning.
* scalarseq() should not put an OP_ENTER kid into scalar context (fixes #18855)Paul "LeoNerd" Evans2021-06-171-2/+7
|
* Rename scalarseq() to a somewhat more meaningful voidnonfinal()Paul "LeoNerd" Evans2021-06-161-7/+8
|
* replace all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITYTomasz Konojacki2021-06-091-2/+2
| | | | | | | | | | | | Since the removal of PERL_OBJECT (acfe0abcedaf592fb4b9cb69ce3468308ae99d91) PERL_IMPLICIT_CONTEXT and MULTIPLICITY have been synonymous and they're being used interchangeably. To simplify the code, this commit replaces all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITY. PERL_IMPLICIT_CONTEXT will stay defined for compatibility with XS modules.
* Rename G_ARRAY to G_LIST; provide back-compat when not(PERL_CORE)Paul "LeoNerd" Evans2021-06-021-4/+4
|
* Base *.[ch] files: Replace leading tabs with blanksMichael G Schwern2021-05-311-4633/+4633
| | | | | | | This is a rebasing by @khw of part of GH #18792, which I needed to get in now to proceed with other commits. It also strips trailing white space from the affected files.
* Make scalar assignment to undef a compile time errorRichard Leach2021-05-251-0/+2
|
* OP_ENTERTRY no longer needs to handle OPf_SPECIAL flagPaul "LeoNerd" Evans2021-02-141-3/+0
|
* A totally new optree structure for try/catch involving three new optypesPaul "LeoNerd" Evans2021-02-141-11/+90
|
* Add a newTRYCATCHOP(); migrate the custom code out of perly.y into itPaul "LeoNerd" Evans2021-02-141-0/+42
|
* Avoid read-after-free of o->op_flags in Perl_ck_eval()Paul "LeoNerd" Evans2021-02-091-1/+2
|
* Initial attempt at feature 'try'Paul "LeoNerd" Evans2021-02-041-0/+2
| | | | | | | | | * Add feature, experimental warning, keyword * Basic parsing * Basic implementation as optree fragment See also https://github.com/Perl/perl5/issues/18504
* Update comment after 5b354d2a8aHugo van der Sanden2021-01-051-1/+1
| | | | | The specified commit fixed a bug by treating ($x, undef) on the LHS as 2 scalars; this comment should have been updated to match.
* add a bareword_filehandles feature, which is enabled by defaultTony Cook2021-01-041-0/+23
| | | | This disables use of bareword filehandles except for the built-in handles
* op.c: croak on "my $_" when "use utf8" is in effectTomasz Konojacki2020-12-301-7/+9
| | | | Fixes #18449
* skip trying to constant fold an incomplete op treeTony Cook2020-12-231-1/+1
| | | | | | | | | | | | | | | This code would try to constant fold an op tree like relop +- null +- constant which would underflow the stack, potentially crashing perl. This is intended as a quick fix rather than as a complete solution. Fixes #18380
* Remove empty "#ifdef"sTom Hukins2020-12-081-4/+0
|
* Fix unitialized warnings in S_pmtransNicolas R2020-11-061-1/+1
|
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-9/+9
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* Perl_custom_op_get_field(): remove undef behaviourDavid Mitchell2020-10-301-8/+6
| | | | | | | | | | | | | | | | | | | Thus function has a couple a switches with default: NOT_REACHED; /* NOTREACHED */ but clang is complaining that the value returned by the function is undefined if those default branches are taken, since the 'any' variable doesn't get set in that path. Replace the NOTREACHED with a croak("panic: ..."). It's possible (albeit not intended) for Perl_custom_op_get_field() to be called with a 'field' arg which triggers the default case. So if this ever happens, make it clear that something has gone wrong, rather than just silently continuing on non-debugging builds. In any case, this shuts up clang.
* Document newSUB, newATTRSUBKarl Williamson2020-10-061-0/+11
|
* Document vload_moduleKarl Williamson2020-09-051-0/+3
|
* perlapi: capitalize 'op'Karl Williamson2020-09-051-1/+1
|
* Reorganize perlapiKarl Williamson2020-09-041-1/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Change some =head1 to apidoc_section linesKarl Williamson2020-09-041-8/+8
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* Document a bunch of foo_nocontext functionsKarl Williamson2020-08-231-0/+5
| | | | These just refer to foo's pod, with an explanation of 'nocontext'
* Use av_top_index() instead of av_tindex()Karl Williamson2020-08-191-1/+1
| | | | | | | I was never happy with this short form, and other people weren't either. Now that most things are better expressed in terms of av_count, convert the few remaining items that are clearer when referring to an index into using the fully spelled out form
* list assign in list context was over-optimisingDavid Mitchell2020-08-111-3/+7
| | | | | | | | | | | | | | | | | | | GH #17816 This code: my $x = 1; print (($x, undef) = (2 => $x)); was printing "22" when it should have been printing "21". An optimisation skips the 'common values on both sides' test when the LHS of an assign only contains a single var; as the example above shows, this is not sufficient. This was broken by v5.23.1-202-g808ce55782 This commit fixes it by counting undef's on the LHS towards the var count if they don't appear first.
* add a default enabled feature "multidimensional"Tony Cook2020-08-101-3/+11
| | | | | | Like "indirect" this feature is enabled by default and enables the perl4 hash-based multidimensional array emulation documented under $; in perlvar.
* re-work opslab handling to avoid non-portable alignment assumptionsTony Cook2020-07-301-40/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #17871 The op slab allocator code made the assumption that since OP and hence OPSLOT contain pointers, the base of each of those would be an integral number of sizeof(pointer) (pointer units) from the beginning of OPSLAB. This assumption is non-portable, and broke calculating the location of the slab based on the address of the op slot and the op slot offset on m68k platforms. To avoid that, this change now stores the opslot_offset as the offset in pointer units from the beginning of opslab_slots rather than from the beginning of the slab. If alignment on a pointer boundary for OPs is required, the compiler will align opslab_opslots and since we work in pointer units from there, any allocated op slots will also be aligned. If we assume PADOFFSET is no larger than a pointer and requires no stricter alignment and structures in themselves have no stricter alignment requirements then since we work in pointer units all core OP structures should have sufficient alignment (if this isn't true, then it's not a new problem, and not the problem I'm trying to solve here.) I haven't been able to test this on m68k hardware (the emulator I tried to use can't maintain a network connection.)