1178479Sjb/*
2178479Sjb * CDDL HEADER START
3178479Sjb *
4178479Sjb * The contents of this file are subject to the terms of the
5178479Sjb * Common Development and Distribution License, Version 1.0 only
6178479Sjb * (the "License").  You may not use this file except in compliance
7178479Sjb * with the License.
8178479Sjb *
9178479Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10178479Sjb * or http://www.opensolaris.org/os/licensing.
11178479Sjb * See the License for the specific language governing permissions
12178479Sjb * and limitations under the License.
13178479Sjb *
14178479Sjb * When distributing Covered Code, include this CDDL HEADER in each
15178479Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16178479Sjb * If applicable, add the following below this CDDL HEADER, with the
17178479Sjb * fields enclosed by brackets "[]" replaced with your own identifying
18178479Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
19178479Sjb *
20178479Sjb * CDDL HEADER END
21178479Sjb */
22178479Sjb/*
23178479Sjb * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24178479Sjb * Use is subject to license terms.
25178479Sjb */
26178479Sjb
27178479Sjb#ifndef	_DT_XLATOR_H
28178479Sjb#define	_DT_XLATOR_H
29178479Sjb
30178479Sjb#pragma ident	"%Z%%M%	%I%	%E% SMI"
31178479Sjb
32178479Sjb#include <libctf.h>
33178479Sjb#include <dtrace.h>
34178479Sjb#include <dt_ident.h>
35178479Sjb#include <dt_list.h>
36178479Sjb
37178479Sjb#ifdef	__cplusplus
38178479Sjbextern "C" {
39178479Sjb#endif
40178479Sjb
41178479Sjbstruct dt_node;
42178479Sjb
43178479Sjbtypedef struct dt_xlator {
44178479Sjb	dt_list_t dx_list;		/* list forward/back pointers */
45178479Sjb	dt_idhash_t *dx_locals;		/* hash of local scope identifiers */
46178479Sjb	dt_ident_t *dx_ident;		/* identifier ref for input param */
47178479Sjb	dt_ident_t dx_souid;		/* fake identifier for sou output */
48178479Sjb	dt_ident_t dx_ptrid;		/* fake identifier for ptr output */
49178479Sjb	ctf_file_t *dx_src_ctfp;	/* CTF container for input type */
50178479Sjb	ctf_id_t dx_src_type;		/* CTF reference for input type */
51178479Sjb	ctf_id_t dx_src_base;		/* CTF reference for input base */
52178479Sjb	ctf_file_t *dx_dst_ctfp;	/* CTF container for output type */
53178479Sjb	ctf_id_t dx_dst_type;		/* CTF reference for output type */
54178479Sjb	ctf_id_t dx_dst_base;		/* CTF reference for output base */
55178479Sjb	struct dt_node *dx_members;	/* list of member translations */
56178479Sjb	uint_t dx_nmembers;		/* length of dx_members list */
57178479Sjb	dtrace_difo_t **dx_membdif;	/* DIF for member expressions */
58178479Sjb	struct dt_node *dx_nodes;	/* list of parse tree nodes */
59178479Sjb	dtrace_hdl_t *dx_hdl;		/* back pointer to containing handle */
60178479Sjb	ulong_t dx_gen;			/* generation number that created me */
61178479Sjb	id_t dx_id;			/* global translator id */
62178479Sjb	int dx_arg;			/* dynamic argument index */
63178479Sjb} dt_xlator_t;
64178479Sjb
65178479Sjbextern dt_xlator_t *dt_xlator_create(dtrace_hdl_t *,
66178479Sjb    const dtrace_typeinfo_t *, const dtrace_typeinfo_t *,
67178479Sjb    const char *, struct dt_node *, struct dt_node *);
68178479Sjb
69178479Sjbextern void dt_xlator_destroy(dtrace_hdl_t *, dt_xlator_t *);
70178479Sjb
71178479Sjb#define	DT_XLATE_FUZZY	0x0		/* lookup any matching translator */
72178479Sjb#define	DT_XLATE_EXACT	0x1		/* lookup only exact type matches */
73178479Sjb#define	DT_XLATE_EXTERN	0x2		/* extern translator if none exists */
74178479Sjb
75178479Sjbextern dt_xlator_t *dt_xlator_lookup(dtrace_hdl_t *,
76178479Sjb    struct dt_node *, struct dt_node *, int);
77178479Sjb
78178479Sjbextern dt_xlator_t *dt_xlator_lookup_id(dtrace_hdl_t *, id_t);
79178479Sjbextern dt_ident_t *dt_xlator_ident(dt_xlator_t *, ctf_file_t *, ctf_id_t);
80178479Sjbextern struct dt_node *dt_xlator_member(dt_xlator_t *, const char *);
81178479Sjbextern int dt_xlator_dynamic(const dt_xlator_t *);
82178479Sjb
83178479Sjb#ifdef	__cplusplus
84178479Sjb}
85178479Sjb#endif
86178479Sjb
87178479Sjb#endif	/* _DT_XLATOR_H */
88