diff options
author | Karl Williamson <khw@cpan.org> | 2018-11-11 21:48:53 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-11-16 09:21:35 -0700 |
commit | 46167d76640b8ae760665fc0fd2f94ac4760438c (patch) | |
tree | 5293f3d96b38ccc90f4ebd7bcd4582243273bb77 | |
parent | 282634ed6aed040ba8694186b410779d98331944 (diff) | |
download | perl-46167d76640b8ae760665fc0fd2f94ac4760438c.tar.gz |
regcomp.sym: longj field is a boolean
The comments could lead one to thinking one could specify any of the
argument fields that nodes can have. But in fact, the value is a
boolean, 0 meaning to use the normal offset field of all regnodes; and 1
meaning to use the ARG field that some regnodes have. If a regnode had
more than just the one argument field, the one that corresponds to that
would be used.
This commit enforces that, and changes regcomp.sym to not use '2',
which is misleading.
It clarifies the comments about this and what '.' means in the flags
field
-rw-r--r-- | pod/perldebguts.pod | 4 | ||||
-rw-r--r-- | regcomp.sym | 10 | ||||
-rw-r--r-- | regen/regcomp.pl | 7 | ||||
-rw-r--r-- | regnodes.h | 4 |
4 files changed, 16 insertions, 9 deletions
diff --git a/pod/perldebguts.pod b/pod/perldebguts.pod index 94b83fe278..080daac63f 100644 --- a/pod/perldebguts.pod +++ b/pod/perldebguts.pod @@ -737,8 +737,8 @@ will be lost. BRANCHJ off 1 1 BRANCH with long offset. # Special Case Regops - IFMATCH off 1 2 Succeeds if the following matches. - UNLESSM off 1 2 Fails if the following matches. + IFMATCH off 1 1 Succeeds if the following matches. + UNLESSM off 1 1 Fails if the following matches. SUSPEND off 1 1 "Independent" sub-RE. IFTHEN off 1 1 Switch, should be preceded by switcher. GROUPP num 1 Whether the group matched. diff --git a/regcomp.sym b/regcomp.sym index f275c7b6c8..6305bfbbcf 100644 --- a/regcomp.sym +++ b/regcomp.sym @@ -11,8 +11,10 @@ # Note that the order in this file is important. # # Format for first section: -# NAME \s+ TYPE, arg-description [num-args] [flags] [longjump-len] ; DESCRIPTION -# flag <S> means is REGNODE_SIMPLE; flag <V> means is REGNODE_VARIES +# NAME \s+ TYPE, arg-description [num-args] [flags] [longjump] ; DESCRIPTION +# flag <S> means is REGNODE_SIMPLE; flag <V> means is REGNODE_VARIES; <.> is +# a placeholder +# longjump is 1 if the (first) argument holds the next offset. # # # run perl regen.pl after editing this file @@ -162,8 +164,8 @@ LONGJMP LONGJMP, off 1 . 1 ; Jump far away. BRANCHJ BRANCHJ, off 1 V 1 ; BRANCH with long offset. #*Special Case Regops -IFMATCH BRANCHJ, off 1 . 2 ; Succeeds if the following matches. -UNLESSM BRANCHJ, off 1 . 2 ; Fails if the following matches. +IFMATCH BRANCHJ, off 1 . 1 ; Succeeds if the following matches. +UNLESSM BRANCHJ, off 1 . 1 ; Fails if the following matches. SUSPEND BRANCHJ, off 1 V 1 ; "Independent" sub-RE. IFTHEN BRANCHJ, off 1 V 1 ; Switch, should be preceded by switcher. GROUPP GROUPP, num 1 ; Whether the group matched. diff --git a/regen/regcomp.pl b/regen/regcomp.pl index ffb7d7a13f..cb9861318d 100644 --- a/regen/regcomp.pl +++ b/regen/regcomp.pl @@ -54,7 +54,7 @@ use strict; # code Op what code is associated with this node (???) # args Op what type of args the node has (which regnode struct) # flags Op (???) -# longj Op Whether this node is a longjump +# longj Op Boolean as to if this node is a longjump # comment Both Comment about node, if any # pod_comment Both Special comments for pod output (preceding lines in def) @@ -89,6 +89,11 @@ sub register_node { $node->{id}= 0 + @all; push @all, $node; $all{ $node->{name} }= $node; + + if ($node->{longj} && $node->{longj} != 1) { + die "longj field must be in [01] if present in ", Dumper($node); + } + } # Parse and add an opcode definition to the global state. diff --git a/regnodes.h b/regnodes.h index 849d2ec494..f94b16b8e7 100644 --- a/regnodes.h +++ b/regnodes.h @@ -479,8 +479,8 @@ static const char reg_off_by_arg[] = { 0, /* NREFFA */ 1, /* LONGJMP */ 1, /* BRANCHJ */ - 2, /* IFMATCH */ - 2, /* UNLESSM */ + 1, /* IFMATCH */ + 1, /* UNLESSM */ 1, /* SUSPEND */ 1, /* IFTHEN */ 0, /* GROUPP */ |