summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-03 21:23:00 +0000
committerPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-08 00:05:10 +0000
commitd2817bd771b5f4a948f1a5395803b7d795453c07 (patch)
tree4dcff879f83d688917b30fd34b9d4bd35238c03b /pp.c
parentb2d0d92ba8eefbcb5afd8e04a8f263b4938f26ef (diff)
downloadperl-d2817bd771b5f4a948f1a5395803b7d795453c07.tar.gz
Add builtin::blessed, refaddr and reftype
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index 202cac6c1c..79b73e45a1 100644
--- a/pp.c
+++ b/pp.c
@@ -7253,6 +7253,60 @@ PP(pp_unweaken)
RETURN;
}
+PP(pp_blessed)
+{
+ dSP;
+ dTARGET;
+ SV *arg = POPs;
+ SV *rv;
+
+ SvGETMAGIC(arg);
+
+ if(SvROK(arg) && SvOBJECT((rv = SvRV(arg)))) {
+ sv_ref(TARG, rv, TRUE);
+ SvSETMAGIC(TARG);
+ }
+ else
+ sv_setsv(TARG, &PL_sv_undef);
+
+ PUSHs(TARG);
+ RETURN;
+}
+
+PP(pp_refaddr)
+{
+ dSP;
+ dTARGET;
+ SV *arg = POPs;
+
+ SvGETMAGIC(arg);
+
+ if(SvROK(arg))
+ sv_setuv_mg(TARG, PTR2UV(SvRV(arg)));
+ else
+ sv_setsv(TARG, &PL_sv_undef);
+
+ PUSHs(TARG);
+ RETURN;
+}
+
+PP(pp_reftype)
+{
+ dSP;
+ dTARGET;
+ SV *arg = POPs;
+
+ SvGETMAGIC(arg);
+
+ if(SvROK(arg))
+ sv_setpv_mg(TARG, sv_reftype(SvRV(arg), FALSE));
+ else
+ sv_setsv(TARG, &PL_sv_undef);
+
+ PUSHs(TARG);
+ RETURN;
+}
+
/*
* ex: set ts=8 sts=4 sw=4 et:
*/