2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License, Version 1.0 only 2N/A * (the "License"). You may not use this file except in compliance 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * Create a member node corresponding to one of the output members of a dynamic 2N/A * translator. We set the member's dn_membexpr to a DT_NODE_XLATOR node that 2N/A * has dn_op set to DT_TOK_XLATE and refers back to the translator itself. The 2N/A * code generator will then use this as the indicator for dynamic translation. 2N/A * xlator refers back to the translator and whose dn_xmember refers to 2N/A * For the member itself, we use a DT_NODE_MEMBER as usual with the 2N/A * appropriate name, output type, and member expression set to 'enp'. 2N/A goto err;
/* no memory for identifier */ 2N/A * If an input parameter name is given, this is a static translator 2N/A * definition: create an idhash and identifier for the parameter. 2N/A goto err;
/* no memory for identifier hash */ 2N/A * If a deferred pragma is pending on the keyword "translator", run all 2N/A * the deferred pragmas on dx_souid and then copy results to dx_ptrid. 2N/A * If no input parameter is given, we're making a dynamic translator: 2N/A * create member nodes for every member of the output type. Otherwise 2N/A * retain the member and allocation node lists presented by the parser. 2N/A * Assign member IDs to each member and allocate space for DIFOs 2N/A * if and when this translator is eventually compiled. 2N/A return (
NULL);
/* fail if these are unresolvable types */ 2N/A * Translators are always defined using a struct or union type, so if 2N/A * we are attempting to translate to type "T *", we internally look 2N/A * for a translation to type "T" by following the pointer reference. 2N/A return (
NULL);
/* fail if the output isn't a struct or union */ 2N/A * In order to find a matching translator, we iterate over the set of 2N/A * available translators in three passes. First, we look for a 2N/A * translation from the exact source type to the resolved destination. 2N/A * Second, we look for a translation from the resolved source type to 2N/A * the resolved destination. Third, we look for a translation from a 2N/A * compatible source type (using the same rules as parameter formals) 2N/A * to the resolved destination. If all passes fail, return NULL. 2N/A goto out;
/* skip remaining passes if exact match required */ 2N/A return (
NULL);
/* no translation available to pointer type */ 2N/A return (
dxp);
/* we succeeded or not allowed to extern */ 2N/A * If we get here, then we didn't find an existing translator, but the 2N/A * caller and xlatemode permit us to create an extern to a dynamic one.