Package org.qdl_lang.evaluate
Class MetaEvaluator
- java.lang.Object
- 
- org.qdl_lang.evaluate.AbstractEvaluator
- 
- org.qdl_lang.evaluate.MetaEvaluator
 
 
- 
- All Implemented Interfaces:
- Serializable,- EvaluatorInterface
 
 public class MetaEvaluator extends AbstractEvaluator This is charged with managing the build-in functions as well as any that the user defines.Created by Jeff Gaynor 
 on 1/16/20 at 6:14 AM- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.qdl_lang.evaluate.AbstractEvaluatorAbstractEvaluator.CommonKeyIterator, AbstractEvaluator.fPointer, AbstractEvaluator.fpResult
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intMETA_BASE_VALUEprotected static List<String>systemNamespaces- 
Fields inherited from class org.qdl_lang.evaluate.AbstractEvaluatorbigArgList, bigArgList0, FILE_OP_AUTO, FILE_OP_BINARY, FILE_OP_INPUT_STREAM, FILE_OP_TEXT_INI, FILE_OP_TEXT_STEM, FILE_OP_TEXT_STRING, FILE_OP_TEXT_WITHOUT_LIST_INI, fNames, MAX_ARG_COUNT
 - 
Fields inherited from interface org.qdl_lang.evaluate.EvaluatorInterfaceUNKNOWN_VALUE
 
- 
 - 
Constructor SummaryConstructors Constructor Description MetaEvaluator()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidaddE(int index, AbstractEvaluator evaluator)Add evaluator at a given index in the listprotected static voidaddE(AbstractEvaluator evaluator)Add evaluator to the end of the list.voidaddEvaluator(int index, AbstractEvaluator evaluator)voidaddEvaluator(AbstractEvaluator evaluator)booleandispatch(Polyad polyad, State state)Does the actual evaluation of thePolyad.booleanevaluate(String alias, Polyad polyad, State state)booleanevaluate(Polyad polyad, State state)Decides if aPolyadis evaluated by this evaluator and if not, returns false, if so, it evaluates it and returns true.booleanevaluateNEW(Polyad polyad, State state)Proposed method to allow for overriding base system functions.booleanevaluateOLD(Polyad polyad, State state)int[]getArgCount(String name)Given the name of a built in function, find the number of possible arguments it can take.FunctionEvaluatorgetFunctionEvaluator()String[]getFunctionNames()static MetaEvaluatorgetInstance()Factory method.StringgetNamespace()static List<String>getSystemNamespaces()intgetType(String name)booleanisBuiltIin(String moduleName, String functionName)Check that a FQ function exists.static booleanisSystemNS(String name)TreeSet<String>listFunctions(boolean listFQ)voidsetFunctionEvaluator(FunctionEvaluator functionEvaluator)static voidsetMetaEvaluator(MetaEvaluator metaEvaluator)- 
Methods inherited from class org.qdl_lang.evaluate.AbstractEvaluatorareAllBigDecimals, areAllBoolean, areAllLongs, areAllNumbers, areAllSets, areAllStems, areAllStrings, areAnyBigDecimals, areNoneStems, bdEquals, checkNull, checkNull, convertArgsToStem, finishExpr, getBigArgList, getBigArgList0, getCommonKeys, getFQFunctionNames, getFunctionReferenceNode, getFunctionReferenceNode, getOperator, getOrCreateStem, isBigDecimal, isBoolean, isBuiltInFunction, isFunctionRef, isLong, isNumber, isScalar, isSet, isStem, isStemList, isString, NEWgetOperator, OLDgetOperator, process1, process2, process2, process3, processSet1, processSet2, processSet2, processStem1, processStem2, processStem3, resolveResourceToFile, tempFname, toBD, toConstants, toStem
 
- 
 
- 
- 
- 
Field Detail- 
META_BASE_VALUEpublic static final int META_BASE_VALUE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getInstancepublic static MetaEvaluator getInstance() Factory method. You should not override this class to add more of your own evaluators. Just get the instance andaddEvaluator(int, AbstractEvaluator)to it at index 0 (or it will get missed -- last index is for functions and throws and exception if no function found. It will snoop through your evaluator too. If you are writing your own evaluator, your type numbers should be negative.- Returns:
 
 - 
addEprotected static void addE(int index, AbstractEvaluator evaluator)Add evaluator at a given index in the list- Parameters:
- index-
- evaluator-
 
 - 
addEprotected static void addE(AbstractEvaluator evaluator) Add evaluator to the end of the list.- Parameters:
- evaluator-
 
 - 
getArgCountpublic int[] getArgCount(String name) Given the name of a built in function, find the number of possible arguments it can take. This is needed for resolving function references.- Parameters:
- name-
- Returns:
 
 - 
getFunctionEvaluatorpublic FunctionEvaluator getFunctionEvaluator() 
 - 
setFunctionEvaluatorpublic void setFunctionEvaluator(FunctionEvaluator functionEvaluator) 
 - 
isSystemNSpublic static boolean isSystemNS(String name) 
 - 
getNamespacepublic String getNamespace() 
 - 
setMetaEvaluatorpublic static void setMetaEvaluator(MetaEvaluator metaEvaluator) 
 - 
addEvaluatorpublic void addEvaluator(AbstractEvaluator evaluator) 
 - 
addEvaluatorpublic void addEvaluator(int index, AbstractEvaluator evaluator)
 - 
getTypepublic int getType(String name) 
 - 
evaluatepublic boolean evaluate(Polyad polyad, State state) Description copied from class:AbstractEvaluatorDecides if aPolyadis evaluated by this evaluator and if not, returns false, if so, it evaluates it and returns true. This function actually just dispatches it toAbstractEvaluator.dispatch(Polyad, State)where the work is done and manages putting better trace information in if there is a failure.- Overrides:
- evaluatein class- AbstractEvaluator
- Returns:
 
 - 
dispatchpublic boolean dispatch(Polyad polyad, State state) Description copied from class:AbstractEvaluatorDoes the actual evaluation of thePolyad.- Specified by:
- dispatchin class- AbstractEvaluator
- Returns:
 
 - 
evaluateNEWpublic boolean evaluateNEW(Polyad polyad, State state) Proposed method to allow for overriding base system functions. Maybe. Still have to decide if this is really a great idea. This can actually the evaluteOLD completely BUT because this requires exception handling to decide if a function is user defined, the performance is slower by a good 15%.To do this right will require that the function Evaluator handle missing functions differently. Probably a fairly substantial rewrite for not much of a clear purpose at this point (4/27/2022) - Parameters:
- polyad-
- state-
- Returns:
 
 - 
isBuiltIinpublic boolean isBuiltIin(String moduleName, String functionName) Check that a FQ function exists. This is used withjisSystemNS(String)to check if the namespace exists in the first place.- Parameters:
- moduleName-
- functionName-
- Returns:
 
 - 
evaluatepublic boolean evaluate(String alias, Polyad polyad, State state) - Overrides:
- evaluatein class- AbstractEvaluator
 
 - 
listFunctionspublic TreeSet<String> listFunctions(boolean listFQ) - Specified by:
- listFunctionsin interface- EvaluatorInterface
- Overrides:
- listFunctionsin class- AbstractEvaluator
 
 - 
getFunctionNamespublic String[] getFunctionNames() - Specified by:
- getFunctionNamesin class- AbstractEvaluator
 
 
- 
 
-