From b55a91c557f380db6f82a664b2d22b208df3b3c4 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 27 Jan 2026 09:50:44 -0500 Subject: [PATCH 1/7] Enable processing for all abstracts. --- .../_internal/PolymodScriptClassMacro.hx | 116 +++++++++--------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index d80049c8..2bb14ebf 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -19,7 +19,7 @@ using StringTools; class PolymodScriptClassMacro { /** * Returns a `Map>` which maps superclass paths to scripted classes. - * So `class ScriptedStage extends Stage implements HScriptable` will be `"Stage" -> ScriptedStage` + * So `class ScriptedStage extends Stage implements HScriptable` will be `"Stage" -> ScriptedStage` */ public static macro function listHScriptedClasses():ExprOf>> { if (!onGenerateCallbackRegistered) @@ -62,10 +62,10 @@ class PolymodScriptClassMacro { static var onAfterTypingCallbackRegistered:Bool = false; static function onGenerate(allTypes:Array) { - // Reset these, since onGenerate persists across multiple builds. + // Reset these, since onGenerate persists across multiple builds. var hscriptedClassType:ClassType = MacroUtil.getClassType('polymod.hscript.HScriptedClass'); - var hscriptedClassEntries:Array = []; + var hscriptedClassEntries:Array = []; var abstractImplEntries:Array = []; var abstractStaticEntries:Array = []; @@ -76,8 +76,8 @@ class PolymodScriptClassMacro { var classType:ClassType = t.get(); var classPath:String = '${classType.pack.concat([classType.name]).join(".")}'; - if (classType.isInterface) { - // Ignore interfaces. + if (classType.isInterface) { + // Ignore interfaces. } else if (MacroUtil.implementsInterface(classType, hscriptedClassType)) { // Context.info('${classPath} implements HScriptedClass? YEAH', Context.currentPos()); // TODO: Do we need to parameterize? @@ -95,54 +95,54 @@ class PolymodScriptClassMacro { } else { } case TAbstract(t, _params): var abstractPath:String = t.toString(); - if (abstractPath == 'flixel.util.FlxColor') { - var abstractType = t.get(); - var abstractImpl = abstractType.impl.get(); - var abstractImplPath = abstractType.impl.toString(); - // Context.info('${abstractImplPath} implements FlxColor', Context.currentPos()); + var abstractType = t.get(); + var abstractImpl = abstractType.impl?.get(); + var abstractImplPath:String = abstractType.impl?.toString() ?? ''; - var entryData = [ - macro $v{abstractPath}, - macro $v{abstractImplPath} - ]; + if (abstractImpl == null) { + // If the abstract doesn't have an implementation, it's usually an extern or something, so we always want to ignore it. + continue; + } - abstractImplEntries.push(macro $a{entryData}); + var entryData = [ + macro $v{abstractPath}, + macro $v{abstractImplPath} + ]; - for (field in abstractImpl.statics.get()) { - switch (field.type) { - case TAbstract(_, _): - // - case TType(_, _): - // - default: - continue; - } - - var key:String = '${abstractImplPath}.${field.name}'; + abstractImplEntries.push(macro $a{entryData}); - if (!staticFieldToClass.exists(key)) { + for (field in abstractImpl.statics.get()) { + switch (field.type) { + case TAbstract(_, _): + // + case TType(_, _): + // + default: continue; - } - - var staticEntryData = [ - macro $v{key}, - macro $v{staticFieldToClass[key]}, - ]; + } + + var key:String = '${abstractImplPath}.${field.name}'; - abstractStaticEntries.push(macro $a{staticEntryData}); + if (!staticFieldToClass.exists(key)) { + continue; } - // Try to apply RTTI? - abstractType.meta.add(':rtti', [], Context.currentPos()); - abstractImpl.meta.add(':rtti', [], Context.currentPos()); + var staticEntryData = [ + macro $v{key}, + macro $v{staticFieldToClass[key]}, + ]; + + abstractStaticEntries.push(macro $a{staticEntryData}); } default: - continue; + continue; } } - var polymodScriptClassClassType:ClassType = MacroUtil.getClassType('polymod.hscript._internal.PolymodScriptClassMacro'); - polymodScriptClassClassType.meta.remove('hscriptedClasses'); + Context.info('PolymodScriptClassMacro: Registering ${hscriptedClassEntries.length} HScriptedClasses, ${abstractImplEntries.length} abstract impls, ${abstractStaticEntries.length} abstract statics', Context.currentPos()); + + var polymodScriptClassClassType:ClassType = MacroUtil.getClassType('polymod.hscript._internal.PolymodScriptClassMacro'); + polymodScriptClassClassType.meta.remove('hscriptedClasses'); polymodScriptClassClassType.meta.add('hscriptedClasses', hscriptedClassEntries, Context.currentPos()); polymodScriptClassClassType.meta.remove('abstractImpls'); polymodScriptClassClassType.meta.add('abstractImpls', abstractImplEntries, Context.currentPos()); @@ -161,11 +161,15 @@ class PolymodScriptClassMacro { var abstractPath = a.toString(); var abstractType = a.get(); - if (abstractPath != 'flixel.util.FlxColor') { + // If the abstract is private, the implementation won't be accessible. + var abstractIsPrivate = abstractType.isPrivate; + if (abstractIsPrivate) { continue; } - - if (abstractType.impl == null) { + + // Check if, for other reasons, the implementation is missing. + var abstractHasNoImpl = abstractType.impl == null; + if (abstractHasNoImpl) { continue; } @@ -187,7 +191,7 @@ class PolymodScriptClassMacro { } if (getter == null) { - throw 'This should not happen'; + throw 'Getter is null?'; } switch (getter.type) { @@ -195,7 +199,7 @@ class PolymodScriptClassMacro { if (args.length != 0) continue; default: - throw 'This should not happen'; + throw 'Getter has an unknown type?'; } canGet = true; @@ -211,7 +215,7 @@ class PolymodScriptClassMacro { } if (setter == null) { - throw 'This should not happen'; + throw 'Setter is null?'; } switch (setter.type) { @@ -219,7 +223,7 @@ class PolymodScriptClassMacro { if (args.length != 1) continue; default: - throw 'This should not happen'; + throw 'Setter has an unknown type?'; } canSet = true; @@ -299,25 +303,25 @@ class PolymodScriptClassMacro { public static function fetchHScriptedClasses():Map> { var metaData = Meta.getType(PolymodScriptClassMacro); - // trace('Got metaData: ' + metaData); + // trace('Got metaData: ' + metaData); if (metaData.hscriptedClasses != null) { - trace('Got hscriptedClasses: ' + metaData.hscriptedClasses); + trace('Got hscriptedClasses: ' + metaData.hscriptedClasses); var result:Map> = []; // Each element is formatted as `[superClassPath, classPath]`. for (element in metaData.hscriptedClasses) { - if (element.length != 2) { - throw 'Malformed element in hscriptedClasses: ' + element; - } + if (element.length != 2) { + throw 'Malformed element in hscriptedClasses: ' + element; + } - var superClassPath:String = element[0]; - var classPath:String = element[1]; + var superClassPath:String = element[0]; + var classPath:String = element[1]; var classType:Class = cast Type.resolveClass(classPath); - result.set(superClassPath, classType); - } + result.set(superClassPath, classType); + } return result; } else { From deac45e44a5c6bd7752a77c1a3cb21ee3440ae9e Mon Sep 17 00:00:00 2001 From: lemz <87707926+lemz1@users.noreply.github.com> Date: Fri, 30 Jan 2026 02:07:28 +0100 Subject: [PATCH 2/7] fix compile errors --- .../_internal/PolymodScriptClassMacro.hx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index 2bb14ebf..ded10a16 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -179,8 +179,6 @@ class PolymodScriptClassMacro { for (field in abstractImplType.statics.get()) { switch (field.kind) { case FVar(read, write): - trace(field.name, read, write); - var canGet:Bool = read == AccInline || read == AccNormal; if (read == AccCall) { var getter:Null = null; @@ -239,9 +237,20 @@ class PolymodScriptClassMacro { pos: Context.currentPos(), name: fieldName, access: [Access.APublic, Access.AStatic], - kind: FProp(canGet ? 'get' : 'never', canSet ? 'set' : 'never', Context.toComplexType(field.type), null) + kind: FProp(canGet ? 'get' : 'never', canSet ? 'set' : 'never', (macro: Dynamic), null) }); + var fieldExpr:Expr = null; + try { + // when this fails, this should mean that we are dealing with an enum abstract + // so we need to handle it differently + var fullPath:String = '${abstractType.module}.${abstractType.name}'; + Context.getType(fullPath); + fieldExpr = Context.parse('${fullPath}.${field.name}', Context.currentPos()); + } catch (_) { + fieldExpr = Context.getTypedExpr(field.expr()); + } + if (canGet) { fields.push({ pos: Context.currentPos(), @@ -252,7 +261,7 @@ class PolymodScriptClassMacro { ret: null, expr: macro { @:privateAccess - return ${Context.parse(abstractPath + '.' + field.name, Context.currentPos())}; + return ${fieldExpr}; } }) }); @@ -268,7 +277,7 @@ class PolymodScriptClassMacro { ret: null, expr: macro { @:privateAccess - return ${Context.parse(abstractPath + '.' + field.name, Context.currentPos())} = value; + return ${fieldExpr} = value; } }) }); From 0472b9a24db2477d2ae58f459641858627a4d8d8 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 31 Jan 2026 06:46:16 -0500 Subject: [PATCH 3/7] Gracefully fail (and display a script error) rather than throwing an exception and crashing if an abstract can't be resolved. --- polymod/hscript/_internal/PolymodInterpEx.hx | 19 ++++++++++++------- .../_internal/PolymodScriptClassMacro.hx | 3 +-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/polymod/hscript/_internal/PolymodInterpEx.hx b/polymod/hscript/_internal/PolymodInterpEx.hx index ae572f52..dddbec89 100644 --- a/polymod/hscript/_internal/PolymodInterpEx.hx +++ b/polymod/hscript/_internal/PolymodInterpEx.hx @@ -324,7 +324,7 @@ class PolymodInterpEx extends Interp continue; } - Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not import ${imp.fullPath}', clsPath); + Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not import ${imp.fullPath}. Check to ensure the module exists and is spelled correctly.', clsPath); } // Check if the scripted classes extend the right type. @@ -338,7 +338,7 @@ class PolymodInterpEx extends Interp case CTPath(path, params): if (params != null && params.length > 0) { - Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not extend ${superClassPath}, do not include type parameters in super class name', clsPath); + Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not extend ${superClassPath}, do not include type parameters in super class name.', clsPath); } default: @@ -346,7 +346,7 @@ class PolymodInterpEx extends Interp } // Default - Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not extend ${superClassPath}, is the type imported?', clsPath); + Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not extend ${superClassPath}. Make sure the type to extend has been imported.', clsPath); } else { @@ -1852,8 +1852,15 @@ class PolymodInterpEx extends Interp } else if (PolymodScriptClass.abstractClassImpls.exists(importedClass.fullPath)) { // We used a macro to map each abstract to its implementation. importedClass.cls = PolymodScriptClass.abstractClassImpls.get(importedClass.fullPath); - trace('RESOLVED ABSTRACT CLASS ${importedClass.fullPath} -> ${Type.getClassName(importedClass.cls)}'); - trace(Type.getClassFields(importedClass.cls)); + + if (importedClass.cls == null) { + trace('UNRESOLVED ABSTRACT CLASS ${importedClass.fullPath}'); + Polymod.warning(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Abstract type ${importedClass.fullPath} could not be resolved. Try using the underlying type instead.', origin); + } else { + trace('RESOLVED ABSTRACT CLASS ${importedClass.fullPath} -> ${Type.getClassName(importedClass.cls)}'); + trace(Type.getClassFields(importedClass.cls)); + } + } else if (_scriptEnumDescriptors.exists(importedClass.fullPath)) { // do nothing } else { @@ -1866,7 +1873,6 @@ class PolymodInterpEx extends Interp // If the class is still not found, skip this import entirely. if (resultCls == null && resultEnm == null) { - //Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not import class ${importedClass.fullPath}', origin); // this could be a scripted class or enum that hasn't been registered yet importsToValidate.set(importedClass.name, importedClass); continue; @@ -1917,7 +1923,6 @@ class PolymodInterpEx extends Interp // If the class is still not found, skip this import entirely. if (resultCls == null) { - //Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not import class ${importedClass.fullPath}', origin); // this could be a scripted class that hasn't been registered yet importsToValidate.set(importedClass.name, importedClass); continue; diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index ded10a16..f905bca4 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -353,7 +353,6 @@ class PolymodScriptClassMacro { var abstractPath:String = element[0]; var abstractImplPath:String = element[1]; - // var abstractType:Class = cast Type.resolveClass(abstractPath); #if js trace('Resolving using JS method'); var abstractImplType:Class = resolveClass(abstractPath); @@ -366,7 +365,7 @@ class PolymodScriptClassMacro { var abstractImplType:Class = cast Type.resolveClass(abstractImplPath); if (abstractImplType == null) { - throw 'Could not resolve ' + abstractImplPath; + // trace('POLYMOD ABSTRACTS: Could not resolve $abstractImplPath'); } #end From fae86807e171dcf81d4c184ce476ba79df0d6dc6 Mon Sep 17 00:00:00 2001 From: Hyper_ <40342021+NotHyper-474@users.noreply.github.com> Date: Sun, 1 Feb 2026 03:42:03 -0300 Subject: [PATCH 4/7] break out from loops after finding getter/setter --- polymod/hscript/_internal/PolymodScriptClassMacro.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index f905bca4..1bf40b3e 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -185,6 +185,7 @@ class PolymodScriptClassMacro { for (f in abstractImplType.statics.get()) { if (f.name == 'get_${field.name}'){ getter = f; + break; } } @@ -209,6 +210,7 @@ class PolymodScriptClassMacro { for (f in abstractImplType.statics.get()){ if (f.name == 'set_${field.name}'){ setter = f; + break; } } From 89031001c8d3ac872f757a93dc7efe13c15cdd1a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 1 Feb 2026 22:32:32 -0500 Subject: [PATCH 5/7] Remove some extra print calls. --- polymod/hscript/_internal/PolymodInterpEx.hx | 7 ++----- polymod/hscript/_internal/PolymodScriptClassMacro.hx | 6 ------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/polymod/hscript/_internal/PolymodInterpEx.hx b/polymod/hscript/_internal/PolymodInterpEx.hx index dddbec89..2f11d675 100644 --- a/polymod/hscript/_internal/PolymodInterpEx.hx +++ b/polymod/hscript/_internal/PolymodInterpEx.hx @@ -1854,11 +1854,10 @@ class PolymodInterpEx extends Interp importedClass.cls = PolymodScriptClass.abstractClassImpls.get(importedClass.fullPath); if (importedClass.cls == null) { - trace('UNRESOLVED ABSTRACT CLASS ${importedClass.fullPath}'); Polymod.warning(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Abstract type ${importedClass.fullPath} could not be resolved. Try using the underlying type instead.', origin); } else { - trace('RESOLVED ABSTRACT CLASS ${importedClass.fullPath} -> ${Type.getClassName(importedClass.cls)}'); - trace(Type.getClassFields(importedClass.cls)); + // trace('RESOLVED ABSTRACT CLASS ${importedClass.fullPath} -> ${Type.getClassName(importedClass.cls)}'); + // trace(Type.getClassFields(importedClass.cls)); } } else if (_scriptEnumDescriptors.exists(importedClass.fullPath)) { @@ -1914,8 +1913,6 @@ class PolymodInterpEx extends Interp } else if (PolymodScriptClass.abstractClassImpls.exists(importedClass.fullPath)) { // We used a macro to map each abstract to its implementation. importedClass.cls = PolymodScriptClass.abstractClassImpls.get(importedClass.fullPath); - trace('RESOLVED ABSTRACT CLASS ${importedClass.fullPath} -> ${Type.getClassName(importedClass.cls)}'); - trace(Type.getClassFields(importedClass.cls)); } else if (_scriptEnumDescriptors.exists(importedClass.fullPath)) { // do nothing } else { diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index 1bf40b3e..0327e594 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -314,11 +314,7 @@ class PolymodScriptClassMacro { public static function fetchHScriptedClasses():Map> { var metaData = Meta.getType(PolymodScriptClassMacro); - // trace('Got metaData: ' + metaData); - if (metaData.hscriptedClasses != null) { - trace('Got hscriptedClasses: ' + metaData.hscriptedClasses); - var result:Map> = []; // Each element is formatted as `[superClassPath, classPath]`. @@ -356,14 +352,12 @@ class PolymodScriptClassMacro { var abstractPath:String = element[0]; var abstractImplPath:String = element[1]; #if js - trace('Resolving using JS method'); var abstractImplType:Class = resolveClass(abstractPath); if (abstractImplType == null) { throw 'Could not resolve ' + abstractPath; } #else - // trace('Resolving using native method'); var abstractImplType:Class = cast Type.resolveClass(abstractImplPath); if (abstractImplType == null) { From 88253e214eb9d1039e5ac995ac9639fad03aa162 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 1 Feb 2026 22:33:56 -0500 Subject: [PATCH 6/7] Properly support enum abstract values (i.e. inline get-only static fields of abstracts) --- .../_internal/PolymodScriptClassMacro.hx | 209 +++++++++--------- 1 file changed, 106 insertions(+), 103 deletions(-) diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index 0327e594..f87e7097 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -170,124 +170,127 @@ class PolymodScriptClassMacro { // Check if, for other reasons, the implementation is missing. var abstractHasNoImpl = abstractType.impl == null; if (abstractHasNoImpl) { + // Only a few classes end up here, generally ones that are implemented directly in code. + // Includes like StdTypes.Float, StdTypes.Dynamic, StdTypes.Void, cpp.Int16, cpp.SizeT, Class, Enum continue; - } + } else { + var abstractImplPath = abstractType.impl.toString(); + var abstractImplType = abstractType.impl.get(); + var abstractImplStatics = abstractImplType.statics.get(); + var underlyingType = abstractType.type; + + for (field in abstractImplStatics) { + switch (field.kind) { + case FVar(read, write): + var canGet:Bool = read == AccInline || read == AccNormal; + if (read == AccCall) { + var getter:Null = null; + for (f in abstractImplStatics) { + if (f.name == 'get_${field.name}'){ + getter = f; + break; + } + } - var abstractImplPath = abstractType.impl.toString(); - var abstractImplType = abstractType.impl.get(); - - for (field in abstractImplType.statics.get()) { - switch (field.kind) { - case FVar(read, write): - var canGet:Bool = read == AccInline || read == AccNormal; - if (read == AccCall) { - var getter:Null = null; - for (f in abstractImplType.statics.get()) { - if (f.name == 'get_${field.name}'){ - getter = f; - break; + if (getter == null) { + throw 'Getter is null?'; } - } - if (getter == null) { - throw 'Getter is null?'; - } + switch (getter.type) { + case TFun(args, _): + if (args.length != 0) + continue; + default: + throw 'Getter has an unknown type?'; + } - switch (getter.type) { - case TFun(args, _): - if (args.length != 0) - continue; - default: - throw 'Getter has an unknown type?'; + canGet = true; } - canGet = true; - } + var canSet:Bool = write == AccNormal; + if (write == AccCall) { + var setter:Null = null; + for (f in abstractImplType.statics.get()){ + if (f.name == 'set_${field.name}'){ + setter = f; + break; + } + } - var canSet:Bool = write == AccNormal; - if (write == AccCall) { - var setter:Null = null; - for (f in abstractImplType.statics.get()){ - if (f.name == 'set_${field.name}'){ - setter = f; - break; + if (setter == null) { + throw 'Setter is null?'; } - } - if (setter == null) { - throw 'Setter is null?'; - } + switch (setter.type) { + case TFun(args, _): + if (args.length != 1) + continue; + default: + throw 'Setter has an unknown type?'; + } - switch (setter.type) { - case TFun(args, _): - if (args.length != 1) - continue; - default: - throw 'Setter has an unknown type?'; + canSet = true; } - canSet = true; - } + if (canGet) { + var fieldName:String = '${abstractImplPath.replace('.', '_')}_${field.name}'; + + fields.push({ + pos: Context.currentPos(), + name: fieldName, + access: [Access.APublic, Access.AStatic], + kind: FProp(canGet ? 'get' : 'never', canSet ? 'set' : 'never', (macro: Dynamic), null) + }); + + var fieldExpr:Expr = null; + try { + // when this fails, this should mean that we are dealing with an enum abstract + // so we need to handle it differently + var fullPath:String = '${abstractType.module}.${abstractType.name}'; + Context.getType(fullPath); + fieldExpr = Context.parse('${fullPath}.${field.name}', Context.currentPos()); + } catch (_) { + fieldExpr = Context.getTypedExpr(field.expr()); + } - if (!canGet && !canSet) { - continue; - } - - var fieldName:String = '${abstractImplPath.replace('.', '_')}_${field.name}'; - - fields.push({ - pos: Context.currentPos(), - name: fieldName, - access: [Access.APublic, Access.AStatic], - kind: FProp(canGet ? 'get' : 'never', canSet ? 'set' : 'never', (macro: Dynamic), null) - }); - - var fieldExpr:Expr = null; - try { - // when this fails, this should mean that we are dealing with an enum abstract - // so we need to handle it differently - var fullPath:String = '${abstractType.module}.${abstractType.name}'; - Context.getType(fullPath); - fieldExpr = Context.parse('${fullPath}.${field.name}', Context.currentPos()); - } catch (_) { - fieldExpr = Context.getTypedExpr(field.expr()); - } - - if (canGet) { - fields.push({ - pos: Context.currentPos(), - name: 'get_${fieldName}', - access: [Access.APublic, Access.AStatic], - kind: FFun({ - args: [], - ret: null, - expr: macro { - @:privateAccess - return ${fieldExpr}; - } - }) - }); - } - - if (canSet) { - fields.push({ - pos: Context.currentPos(), - name: 'set_${fieldName}', - access: [Access.APublic, Access.AStatic], - kind: FFun({ - args: [{name: 'value'}], - ret: null, - expr: macro { - @:privateAccess - return ${fieldExpr} = value; - } - }) - }); - } + if (canGet) { + fields.push({ + pos: Context.currentPos(), + name: 'get_${fieldName}', + access: [Access.APublic, Access.AStatic], + kind: FFun({ + args: [], + ret: null, + expr: macro { + @:privateAccess + return ${fieldExpr}; + } + }) + }); + } - staticFieldToClass.set('${abstractImplPath}.${field.name}', 'polymod.hscript._internal.AbstractStaticMembers_${iteration}'); - default: - continue; + if (canSet) { + fields.push({ + pos: Context.currentPos(), + name: 'set_${fieldName}', + access: [Access.APublic, Access.AStatic], + kind: FFun({ + args: [{name: 'value'}], + ret: null, + expr: macro { + @:privateAccess + return ${fieldExpr} = value; + } + }) + }); + } + + staticFieldToClass.set('${abstractImplPath}.${field.name}', 'polymod.hscript._internal.AbstractStaticMembers_${iteration}'); + } + + default: + continue; + } } } default: From 68d46b75c69e831932b15878b3bf1b61cab02362 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 1 Feb 2026 22:34:15 -0500 Subject: [PATCH 7/7] Add timing data for processing abstracts to the compilation output. --- .../_internal/PolymodScriptClassMacro.hx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/polymod/hscript/_internal/PolymodScriptClassMacro.hx b/polymod/hscript/_internal/PolymodScriptClassMacro.hx index f87e7097..f2c53a5d 100644 --- a/polymod/hscript/_internal/PolymodScriptClassMacro.hx +++ b/polymod/hscript/_internal/PolymodScriptClassMacro.hx @@ -69,6 +69,10 @@ class PolymodScriptClassMacro { var abstractImplEntries:Array = []; var abstractStaticEntries:Array = []; + Context.info('PolymodScriptClassMacro: Processing abstracts...', Context.currentPos()); + + var startTime:Float = Sys.time(); + for (type in allTypes) { switch (type) { // Class instances @@ -139,7 +143,11 @@ class PolymodScriptClassMacro { } } - Context.info('PolymodScriptClassMacro: Registering ${hscriptedClassEntries.length} HScriptedClasses, ${abstractImplEntries.length} abstract impls, ${abstractStaticEntries.length} abstract statics', Context.currentPos()); + var endTime:Float = Sys.time(); + + var duration:Float = endTime - startTime; + + Context.info('PolymodScriptClassMacro: Registered ${hscriptedClassEntries.length} HScriptedClasses, ${abstractImplEntries.length} abstract impls, ${abstractStaticEntries.length} abstract statics in ${duration} sec.', Context.currentPos()); var polymodScriptClassClassType:ClassType = MacroUtil.getClassType('polymod.hscript._internal.PolymodScriptClassMacro'); polymodScriptClassClassType.meta.remove('hscriptedClasses'); @@ -155,6 +163,10 @@ class PolymodScriptClassMacro { static function onAfterTyping(types: Array):Void { var fields:Array = []; + Context.info('PolymodScriptClassMacro: Processing abstract static fields...', Context.currentPos()); + + var startTime:Float = Sys.time(); + for (type in types) { switch (type) { case TAbstract(a): @@ -310,6 +322,12 @@ class PolymodScriptClassMacro { fields: fields }); + var endTime:Float = Sys.time(); + + var duration:Float = endTime - startTime; + + Context.info('PolymodScriptClassMacro: Processed ${fields.length} static fields in ${duration} sec (iteration #${iteration}).', Context.currentPos()); + iteration++; } #end