*
* @param n The scope definition node
*/
public void visitScopeDefinition(GNode n) {
// Adding code to build the list of node names that need to process scope
Node pat = n.getGeneric(0);
for (int i = 0; i < pat.size(); i++) {
Node patterns = pat.getGeneric(i).getGeneric(0);
for (int j = 0; j < patterns.size(); j++) {
processScopeNodes.add(getNodeName(patterns.getGeneric(j)));
}
}
Node match = GNode.create("MatchExpression",
GNode.create("LowerID","n"), n.getGeneric(0));
match.setProperty("__arg_type", n.getProperty("__arg_type"));
match.setProperty(TYPE,
mapper.getPatternMatchRightType(n.getProperty(TYPE)));
seenScope = true;
Node pmatch = n.getGeneric(0);
pmatch.setProperty(MATCHARG, "n");
@SuppressWarnings("unchecked")
List<Node> nodes = (List<Node>)dispatch(pmatch);
nodes.add(factory.ret(GNode.create("NullLiteral")));
// Create typical AST
Node top = GNode.create("ValueDefinition",
"getScope",
GNode.create("Parameters",
GNode.create("Parameter",
"n",
GNode.create("UserDefinedType",
"node")
)
),
GNode.create("BooleanLiteral", "true")
);
top.setProperty(TYPE, table.current().lookup("value(getScope)"));
top.setProperty("__isfunction", null);
Node block = GNode.create("Block");
for (Node node : nodes) block.add(node);
Node scopefunc = (Node)dispatch(top);
scopefunc.getGeneric(2).getGeneric(0).getGeneric(2).getGeneric(4).
getGeneric(0).set(7, block);
functionDefinitions.add(scopefunc);
return;
}