summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--regen.pl1
-rw-r--r--regen/scope_types.pl176
-rw-r--r--scope_types.h245
-rw-r--r--t/porting/regen.t4
5 files changed, 312 insertions, 115 deletions
diff --git a/MANIFEST b/MANIFEST
index 62a95479aa..9b1baf1ade 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5532,6 +5532,7 @@ regen/regcharclass.pl Generate regcharclass.h from inline data
regen/regcharclass_multi_char_folds.pl Generate input for regcharclass.pl
regen/regcomp.pl Builder of regnodes.h
regen/regen_lib.pl Common file routines for generator scripts
+regen/scope_types.pl Regenerate scope_types.h
regen/uconfig_h.pl generate uconfig.h (requires /bin/sh)
regen/unicode_constants.pl generate unicode_constants.h
regen/warnings.pl Program to write warnings.h and lib/warnings.pm
diff --git a/regen.pl b/regen.pl
index 71a6eda60a..525779326b 100644
--- a/regen.pl
+++ b/regen.pl
@@ -30,3 +30,4 @@ regcomp.pl
warnings.pl
embed.pl
feature.pl
+scope_types.pl
diff --git a/regen/scope_types.pl b/regen/scope_types.pl
new file mode 100644
index 0000000000..2d56557ece
--- /dev/null
+++ b/regen/scope_types.pl
@@ -0,0 +1,176 @@
+#!/usr/bin/perl -w
+#
+#
+# Regenerate (overwriting only if changed):
+#
+# scope_types.h
+#
+# from information contained in this file in the
+# __DATA_ section below.
+#
+# To add a new type simply add its name to the list
+# below in the correct section (marked by C comments)
+# and then regenerate with 'make regen'.
+#
+# Accepts the standard regen_lib -q and -v args.
+#
+# This script is normally invoked from regen.pl.
+
+# The style of this file is determined by:
+#
+# perltidy -w -ple -bbb -bbc -bbs -nolq -l=80 -noll -nola -nwls='=' \
+# -isbc -nolc -otr -kis -ci=4 -se -sot -sct -nsbl -pt=2 -fs \
+# -fsb='##!' -fse='##.'
+
+BEGIN {
+ # Get function prototypes
+ require './regen/regen_lib.pl';
+}
+
+use strict;
+use warnings;
+
+my %args= (
+ "zero" => 0,
+ "one" => 1,
+ "two" => 2,
+ "three" => 3,
+);
+my $nargs= 0;
+my @arg_num;
+my @types;
+my $tlen= 0;
+my @lines;
+
+foreach my $line (<DATA>) {
+ $line =~ s/\s+\z//;
+ if ($line =~ /(\w+) arg/) {
+ $nargs= $args{$1} // die "panic: Bad arg number '$1'";
+ }
+ if ($line =~ /^SAVEt/) {
+ my $id= 0 + @arg_num;
+ $tlen= length($line) if $tlen < length($line);
+ push @types, $line;
+ push @arg_num, [ $nargs, $line ];
+ push @lines, [ $line, $id ];
+ }
+ else {
+ push @lines, $line;
+ }
+}
+
+my $c_code= "";
+foreach my $num (0 .. $#lines) {
+ my $line= $lines[$num];
+ if (ref $line) {
+ my ($type, $id)= @$line;
+ $line= sprintf "#define %*s %*d",
+ -$tlen, $type, length(0 + @types), $id;
+ }
+ $c_code .= $line . "\n";
+}
+
+$c_code .= <<EOF_C;
+
+static const U8 leave_scope_arg_counts[] = {
+EOF_C
+
+foreach my $tuple (@arg_num) {
+ my ($nargs, $type)= @$tuple;
+ $c_code .= sprintf " %d%s /* %*s */\n",
+ $nargs, $tuple == $arg_num[-1] ? " " : ",",
+ -$tlen, $type;
+}
+my $max_savet= $#arg_num;
+
+$c_code .= <<EOF_C;
+};
+
+#define MAX_SAVEt $max_savet
+EOF_C
+
+my $final= <<'EOF_FINAL';
+The defines and contents of the leave_scope_arg_counts[] array
+must match. To add a new type modify the __DATA__ section in
+regen/scope_types.pl and run `make regen` to rebuild the file.
+EOF_FINAL
+
+my $out= open_new(
+ 'scope_types.h',
+ '>', {
+ by => 'regen/scope_types.pl',
+ copyright => [2022],
+ final => $final,
+ });
+print $out $c_code;
+read_only_bottom_close_and_rename($out);
+
+__DATA__
+/* zero args */
+
+SAVEt_ALLOC
+SAVEt_CLEARPADRANGE
+SAVEt_CLEARSV
+SAVEt_REGCONTEXT
+
+/* one arg */
+
+SAVEt_TMPSFLOOR
+SAVEt_BOOL
+SAVEt_COMPILE_WARNINGS
+SAVEt_COMPPAD
+SAVEt_FREECOPHH
+SAVEt_FREEOP
+SAVEt_FREEPV
+SAVEt_FREESV
+SAVEt_I16
+SAVEt_I32_SMALL
+SAVEt_I8
+SAVEt_INT_SMALL
+SAVEt_MORTALIZESV
+SAVEt_NSTAB
+SAVEt_OP
+SAVEt_PARSER
+SAVEt_STACK_POS
+SAVEt_READONLY_OFF
+SAVEt_FREEPADNAME
+SAVEt_STRLEN_SMALL
+
+/* two args */
+
+SAVEt_AV
+SAVEt_DESTRUCTOR
+SAVEt_DESTRUCTOR_X
+SAVEt_GENERIC_PVREF
+SAVEt_GENERIC_SVREF
+SAVEt_GP
+SAVEt_GVSV
+SAVEt_HINTS
+SAVEt_HPTR
+SAVEt_HV
+SAVEt_I32
+SAVEt_INT
+SAVEt_ITEM
+SAVEt_IV
+SAVEt_LONG
+SAVEt_PPTR
+SAVEt_SAVESWITCHSTACK
+SAVEt_SHARED_PVREF
+SAVEt_SPTR
+SAVEt_STRLEN
+SAVEt_SV
+SAVEt_SVREF
+SAVEt_VPTR
+SAVEt_ADELETE
+SAVEt_APTR
+SAVEt_RCPV_FREE
+
+/* three args */
+
+SAVEt_HELEM
+SAVEt_PADSV_AND_MORTALIZE
+SAVEt_SET_SVFLAGS
+SAVEt_GVSLOT
+SAVEt_AELEM
+SAVEt_DELETE
+SAVEt_HINTS_HH
diff --git a/scope_types.h b/scope_types.h
index 0ab89d5a5e..960219c648 100644
--- a/scope_types.h
+++ b/scope_types.h
@@ -1,128 +1,147 @@
+/* -*- buffer-read-only: t -*-
+
+ Copyright (C) 2022 by Larry Wall and others
+
+ You may distribute under the terms of either the GNU General Public
+ License or the Artistic License, as specified in the README file.
+
+ !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+ This file is built by regen/scope_types.pl.
+ Any changes made here will be lost!
+ The defines and contents of the leave_scope_arg_counts[] array
+ must match. To add a new type modify the __DATA__ section in
+ regen/scope_types.pl and run `make regen` to rebuild the file.
+ */
+
/* zero args */
-#define SAVEt_ALLOC 0
-#define SAVEt_CLEARPADRANGE 1
-#define SAVEt_CLEARSV 2
-#define SAVEt_REGCONTEXT 3
+#define SAVEt_ALLOC 0
+#define SAVEt_CLEARPADRANGE 1
+#define SAVEt_CLEARSV 2
+#define SAVEt_REGCONTEXT 3
/* one arg */
-#define SAVEt_TMPSFLOOR 4
-#define SAVEt_BOOL 5
-#define SAVEt_COMPILE_WARNINGS 6
-#define SAVEt_COMPPAD 7
-#define SAVEt_FREECOPHH 8
-#define SAVEt_FREEOP 9
-#define SAVEt_FREEPV 10
-#define SAVEt_FREESV 11
-#define SAVEt_I16 12
-#define SAVEt_I32_SMALL 13
-#define SAVEt_I8 14
-#define SAVEt_INT_SMALL 15
-#define SAVEt_MORTALIZESV 16
-#define SAVEt_NSTAB 17
-#define SAVEt_OP 18
-#define SAVEt_PARSER 19
-#define SAVEt_STACK_POS 20
-#define SAVEt_READONLY_OFF 21
-#define SAVEt_FREEPADNAME 22
-#define SAVEt_STRLEN_SMALL 23
+#define SAVEt_TMPSFLOOR 4
+#define SAVEt_BOOL 5
+#define SAVEt_COMPILE_WARNINGS 6
+#define SAVEt_COMPPAD 7
+#define SAVEt_FREECOPHH 8
+#define SAVEt_FREEOP 9
+#define SAVEt_FREEPV 10
+#define SAVEt_FREESV 11
+#define SAVEt_I16 12
+#define SAVEt_I32_SMALL 13
+#define SAVEt_I8 14
+#define SAVEt_INT_SMALL 15
+#define SAVEt_MORTALIZESV 16
+#define SAVEt_NSTAB 17
+#define SAVEt_OP 18
+#define SAVEt_PARSER 19
+#define SAVEt_STACK_POS 20
+#define SAVEt_READONLY_OFF 21
+#define SAVEt_FREEPADNAME 22
+#define SAVEt_STRLEN_SMALL 23
/* two args */
-#define SAVEt_AV 24
-#define SAVEt_DESTRUCTOR 25
-#define SAVEt_DESTRUCTOR_X 26
-#define SAVEt_GENERIC_PVREF 27
-#define SAVEt_GENERIC_SVREF 28
-#define SAVEt_GP 29
-#define SAVEt_GVSV 30
-#define SAVEt_HINTS 31
-#define SAVEt_HPTR 32
-#define SAVEt_HV 33
-#define SAVEt_I32 34
-#define SAVEt_INT 35
-#define SAVEt_ITEM 36
-#define SAVEt_IV 37
-#define SAVEt_LONG 38
-#define SAVEt_PPTR 39
-#define SAVEt_SAVESWITCHSTACK 40
-#define SAVEt_SHARED_PVREF 41
-#define SAVEt_SPTR 42
-#define SAVEt_STRLEN 43
-#define SAVEt_SV 44
-#define SAVEt_SVREF 45
-#define SAVEt_VPTR 46
-#define SAVEt_ADELETE 47
-#define SAVEt_APTR 48
-#define SAVEt_RCPV_FREE 49
+#define SAVEt_AV 24
+#define SAVEt_DESTRUCTOR 25
+#define SAVEt_DESTRUCTOR_X 26
+#define SAVEt_GENERIC_PVREF 27
+#define SAVEt_GENERIC_SVREF 28
+#define SAVEt_GP 29
+#define SAVEt_GVSV 30
+#define SAVEt_HINTS 31
+#define SAVEt_HPTR 32
+#define SAVEt_HV 33
+#define SAVEt_I32 34
+#define SAVEt_INT 35
+#define SAVEt_ITEM 36
+#define SAVEt_IV 37
+#define SAVEt_LONG 38
+#define SAVEt_PPTR 39
+#define SAVEt_SAVESWITCHSTACK 40
+#define SAVEt_SHARED_PVREF 41
+#define SAVEt_SPTR 42
+#define SAVEt_STRLEN 43
+#define SAVEt_SV 44
+#define SAVEt_SVREF 45
+#define SAVEt_VPTR 46
+#define SAVEt_ADELETE 47
+#define SAVEt_APTR 48
+#define SAVEt_RCPV_FREE 49
/* three args */
-#define SAVEt_HELEM 50
+#define SAVEt_HELEM 50
#define SAVEt_PADSV_AND_MORTALIZE 51
-#define SAVEt_SET_SVFLAGS 52
-#define SAVEt_GVSLOT 53
-#define SAVEt_AELEM 54
-#define SAVEt_DELETE 55
-#define SAVEt_HINTS_HH 56
+#define SAVEt_SET_SVFLAGS 52
+#define SAVEt_GVSLOT 53
+#define SAVEt_AELEM 54
+#define SAVEt_DELETE 55
+#define SAVEt_HINTS_HH 56
static const U8 leave_scope_arg_counts[] = {
- 0, /* SAVEt_ALLOC */
- 0, /* SAVEt_CLEARPADRANGE */
- 0, /* SAVEt_CLEARSV */
- 0, /* SAVEt_REGCONTEXT */
- 1, /* SAVEt_TMPSFLOOR */
- 1, /* SAVEt_BOOL */
- 1, /* SAVEt_COMPILE_WARNINGS */
- 1, /* SAVEt_COMPPAD */
- 1, /* SAVEt_FREECOPHH */
- 1, /* SAVEt_FREEOP */
- 1, /* SAVEt_FREEPV */
- 1, /* SAVEt_FREESV */
- 1, /* SAVEt_I16 */
- 1, /* SAVEt_I32_SMALL */
- 1, /* SAVEt_I8 */
- 1, /* SAVEt_INT_SMALL */
- 1, /* SAVEt_MORTALIZESV */
- 1, /* SAVEt_NSTAB */
- 1, /* SAVEt_OP */
- 1, /* SAVEt_PARSER */
- 1, /* SAVEt_STACK_POS */
- 1, /* SAVEt_READONLY_OFF */
- 1, /* SAVEt_FREEPADNAME */
- 1, /* SAVEt_STRLEN_SMALL */
- 2, /* SAVEt_AV */
- 2, /* SAVEt_DESTRUCTOR */
- 2, /* SAVEt_DESTRUCTOR_X */
- 2, /* SAVEt_GENERIC_PVREF */
- 2, /* SAVEt_GENERIC_SVREF */
- 2, /* SAVEt_GP */
- 2, /* SAVEt_GVSV */
- 2, /* SAVEt_HINTS */
- 2, /* SAVEt_HPTR */
- 2, /* SAVEt_HV */
- 2, /* SAVEt_I32 */
- 2, /* SAVEt_INT */
- 2, /* SAVEt_ITEM */
- 2, /* SAVEt_IV */
- 2, /* SAVEt_LONG */
- 2, /* SAVEt_PPTR */
- 2, /* SAVEt_SAVESWITCHSTACK */
- 2, /* SAVEt_SHARED_PVREF */
- 2, /* SAVEt_SPTR */
- 2, /* SAVEt_STRLEN */
- 2, /* SAVEt_SV */
- 2, /* SAVEt_SVREF */
- 2, /* SAVEt_VPTR */
- 2, /* SAVEt_ADELETE */
- 2, /* SAVEt_APTR */
- 2, /* SAVEt_RCPV_FREE */
- 3, /* SAVEt_HELEM */
- 3, /* SAVEt_PADSV_AND_MORTALIZE*/
- 3, /* SAVEt_SET_SVFLAGS */
- 3, /* SAVEt_GVSLOT */
- 3, /* SAVEt_AELEM */
- 3, /* SAVEt_DELETE */
- 3 /* SAVEt_HINTS_HH */
+ 0, /* SAVEt_ALLOC */
+ 0, /* SAVEt_CLEARPADRANGE */
+ 0, /* SAVEt_CLEARSV */
+ 0, /* SAVEt_REGCONTEXT */
+ 1, /* SAVEt_TMPSFLOOR */
+ 1, /* SAVEt_BOOL */
+ 1, /* SAVEt_COMPILE_WARNINGS */
+ 1, /* SAVEt_COMPPAD */
+ 1, /* SAVEt_FREECOPHH */
+ 1, /* SAVEt_FREEOP */
+ 1, /* SAVEt_FREEPV */
+ 1, /* SAVEt_FREESV */
+ 1, /* SAVEt_I16 */
+ 1, /* SAVEt_I32_SMALL */
+ 1, /* SAVEt_I8 */
+ 1, /* SAVEt_INT_SMALL */
+ 1, /* SAVEt_MORTALIZESV */
+ 1, /* SAVEt_NSTAB */
+ 1, /* SAVEt_OP */
+ 1, /* SAVEt_PARSER */
+ 1, /* SAVEt_STACK_POS */
+ 1, /* SAVEt_READONLY_OFF */
+ 1, /* SAVEt_FREEPADNAME */
+ 1, /* SAVEt_STRLEN_SMALL */
+ 2, /* SAVEt_AV */
+ 2, /* SAVEt_DESTRUCTOR */
+ 2, /* SAVEt_DESTRUCTOR_X */
+ 2, /* SAVEt_GENERIC_PVREF */
+ 2, /* SAVEt_GENERIC_SVREF */
+ 2, /* SAVEt_GP */
+ 2, /* SAVEt_GVSV */
+ 2, /* SAVEt_HINTS */
+ 2, /* SAVEt_HPTR */
+ 2, /* SAVEt_HV */
+ 2, /* SAVEt_I32 */
+ 2, /* SAVEt_INT */
+ 2, /* SAVEt_ITEM */
+ 2, /* SAVEt_IV */
+ 2, /* SAVEt_LONG */
+ 2, /* SAVEt_PPTR */
+ 2, /* SAVEt_SAVESWITCHSTACK */
+ 2, /* SAVEt_SHARED_PVREF */
+ 2, /* SAVEt_SPTR */
+ 2, /* SAVEt_STRLEN */
+ 2, /* SAVEt_SV */
+ 2, /* SAVEt_SVREF */
+ 2, /* SAVEt_VPTR */
+ 2, /* SAVEt_ADELETE */
+ 2, /* SAVEt_APTR */
+ 2, /* SAVEt_RCPV_FREE */
+ 3, /* SAVEt_HELEM */
+ 3, /* SAVEt_PADSV_AND_MORTALIZE */
+ 3, /* SAVEt_SET_SVFLAGS */
+ 3, /* SAVEt_GVSLOT */
+ 3, /* SAVEt_AELEM */
+ 3, /* SAVEt_DELETE */
+ 3 /* SAVEt_HINTS_HH */
};
+
+#define MAX_SAVEt 56
+
+/* ex: set ro: */
diff --git a/t/porting/regen.t b/t/porting/regen.t
index d684fdc19f..b54293a5bd 100644
--- a/t/porting/regen.t
+++ b/t/porting/regen.t
@@ -26,7 +26,7 @@ if ( $Config{usecrosscompile} ) {
skip_all( "Not all files are available during cross-compilation" );
}
-my $tests = 24; # I can't see a clean way to calculate this automatically.
+my $tests = 25; # I can't see a clean way to calculate this automatically.
my %skip = ("regen_perly.pl" => [qw(perly.act perly.h perly.tab)],
"regen/keywords.pl" => [qw(keywords.c keywords.h)],
@@ -62,7 +62,7 @@ die "Can't find __END__ in regen.pl"
foreach (qw(embed_lib.pl regen_lib.pl uconfig_h.pl
regcharclass_multi_char_folds.pl
charset_translations.pl
- mph.pl
+ mph.pl sorted_types.pl
),
map {chomp $_; $_} <$fh>) {
++$skip{"regen/$_"};