Esempio n. 1
0
File: typeck.c Progetto: AHelper/gcc
void
set_java_signature (tree type, tree sig)
{
  tree old_sig;
  while (TREE_CODE (type) == POINTER_TYPE)
    type = TREE_TYPE (type);
  MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
  old_sig = TYPE_SIGNATURE (type);
  if (old_sig != NULL_TREE && old_sig != sig)
    abort ();
  TYPE_SIGNATURE (type) = sig;
#if 0 /* careful about METHOD_TYPE */
  if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type))
    IDENTIFIER_SIGNATURE_TYPE (sig) = type;
#endif
}
Esempio n. 2
0
/*
 *	Constructors for pointer, array and function types.
 *	(RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
 *	constructed by language-dependent code, not here.)
 *
 *	Construct, lay out and return the type of pointers
 *	to TO_TYPE. If such a type has already been
 *	constructed, reuse it.
 */
tree
build_pointer_type (tree to_type)
{
	register tree		t = TYPE_POINTER_TO (to_type);
	register OBSTACK	*ambient_obstack = current_obstack;
	register OBSTACK	*ambient_saveable_obstack = saveable_obstack;

	/*
	 *	First, if we already have a type for
	 *	pointers to TO_TYPE, use it.
	 */
	if (t)
		return t;

	/*
	 *	We need a new one.
	 *	If TO_TYPE is permanent, make this permanent too.
	 */
	if (TREE_PERMANENT (to_type))
	{
		current_obstack = &permanent_obstack;
		saveable_obstack = &permanent_obstack;
	}

	t = make_node (POINTER_TYPE);
	TREE_TYPE (t) = to_type;

	/*
	 *	Record this type as the pointer to TO_TYPE.
	 */
	TYPE_POINTER_TO (to_type) = t;

	/*
	 *	Lay out the type. This function has many callers
	 *	that are concerned with expression-construction,
	 *	and this simplifies them all. Also, it guarantees
	 *	the TYPE_SIZE is permanent if the type is.
	 */
	layout_type (t);

	current_obstack = ambient_obstack;
	saveable_obstack = ambient_saveable_obstack;

	return (t);

}	/* end build_pointer_type */
Esempio n. 3
0
/*
 *	Return a type like TYPE except that its TREE_READONLY
 *	is CONSTP and its TREE_VOLATILE is VOLATILEP.
 *
 *	Such variant types already made are recorded so that
 *	duplicates are not made.
 *
 *	A variant types should never be used as the type of
 *	an expression. Always copy the variant information into
 *	the TREE_READONLY and TREE_VOLATILE of the expression,
 *	and then give the expression as its type the
 *	"main variant", the variant whose TREE_READONLY
 *	and TREE_VOLATILE are zero.  Use TYPE_MAIN_VARIANT
 *	to find the main variant.
 */
tree
build_type_variant (tree type, int constp, int volatilep)
{
	register tree	t, m = TYPE_MAIN_VARIANT (type);
	register OBSTACK *ambient_obstack = current_obstack;

	/*
 	 *	Treat any nonzero argument as 1.
	 */
	constp = !!constp;
	volatilep = !!volatilep;

	/*
	 *	First search the chain variants for one
	 *	that is what we want.
	 */
	for (t = m; t; t = TYPE_NEXT_VARIANT (t))
	{
		if (constp == TREE_READONLY (t) && volatilep == TREE_VOLATILE (t))
			return t;
	}

	/*
	 *	We need a new one.
	 */
	current_obstack = TREE_PERMANENT (type) ?
				&permanent_obstack : saveable_obstack;

	t = copy_node (type);
	TREE_READONLY (t) = constp;
	TREE_VOLATILE (t) = volatilep;
	TYPE_POINTER_TO (t) = NULL_TREE;
	TYPE_REFERENCE_TO (t) = NULL_TREE;

	/*
	 *	Add this type to the chain of variants of TYPE.
	 */
	TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
	TYPE_NEXT_VARIANT (m) = t;

	current_obstack = ambient_obstack;

	return (t);

}	/* end build_type_variant */
Esempio n. 4
0
/*
 ****************************************************************
 *	Build the node for the type of references-to-TO_TYPE	*
 ****************************************************************
 */
tree
build_reference_type (tree to_type)
{
	register tree		t = TYPE_REFERENCE_TO (to_type);
	register OBSTACK	*ambient_obstack = current_obstack;
	register OBSTACK	*ambient_saveable_obstack = saveable_obstack;

	/*
	 *	First, if we already have a type for pointers
	 *	to TO_TYPE, use it.
	 */
	if (t)
		return t;

	/*
	 *	We need a new one.
	 *	If TO_TYPE is permanent, make this permanent too.
	 */
	if (TREE_PERMANENT (to_type))
	{
			current_obstack = &permanent_obstack;
			saveable_obstack = &permanent_obstack;
	}

	t = make_node (REFERENCE_TYPE);
	TREE_TYPE (t) = to_type;

	/*
	 *	Record this type as the pointer to TO_TYPE.
	 */
	TYPE_REFERENCE_TO (to_type) = t;

	layout_type (t);

	current_obstack = ambient_obstack;
	saveable_obstack = ambient_saveable_obstack;

	return (t);

}	/* end build_reference_type */