/* -*- mode: C -*-
Algol 68 frontend for GCC.
Copyright (C) 2011 Jose E. Marchesi.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/* Written by Jose E. Marchesi */
/* This file contains the constants and data types required by gcc to
find the entry points to the frontend. The referenced functions
are the C functions generated by the ctrans Algol 68 compiler and
accessed here. */
#include
#include
#include "config.h"
#include "system.h"
#include "ansidecl.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
#include "flags.h"
#include "langhooks.h"
#include "langhooks-def.h"
#include "timevar.h"
#include "tm.h"
#include "function.h"
#include "ggc.h"
#include "toplev.h"
#include "target.h"
#include "debug.h"
#include "diagnostic.h"
#include "tree-dump.h"
#include "cgraph.h"
/* Types expected by gcc's garbage collector.
These types exist to allow language front-ends to
add extra information in gcc's parse tree data structure. */
/* Language-specific type information. */
struct GTY(()) lang_type
{
char dummy;
};
/* Language-specific declaration information. */
struct GTY(()) lang_decl
{
char dummy;
};
/* Language-specific identifier information. */
struct GTY(()) lang_identifier
{
struct tree_identifier common;
};
/* Language-specific tree node information. */
union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
chain_next ("(union lang_tree_node *) TREE_CHAIN (&%h.generic)")))
lang_tree_node
{
union tree_node GTY((tag ("0"),
desc ("tree_node_structure (&%h)"))) generic;
struct lang_identifier GTY((tag ("1"))) identifier;
};
struct GTY(()) language_function
{
int dummy;
};
/* Define lang hooks.
These hooks invoke Algol 68 procedures defined in a68lang.a68,
making use of the A_xxx_yyy functions from the algol68toc library
for type conversion. */
/* This type shall be changed only if the corresponding type for CSTR
changes in spaliens.a68 in the algol68toc compiler. */
A_ISTRUCT(A68_CHAR ,16000000,A68t34);
typedef struct A68t34 A68_34 ; /* STRUCT 16000000 CHAR */
/* Forward references */
A68_BOOL algol68init (void);
A68_INT algol68langhookinitoptions (A68_INT, A68_34 **);
A68_INT algol68langhookhandleoption (A68_INT, A68_34 *, A68_INT);
A68_BOOL algol68langhookpostoptions (A68_34 **);
A68_VOID algol68langhookparsefile (A68_INT);
A68_VOID algol68langhookwriteglobals (void);
A68_INT algol68langhookglobalbindingsp (void);
A68_BITS *algol68langhookpushdecl (A68_BITS *);
A68_BITS *algol68langhooktypeforsize (A68_INT, A68_INT);
A68_BITS *algol68langhookbuiltinfunction (A68_BITS *);
A68_BITS *algol68langhookgetdecls (void);
A68_BITS *algol68langhooktypeformode (A68_INT, A68_INT);
A68_INT algol68gimplifyexpr (A68_BITS **, A68_BITS **, A68_BITS **);
A68_VOID algol68printablename (A68_BITS *, A68_INT, A68_VC *);
A68_BITS *algol68convert (A68_BITS *, A68_BITS *);
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU Algol 68"
void algol68_decs_init (void);
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT init
static bool
init (void)
{
int argc = 0;
/* Initialize the algol68toc runtime. */
A_GC_STARTUP(argc);
/* USE algol68 lang. */
algol68_decs_init ();
return A_INT_int (algol68init ());
}
#undef LANG_HOOKS_INIT_OPTIONS
#define LANG_HOOKS_INIT_OPTIONS init_options
static unsigned int
init_options (unsigned int argc,
const char **argv)
{
return A_INT_int (algol68langhookinitoptions (A_int_INT(argc),
(A68_34 **) argv));
}
#undef LANG_HOOKS_HANDLE_OPTION
#define LANG_HOOKS_HANDLE_OPTION handle_option
static int
handle_option (size_t scode,
const char *arg,
int value)
{
return A_INT_int (algol68langhookhandleoption (A_size_t_INT (scode),
(A68_34 *) arg,
A_int_INT (value)));
}
#undef LANG_HOOKS_POST_OPTIONS
#define LANG_HOOKS_POST_OPTIONS post_options
static bool
post_options (const char **pfilename)
{
return (bool) algol68langhookpostoptions ((A68_34 **) pfilename);
}
#undef LANG_HOOKS_PARSE_FILE
#define LANG_HOOKS_PARSE_FILE parse_file
static void
parse_file (int set_yy_debug)
{
algol68langhookparsefile (A_int_INT (set_yy_debug));
}
#undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS write_globals
static void
write_globals (void)
{
algol68langhookwriteglobals ();
}
#undef LANG_HOOKS_PUSHDECL
#define LANG_HOOKS_PUSHDECL pushdecl
static tree
pushdecl (tree decl)
{
return (tree) algol68langhookpushdecl ((A68_BITS *)decl);
}
#undef LANG_HOOKS_GLOBAL_BINDINGS_P
#define LANG_HOOKS_GLOBAL_BINDINGS_P global_bindings_p
static int
global_bindings_p (void)
{
return A_INT_int (algol68langhookglobalbindingsp ());
}
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE type_for_size
static tree
type_for_size (unsigned int bits,
int unsignedp)
{
return (tree) algol68langhooktypeforsize (A_int_INT (bits),
A_int_INT (unsignedp));
}
#undef LANG_HOOKS_TYPE_FOR_MODE
#define LANG_HOOKS_TYPE_FOR_MODE type_for_mode
static tree
type_for_mode (enum machine_mode mode ATTRIBUTE_UNUSED,
int unsignedp ATTRIBUTE_UNUSED)
{
return (tree)
algol68langhooktypeformode (A_int_INT(mode), A_int_INT(unsignedp));
}
#undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION builtin_function
static tree
builtin_function (tree decl)
{
return (tree) algol68langhookbuiltinfunction ((A68_BITS*)decl);
}
#undef LANG_HOOKS_GETDECLS
#define LANG_HOOKS_GETDECLS getdecls
static tree
getdecls (void)
{
return (tree) algol68langhookgetdecls ();
}
#undef LANG_HOOKS_GIMPLIFY_EXPR
#define LANG_HOOKS_GIMPLIFY_EXPR a68_gimplify_expr
static int
a68_gimplify_expr (tree *expr_p,
gimple_seq *pre_p,
gimple_seq *post_p)
{
return A_INT_int (algol68gimplifyexpr ((A68_BITS**) expr_p,
(A68_BITS**) pre_p,
(A68_BITS**) post_p));
}
#undef LANG_HOOKS_DECL_PRINTABLE_NAME
#define LANG_HOOKS_DECL_PRINTABLE_NAME printable_name
static const char *printable_name (tree decl,
int kind)
{
A68_VC returned_value;
algol68printablename ((A68_BITS*) decl,
A_int_INT (kind),
&returned_value);
return (const char *) A_VC_charptr (returned_value);
}
tree convert (tree type ATTRIBUTE_UNUSED, tree expr)
{
return (tree) algol68convert ((A68_BITS*) type, (A68_BITS*) expr);
}
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
#include "gt-algol68-a681.h"
#include "gtype-algol68.h"
/* End of a681.c */