summaryrefslogtreecommitdiff
path: root/perly.act
Commit message (Collapse)AuthorAgeFilesLines
* detect sub attributes following a signatureDavid Mitchell2018-03-021-144/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RT #132760 A recent commit (v5.27.7-212-g894f226) moved subroutine attributes back before the subroutine's signature: e.g. sub foo :prototype($$) ($a, $b) { ... } # 5.18 and 5.28 + sub foo ($a, $b) :prototype($$) { ... } # 5.20 .. 5.26 This change means that any code still using an attribute following the signature is going to trigger a syntax error. However, the error, followed by error recovery and further warnings and errors, is very unfriendly and gives no indication of the root cause. This commit introduces a new error, "Subroutine attributes must come before the signature". For example, List::Lazy, the subject of the ticket, failed to compile tests, with output like: Array found where operator expected at blib/lib/List/Lazy.pm line 43, near "$$@)" (Missing operator before @)?) "my" variable $step masks earlier declaration in same statement at blib/lib/List/Lazy.pm line 44. syntax error at blib/lib/List/Lazy.pm line 36, near ") :" Global symbol "$generator" requires explicit package name (did you forget to declare "my $generator"?) at blib/lib/List/Lazy.pm line 38. Global symbol "$state" requires explicit package name (did you forget to declare "my $state"?) at blib/lib/List/Lazy.pm line 39. Global symbol "$min" requires explicit package name (did you forget to declare "my $min"?) at blib/lib/List/Lazy.pm line 43. Global symbol "$max" requires explicit package name (did you forget to declare "my $max"?) at blib/lib/List/Lazy.pm line 43. Global symbol "$step" requires explicit package name (did you forget to declare "my $step"?) at blib/lib/List/Lazy.pm line 43. Invalid separator character '{' in attribute list at blib/lib/List/Lazy.pm line 44, near "$step : sub " Global symbol "$step" requires explicit package name (did you forget to declare "my $step"?) at blib/lib/List/Lazy.pm line 44. But following this commit, it now just outputs: Subroutine attributes must come before the signature at blib/lib/List/Lazy.pm line 36. Compilation failed in require at t/append.t line 5. BEGIN failed--compilation aborted at t/append.t line 5. It works by: 1) adding a boolean flag (sig_seen) to the parser state to indicate that a signature has been parsed; 2) at the end of parsing a signature, PL_expect is set to XATTRBLOCK rather than XBLOCK. Then if something looking like one or more attributes is encountered by the lexer immediately afterwards, it scans it as if it were an attribute, but then if sig_seen is true, it croaks.
* rationalise subroutine parsing rulesDavid Mitchell2018-03-021-396/+424
| | | | | | | | | | | | | | | | | | | | | | Now that the parser rules have been split into separate rules for subs under 'use feature "signatures"' and not, refine the rules to reflect the different regimes. In particular: 1) no longer include 'proto' in the signature variants: as it happens the toker would never return a proto THING under signatures anyway, but removing it from the grammar makes it clearer what's expected and not expected. 2) Remove 'subsignature' from non-sig rules: what used to happen before was that outside of 'use feature "signatures"', it might still try to parse a signature, e.g. $ perl5279 -we 'sub f :lvalue ($$@) { $x = 1 }' Illegal character following sigil in a subroutine signature at -e line 1, near "($" syntax error at -e line 1, near "$$@" Now it's just a plain syntax error.
* parse subs and signature subs separatelyDavid Mitchell2018-03-021-429/+461
| | | | | | | | | | | | | | | | Currently the toker returns a SUB or ANONSUB token at the beginning of a sub (or BEGIN etc). Change it so that in the scope of 'use feature "signatures"', it returns a SIGSUB / ANON_SIGSUB token instead. Then in perly.y, duplicate the 2 rules containing SUB / ANONSUB to cope with these two new tokens. The net effect of this is to use different rules in the parser for parsing subs when signatures are in scope. Since the two sets of rules have just been cut and pasted, there should be no functional changes yet, but that will change shortly.
* add Perl_init_named_cv() functiomDavid Mitchell2018-03-021-234/+218
| | | | | | | This moves a block of code out from perly.y into its own function, because it will shortly be needed in more than one place. Should be no functional changes.
* move sub attributes before the signatureDavid Mitchell2018-01-191-427/+389
| | | | | | | | | | | | | | | | | | | | | | | RT #132141 Attributes such as :lvalue have to come *before* the signature to ensure that they're applied to any code block within the signature; e.g. sub f :lvalue ($a = do { $x = "abc"; return substr($x,0,1)}) { .... } So this commit moves sub attributes to come before the signature. This is how they were originally, but they were swapped with v5.21.7-394-gabcf453. This commit is essentially a revert of that commit (and its followups v5.21.7-395-g71917f6, v5.21.7-421-g63ccd0d), plus some extra work for Deparse, and an extra test. See: RT #123069 for why they were originally swapped RT #132141 for why that broke :lvalue http://nntp.perl.org/group/perl.perl5.porters/247999 for a general discussion about RT #132141
* fix parsing of braced subscript after parensZefram2018-01-161-118/+130
| | | | | | | | | Where an arrow is omitted between subscripts, if a parenthesised subscript is followed by a braced one, PL_expect was getting set to XBLOCK due to code intended for "foreach (...) {...}". This broke bareword autoquotation, and the parsing of operators following the braced subscript. Alter PL_expect from XBLOCK to XOPERATOR following a parenthesised subscript. Fixes [perl #8045].
* revert smartmatch to 5.27.6 behaviourZefram2017-12-291-422/+416
| | | | | | | | | | | | | The pumpking has determined that the CPAN breakage caused by changing smartmatch [perl #132594] is too great for the smartmatch changes to stay in for 5.28. This reverts most of the merge in commit da4e040f42421764ef069371d77c008e6b801f45. All core behaviour and documentation is reverted. The removal of use of smartmatch from a couple of tests (that aren't testing smartmatch) remains. Customisation of a couple of CPAN modules to make them portable across smartmatch types remains. A small bugfix in scope.c also remains.
* add "whereis"Zefram2017-12-061-208/+220
| | | | | "whereis" is like "whereso" except that it performs an implicit smartmatch.
* internally change "when" to "whereso"Zefram2017-12-051-3/+3
| | | | | The names of ops, context types, functions, etc., all change in accordance with the change of keyword.
* change "when" keyword to "whereso"Zefram2017-12-051-1/+1
|
* remove useless "default" mechanismZefram2017-11-281-359/+353
|
* expand code comment in perly.yDavid Mitchell2017-11-161-2/+2
| | | | | | ASSIGNOP includes mutators like += as well as basic assignment NPD
* Replace multiple 'use vars' by 'our' in regen.Nicolas R2017-11-111-2/+2
| | | | then run ./regen_perly.pl to update perly files
* parse yada-yada only as a statementZefram2017-11-101-325/+325
| | | | | | | | | | | | | | Commit f5727a1c71878a34f6255eb1a506c0b21af7d36f tried to make yada-yada be parsed consistently as a term expression, but actually things are more complicated than that. The tokeniser didn't accept yada-yada in the right contexts to make it usable as an expression, and changing that would require decisions on resolving ambiguities between yada-yada and flip-flop. It's also documented as being a statement rather than an expression, though with some incorrect information about ambiguities. Overall it looks more like the intent was for yada-yada to be a statement. This commit makes it grammatically treated as such, and also fixes up the dubious parts of the documentation. [perl #132150]
* perly.y: add $$ = 0 for midrule code blocksDavid Mitchell2017-06-071-244/+250
| | | | | | | | | | | | | | | | | In places where a rule contains multiple code blocks, ensure that $$ is assigned a valid value at the end of midrule blocks, so that valgrind ./perl -Dpv ... doesn't display zillions of Conditional jump or move depends on uninitialised value errors, when perl tries to display the parse stack. I've only done the various newish top-level grammar entries - these all seemed to have the same defect, while from a quick glance elsewhere in the file, it seemed like older rules already do this.
* yyparse: only calculate yytoken on yychar changeDavid Mitchell2016-12-051-4/+4
| | | | | | | | yytoken is a translated (via lookup table) version of parser->yychar. So we only need to recalculate it when yychar changes (usually by assigning the result of yylex() to it). This means when multiple reductions are done without shifting another token, we skip the extra overhead each time.
* Regen from the "special" regen scriptsAaron Crane2016-11-111-1/+1
| | | | | | A few regen scripts aren't run by "make regen", either because they depend on an external tool, or they must be run by the Perl just built. So they must be run manually.
* perly.y: remove redundant NULL castsLukas Mai2016-10-201-668/+911
|
* [perl #129073] Assert failure: ${p{};sub p}()Father Chrysostomos2016-09-041-899/+658
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When parsing the special ${var{subscript}} syntax, the lexer notes that the } matching the ${ will be a fake bracket, and should be ignored. In the case of ${p{};sub p}() the first syntax error causes tokens to be popped, such that the } following the sub declaration ends up being the one treated as a fake bracket and ignored. The part of the lexer that deals with sub declarations treats a ( fol- lowing the sub name as a prototype (which is a single term) if signa- tures are disabled, but ignores it and allows the rest of the lexer to treat it as a parenthesis if signatures are enabled. Hence, the part of the parser (perly.y) that parses signatures knows that a parenthesis token can only come after a sub if signatures are enabled, and asserts as much. In the case of an error and tokens being discarded, a parenthesis may come after a sub name as far as the parser is concerned, even though there was a } in between that got discarded. The sub part of the lexer, of course did not see the parenthesis because of the interven- ing brace, and did not treat it as a prototype. So we get an asser- tion failure. The simplest fix is to loosen up the assertion and allow for anomalies after errors. It does not hurt to go ahead and parse a signature at this point, even though the feature is disabled, because there has been a syntax error already, so the parsed code will never run, and the parsed sub will not be installed.
* signatures: eliminate XSIGVAR, add KEY_sigvarDavid Mitchell2016-08-181-656/+900
| | | | | | | | | | | | | | When I moved subroutine signature processing into perly.y with v5.25.3-101-gd3d9da4, I added a new lexer PL_expect state, XSIGVAR. This indicated, when about to parse a variable, that it was a signature element rather than a my variable; in particular, it makes ($,...) be toked as the lone sigil '$' rather than the punctuation variable '$,'. However this is a bit heavy-handled; so instead this commit adds a new allowed pseudo-keyword value to PL_in_my: as well as KEY_my, KEY_our and KEY_state, it can now be KEY_sigvar. This is a less intrusive change to the lexer.
* Use parser, not PL_parser, in perly.yFather Chrysostomos2016-08-041-914/+671
| | | | | | The code snippets in perly.y are #included in a C function that has a ‘parser’ local variable. Local variables require less machine code (especially under threads).
* silence compiler warning in perly.yDavid Mitchell2016-08-031-2/+2
| | | | | assigning a char from an I32 gives a warning. Add an explicit cast as we know the int only ever holds a char.
* signatures: make param and optional param count IVDavid Mitchell2016-08-031-153/+154
| | | | | | | | | During the course of parsing end exection, these values get stored as ints and UVs, then used as SSize_t. Standardise on IVs instead. Technically they can never be negative, but their final use is as indices into AVs, which is SSize_t, so it's easier to standardise on a signed value throughout.
* ucfirst() new signature diagnostic messagesDavid Mitchell2016-08-031-2/+2
| | | | | | | | | | | | | e.g. a slurpy parameter may not have a default value => A slurpy parameter may not have a default value Also, split the "Too %s arguments for subroutine" diagnostic into separate "too few" and "too many" entries in perldiag. Based on suggestions by Father Chrysostomos.
* add OP_ARGELEM, OP_ARGDEFELEM, OP_ARGCHECK opsDavid Mitchell2016-08-031-288/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently subroutine signature parsing emits many small discrete ops to implement arg handling. This commit replaces them with a couple of ops per signature element, plus an initial signature check op. These new ops are added to the OP tree during parsing, so will be visible to hooks called up to and including peephole optimisation. It is intended soon that the peephole optimiser will take these per-element ops, and replace them with a single OP_SIGNATURE op which handles the whole signature in a single go. So normally these ops wont actually get executed much. But adding these intermediate-level ops gives three advantages: 1) it allows the parser to efficiently generate subtrees containing individual signature elements, which can't be done if only OP_SIGNATURE or discrete ops are available; 2) prior to optimisation, it provides a simple and straightforward representation of the signature; 3) hooks can mess with the signature OP subtree in ways that make it no longer possible to optimise into an OP_SIGNATURE, but which can still be executed, deparsed etc (if less efficiently). This code: use feature "signatures"; sub f($a, $, $b = 1, @c) {$a} under 'perl -MO=Concise,f' now gives: d <1> leavesub[1 ref] K/REFC,1 ->(end) - <@> lineseq KP ->d 1 <;> nextstate(main 84 foo:6) v:%,469762048 ->2 2 <+> argcheck(3,1,@) v ->3 3 <;> nextstate(main 81 foo:6) v:%,469762048 ->4 4 <+> argelem(0)[$a:81,84] v/SV ->5 5 <;> nextstate(main 82 foo:6) v:%,469762048 ->6 8 <+> argelem(2)[$b:82,84] vKS/SV ->9 6 <|> argdefelem(other->7)[2] sK ->8 7 <$> const(IV 1) s ->8 9 <;> nextstate(main 83 foo:6) v:%,469762048 ->a a <+> argelem(3)[@c:83,84] v/AV ->b - <;> ex-nextstate(main 84 foo:6) v:%,469762048 ->b b <;> nextstate(main 84 foo:6) v:%,469762048 ->c c <0> padsv[$a:81,84] s ->d The argcheck(3,1,@) op knows the number of positional params (3), the number of optional params (1), and whether it has an array / hash slurpy element at the end. This op is responsible for checking that @_ contains the right number of args. A simple argelem(0)[$a] op does the equivalent of 'my $a = $_[0]'. Similarly, argelem(3)[@c] is equivalent to 'my @c = @_[3..$#_]'. If it has a child, it gets its arg from the stack rather than using $_[N]. Currently the only used child is the logop argdefelem. argdefelem(other->7)[2] is equivalent to '@_ > 2 ? $_[2] : other'. [ These ops currently assume that the lexical var being introduced is undef/empty and non-magival etc. This is an incorrect assumption and is fixed in a few commits' time ]
* sub signatures: use parser rather than lexerDavid Mitchell2016-08-031-377/+650
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the signature of a sub (i.e. the '($a, $b = 1)' bit) is parsed in toke.c using a roll-your-own mini-parser. This commit makes the signature be part of the general grammar in perly.y instead. In theory it should still generate the same optree as before, except that an OP_STUB is no longer appended to each signature optree: it's unnecessary, and I assume that was a hangover from early development of the original signature code. Error messages have changed somewhat: the generic 'Parse error' has changed to the generic 'syntax error', with the addition of ', near "xyz"' now appended to each message. Also, some specific error messages have been added; for example (@a=1) now says that slurpy params can't have a default vale, rather than just giving 'Parse error'. It introduces a new lexer expect state, XSIGVAR, since otherwise when the lexer saw something like '($, ...)' it would see the identifier '$,' rather than the tokens '$' and ','. Since it no longer uses parse_termexpr(), it is no longer subject to the bug (#123010) associated with that; so sub f($x = print, $y) {} is no longer mis-interpreted as sub f($x = print($_, $y)) {}
* rename "WORD" lexical token to "BAREWORD"David Mitchell2016-07-201-617/+844
| | | | | | | | | | | | | | | | | | | | | | The enum value "WORD" can apparently clash with a enum value in windows headers. It used to be worked around in windows by #defining YYTOKENTYPE, which caused the enum yytokentype { ... WORD = ...; } in perly.h to be skipped, while still using the #define WORD ... which appears later in the same file. In bison 3.x, the auto-generated perl.h no longer includes the #defines, so this workaround no longer works. Instead, change the name of the token from "WORD" to "BAREWORD".
* Allow my \$aFather Chrysostomos2016-07-171-118/+128
| | | | | | | | | | This applies to ‘my’, ‘our’, ‘state’ and ‘local’, and both to single variable and lists of variables, in all their variations: my \$a # equivalent to \my $a my \($a,$b) # equivalent to \my($a, $b) my (\($a,$b)) # same my (\$a, $b) # equivalent to (\my $a, $b)
* Simplify parser’s handling of my/localFather Chrysostomos2016-05-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Perl 5.000, the same token, LOCAL, was used for both ‘my’ and ‘local’, with a token value, passed to localize() as a second argu- ment, to distinguish between them. perl-5.003_07-9-g55497cf (inseparable changes from patch from perl5.003_07 to perl5.003_08), for no apparent reason, split them into two tokens, removing the token values and assigning values in perly.y via $$ = 0 and $$ = 1. They still ultimately made their way through the same grammar rule, as there was only one localize() call in perly.y. The code still made sense. perl-5.005_02-1816-g09bef84 (sub : attrlist) changed things, such that the tokens are separate *and* they get separate token values assigned to them. ‘local’ and ‘my’ no longer follow the same grammar rules in perly.y, so there are separate localize() calls for the different token types. Hence, the use of a token value to distinguish them does not make sense. It just makes this more complicated that necessary. So this commit removes the token values. Since the two token types follow different paths through perly.y and have separate localize() calls, we can hard-code the argument to localize() there, instead of passing the value through from toke.c as a token value. This does shrink toke.o slightly (for me it went from 876040 to 876000), and it makes this conceptually clearer.
* regen_perly.pl: Correct typoFather Chrysostomos2016-05-161-227/+230
| | | | | Sorry for the noisy patch. I can’t modify regen_perly.pl without regenerating stuff, because the checksum changes.
* run regen_perly.plDavid Mitchell2016-02-111-1/+1
|
* Add support for bison 3.0David Mitchell2016-02-031-2/+2
| | | | | | Mainly it no longer generates some tables used for debugging. This commit also adds a new define showing what bison version was used.
* [perl #127122] warn on unless (assignment) when syntax warnings are onTony Cook2016-01-211-296/+291
| | | | | | Previously the assignment was hidden by the not op wrapped around the condition, but newCONDOP() is sufficiently flexible that it isn't needed.
* given(): remove support for lexical $_David Mitchell2015-10-021-428/+419
| | | | | | | | | | | | | | There is dead code that used to allow my $_; ... given ($foo) { # lexical $_ aliased to $foo here } Now that lexical $_ has been removed, remove the code. I've left the signatures of the newFOO() functions unchanged; they just expect a target of 0 to always be passed now.
* perly.y: Remove type from ';'Father Chrysostomos2015-02-151-1/+1
| | | | | | This token’s type is never used. We don’t bother setting the type, either, in toke.c, so it will be garbage. Removing the type makes it harder to use the garbage value by mistake in refactoring.
* perly.y: Remove types for '$' and '*'Father Chrysostomos2015-02-071-1/+1
| | | | | | | These two tokens never use their value, and the value is not even set in toke.c, which means it will contain a junk value from some previous token. Removing the types prevents that junk value from being acci- dentally used.
* Parse and compile string- and num-specific bitopsFather Chrysostomos2015-01-311-228/+231
| | | | Yay, the semicolons are back.
* perly.y changes from Lukas Mai in RT 123069Peter Martini2015-01-181-522/+557
| | | | | | | | | This moves signatures before attributes in the grammar by creating separate branches for the prototype and signatures cases, so that the introduced block and the fact that signatures do not allow for declarations can be handled properly. Tests and regen_perly to follow.
* Simplify s/// and tr/// parsing logicFather Chrysostomos2015-01-081-30/+40
| | | | | | | | | | | | | | | | These two operators were being translated into subst("","") and tr("","") by the lexer. Then pmruntime in op.c would take apart the resulting list op. Instead of constructing a list op only to take it apart again, feed the replacement part to pmruntime separately. We can achieve this by introducing a new token ('/') that the parser rec- ognizes as introducing a replacement. If we had followed this approach to begin with, then bug #123542 would never have happened. (Actually, it seems the parser did know about the replacement part to begin with, but it changed in perl-5.8.0-4047-g131b3ad to fix some overloading problems.)
* perly.y: Don’t call op_lvalue on refgen kidFather Chrysostomos2015-01-061-2/+2
| | | | | | ck_spair also applies lvalue context to the kid ops, so we just end up calling op_lvalue twice on the same ops. It’s harmless (being idempo- tent), but wasteful.
* Unify format and named-sub pad weakref codeFather Chrysostomos2014-12-091-201/+200
|
* Deparse formats in the right spotFather Chrysostomos2014-12-061-199/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formats need the same logic applied in 34b54951568, to avoid this: Input: { my $x; format STDOUT = @ $x . } __END__ $ pbpaste|./perl -Ilib -MO=Deparse { my $x; } format STDOUT = @ $x . __DATA__ - syntax OK That $x in the format is now global, not lexical. Also, we need to make sure the sequence numbers are correct. The statement after the format stopped having a higher sequence number than CvOUTSIDE_SEQ(format) in 8635e3c238f, because the ‘pending’ sequence number set aside for the nextstate op created just after com- pile-time block exit (which nextstate op comes before the block) was not actually being used by newFORM (unlike newATTRSUB), so the follow- ing statement was using that number.
* [perl #123286] Lone C-style for in a blockFather Chrysostomos2014-11-251-184/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A block in perl usually consists of an enter/leave pair plus the con- tents of the block: leave enter nextstate whatever But if the contents of the block are simple enough to forego the full block structure, a simple scope op is used, which is not even executed: scope ex-nextstate whatever If there is a real nextstate op anywhere in the block, it resets the stack to whatever it was at block entry, based on the value on the context stack placed there by the enter op. That’s why we can never have scope+nextstate (we have ex-nextstate, or a former nextstate op that is not executed). A for-loop (for(init; cond; cont) { ... }) executes the init section first, and then an unstack op, which is like nextstate in that it resets the stack based on what the context stack says is the base off- set for this block. If we have an unstack op, we can’t use scope, just as we can’t use it with nextstate. But we *were* nonetheless using scope in this case. Hence, map { for(...;...;...) {...} } ... caused the for-loop to reset the stack to the beginning of map’s own arguments. So the for-loop would stomp on them. We can see the same bug with ‘for’ clobbering an outer list: $ perl5.20.1 -le 'print 1..3, do{for(0;0;){}}, 4..6;' 0456
* [perl #77452] Deparse { ...; BEGIN{} } correctlyFather Chrysostomos2014-11-201-213/+217
| | | | | | | | | | | | | | | | | | | | | | | 8635e3c2 (5.21.6) changed the COP sequence numbers for nested blocks, such that most BEGIN blocks (incl. ‘use’ statements) and sub declara- tions end up in the right place. However, it had the side effect of causing declarations at the end of the enclosing scope to fall out of it and appear below. This commit fixes that by adding an extra nulled COP to the end of the enclosing scope if that scope ends with a sub, so the final declara- tion gets deparsed before it. The frequency of sub declarations at the end of the enclosing scope is sufficiently low (I’m guessing a bit here) that this slight increase in run-time memory usage is probably acceptable. I had to change B::Deparse to deparse nulled COPs the same way it does live COPs, which means we get more extraneous semicolons than before. I hope to fix that in a forthcoming commit. I also ran into a B bug, in that null ops are not presented to Perl code with the right op class (see the blessing in the patch). I plan to fix that in a separ- ate commit, too.
* [perl #77452] Deparse BEGIN blocks in the right placeFather Chrysostomos2014-11-061-449/+453
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the op tree, a statement consists of a nextstate/dbstate op (of class cop) followed by the contents of the statement. This cop is created after the statement has been parsed. So if you have nested statements, the outermost statement has the highest sequence number (cop_seq). Every sub (including BEGIN blocks) has a sequence number indicating where it occurs in its containing sub. So BEGIN { } #1 # seq 2 { # seq 1 ... } is indistinguishable from # seq 2 { BEGIN { } #1 # seq 1 ... } because the sequence number of the BEGIN block is 1 in both examples. By reserving a sequence number at the start of every block and using it once the block has finished parsing, we can do this: BEGIN { } #1 # seq 1 { # seq 2 ... } # seq 1 { BEGIN { } #2 # seq 2 ... } and now B::Deparse can tell where to put the blocks. PL_compiling.cop_seq was unused, so this is where I am stashing the pending sequence number.
* rename convert to op_convert_list and APIfyLukas Mai2014-10-261-237/+234
|
* Remove redundant op_lvalue calls in perly.yFather Chrysostomos2014-10-241-184/+182
| | | | | | | | | | | | | When (\$x)=\$y is compiled, the \ on the lhs gives lvalue context to its argument by calling op_lvalue. Then later the = gives lvalue con- text to the \, calling op_lvalue again, which transforms the $x into an lvref op (via op.c:S_lvref). I just copied that logic when I extended aliasing via reference to foreach \$x. But here, we don’t need to call op_lvalue on the $x, because we know it is going to go through op.c:S_lvref, which doesn’t care whether it has been through op_lvalue already or not. The end result is the same.
* foreach \$varFather Chrysostomos2014-10-111-586/+623
| | | | Some passing tests are still marked to-do. We need more tests still.
* Make OP_METHOD* to be of new class METHOPsyber2014-10-031-230/+227
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new opcode class, METHOP, which will hold class/method related info needed at runtime to improve performance of class/object method calls, then change OP_METHOD and OP_METHOD_NAMED from being UNOP/SVOP to being METHOP. Note that because OP_METHOD is a UNOP with an op_first, while OP_METHOD_NAMED is an SVOP, the first field of the METHOP structure is a union holding either op_first or op_sv. This was seen as less messy than having to introduce two new op classes. The new op class's character is '.' Nothing has changed in functionality and/or performance by this commit. It just introduces new structure which will be extended with extra fields and used in later commits. Added METHOP constructors: - newMETHOP() for method ops with dynamic method names. The only optype for this op is OP_METHOD. - newMETHOP_named() for method ops with constant method names. Optypes for this op are: OP_METHOD_NAMED (currently) and (later) OP_METHOD_SUPER, OP_METHOD_REDIR, OP_METHOD_NEXT, OP_METHOD_NEXTCAN, OP_METHOD_MAYBENEXT (This commit includes fixups by davem)
* In perly.y, change PL_parser to parserFather Chrysostomos2014-08-241-31/+31
| | | | | | | | | | | | | | | | | All these code snippets are embedded inside a function (perly.c:yyparse) that puts the current value of PL_parser in a local variable named parser. So the two are equivalent, but the latter only has to access a local variable. Before: $ ls -ld perly.o -rw-r--r-- 1 sprout staff 94748 Aug 22 06:12 perly.o After: $ ls -ld perly.o -rw-r--r-- 1 sprout staff 94340 Aug 22 06:15 perly.o