Package org.allspice.structured

Examples of org.allspice.structured.FileUnit


   */
  public static void javac() throws Exception {
    // Get the compiler
    Compiler compiler = JavaCompilerCompiler.loadJavaCompiler();
    // Parse the file
    FileUnit fu = compiler.parse(new JavaTokenizer(new StringReader(source))) ;

    // Create a class with the parsed HelloWorld.
    ClassConverter.writeClassFiles(StdJavaExpressions.INSTANCE,new File(System.getProperty("java.io.tmpdir")),new FIFO<FileUnit>(fu)) ;
  }
View Full Code Here


   */
  public static Object javac(String line) throws Exception {
    // Get the compiler
    Compiler compiler = JavaCompilerCompiler.loadJavaCompiler();
    // Parse the file
    FileUnit fu = compiler.parse(new JavaTokenizer(new StringReader(String.format(source,line)))) ;

    // Create a class loader with the parsed ExprEval.
    ClassLoader loader = ClassConverter.createLoader(StdJavaExpressions.INSTANCE,new FIFO<FileUnit>(fu)) ;
    // invoke expr.
    Method m = loader.loadClass("ExprEval").getMethod("expr") ;
View Full Code Here

* @param state
* @return The object
**/
private static final FileUnit reduce16(PositionRange range,Parser parser,ParserState state) {
{
  return new FileUnit() ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FileUnit reduce17(PositionRange range,Parser parser,ParserState state) {
      FileUnit fileunit = (FileUnit)state.reductions.tail.head.o ;
      ClassDecl classdecl = (ClassDecl)state.reductions.head.o ;
{
  return fileunit.addClassDecl(classdecl) ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FileUnit reduce18(PositionRange range,Parser parser,ParserState state) {
      FileUnit fileunit = (FileUnit)state.reductions.tail.tail.tail.head.o ;
      String nonarraytype = (String)state.reductions.tail.head.o ;
{
  return fileunit.setPackageName(nonarraytype) ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FileUnit reduce22(PositionRange range,Parser parser,ParserState state) {
      FileUnit fileunit = (FileUnit)state.reductions.tail.tail.tail.head.o ;
      String importspec = (String)state.reductions.tail.head.o ;
{
  return fileunit.addImport(importspec) ;
}
}
View Full Code Here

      }
      FieldAttrs fa = new FieldAttrs().setVisibility(Visibility.PUBLIC) ;
      meths = meths.insert(new MethodDecl(fa,returnType,name,vars, new FIFO<String>(),new FIFO<Statement>(stats))) ;
    }
    ClassDecl cd = new ClassDecl(Visibility.PUBLIC,ClassType.DEFAULT,"NewClass","java.lang.Object",new FIFO<String>(iface.getName()),meths) ;
    FileUnit fu = new FileUnit().addClassDecl(cd).setPackageName("org.allspice.structuredtobc.test") ;
    ClassLoader loader = ClassConverter.createLoader(StdJavaExpressions.INSTANCE,new FIFO<FileUnit>(fu)) ;
    Class<?> cl = loader.loadClass(ClassPool.getClassName(fu,cd).toString()) ;
    return (T)cl.newInstance() ;   
  }
View Full Code Here

      is.close() ;
    }
  }
 
  public static <T> Class<T> makeClass(URL url,Reader classdecl,String className) throws Exception {
    FileUnit fu = compiler.parse(new JavaTokenizer(classdecl)) ;
    fu = fu.setFileName(url.getFile()) ;
    ClassLoader loader = ClassConverter.createLoader(StdJavaExpressions.INSTANCE,new FIFO<FileUnit>(fu)) ;
    return (Class<T>)loader.loadClass(className) ;
  }
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final Object reduce0(PositionRange range,Parser parser,ParserState state) {
      FileUnit fileunit = (FileUnit)state.reductions.head.o ;
{
  return fileunit ;
}
}
View Full Code Here

TOP

Related Classes of org.allspice.structured.FileUnit

Copyright © 2018 www.massapicom. 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.