本文整理汇总了Java中jdk.nashorn.internal.tools.nasgen.MemberInfo.Kind.PROPERTY属性的典型用法代码示例。如果您正苦于以下问题:Java Kind.PROPERTY属性的具体用法?Java Kind.PROPERTY怎么用?Java Kind.PROPERTY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类jdk.nashorn.internal.tools.nasgen.MemberInfo.Kind
的用法示例。
在下文中一共展示了Kind.PROPERTY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGetter
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
final int access = ACC_PUBLIC;
final String name = GETTER_PREFIX + memInfo.getJavaName();
final String desc = getterDesc(memInfo);
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
mi.visitCode();
if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
} else {
mi.loadLocal(0);
mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
}
mi.returnValue();
mi.computeMaxs();
mi.visitEnd();
}
示例2: addSetter
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
final int access = ACC_PUBLIC;
final String name = SETTER_PREFIX + memInfo.getJavaName();
final String desc = setterDesc(memInfo);
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
mi.visitCode();
if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
mi.loadLocal(1);
mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
} else {
mi.loadLocal(0);
mi.loadLocal(1);
mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
}
mi.returnVoid();
mi.computeMaxs();
mi.visitEnd();
}
示例3: visitField
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
final String fieldDesc, final String signature, final Object value) {
final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
// non-instance @Property fields - these have to go elsewhere unless 'static final'
return null;
}
final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
signature, value);
return new FieldVisitor(Opcodes.ASM4, delegateFV) {
@Override
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
if (ScriptClassInfo.annotations.containsKey(desc)) {
// ignore script field annotations
return null;
}
return fv.visitAnnotation(desc, visible);
}
@Override
public void visitAttribute(final Attribute attr) {
fv.visitAttribute(attr);
}
@Override
public void visitEnd() {
fv.visitEnd();
}
};
}
示例4: visitField
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
final String fieldDesc, final String signature, final Object value) {
final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
// non-instance @Property fields - these have to go elsewhere unless 'static final'
return null;
}
final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
signature, value);
return new FieldVisitor(Main.ASM_VERSION, delegateFV) {
@Override
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
if (ScriptClassInfo.annotations.containsKey(desc)) {
// ignore script field annotations
return null;
}
return fv.visitAnnotation(desc, visible);
}
@Override
public void visitAttribute(final Attribute attr) {
fv.visitAttribute(attr);
}
@Override
public void visitEnd() {
fv.visitEnd();
}
};
}