public String getNewField(String type, String name, Object init) { ClassVisitor cv = getClassVisitor(); // declare the field cv.visitField(ACC_PRIVATE, name, type, null, null).visitEnd(); if (init != null) { initMethod.aload(THIS); initMethod.ldc(init); initMethod.putfield(getClassname(), name, type); } return name; }
private void beginInit() { ClassVisitor cv = getClassVisitor(); initMethod = new SkinnyMethodAdapter(cv, ACC_PUBLIC, "<init>", sig(Void.TYPE), null, null); initMethod.start(); initMethod.aload(THIS); initMethod.invokespecial(p(AbstractScript.class), "<init>", sig(Void.TYPE)); // JRUBY-3014: make __FILE__ dynamically determined at load time, but // we provide a reasonable default here initMethod.aload(THIS); initMethod.ldc(getSourcename()); initMethod.putfield(getClassname(), "filename", ci(String.class)); }
public String getNewConstant(String type, String name_prefix, Object init) { ClassVisitor cv = getClassVisitor(); String realName = getNewConstantName(); // declare the field cv.visitField(ACC_PRIVATE, realName, type, null, null).visitEnd(); if (init != null) { initMethod.aload(THIS); initMethod.ldc(init); initMethod.putfield(getClassname(), realName, type); } return realName; }