From 99b497aa90ed7db99d29a301b47c91fba65c9cb3 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 24 Dec 2022 13:17:47 +0000 Subject: Initial attack at basic 'class' feature Adds a new experimental warning, feature, keywords and enough parsing to implement basic classes with an empty `new` constructor method. Inject a $self lexical into method bodies; populate it with the object instance, suitably shifted Creates a new OP_METHSTART opcode to perform method setup Define an aux flag to remark which stashes are classes Basic implementation of fields. Basic anonymous methods. --- hv.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'hv.h') diff --git a/hv.h b/hv.h index c005ec653a..7866dea540 100644 --- a/hv.h +++ b/hv.h @@ -132,10 +132,19 @@ struct xpvhv_aux { used to detect each() after insert for warnings */ #endif U32 xhv_aux_flags; /* assorted extra flags */ + + /* The following fields are only valid if we have the flag HvAUXf_IS_CLASS */ + AV *xhv_class_adjust_blocks; /* CVs containing the ADJUST blocks */ + PADNAMELIST *xhv_class_fields; /* PADNAMEs with PadnameIsFIELD() */ + PADOFFSET xhv_class_next_fieldix; }; #define HvAUXf_SCAN_STASH 0x1 /* stash is being scanned by gv_check */ #define HvAUXf_NO_DEREF 0x2 /* @{}, %{} etc (and nomethod) not present */ +#define HvAUXf_IS_CLASS 0x4 /* the package is a 'class' */ + +#define HvSTASH_IS_CLASS(hv) \ + (HvHasAUX(hv) && HvAUX(hv)->xhv_aux_flags & HvAUXf_IS_CLASS) /* hash structure: */ /* This structure must match the beginning of struct xpvmg in sv.h. */ -- cgit v1.2.1