summaryrefslogtreecommitdiff
path: root/opcode.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove boolkeys opFather Chrysostomos2012-08-261-6/+0
|
* Banish boolkeysFather Chrysostomos2012-08-251-1/+2
| | | | | | | | | | | | | | Since 6ea72b3a1, rv2hv and padhv have had the ability to return boo- leans in scalar context, instead of bucket stats, if flagged the right way. sub { %hash || ... } is optimised to take advantage of this. If the || is in unknown context at compile time, the %hash is flagged as being maybe a true boolean. When flagged that way, it returns a bool- ean if block_gimme() returns G_VOID. If rv2hv and padhv can already do this, then we don’t need the boolkeys op any more. We can just flag the rv2hv to return a boolean. In all the cases where boolkeys was used, we know at compile time that it is true boolean context, so we add a new flag for that.
* Add freed ops to PL_op_(name|desc)Father Chrysostomos2012-08-081-0/+2
| | | | This is useful for debugging, especially with -DT.
* Merge ck_trunc and ck_chdirFather Chrysostomos2012-07-251-1/+1
| | | | | | ck_chdir, added in 2006 (d4ac975e) duplicates ck_trunc, added in 1993 (79072805), except for a null op check which is harmless when applied to chdir.
* [perl #113470] Constant folding for packFather Chrysostomos2012-07-131-1/+1
| | | | | | | | | | | | | This takes the pessimistic approach of skipping it for any first argu- ment that is not a plain non-magical PV, just in case there is a 'p' or 'P' in the stringified form. Otherwise it scans the PV for 'p' or 'P' and skips the folding if either is present. Then it falls through to the usual op-filtering logic. I nearly made ‘pack;’ crash, so I added a test to bproto.t.
* Constant folding for xFather Chrysostomos2012-06-081-1/+1
|
* Make pos use ck_fun and OA_SCALARREFFather Chrysostomos2012-05-291-2/+2
| | | | | | See the previous commit. The same applies here. In short, this allows core_prototype and pp_coreargs to be simpler.
* Make undef use ck_fun and OA_SCALARREFFather Chrysostomos2012-05-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | In regen/opcodes, we have some operators that use ck_fun and have R for the argument. And there are some that use ck_lfun and have S for the argument. These both amount to more or less the same thing. ck_fun/R goes through the OA_SCALARREF case in ck_fun, which calls op_lvalue(scalar()) on the child op. ck_lfun/S goes through the OA_SCALAR case in ck_fun, which calls scalar(), and then ck_lfun sees to it that op_lvalue is called. The only real difference is that the OA_SCALAR case makes sure there are not too many arguments. Since both core_prototype and pp_coreargs need special cases to deal with OA_SCALAR that is really ‘supposed’ to be OA_SCALARREF, it becomes simpler to add &CORE::undef if undef uses R. In that case, we also have to put the argument-checking in the OA_SCALARREF, but we make it conditional on the op being an undef op, for the sake of doing one thing at a time. (This is a bit of a mess; see ticket #96006.)
* Implement the fc keyword and the \F string escape.Brian Fraser2012-01-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | Along with the simple_casefolding and full_casefolding features. fc() stands for foldcase, a sort of pseudo case (like lowercase), which is used to implement Unicode casefolding. It maps a string to a form where all case differences are erased, so it's a locale-independent way of checking if two strings are the same, regardless of case. This functionality was, and still is, available through the regular expression engine -- /i matches would use casefolding internally. The fc keyword merely exposes this for easier access. Previously, one could attempt to case-insensitively test two strings for equality by doing lc($a) eq lc($b) But that might get you wrong results, for example in the case of \x{DF}, LATIN SMALL LETTER SHARP S.
* [perl #103492] Give lvalue cx to (s)printf argsFather Chrysostomos2011-12-311-1/+1
| | | | | | | | | Or potential lvalue context, like function calls. The %n format code’s existence renders these two very much like func- tion calls, as they can modify their arguments. This allows sprintf("...%n", substr ...) to work.
* Stop seek($glob_copy...) from clearing PL_last_in_gvFather Chrysostomos2011-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | seek had the same bug as tell. Here is the commit message from 8dc99089, which fixed tell: ---------------------------------------------------------------------- Stop tell($glob_copy) from clearing PL_last_in_gv This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* Stop tell($glob_copy) from clearing PL_last_in_gvFather Chrysostomos2011-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* [perl #80628] __SUB__Father Chrysostomos2011-11-221-0/+5
| | | | | After much alternation, altercation and alteration, __SUB__ is finally here.
* Throw a helpful warning when someone tries length(@array) or length(%hash)Matthew Horsfall (alh)2011-11-181-1/+1
|
* Add evalbytes functionFather Chrysostomos2011-11-061-1/+1
| | | | | | | | | | | This function evaluates its argument as a byte string, regardless of the internal encoding. It croaks if the string contains characters outside the byte range. Hence evalbytes(" use utf8; '\xc4\x80' ") will return "\x{100}", even if the original string had the UTF8 flag on, and evalbytes(" '\xc4\x80' ") will return "\xc4\x80". This has the side effect of fixing the deparsing of CORE::break under ‘use feature’ when there is an override.
* Warn for $[ ‘version’ checksFather Chrysostomos2011-11-011-8/+8
| | | | | | | Following Michael Schwern’s suggestion, here is a warning for those hapless folks who use $[ for version checks. It applies whenever $[ is used in one of: < > <= >=
* Merge postinc and postdecFather Chrysostomos2011-09-161-3/+4
| | | | They were nearly identical.
* Merge preinc and postincFather Chrysostomos2011-09-161-3/+4
| | | | | They are almost identical. This gives the compiler less code to digest.
* Refactor unpack’s newDEFSVOP logic; correct prototypeFather Chrysostomos2011-08-211-2/+2
| | | | | | | | | | | | | | | | | unpack is the only op that takes an implicit $_ for its second argu- ment. (For others it’s the first.) Instead of special-casing unpack with its own ck_ routine, we can sim- ply modify the logic in ck_fun to apply OA_DEFGV to the first optional argument, not just the first argument. Currently OA_DEFGV is not set in PL_opargs[OP_UNPACK], which means the automatically-generated prototype is ($;$), instead of ($_). This commit sets the flag on the op, changes it to use ck_fun directly, and updates ck_fun and the prototype-generation code accord- ingly. I couldn’t put this in multiple commits, as the changes are interdependent.
* Add coreargs opFather Chrysostomos2011-08-181-0/+5
| | | | &CORE::foo subs will use this operator for sorting out @_.
* Change (l)stat’s prototype from * to ;*Father Chrysostomos2011-08-121-2/+2
| | | | | | | | | | | | | | Since the argument is optional, we need a semicolon. This commit accomplishes that by setting the OA_OPTIONAL flag for the appropriate entries in PL_opargs. This should not affect anything else, as ck_ftst (the check routine for [l]stat) doesn’t even look at PL_opargs. It also has to tweak the prototype-generation logic slightly, because PL_opargs also has OA_DEFGV set. I think this is insignificant enough not to warrant a delta entry.
* Reorder ops so that trans{,r} and aelemfast{,_lex} are adjacent.Nicholas Clark2011-06-121-12/+12
|
* Split OP_AELEMFAST_LEX out from OP_AELEMFAST.Nicholas Clark2011-06-121-0/+6
| | | | | | | | | | | | | 6a077020aea1c5f0 extended the OP_AELEMFAST optimisation to lexical arrays. Previously OP_AELEMFAST was only used as an optimisation for OP_GV, which is a PADOP/SVOP. However, by reusing the same opcode, and signalling (pad) lexical vs package, it introduced a myriad of special cases, because OP_PADAV is a BASEOP (not a PADOP), whilst OP_AELEMFAST is a PADOP/SVOP (which is larger). Using two OP numbers allows each variant to have the correct OP flags in PL_opargs. Both can continue to share the same C code.
* Make push/shift $scalar accept only unblessed aryrefsFather Chrysostomos2011-04-181-3/+3
| | | | See ticket #80626.
* Move all the generated file header printing into read_only_top()Nicholas Clark2011-01-231-4/+4
| | | | | | | | | Previously all the scripts in regen/ had code to generate header comments (buffer-read-only, "do not edit this file", and optionally regeneration script, regeneration data, copyright years and filename). This change results in some minor reformatting of header blocks, and standardises the copyright line as "Larry Wall and others".
* Merge the implementations of {end,set}{gr,pw}ent with endhostent.Nicholas Clark2011-01-101-4/+8
| | | | | Unlike set{host,net,proto,serv}ent, set{gr,pw}ent don't have stayopen parameter, hence their "signature" is the same as the ent*ent functions.
* Merge the implementations of pp_s{host,net,proto,serv}ent.Nicholas Clark2011-01-101-3/+6
|
* Merge the implementations of pp_e{host,net,proto,serv}ent.Nicholas Clark2011-01-101-3/+6
| | | | | | | PL_op_desc[] rather than PL_op_name(), as the OPs are internally named e*ent, but implement the ent*ent functions, and when unimplemented report themselves using the function name. No need for OP_DESC(), as the switch statement means that we can't encounter OP_CUSTOM.
* Generate "Unsupported socket function" stubs using PL_ppaddr.Nicholas Clark2011-01-091-0/+18
| | | | | | | | | | | | | | | Instead of having each socket op conditionally compile as either the implementation or a DIE() depending on #HAS_SOCKET 1: remove the conditional code from the ops themselves 2: only compile the ops if HAS_SOCKET is defined 3: general conditional code for the intialisation of PL_ppaddr - as appropriate either the ops, or Perl_unimplemented_op 4: Amend Perl_unimplemented_op to generate the appropriate DIE() for socket ops (ie not the "panic"... message) Whilst this complicates the support code in regen/opcode.pl, it's already a net saving of 5 lines in the C code.
* Rename pp_send to pp_syswrite, making send an alias for syswrite.Nicholas Clark2011-01-091-3/+3
| | | | | Previously syswrite was an alias for send. However, syswrite is always available, whereas send is not implemented if HAS_SOCKET is not defined.
* In opcode.h, use the alias macros in PL_ppaddr[]Nicholas Clark2011-01-091-96/+96
| | | | | | | | For OPs that share implementations, use #define aliases for the "original" names in PL_ppaddr[], instead of having regen/opcode.pl replace them with the name of the implementing OP body. Whilst this initially adds another layer of indirection, it will give more flexibility where conditional compilation of OPs is determined by the feature macros in config.h
* regen/opcode.pl should only generate prototypes for pp_* functions that exist.Nicholas Clark2011-01-091-3/+0
| | | | | | | It now generates prototypes for all functions that implement OPs. Hence Perl_unimplemented_op no longer needs a special-case prototype. As it is now generating a prototype for Perl_do_kv, no need for regen/embed.pl to duplicate this. Convert the last two users of the macro do_kv() to Perl_do_kv(aTHX).
* Replace OP stubs in mathoms.c with #define aliases in opcode.hNicholas Clark2011-01-091-7/+99
| | | | | | | External code that references OPs by name will still link (and work). Unlike the other compatibility functions in mathoms.c, the OP stubs were simply making calls onwards to their replacements, so simply taking up space without adding anything.
* Merge the opcode bodies for pp_bind and pp_connect.Nicholas Clark2010-12-301-1/+1
|
* Merge the opcode bodies for chop/chomp and schop/schomp.Nicholas Clark2010-12-271-4/+4
|
* Make entertry a LOGOP, not BASEOP/UNOPReini Urban2010-12-121-1/+1
| | | | | | | The initial parse-time UNOP is upgraded at ck_eval to an LOGOP - op_other holding the ptr to leavetry - which causes problems at run-time B optype inspection. The opclass info was always wrong, the Bytecode compiler broke with 5.12.
* Improve custom OP support.Ben Morrow2010-11-141-5/+0
| | | | | | | | | | | | | | | | | Change the custom op registrations from two separate hashes to one hash holding structure pointers, and add API functions to register ops and look them up. This will make it easier to add new properties of custom ops in the future. Copy entries across from the old hashes where necessary, to preserve compatibility. Add two new properties, in addition to the already-existing 'name' and 'description': 'class' and 'peep'. 'class' is one of the OA_*OP constants, and allows B and other introspection mechanisms to work with custom ops that aren't BASEOPs. 'peep' is a pointer to a function that will be called for ops of this type from Perl_rpeep. Adjust B.xs to take account of the new properties, and also to give custom ops their registered name rather than simply 'custom'.
* Add transr op typeFather Chrysostomos2010-11-021-1/+6
| | | | | for the upcoming y///r feature. There are not enough flag bits, hence the extra type.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* opcode.pl -> regen/opcode.plFather Chrysostomos2010-10-131-2/+2
|
* Remove MEMBER_TO_FPTR.Ben Morrow2010-10-061-732/+732
| | | | This is left over from PERL_OBJECT (see beeff2, 16c915, and so on).
* Remove OA_RETINTEGER, unused since 2002 (commit e7311069df54baa6)Nicholas Clark2010-08-281-344/+344
| | | | | | | | This returns us to 8 flag bits, and restores OCSHIFT and OASHIFT to 8 and 12 Previously these were 9 and 13, and effectively PL_opargs[] was using 33 of 32 bits, relying on the ugly hack that no 5 argument builtin had an optional 5th argument, hence the (13 + 5 * 4)th bit was always zero. is effectively 33 bits.
* srand: change to return its seedKarl Williamson2010-07-281-1/+1
| | | | | | | | | | | | | | This commit changes srand to to return the seed instead of always returning 1. The motivation behind this is to allow applications to not have to come up with their own pseudo-random generator if they want repeatable results. The previous return behavior has never been documented. Note that it is possible, but very unlikely, for the seed to end up being 0, which means that if someone were relying on the undocumented previous behavior of srand returning true, that in very rare instances it would return 0, failing, and the next time they ran it, it would succeed, possibly leading to puzzlement and very rare unexplained failures.
* Make eval {} compile directly to OP_ENTERTRYRafael Garcia-Suarez2009-12-201-2/+2
| | | | | This way, it's correctly caught and blocked by Safe, separately from eval "".
* Move the boolkeys op to the group of hash ops.Nicholas Clark2009-10-151-5/+5
| | | | This breaks binary compatibility.
* Optimise if (%foo) to be faster than if(keys %foo)demerphq2009-10-151-0/+5
| | | | | | | | | | | Thread was "[PATCH] Make if (%hash) {} act the same as if (keys %hash) {}" http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2006-11/msg00432.html but the implementation evolved from the approach described in the subject, to instead add a new opcode pp_boolkeys, to exactly preserve the existing behaviour. Various conflicts with the passage of time resolved, 'register' removed, and a $VERSION bump.
* Ensure that constant folding runs with IN_PERL_RUNTIME true, by copyingNicholas Clark2008-02-251-1/+1
| | | | | | the current compiling cop to a different address. This ensures that lexical hints are correctly honoured, and allows us to fold sprintf. p4raw-id: //depot/perl@33369
* Re: [PATCH] Splitting OP_CONST (Was: pp_const, not, that, hot?)Vincent Pit2008-02-231-0/+5
| | | | | | Message-ID: <47B60D72.50708@profvince.com> Date: Fri, 15 Feb 2008 23:08:50 +0100 p4raw-id: //depot/perl@33356
* Eliminate ck_lengthconst.Nicholas Clark2008-02-201-1/+1
| | | p4raw-id: //depot/perl@33338
* Setting the f flag on length causes the op to be constant folded.Nicholas Clark2008-02-201-1/+1
| | | p4raw-id: //depot/perl@33337