/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* CTF Declaration Stack
*
* In order to implement ctf_type_name(), we must convert a type graph back
* into a C type declaration. Unfortunately, a type graph represents a storage
* class ordering of the type whereas a type declaration must obey the C rules
* for operator precedence, and the two orderings are frequently in conflict.
* For example, consider these CTF type graphs and their C declarations:
*
* CTF_K_POINTER -> CTF_K_FUNCTION -> CTF_K_INTEGER : int (*)()
* CTF_K_POINTER -> CTF_K_ARRAY -> CTF_K_INTEGER : int (*)[]
*
* In each case, parentheses are used to raise operator * to higher lexical
* precedence, so the string form of the C declaration cannot be constructed by
* walking the type graph links and forming the string from left to right.
*
* The functions in this file build a set of stacks from the type graph nodes
* corresponding to the C operator precedence levels in the appropriate order.
* The code in ctf_type_name() can then iterate over the levels and nodes in
* lexical precedence order and construct the final C declaration string.
*/
#include <ctf_impl.h>
void
{
int i;
for (i = CTF_PREC_BASE; i < CTF_PREC_MAX; i++)
}
void
{
int i;
for (i = CTF_PREC_BASE; i < CTF_PREC_MAX; i++) {
}
}
}
void
{
int is_qual = 0;
return;
}
case CTF_K_ARRAY:
n = ar.ctr_nelems;
break;
case CTF_K_TYPEDEF:
return;
}
break;
case CTF_K_FUNCTION:
break;
case CTF_K_POINTER:
break;
case CTF_K_VOLATILE:
case CTF_K_CONST:
case CTF_K_RESTRICT:
is_qual++;
break;
default:
}
return;
}
/*
* Reset cd_qualp to the highest precedence level that we've seen so
* far that can be qualified (CTF_PREC_BASE or CTF_PREC_POINTER).
*/
/*
* C array declarators are ordered inside out so prepend them. Also by
* convention qualifiers of base types precede the type specifier (e.g.
* const int vs. int const) even though the two forms are equivalent.
*/
else
}
/*PRINTFLIKE2*/
void
{
size_t n;
}