org.jaitools.jiffle.parser
Class FunctionLookup

java.lang.Object
  extended by org.jaitools.jiffle.parser.FunctionLookup

public class FunctionLookup
extends java.lang.Object

A lookup service used by the Jiffle compiler when parsing function calls in scripts.

Since:
0.1
Version:
$Id: FunctionLookup.java 1653 2011-06-16 10:23:02Z michael.bedward $
Author:
Michael Bedward

Constructor Summary
FunctionLookup()
           
 
Method Summary
static FunctionInfo getInfo(java.lang.String jiffleName, java.util.List<java.lang.String> argTypes)
          Gets the info for a function.
static java.lang.String getReturnType(java.lang.String jiffleName)
          Searches for a function with a script name that matches jiffleName and gets its return type.
static java.lang.String getRuntimeExpr(java.lang.String jiffleName, java.util.List<java.lang.String> argTypes)
          Gets the runtime source for the function.
static boolean isDefined(java.lang.String jiffleName, java.util.List<java.lang.String> argTypes)
          Checks if a function is defined.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionLookup

public FunctionLookup()
Method Detail

isDefined

public static boolean isDefined(java.lang.String jiffleName,
                                java.util.List<java.lang.String> argTypes)
Checks if a function is defined.

Parameters:
jiffleName - the name of the function used in a Jiffle script
argTypes - argument type names; null or empty for no-arg functions
Returns:
true if defined; false otherwise

getInfo

public static FunctionInfo getInfo(java.lang.String jiffleName,
                                   java.util.List<java.lang.String> argTypes)
                            throws UndefinedFunctionException
Gets the info for a function.

Parameters:
jiffleName - the name of the function used in a Jiffle script
argTypes - argument type names; null or empty for no-arg functions
Returns:
function info
Throws:
UndefinedFunctionException - if jiffleName is not recognized

getRuntimeExpr

public static java.lang.String getRuntimeExpr(java.lang.String jiffleName,
                                              java.util.List<java.lang.String> argTypes)
                                       throws UndefinedFunctionException
Gets the runtime source for the function. This will consist of provider name plus function name in the case of JiffleFunction and java.lang.Math methods, or runtime class field name in the case of proxy (image info) functions.

Parameters:
jiffleName - the name of the function used in a Jiffle script
argTypes - argument type names; null or empty for no-arg functions
Returns:
the runtime source
Throws:
UndefinedFunctionException - if jiffleName is not recognized

getReturnType

public static java.lang.String getReturnType(java.lang.String jiffleName)
                                      throws UndefinedFunctionException
Searches for a function with a script name that matches jiffleName and gets its return type. This method relies on the fact that Jiffle has the same return type for all functions with the same root name.

Parameters:
jiffleName - name to match
Returns:
the return type: D or List
Throws:
UndefinedFunctionException - if the name is not matched


Copyright © 2011. All Rights Reserved.