net.janino
Class EvaluatorBase

java.lang.Object
  |
  +--net.janino.EvaluatorBase
Direct Known Subclasses:
ClassBodyEvaluator, ExpressionEvaluator, ScriptEvaluator, SimpleCompiler

public class EvaluatorBase
extends java.lang.Object

Utilities for the various "...Evaluator" classes.


Constructor Summary
protected EvaluatorBase(java.lang.ClassLoader classLoader)
           
 
Method Summary
protected  Java.ClassDeclaration addClassDeclaration(Scanner.Location location, Java.CompilationUnit compilationUnit, java.lang.String className, java.lang.Class extendedType, java.lang.Class[] implementedTypes)
          To the given Java.CompilationUnit, add A class declaration with the given name, superclass and interfaces A method declaration with the given return type, name, parameter names and values and thrown exceptions
protected  Java.Block addClassMethodBlockDeclaration(Scanner.Location location, Java.CompilationUnit compilationUnit, java.lang.String className, java.lang.Class extendedType, java.lang.Class[] implementedTypes, java.lang.Class returnType, java.lang.String methodName, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes, java.lang.Class[] thrownExceptions)
          To the given Java.CompilationUnit, add A class declaration with the given name, superclass and interfaces A method declaration with the given return type, name, parameter names and values and thrown exceptions A block
protected  Java.Type[] classesToTypes(Scanner.Location location, java.lang.Class[] classes)
          Convert an array of Classes into an array ofJava.Types.
protected  Java.Type classToType(Scanner.Location location, java.lang.Class clazz)
          Wrap a reflection Class in a Java.Type object.
protected  java.lang.ClassLoader compileAndLoad(Java.CompilationUnit compilationUnit)
          Compile the given compilation unit.
protected  java.lang.Class compileAndLoad(Java.CompilationUnit compilationUnit, java.lang.String newClassName)
          Compile the given compilation unit, load all generated classes, and return the class with the given name.
protected  Java.FormalParameter[] makeFormalParameters(Scanner.Location location, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes)
          Convert name and Class-base parameters into an array of Java.FormalParameters.
protected  void parseImportDeclarations(Java.CompilationUnit compilationUnit, Scanner scanner)
          Parse as many import declarations as possible for the given Java.CompilationUnit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvaluatorBase

protected EvaluatorBase(java.lang.ClassLoader classLoader)
Method Detail

parseImportDeclarations

protected void parseImportDeclarations(Java.CompilationUnit compilationUnit,
                                       Scanner scanner)
                                throws Scanner.ScanException,
                                       Parser.ParseException,
                                       java.io.IOException
Parse as many import declarations as possible for the given Java.CompilationUnit.
Parameters:
compilationUnit -  
scanner - Source of tokens
Throws:
Scanner.ScanException -  
Parser.ParseException -  
java.io.IOException -  

addClassDeclaration

protected Java.ClassDeclaration addClassDeclaration(Scanner.Location location,
                                                    Java.CompilationUnit compilationUnit,
                                                    java.lang.String className,
                                                    java.lang.Class extendedType,
                                                    java.lang.Class[] implementedTypes)
                                             throws Parser.ParseException,
                                                    Scanner.ScanException,
                                                    java.io.IOException
To the given Java.CompilationUnit, add
Parameters:
location -  
compilationUnit -  
className -  
extendedType - (null == java.lang.Object)
implementedTypes -  
Returns:
The created Java.ClassDeclaration object
Throws:
Parser.ParseException -  
Scanner.ScanException -  
java.io.IOException -  

addClassMethodBlockDeclaration

protected Java.Block addClassMethodBlockDeclaration(Scanner.Location location,
                                                    Java.CompilationUnit compilationUnit,
                                                    java.lang.String className,
                                                    java.lang.Class extendedType,
                                                    java.lang.Class[] implementedTypes,
                                                    java.lang.Class returnType,
                                                    java.lang.String methodName,
                                                    java.lang.String[] parameterNames,
                                                    java.lang.Class[] parameterTypes,
                                                    java.lang.Class[] thrownExceptions)
                                             throws Parser.ParseException,
                                                    Scanner.ScanException,
                                                    java.io.IOException
To the given Java.CompilationUnit, add
Parameters:
location -  
compilationUnit -  
className -  
extendedType - (null == java.lang.Object)
implementedTypes -  
returnType -  
methodName -  
parameterNames -  
parameterTypes -  
thrownExceptions -  
Returns:
The created Java.Block object
Throws:
Parser.ParseException -  
Scanner.ScanException -  
java.io.IOException -  

classToType

protected Java.Type classToType(Scanner.Location location,
                                java.lang.Class clazz)
Wrap a reflection Class in a Java.Type object.

classesToTypes

protected Java.Type[] classesToTypes(Scanner.Location location,
                                     java.lang.Class[] classes)
Convert an array of Classes into an array ofJava.Types.

makeFormalParameters

protected Java.FormalParameter[] makeFormalParameters(Scanner.Location location,
                                                      java.lang.String[] parameterNames,
                                                      java.lang.Class[] parameterTypes)
Convert name and Class-base parameters into an array of Java.FormalParameters.

compileAndLoad

protected java.lang.ClassLoader compileAndLoad(Java.CompilationUnit compilationUnit)
                                        throws Java.CompileException
Compile the given compilation unit. (A "compilation unit" is typically the contents of a JavaTM source file.)
Parameters:
compilationUnit - The parsed compilation unit
Returns:
A java.lang.ClassLoader object through which the compiled classes can be accessed
Throws:
Java.CompileException -  

compileAndLoad

protected java.lang.Class compileAndLoad(Java.CompilationUnit compilationUnit,
                                         java.lang.String newClassName)
                                  throws Java.CompileException,
                                         java.lang.ClassNotFoundException
Compile the given compilation unit, load all generated classes, and return the class with the given name.
Parameters:
compilationUnit -  
newClassName - The fully qualified class name
Returns:
The loaded class
Throws:
Java.CompileException -  
java.lang.ClassNotFoundException - A class with the given name was not declared in the compilation unit