use of kalang.ast.StaticFieldExpr in project kalang by kasonyang.
the class AstUtil method createGetter.
public static void createGetter(ClassNode clazz, FieldDescriptor field, int accessModifier) {
String fn = field.getName();
String getterName = "get" + NameUtil.firstCharToUpperCase(fn);
boolean isStatic = isStatic(field.getModifier());
if (isStatic) {
accessModifier |= Modifier.STATIC;
}
MethodNode getter = clazz.createMethodNode(field.getType(), getterName, accessModifier);
// getter.offset = field.offset;
BlockStmt body = getter.getBody();
FieldExpr fe;
ClassReference cr = new ClassReference(clazz);
if (isStatic) {
fe = new StaticFieldExpr(cr, field);
} else {
fe = new ObjectFieldExpr(new ThisExpr(Types.getClassType(clazz)), field);
}
body.statements.add(new ReturnStmt(fe));
}
Aggregations