[Home] DMelt member access. Java source code: org.python.compiler.ClassFile
// Copyright (c) Corporation for National Research Initiatives
package org.python.compiler;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.python.core.imp;
import org.python.compiler.ProxyCodeHelpers.AnnotationDescr;
public class ClassFile
{
ClassWriter cw;
int access;
long mtime;
public String name;
String superclass;
String sfilename;
String[] interfaces;
List methodVisitors;
List fieldVisitors;
List annotationVisitors;
public static String fixName(String n) {
if (n.indexOf('.') == -1)
return n;
char[] c = n.toCharArray();
for(int i=0; i fields) {
for (Entryfield: fields.entrySet()) {
visitAnnotation(av, field.getKey(), field.getValue());
}
}
// See org.objectweb.asm.AnnotationVisitor for details
// TODO Support annotation annotations and annotation array annotations
public static void visitAnnotation(AnnotationVisitor av, String fieldName, Object fieldValue) {
Class> fieldValueClass = fieldValue.getClass();
if (fieldValue instanceof Class) {
av.visit(fieldName, Type.getType((Class>)fieldValue));
} else if (fieldValueClass.isEnum()) {
av.visitEnum(fieldName, ProxyCodeHelpers.mapType(fieldValueClass), fieldValue.toString());
} else if (fieldValue instanceof List) {
AnnotationVisitor arrayVisitor = av.visitArray(fieldName);
List
Ads help maintain this website.