Skip to content

Introduce symbol table API into pad #22850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 41 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0cb83e4
Clean trailing whitespaces
Sep 23, 2024
e77f8cf
[pad] Perl_Symbol_Table - enum for internal (pad) symbol table identi…
Dec 5, 2024
b45a669
[pad] Perl_Symbol_Table_Scalar - identify usage of '$' as symbol type
Dec 4, 2024
80a78c2
[pad] Perl_Symbol_Table_Code - identify usage of '&' as symbol table
Dec 5, 2024
f26f41d
[pad] Perl_Symbol_Table_Array - identify usage of '@' as symbol type
Dec 5, 2024
2ae5f3a
[pad] Perl_Symbol_Table_Hash - identify usage of '%' as symbol type
Dec 5, 2024
ef9707b
[pad] Padname_Is_Symbol_Table - whether PADNAME represents symbol fro…
Dec 5, 2024
cabc797
[pad] Padname_Is_Symbol_Table_Scalar - use macro
Dec 5, 2024
784b654
[pad] Padname_Is_Symbol_Table_Code - use macro
Dec 5, 2024
581c4fa
[pad] Padname_Is_Symbol - factor out duplicated predicate
Dec 6, 2024
675f75f
[pad] Padname_Symbol_Table - extract symbol table id
Dec 6, 2024
cda643a
[pad] Padname_Symbol_Name - extract symbol name
Dec 6, 2024
113c640
[pad] Padname_Symbol_Name_Length - length of symbol name
Dec 6, 2024
0db3048
[pad] Padname_Symbol_Is_Anonymous - whether PADNAME represents anonym…
Dec 7, 2024
f117281
[pad] Perl_Sigil_To_Symbol_Table - convert sigil to symbol table iden…
Dec 7, 2024
8af996b
[pad] Perl_Symbol_Table_Title_lc/ucfirst - factor out symbol table title
Dec 7, 2024
a09287f
[pad] Padname_Symbol_Table_Title_* - factor out symbol table title
Dec 7, 2024
36d413a
[pad] Padname_Symbol_Printf_Format and Params
Dec 9, 2024
5bbe791
[pad] Padname_Symbol_Printf_Format/Params - use dedicated format for …
Dec 7, 2024
fc1e956
[pad] refactor if/else sequences into switch/case (symbol type)
Dec 7, 2024
3a2302c
[pad] perl_symbol_table_id - type alias of symbol table id
Dec 7, 2024
8b67580
[pad] new_padname_symbol_pvn - newPADNAMEpvn alternative with explici…
Dec 9, 2024
e6001bd
[pad] new_padname_symbol_pvn - replace usage of newPADNAMEpvn
Nov 25, 2024
7a98c55
[pad] pad_add_symbol_pvn - pad_add_name_pvn alternative with explicit…
Dec 8, 2024
1b237ce
[pad] pad_add_symbol_pvn - replace usage of pad_add_name_pvn
Dec 8, 2024
5c66687
[handy] EXPAND_CALL - helper macro to call macro expanding its argume…
Nov 27, 2024
b3e2973
[pad] pad_add_symbol_pvs - pad_add_name_pvs alternative with explicit…
Nov 26, 2024
213328d
[pad] pad_add_symbol_pvs - replace usage of pad_add_name_pvs
Nov 26, 2024
c51ac70
[pad] pad_add_symbol_pv - pad_add_name_pv alternative with explicit s…
Nov 26, 2024
c37bc9c
[pad] pad_add_symbol_sv - pad_add_name_sv alternative with explicit s…
Dec 8, 2024
f57c569
[pad] pad_add_symbol_sv - replace usage of pad_add_name_sv
Dec 8, 2024
cdb5627
[pad] pad_findlex - make function work with explicit symbol table
Dec 4, 2024
0d38172
[XS-APItest] [pad_scalar] Export tested function id as constant
Nov 28, 2024
db133fc
[XS-APItest] [pad_scalar] Possible bug fix
Dec 8, 2024
9520792
[XS-APItest] [pad_scalar] Add few assert messages to express what is …
Dec 8, 2024
328acf2
[pad] pad_find_my_symbol_pvn - pad_findmy_pvn alternative with explic…
Dec 8, 2024
543056c
[pad] pad_find_my_symbol_pvn - replace usage of pad_findmy_pvn
Nov 28, 2024
04606c2
[pad] pad_find_my_symbol_pv - pad_findmy_pv alternative with explicit…
Dec 8, 2024
e41bdd0
[pad] pad_find_my_symbol_pvs - pad_findmy_pvs alternative with explic…
Nov 30, 2024
8dc2fc1
[pad] pad_find_my_symbol_sv - pad_findmy_sv alternative with explicit…
Dec 8, 2024
7f7f7c7
[pad] pad_find_my_symbol_sv - replace usage of pad_findmy_sv
Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pad] refactor if/else sequences into switch/case (symbol type)
extracting common part of condition and using `Perl_Symbol_Table_*` constants
  • Loading branch information
