Class Ek9ClassWriter
Standard ClassWriter.COMPUTE_FRAMES uses ClassLoader to find common superclasses when computing stack map frames. This fails when generating multiple classes in the same compilation unit because referenced classes aren't on classpath yet.
This custom writer uses a type hierarchy map (built from ISymbol data) to find actual common superclasses. This is essential for function delegate polymorphism: when if/else branches assign different concrete functions (e.g., UpperProcessor, LowerProcessor) to a variable of abstract type (Processor), ASM needs to know the actual common superclass (Processor) rather than defaulting to Object.
For exception types, uses java/lang/Throwable as the common superclass. For types not in the hierarchy map, defaults to java/lang/Object.
-
Field Summary
Fields inherited from class org.objectweb.asm.ClassWriter
COMPUTE_FRAMES, COMPUTE_MAXSFields inherited from class org.objectweb.asm.ClassVisitor
api, cv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetCommonSuperClass(String type1, String type2) Override getCommonSuperClass to use EK9's type hierarchy from ISymbol data.Methods inherited from class org.objectweb.asm.ClassWriter
getClassLoader, hasFlags, newClass, newConst, newConstantDynamic, newField, newHandle, newHandle, newInvokeDynamic, newMethod, newMethodType, newModule, newNameType, newPackage, newUTF8, setFlags, toByteArray, visit, visitAnnotation, visitAttribute, visitEnd, visitField, visitInnerClass, visitMethod, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource, visitTypeAnnotationMethods inherited from class org.objectweb.asm.ClassVisitor
getDelegate
-
Constructor Details
-
Ek9ClassWriter
-
-
Method Details
-
getCommonSuperClass
Override getCommonSuperClass to use EK9's type hierarchy from ISymbol data. Walks up both type hierarchies to find the first common ancestor.- Overrides:
getCommonSuperClassin classorg.objectweb.asm.ClassWriter- Parameters:
type1- First type (internal name, e.g., "module/UpperProcessor")type2- Second type (internal name, e.g., "module/LowerProcessor")- Returns:
- Common superclass internal name (e.g., "module/Processor")
-