Examples of MethodGenerator


Examples of org.apache.xalan.xsltc.compiler.util.MethodGenerator

             NodeSortRecordGenerator sortRecord,
             ConstantPoolGen cpg,
             String className)
    {
  final InstructionList il = new InstructionList();
  final MethodGenerator init =
      new MethodGenerator(ACC_PUBLIC,
        org.apache.bcel.generic.Type.VOID,
        null, null, "<init>", className,
        il, cpg);

  // Call the constructor in the NodeSortRecord superclass
  il.append(ALOAD_0);
  il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
                 "<init>", "()V")));

  final int initLocale =  cpg.addMethodref("java/util/Locale",
             "<init>",
             "(Ljava/lang/String;"+
             "Ljava/lang/String;)V");
 
  final int getCollator = cpg.addMethodref(COLLATOR_CLASS,
             "getInstance",
             "(Ljava/util/Locale;)"+
             COLLATOR_SIG);

  final int setStrength = cpg.addMethodref(COLLATOR_CLASS,
             "setStrength", "(I)V");

  final int levels = sortObjects.size();

  /*
  final int levelsField = cpg.addFieldref(className, "_levels", "I");
  il.append(new PUSH(cpg, levels));
  il.append(new PUTSTATIC(levelsField));
  */

  // Compile code that initializes the locale
  String language = null;
  String country = null;
  Sort sort = (Sort)sortObjects.elementAt(0);

  for (int level = 0; level < levels; level++) {
      if (language == null && sort._lang != null) {
    language = sort._lang;
      }
      if (country == null && sort._country != null) {
    country = sort._country;
      }
  }

  final int collator =
      cpg.addFieldref(className, "_collator", COLLATOR_SIG);
  final int locale =
      cpg.addFieldref(className, "_locale", LOCALE_SIG);

  if (language != null) {
      // Create new Locale object on stack
      il.append(new NEW(cpg.addClass("java/util/Locale")));
      il.append(DUP);
      il.append(DUP);
      il.append(new PUSH(cpg, language));
      il.append(new PUSH(cpg, (country != null ? country : EMPTYSTRING)));
      il.append(new INVOKESPECIAL(initLocale));
      il.append(ALOAD_0);
      il.append(SWAP);
      il.append(new PUTFIELD(locale));
     
      // Use that Locale object to get the required Collator object
      il.append(new INVOKESTATIC(getCollator));
      il.append(ALOAD_0);
      il.append(SWAP);
      il.append(new PUTFIELD(collator));
  }

  il.append(ALOAD_0);
  il.append(new GETFIELD(collator));
  il.append(new ICONST(Collator.TERTIARY));
  il.append(new INVOKEVIRTUAL(setStrength));

  il.append(RETURN);

  init.stripAttributes(true);
  init.setMaxLocals();
  init.setMaxStack();

  return init.getMethod();
    }
View Full Code Here

Examples of org.dmd.dmg.extended.MethodGenerator

        super(new MethodGeneratorDMO(mods), org.dmd.dmg.generated.DmgSchemaAG._MethodGenerator);
    }

    // Generated from: org.dmd.dmg.generators.BaseDMWGeneratorNewest.dumpWrapper(BaseDMWGeneratorNewest.java:491)
    public MethodGenerator getModificationRecorder(){
        MethodGenerator rc = new MethodGenerator();
        rc.setName(getName());
        rc.setModifier(new DmcTypeModifierMV(MetaDMSAG.__modify));
        return(rc);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.