Branislav Zahradník committed Dec 10, 2024
commit fc1e956ed9b9edee6df160d154fd0a673107bfc5
42 changes: 28 additions & 14 deletions pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,19 @@ Perl_pad_add_name_pvn(pTHX_ const char *namepv, STRLEN namelen,
/* if it's not a simple scalar, replace with an AV or HV */
assert(SvTYPE(PL_curpad[offset]) == SVt_NULL);
assert(SvREFCNT(PL_curpad[offset]) == 1);
if (namelen != 0 && *namepv == Perl_Symbol_Table_Array)
sv_upgrade(PL_curpad[offset], SVt_PVAV);
else if (namelen != 0 && *namepv == Perl_Symbol_Table_Hash)
sv_upgrade(PL_curpad[offset], SVt_PVHV);
else if (namelen != 0 && *namepv == Perl_Symbol_Table_Code)
sv_upgrade(PL_curpad[offset], SVt_PVCV);
if (namelen != 0) {
switch (*namepv) {
case Perl_Symbol_Table_Array:
sv_upgrade(PL_curpad[offset], SVt_PVAV);
break;
case Perl_Symbol_Table_Hash:
sv_upgrade(PL_curpad[offset], SVt_PVHV);
break;
case Perl_Symbol_Table_Code:
sv_upgrade(PL_curpad[offset], SVt_PVCV);
break;
}
}
assert(SvPADMY(PL_curpad[offset]));
DEBUG_Xv(PerlIO_printf(Perl_debug_log,
"Pad addname: %ld \"" Padname_Symbol_Printf_Format "\" new lex=0x%" UVxf "\n",
Expand Down Expand Up @@ -1254,14 +1261,21 @@ S_pad_findlex(pTHX_ const char *namepv, STRLEN namelen, U32 flags, const CV* cv,
}
}
if (!*out_capture) {
if (namelen != 0 && *namepv == Perl_Symbol_Table_Array)
*out_capture = newSV_type_mortal(SVt_PVAV);
else if (namelen != 0 && *namepv == Perl_Symbol_Table_Hash)
*out_capture = newSV_type_mortal(SVt_PVHV);
else if (namelen != 0 && *namepv == Perl_Symbol_Table_Code)
*out_capture = newSV_type_mortal(SVt_PVCV);
else
*out_capture = newSV_type_mortal(SVt_NULL);
if (namelen != 0) {
switch (*namepv) {
case Perl_Symbol_Table_Array:
*out_capture = newSV_type_mortal(SVt_PVAV);
break;
case Perl_Symbol_Table_Hash:
*out_capture = newSV_type_mortal(SVt_PVHV);
break;
case Perl_Symbol_Table_Code:
*out_capture = newSV_type_mortal(SVt_PVCV);
break;
default:
*out_capture = newSV_type_mortal(SVt_NULL);
}
}
}
}

Expand Down