Search in sources :

Example 1 with CompiledFunction

use of com.laytonsmith.core.functions.CompiledFunction in project CommandHelper by EngineHub.

the class MethodScriptStaticCompiler method go.

private static void go(ParseTree node, StringBuilder b, api.Platforms platform) throws ConfigCompileException {
    if (node.hasChildren()) {
        FunctionBase f = FunctionList.getFunction(node.getData(), platform);
        if (!(f instanceof CompiledFunction)) {
            throw new ConfigCompileException("The function " + f.getName() + " is unknown in this platform.", node.getData().getTarget());
        }
        CompiledFunction cf = (CompiledFunction) f;
        List<String> children = new ArrayList<String>();
        for (ParseTree baby : node.getChildren()) {
            StringBuilder bb = new StringBuilder();
            go(baby, bb, platform);
            children.add(bb.toString());
        }
        b.append(cf.compile(node.getData().getTarget(), children.toArray(new String[children.size()])));
    } else {
        if (platform.getResolver() == null) {
            b.append(node.getData().val());
        } else {
            b.append(platform.getResolver().outputConstant(node.getData()));
        }
    }
}
Also used : CompiledFunction(com.laytonsmith.core.functions.CompiledFunction) FunctionBase(com.laytonsmith.core.functions.FunctionBase) ArrayList(java.util.ArrayList) ConfigCompileException(com.laytonsmith.core.exceptions.ConfigCompileException) ParseTree(com.laytonsmith.core.ParseTree)

Aggregations

ParseTree (com.laytonsmith.core.ParseTree)1 ConfigCompileException (com.laytonsmith.core.exceptions.ConfigCompileException)1 CompiledFunction (com.laytonsmith.core.functions.CompiledFunction)1 FunctionBase (com.laytonsmith.core.functions.FunctionBase)1 ArrayList (java.util.ArrayList)1