#include "config.h"
#include "system.h"
#include "tree.h"
#include "rtl.h"
#include "expr.h"
#include "cp-tree.h"
#include "lex.h"
#include "c-common.h"
#include "flags.h"
#include "input.h"
#include "except.h"
#include "output.h"
#include "toplev.h"
#include "cpplib.h"
#include "debug.h"
#include "target.h"
#include "varray.h"
#include "objc-act.h"
#include "objcp-decl.h"
#include "genindex.h"
static tree objcp_parmlist = NULL_TREE;
tree
objcp_start_struct (code, name)
enum tree_code code ATTRIBUTE_UNUSED;
tree name;
{
int new_scope = 0;
tree h, s;
push_lang_context (lang_name_c);
if (!name)
name = make_anon_name ();
h = handle_class_head (record_type, 0, name, 0, 1, &new_scope);
flag_suppress_builtin_indexing = 1;
s = begin_class_definition (TREE_TYPE (h));
flag_suppress_builtin_indexing = 0;
return s;
}
tree
objcp_finish_struct (t, fieldlist, attributes)
tree t;
tree fieldlist, attributes;
{
tree s, field, next_field;
flag_suppress_builtin_indexing = 1;
for (field = fieldlist; field; field = next_field)
{
next_field = TREE_CHAIN (field);
TREE_CHAIN (field) = NULL_TREE;
finish_member_declaration (field);
}
s = finish_class_definition (t, attributes, 1, 0);
flag_suppress_builtin_indexing = 0;
pop_lang_context ();
return s;
}
int
objcp_start_function (declspecs, declarator, attributes)
tree declspecs, declarator, attributes;
{
return start_function (declspecs, declarator, attributes, 0);
}
void
objcp_finish_function (nested)
int nested ATTRIBUTE_UNUSED;
{
expand_body (finish_function (0));
}
tree
objcp_start_decl (declarator, declspecs, initialized, attributes)
tree declarator, declspecs;
int initialized;
tree attributes;
{
return start_decl (declarator, declspecs, initialized,
attributes, NULL_TREE);
}
void
objcp_finish_decl (decl, init, asmspec)
tree decl, init, asmspec;
{
cp_finish_decl (decl, init, asmspec, 0);
}
tree
objcp_lookup_name (name)
tree name;
{
return lookup_name (name, -1);
}
tree
objcp_push_parm_decl (parm)
tree parm;
{
TREE_VALUE (parm) = TREE_PURPOSE (parm);
TREE_PURPOSE (parm) = NULL_TREE;
if (objcp_parmlist)
objcp_parmlist = chainon (objcp_parmlist, parm);
else
objcp_parmlist = parm;
return objcp_parmlist;
}
tree
objcp_get_parm_info (void_at_end)
int void_at_end;
{
tree parm_info = finish_parmlist (objcp_parmlist, !void_at_end);
parm_info = build_tree_list (parm_info, NULL_TREE);
objcp_parmlist = NULL_TREE;
return parm_info;
}
void
objcp_store_parm_decls ()
{
}
tree
objcp_build_function_call (function, args)
tree function, args;
{
return build_function_call (function, args);
}
tree
objcp_xref_tag (code, name)
enum tree_code code;
tree name;
{
if (code != RECORD_TYPE)
abort ();
return xref_tag (record_type, name, 0, 1);
}
tree
objcp_grokfield (filename, line, declarator, declspecs, width)
const char *filename ATTRIBUTE_UNUSED;
int line ATTRIBUTE_UNUSED;
tree declarator, declspecs, width;
{
return (width) ? grokbitfield (declarator, declspecs, width)
: grokfield (declarator, declspecs, 0, 0, 0);
}
tree
objcp_build_component_ref (datum, component)
tree datum, component;
{
return finish_class_member_access_expr (datum, component);
}
int
objcp_comptypes (type1, type2)
tree type1, type2;
{
return comptypes (type1, type2, 0);
}
tree
objcp_type_name (type)
tree type;
{
if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
return DECL_NAME (TYPE_NAME (type));
else
return TYPE_NAME (type);
}
tree
objcp_type_size (type)
tree type;
{
tree size = TYPE_SIZE (type);
if (size == NULL_TREE)
{
warning ("Requesting size of incomplete type `%s'",
IDENTIFIER_POINTER (objcp_type_name (type)));
layout_type (type);
size = TYPE_SIZE (type);
}
return build_int_2 (TREE_INT_CST_LOW (size), 0);
}
tree
objcp_builtin_function (name, type, code, class, libname, attrs)
const char *name;
tree type;
int code;
enum built_in_class class;
const char *libname ATTRIBUTE_UNUSED;
tree attrs;
{
tree decl = NULL;
decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
make_decl_rtl (decl, NULL);
pushdecl (decl);
DECL_BUILT_IN_CLASS (decl) = class;
DECL_FUNCTION_CODE (decl) = code;
DECL_ANTICIPATED (decl) = 1;
if (attrs)
decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
else
decl_attributes (&decl, NULL_TREE, 0);
return decl;
}
int
objcp_lookup_identifier (token, id, check_conflict)
tree token;
tree *id;
int check_conflict;
{
tree objc_id = lookup_objc_ivar (token);
if (!check_conflict || objc_id && IS_SUPER (objc_id))
*id = objc_id;
else if (objc_id && *id && IDENTIFIER_BINDING (token))
warning ("local declaration of `%s' hides instance variable",
IDENTIFIER_POINTER (token));
return (objc_id != NULL_TREE);
}