Allow for setting fields before super

also improved fetching superclass fields
This commit is contained in:
Jaime Humberto Macias Bustamante
2025-06-20 14:45:06 -07:00
parent 1af4a64b10
commit b48a3ee9ed
2 changed files with 75 additions and 6 deletions
+16
View File
@@ -348,6 +348,13 @@ class ClassExtendMacro {
// Adding hscript getters and setters
shadowClass.fields.push({
name: "__cachedFieldSet",
pos: Context.currentPos(),
kind: FVar(macro: Map<String, Dynamic>),
access: [APublic, AStatic]
});
shadowClass.fields.push({
name: "__interp",
pos: Context.currentPos(),
@@ -573,6 +580,15 @@ class ClassExtendMacro {
expr: macro {
// Call the super constructor with appropriate args
super($a{superCallArgs});
if(__cachedFieldSet != null) {
for(k => v in __cachedFieldSet) {
Reflect.setProperty(this, k, v);
trace(k);
}
__cachedFieldSet.clear();
__cachedFieldSet = null;
}
}
}),
};