summaryrefslogtreecommitdiff
path: root/pad.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix typo of 'compilation' in docs in pad.cPaul "LeoNerd" Evans2023-02-191-1/+1
|
* Fix a bunch of memory leaks in feature 'class'Paul "LeoNerd" Evans2023-02-171-1/+14
| | | | | | | | | | | * Free the attrlist OP fragment when applying class or field attribute * Free the OP_PADxV ops we only use to get the pad index out for fieldvar declarations * Add a refcount to the `struct padname_fieldinfo` to keep track of its capture in inner closures so it can be freed at the right time * Free the class-related fields out of HvAUX * Free the actual ObjectFIELDS() array when destroying an object instance * Dup fieldinfo->paramname at sv_dup() time / free it at free time
* Ensure that sv_dup() handles new class structuresPaul "LeoNerd" Evans2023-02-131-0/+10
| | | | | | | It needs to: * clone SVt_PVOBJ instances * clone the xhv_class_* fields of an SVt_PVHV * clone the PadnameFIELDINFO structure of a padname
* Provide padname_dup_inc() and padnamelist_dup_inc()Paul "LeoNerd" Evans2023-02-131-5/+2
|
* Move the macros which wrap sv_dup_inc() into sv.hPaul "LeoNerd" Evans2023-02-131-2/+0
|
* Initial attack at basic 'class' featurePaul "LeoNerd" Evans2023-02-101-6/+39
| | | | | | | | | | | | | Adds a new experimental warning, feature, keywords and enough parsing to implement basic classes with an empty `new` constructor method. Inject a $self lexical into method bodies; populate it with the object instance, suitably shifted Creates a new OP_METHSTART opcode to perform method setup Define an aux flag to remark which stashes are classes Basic implementation of fields. Basic anonymous methods.
* Define the concept of a suspended compcvPaul "LeoNerd" Evans2023-02-101-0/+85
|
* Correct typos as per GH 20435James E Keenan2022-12-291-3/+3
| | | | | | | | | | | | | | | | | | | In GH 20435 many typos in our C code were corrected. However, this pull request was not applied to blead and developed merge conflicts. I extracted diffs for the individual modified files and applied them with 'git apply', excepting four files where patch conflicts were reported. Those files were: handy.h locale.c regcomp.c toke.c We can handle these in a subsequent commit. Also, had to run these two programs to keep 'make test_porting' happy: $ ./perl -Ilib regen/uconfig_h.pl $ ./perl -Ilib regen/regcomp.pl regnodes.h
* Add a PadnameREFCNT_inc() macroPaul "LeoNerd" Evans2022-08-171-3/+3
| | | | | | | | | Implemented as a static inline function call, so that it can return the padname pointer itself. This would allow use in expressions such as ptr->field = PadnameREFCNT_inc(pn); That makes it similar to the familiar SvREFCNT_inc() macro.
* Define a CvREFCOUNTED_ANYSV flagPaul "LeoNerd" Evans2022-08-161-1/+6
| | | | | | | | If this flag is set, then the CvXSUBANY(cv).any_sv pointer will have its reference count decremented when the CV itself is freed. This is useful for XS extensions that wish to store extra data in here. Without this flag, such extensions have to resort to using magic with a 'free' function to perform this work.
* Rename CVf_METHOD to CVf_NOWARN_AMBIGUOUSPaul "LeoNerd" Evans2022-07-261-2/+2
| | | | Also renames the CvMETHOD* macro family to CvNOWARN_AMBIGUOUS*
* Guard the older `SvPAD*` wrappers with `#ifndef PERL_CORE`Paul "LeoNerd" Evans2022-07-051-27/+27
|
* Neaten the PADNAME flag constantsPaul "LeoNerd" Evans2022-07-051-3/+3
| | | | | | | | | | | 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.
* Convert '!!' to cBOOL()Karl Williamson2022-06-141-1/+1
| | | | | | | | | | | | 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.
* Remove pod for non-existent functionsKarl Williamson2022-06-101-20/+0
| | | | | 7008caa915ad99e650acf2aea40612b5e48b7ba2 removed several deprecated functions, but did not remove all the pods thereof.
* Perl_newSV_type_mortal - new inline function introduced and usedRichard Leach2022-03-071-5/+5
| | | | | | | | | | | | | | | There's no efficient way to create a mortal SV of any type other than SVt_NULL (via sv_newmortal). The options are either to do: * SV* sv = sv_newmortal; sv_upgrade(sv, SVt_SOMETYPE); but sv_upgrade is needlessly inefficient on new SVs. * SV* sv = sv_2mortal(newSV_type(SVt_SOMETYPE) but this will perform runtime checks to see if (sv) and if (SvIMMORTAL(sv), and for a new SV we know that those answers will always be yes and no. This commit adds a new inline function which is basically a mortalizing wrapper around the now-inlined newSV_type.
* Inlined newSV_type(SVt_NULL) leaner than non-inlined newSV(0)Richard Leach2022-03-071-8/+8
| | | | | | | | | | | | 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
* pad.c: Fix GH Issue #19463, -DXv fails assert when dumping anonymous ↵Yves Orton2022-03-021-3/+8
| | | | | | | | | | | | | | | | constant sub Anonymous constant subs were changed to be implemented internally as XSUBs in 5.21.6, commit 1567c65ac069266bfe65959430c185babd476538. This broke DEBUGGING perls running under -DXv which weren't taught about the new implementation. In ed958fa3156084f3cf4d8c4768716d9e1a11ce91 strict.pm also was changed to use such subs, which then breaks many uses of -DXv. See t/run/switchDx.t for an example of code that would trigger this that does not depend on strict.pm This fixes the problem and adds a test for -Dx.
* Add a builtin:: namespace, with true/false/isboolPaul "LeoNerd" Evans2021-11-291-6/+17
| | | | | | | | This finishes the perl-visible API required for RFC 0008 https://github.com/Perl/RFCs/blob/master/rfcs/rfc0008.md It also begins the "builtin::" namespace of RFC 0009 https://github.com/Perl/RFCs/blob/master/rfcs/rfc0009.md
* Expose a public SAVESTRLEN() macroPaul "LeoNerd" Evans2021-10-051-10/+10
| | | | | | | This seems to have been forgotten in the public API, perhaps because it was added later. Fixes #19165
* Perl_pad_alloc: simplify av_fetch() callsRichard Leach2021-07-031-2/+2
| | | | The nature of PL_comppad allows this.
* Perl_pad_new: directly allocate SV* array, remove av_store() callsRichard Leach2021-05-221-2/+9
|
* Perl_pad_push: directly allocate SV* array, remove av_store() callsRichard Leach2021-05-221-2/+6
|
* Perl_pad_push: assign the SV to store in sv, use single av_store()Richard Leach2021-05-221-6/+5
|
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-1100/+1100
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* Remove empty "#ifdef"sTom Hukins2020-12-081-2/+0
|
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-2/+2
| | | | | | | | | | | 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.
* Fix typosSamanta Navarro2020-10-031-1/+1
| | | | | | | | | For: https://github.com/Perl/perl5/pull/18201 Committer: Samanta Navarro is now a Perl author. To keep 'make test_porting' happy: Increment $VERSION in several files. Regenerate uconfig.h via './perl -Ilib regen/uconfig_h.pl'.
* 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-1/+1
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-3/+0
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* Note that certain flags are documentedKarl Williamson2019-12-171-0/+6
| | | | | | | | | | | This is useful in Devel::PPPort for generating its api-info data. That useful feature of D:P allows someone to find out what was the first release of Perl to have a function, macro, or flag. And whether using ppport.h backports it further. I went through apidoc.pod and looked for flags that were documented but that D:P didn't know about. This commit adds entries for each so that D:P can find them.
* Fully spell out "subroutine" and "variable"Dagfinn Ilmari Mannsåker2019-10-211-5/+5
| | | | | | A bunch of places were using "%se" and "subroutin" or "variabl" when generating error messages that could refer to either a subroutine or variable. Spell the words out and use plain "%s" instead.
* Eliminate modifiable variables in constantsJames E Keenan2019-10-021-18/+4
| | | | | | | | | | Transform previously deprecated cases into exceptions. Update diagnostic; change D to F remove now irrelevant code (TonyC) For: RT 134138
* Fix apidoc macro entriesKarl Williamson2019-06-251-3/+3
| | | | | | | | | | This makes various fixes to the text that is used to generate the documentation. The dominant change is to add the 'n' flag to indicate that the macro takes no arguments. A couple should have been marked with a D (for deprecated) flag, and a couple were missing parameters, and a couple were missing return values. These were spotted by using Devel::PPPort on them.
* Remove redundant info on =for apidoc linesKarl Williamson2019-05-301-27/+27
| | | | | | | | | This information is already in embed.fnc, and we know it compiles. Some of this information is now out-of-date. Get rid of it. There was one bit of information that was (apparently) wrong in embed.fnc. The apidoc line asked that there be no usage example generated for newXS. I added that flag to the embed.fnc entry.
* Correct pad.c pod: PadARRAY, not PAD_ARRAYFather Chrysostomos2018-01-181-1/+1
|
* Fix broken POD markup in perlapi/Pad Data StructuresDagfinn Ilmari Mannsåker2018-01-161-1/+1
|
* assert nested CV existence when freeing CVZefram2017-12-301-2/+4
| | | | | | | [perl #131631] has a convoluted test case that messes up parser error recovery and causes a segv via null pointer dereference. Turn the segv into an assertion failure, by asserting non-nullness of the pointer. This doesn't fix the actual problem with error recovery.
* put shadowing warnings in their own categoryZefram2017-12-061-4/+4
| | | | As proposed in [perl #125330].
* [perl #129916] Allow sub-in-stash outside of mainFather Chrysostomos2017-10-081-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The sub-in-stash optimization introduced in 2eaf799e only applied to subs in the main stash, not in other stashes, due to a problem with the logic in newATTRSUB. This comment: Also, we may be called from load_module at run time, so PL_curstash (which sets CvSTASH) may not point to the stash the sub is stored in. explains why we need the PL_curstash != CopSTASH(PL_curcop) check. (Perl_load_module will fail without it.) But that logic does not work properly at compile time (when PL_curcop == &PL_compiling). The value of CopSTASH(&PL_compiling) is never actually used. It is always set to the main stash. So if we check that PL_curstash != CopSTASH(PL_curcop) and forego the optimization in that case, we will never optimize subs outside of the main stash. What we really need is to check IN_PERL_RUNTIME && PL_curstash != opSTASH(PL_curcop). I.e., forego the optimization at run time if the stashes differ. That is what this commit implements. One observable side effect of this change is that deleting a stash element no longer anonymizes the CV if the CV had no GV that it was depending on to provide its name. Since the main thing in such situa- tions is that we do not get a crash, I think this change (arguably an improvement) is acceptable.) ----------- A bit of explanation of various other changes: gv.c:require_tie_mod needed a bit of help, since it could not handle sub refs in stashes. To keep localisation of stash elements working the same way, local($Stash::{foo}) now upgrades a coderef to a full GV before the localisation. (Changes in two pp*.c files and in scope.c:save_gp.) t/op/stash.t contains a test that makes sure that perl does not crash when a GV with a CV pointing to it gets deleted. This commit tweaks the test so that it continues to test that. (There has to be a GV for the test to test what it is meant to test.) Similarly with t/uni/caller.t and t/uni/stash.t. op.c:rv2cv_op_cv with the _MAYBE_NAME_GV flag was returning the cal- ling GV in those cases where a GV-less sub is called via a GV. E.g., *main = \&Foo::foo; main(). This meant that errors like ‘Not enough arguments’ were giving the wrong sub name. newATTRSUB was not calling mro_method_changed_in when storing a sub as an RV. gv_init needs to arrange for the new GV to have the file and line num- ber corresponding to the sub in it. These are taken from CvSTART, which may be off by a few lines, but is the closest we have to the place the sub was declared.
* pad.c: comment typoFather Chrysostomos2017-07-021-1/+1
|
* pad.c: POD typoFather Chrysostomos2017-07-021-1/+1
|
* Deprecating the modifyable variables in constants by 5.32.Abigail2017-01-161-1/+2
| | | | It was already deprecated, but we're now adding a version number.
* Change white space to avoid C++ deprecation warningKarl Williamson2016-11-181-29/+29
| | | | | | | | | | | | | | | | | | | | | | C++11 requires space between the end of a string literal and a macro, so that a feature can unambiguously be added to the language. Starting in g++ 6.2, the compiler emits a warning when there isn't a space (presumably so that future versions can support C++11). Unfortunately there are many such instances in the perl core. This commit fixes those, including those in ext/, but individual commits will be used for the other modules, those in dist/ and cpan/. This commit also inserts space at the end of a macro before a string literal, even though that is not deprecated, and removes useless "" literals following a macro (instead of inserting a blank). The result is easier to read, making the macro stand out, and be clearer as to the intention. Code and modules included with the Perl core need to be compilable using C++. This is so that perl can be embedded in C++ programs. (Actually, only the hdr files need to be so compilable, but it would be hard to test that just the hdrs are compilable.) So we need to accommodate changes to the C++ language.
* Eliminate xpad_cop_seq from _xnvu unionDavid Mitchell2016-09-271-2/+2
| | | | | | | | | | | | | PVNV's used to be used to hold pad names (like '$lex'), but aren't used for this purpose any more. So eliminate the xpad_cop_seq part of the union. Since S_scan_subst() was using xnv_u.xpad_cop_seq.xlow to store a temporary line count, add a new union member for that. The main usage of this field on CPAN is to define COP_SEQ_RANGE_LOW()-style macros, so if the module is still using xpad_cop_seq for that purpose, it's already broken.
* make PL_ pad vars be of type PADOFFSETDavid Mitchell2016-09-261-36/+34
| | | | | | | | | | | | | | | | | | Now that that PADOFFSET is signed, make PL_comppad_name_fill PL_comppad_name_floor PL_padix PL_constpadix PL_padix_floor PL_min_intro_pending PL_max_intro_pending be of type PADOFFSET rather than I32, to match the rest of the pad interface. At the same time, change various I32 local vars in pad.c functions to be PADOFFSET.
* remove a bunch of XXX's from pad.cDavid Mitchell2016-09-261-38/+0
| | | | | | | | | | | | | | | | When in 2002 I moved a bunch of code from op.c etc into a new file, pad.c, I left this comment at the top: /* XXX DAPM * As of Sept 2002, this file is new and may be in a state of flux for * a while. I've marked things I intent to come back and look at further * with an 'XXX DAPM' comment. */ Well, 12 years have passed since then, and if I was going to do any of this stuff I would probably have done it by now, or someone else would. So this commit removes the XXX's.
* pad.c comments: clarify PERL_PADSEQ_INTRODavid Mitchell2016-09-261-2/+8
|
* fix builds under USE_PAD_RESETDavid Mitchell2016-09-261-1/+1
| | | | It had suffered some bitrot.