summaryrefslogtreecommitdiff
path: root/op.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't set OPf_SPECIAL on implicit attributes->import callDagfinn Ilmari Mannsåker2022-07-271-1/+1
| | | | This flag does not appear to have ever been used for anything.
* Don't set OPf_SPECIAL on ENTERSUB for lvalue sub assignmentsDagfinn Ilmari Mannsåker2022-07-271-2/+1
| | | | This flag does not appear ever have been used for anything in this context.
* Don't set the OPf_SPECIAL bit on implicit VERSION/import/export callsDagfinn Ilmari Mannsåker2022-07-271-2/+2
| | | | | | The implicit method calls use by `use` and `no` were setting the OPf_SPECIAL bit on the ENTERSUB op, but that has never made any difference to anything.
* Rename CVf_METHOD to CVf_NOWARN_AMBIGUOUSPaul "LeoNerd" Evans2022-07-261-4/+4
| | | | Also renames the CvMETHOD* macro family to CvNOWARN_AMBIGUOUS*
* Guard the older `SvPAD*` wrappers with `#ifndef PERL_CORE`Paul "LeoNerd" Evans2022-07-051-1/+1
|
* Neaten the PADNAME flag constantsPaul "LeoNerd" Evans2022-07-051-1/+1
| | | | | | | | | | | Rename the `PADNAMEt_*` constants to `PADNAMEf_*`, as they're supposed to represent bitflags, not a type enumeration. Also updated the `B` and `B::Deparse` modules to make use of the new modern names (and avoid the old `SVpad_*` flags). Also added `PADNAMEt_*` back-compat defines, guarded by `#ifndef PERL_CORE` so as not to permit their use accidentally within perl core.
* fix no bareword_filehandles for method calls as first argument of LSTOPsTony Cook2022-07-041-1/+18
| | | | | | | | | | | | | | | | | | | The original code in toke.c tried to detect a bareword as a file handle during tokenization rather than once the expression following the LSTOP has been parsed. I've moved the checking for a bareword filehandle to the ck functions for each OP in most cases, which covers most OPs except for LSTOPs like print. To handle that I've added a check in newGVREF(). This means in most cases that the error is produced just as the bareword would normally be wrapped in an OP_RV2GV. The special case for that is readline(), which does it's own rv2gv() at runtime, but it does have a ck function which can check for the bareword handle.
* Adjust comments in op.c and peep.c about the files' contentsPaul "LeoNerd" Evans2022-06-201-2/+2
|
* Split optree optimizer and finalizer from op.c into new peep.cPaul "LeoNerd" Evans2022-06-201-4001/+25
| | | | | | | | | | | * Create a new `peep.c` file * Move the functions related to optree optimisation and finalisation out of `op.c` into this new file * Several previously-static functions now have to be non-static and declared as internal API in order to be shared between these two files.
* Move the handy OpTYPE_set() macro out of op.c into op.h where other code can ↵Paul "LeoNerd" Evans2022-06-201-6/+0
| | | | | | | see it Also defend it against side-effects in arguments, by allocating temporary variables.
* Convert '!!' to cBOOL()Karl Williamson2022-06-141-2/+2
| | | | | | | | | | | | I believe the '!!' is somewhat obscure; I for one didn't know about it for years of programming C, and it was buggy in one compiler, which is why cBOOL was created, I believe. And it is graphically dense, and generally harder to read than the cBOOL() construct. This commit dates from before we moved to C99 where we can simply cast to (bool), and cBOOL() has been rewritten to do that. But the vast majority of code uses cBOOL(), and this commit brings the remainder of the core .[ch] files into uniformity.
* op.c: Improve commentsKarl Williamson2022-06-101-25/+31
|
* Appease gcc's warning that keysv may be used uninitialized in op.cPaul "LeoNerd" Evans2022-06-081-1/+1
|
* Correctly indent the body of the while{} loop in S_aassign_scan()Paul "LeoNerd" Evans2022-06-071-168/+167
|
* Also join the 'else if'Paul "LeoNerd" Evans2022-06-071-3/+2
|
* Fix indentation of a line of code in op.c to not be misleadingPaul "LeoNerd" Evans2022-06-071-2/+1
|
* Refactor warning-generating code in two different places into one common ↵Paul "LeoNerd" Evans2022-06-061-55/+55
| | | | | | | | | function The new combined function, named `S_warn_elem_scalar_context()`, is much more meaningful and useful to become exported in an intended subsequent change, than the previous (poorly-named) `S_op_pretty()` would have been.
* Make tr/// SV compiled components ReadOnlyKarl Williamson2022-06-051-2/+10
| | | | | This could trigger some optimisations, and makes it clear to maintainers that they do not get modified.
* Mark internal and document op_refcnt_lock/unlock()Karl Williamson2022-05-071-0/+16
|
* perlapi: Consolidate load_module(_nocontext)?Karl Williamson2022-05-031-7/+7
|
* for my ($x) ...: fix handling of degenerate 1-varDavid Mitchell2022-04-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new for my ($x,$y,...) (...) { ... } syntax has a couple of problems in the degenerate case of a single variable: for my ($x) (...) { ... } First, the loop variable is marked as lexical, but not as a variable to be introduced. So it behaves roughly as if written like: { my $x; for $x (...) { ... } } I can't think of any user-visible runtime change in behaviour this bug causes, so I haven't included a test for it. Second, it was being incorrectly deparsed as for $x (...) { ... } (i.e. without the 'my'). This commit fixes both of these issues. The basic problem is that the parser, in the case of multiple vars, passes a list subtree of PADSVs as the 'sv' argument of Perl_newFOROP, but in the case of a single var, passes a single PADSV op instead. This single PADSV doesn't have the LVINTRO flag set, so is indistinguishable from plain my $x; for $x .... This commit makes the parser set the OPf_PARENS flag on the lone PADSV to signal to newFOROP() that it's a degenerate 1-var list, and newFOROP() sets the OPf_PARENS flag on the ENTERITER op to signal to the deparser that this is "for my (...)" syntax, even if it only has a single var.
* No need to document 'useless use of sort in scalar context' separately now ↵Paul "LeoNerd" Evans2022-03-141-1/+1
| | | | there's a general category for it
* Move sort's scalar context warning to new 'scalar' categoryPaul "LeoNerd" Evans2022-03-081-1/+1
|
* assert() PL_parser before trying to dereference itPaul "LeoNerd" Evans2022-03-071-0/+1
|
* Inlined newSV_type(SVt_NULL) leaner than non-inlined newSV(0)Richard Leach2022-03-071-3/+3
| | | | | | | | | | | | When a function outside of sv.c creates a SV via newSV(0): * There is a call to Perl_newSV * A SV head is uprooted and its flags set * A runtime check is made to effectively see if 0 > 0 * The new SV* is returned Replacing newSV(0) with newSV_type(SVt_NULL) should be more efficient, because (assuming there are SV heads to uproot), the only step is: * A SV head is uprooted and its flags set
* Reapply squashed "avoid identical stack traces" patchesYves Orton2022-02-191-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reapplies two reverted patches as a single squashed commit. Revert "Revert "avoid identical stack traces"" This reverts commit 79f75eaa716307235be78834c99ba0599a00319b which itself reverted f2f32cd638746f538da6db804dab6dd54e654f30 Revert "Revert "fixup to "avoid identical stack traces" - try 2"" This reverts commit 2abf7efcc0ff8978340af661cb333175a899a84e which itself reverted ad89278aa25475fb03971aec66692e18e35d9c07 Original Author: David Mitchell <davem@iabyn.com> Original Date: Fri Dec 13 13:48:25 2019 +0000 avoid identical stack traces GH #15109 The output of caller() (e.g. as produced by carp::Confess) produces multiple identical outputs when within a nested use/require. This is because at the time of calling the 'BEGIN { require ... }', PL_curcop is set to &PL_compiling, which is a fixed buffer within the interpreter, whose individual file and line fields are saved and restored when doing a new require/eval. This means that within the innermost require, PL_compiling has file:lineno of the innermost source file, and multiple saved PL_curcop values in the context stack frames all point to the same &PL_copmpiling. So all levels of the stack trace appear to come from the innermost file. This commit fixes this (after a fashion) by, at the start of calling a BEGIN, making PL_curcop point to a temporary copy of PL_compiling instead. This is all a bit of a hack.
* Might as well just do numerical comparisons against shortver rather than ↵Paul "LeoNerd" Evans2022-02-131-3/+2
| | | | creating new temporary "version" objects
* Print a deprecation warning if downgrading to a use VERSION below v5.11Paul "LeoNerd" Evans2022-02-131-1/+10
|
* Add a PL_prevailing_version interpreter varPaul "LeoNerd" Evans2022-02-131-0/+30
| | | | | | Save/restore PL_prevailing_version at SAVEHINTS time Have PL_prevailing_version track the applied use VERSION currently in scope
* Favour switch over if/else if to improve readabilityBranislav Zahradník2022-02-051-5/+6
|
* Emit experimental::snail_in_signatures warnings on uses of @_ (aka "snail") ↵Paul "LeoNerd" Evans2022-01-311-0/+56
| | | | in signatured subs
* Add '=cut' to silence POD formatting warningJames E Keenan2022-01-211-0/+1
|
* 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.)