Nice TWiki > Doc > CodeExamples > BuilderPatternMultiMethodExample > InstanceGeneratorMultiMethodExample (r1.3) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }
/* Please try the NoviceExamples before the MultiMethodExamples
To compile:
   nicec --sourcepath=.. -a builderpattern.jar builderpattern
To run:
   java -jar builderpattern.jar
*/

package builderpattern;


//==== dumpHeader

//==== dumpInnerClasses

//==== dumpLoop

//==== dumpFun


dumpFun(InstanceStyle){
   out.println("static int " + InstanceStyle + "() {");
   createVisitees(InstanceStyle);
   out.println("");
   startTimer(InstanceStyle);
   out.println( "   long sumInstanceof = 0;\n" +
                "   for (int i=0;i<"+ITERS+";i++)\n"+
                "      for (int j=0;j<"+VISITEES+";j++) {\n"+
                "         A tmp = a[j];"
      );
   
   for (int k=0;k<VISITORS;k++){
      for (int j=VISITEES-1;j>=0;j--)
         out.println("         if (tmp instanceof A"+j+") sumInstanceof += " + j + "; else");

      out.print("\n");
      }
      out.println("            throw new Error(\"Illegal call\");");   
      out.println("      }\n");
      stopTimer(InstanceStyle);   
      out.println("   }");
}

//==== dumpFooter

-- IsaacGouy - 30 Jan 2004

Topic InstanceGeneratorMultiMethodExample . { Edit | Attach | Ref-By | Printable | Diffs | r1.6 | > | r1.5 | > | r1.4 | More }
Revision r1.3 - 28 Oct 2004 - 11:29 GMT - ArjanB
Parents: WebHome > CodeExamples > BuilderPatternMultiMethodExample
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.