}
return result;
}
private AbstractAST buildContextFreeNode(IConstructor tree) {
AbstractAST cached = sortCache.get(tree);
if (cached != null) {
return cached;
}
String constructorName = TreeAdapter.getConstructorName(tree);
if (constructorName == null) {
throw new ImplementationError("All Rascal productions should have a constructor name: " + TreeAdapter.getProduction(tree));
}
String cons = capitalize(constructorName);
String sort = sortName(tree);
if (sort.length() == 0) {
throw new ImplementationError("Could not retrieve sort name for " + tree);
}
sort = sort.equalsIgnoreCase("pattern") ? "Expression" : capitalize(sort);
switch(sort){
case "Mapping":
sort = "Mapping_Expression"; break;
case "KeywordArgument":
sort = "KeywordArgument_Expression"; break;
case "KeywordArguments":
sort = "KeywordArguments_Expression"; break;
}
IList args = getASTArgs(tree);
int arity = args.length();
Object actuals[] = new Object[arity+1];
actuals[0] = tree;
int i = 1;
for (IValue arg : args) {
IConstructor argTree = (IConstructor) arg;
if (TreeAdapter.isList(argTree)) {
actuals[i] = buildList((IConstructor) arg);
}
else {
actuals[i] = buildValue(arg);
}
i++;
}
AbstractAST ast = callMakerMethod(sort, cons, tree.asAnnotatable().getAnnotations(), actuals, null);
sortCache.putUnsafe(tree, ast);
return ast;
}