/** * Set the type of the given node to be a record token that contains fields for each name in the * record construction, where the type of each field in the record is determined by the * corresponding type of the child nodes. * * @param node The specified node. * @exception IllegalActionException If an inference error occurs. */ public void visitRecordConstructNode(ASTPtRecordConstructNode node) throws IllegalActionException { Type[] childTypes = _inferAllChildren(node); String[] names = (String[]) node.getFieldNames().toArray(new String[node.jjtGetNumChildren()]); _setType(node, new RecordType(names, childTypes)); }
/** * Construct a record by assigning the fields values given by the children nodes. * * @param node The record constructor node. * @exception IllegalActionException If an evaluation error occurs. */ public void visitRecordConstructNode(ASTPtRecordConstructNode node) throws IllegalActionException { if (node.isConstant() && node.isEvaluated()) { _evaluatedChildToken = node.getToken(); return; } ptolemy.data.Token[] tokens = _evaluateAllChildren(node); int numChildren = node.jjtGetNumChildren(); _assert( node.getFieldNames().size() == numChildren, node, "The number of labels and values does not " + "match in parsing a record expression."); String[] labels = (String[]) node.getFieldNames().toArray(new String[numChildren]); _evaluatedChildToken = (new RecordToken(labels, tokens)); if (node.isConstant()) { node.setToken(_evaluatedChildToken); } }