Commit 96e3ac4f by Tim Josling Committed by Tim Josling

Fixes to make treelang worg with PCH gengtype.c changes.

From-SVN: r54425
parent 02ef40d9
2002-06-10 Tim Josling <tej@melbpc.org.au>
* gengtype.c (unnamed enum containing BASE_FILE_*): Add languages
TREELANG and COBOL.
(lang_names): Add treelang and cobol.
(get_file_basename): Add code to support treelang and cobol as
4th and 5th users of c-common.c.
2002-06-09 Geoffrey Keating <geoffk@redhat.com>
* Makefile.in (install-driver): Install driver as
......
......@@ -500,10 +500,13 @@ FILE * header_file;
enum {
BASE_FILE_C,
BASE_FILE_OBJC,
BASE_FILE_CPLUSPLUS
BASE_FILE_CPLUSPLUS,
BASE_FILE_TREELANG,
BASE_FILE_COBOL
};
static const char *lang_names[] = {
"c", "objc", "cp", "f", "ada", "java"
"c", "objc", "cp", "treelang", "cobol", "f", "ada", "java"
};
#define NUM_BASE_FILES (sizeof (lang_names) / sizeof (lang_names[0]))
FILE *base_files[NUM_BASE_FILES];
......@@ -608,6 +611,10 @@ get_file_basename (f)
basename -= 5;
else if (startswith (basename - f, basename-5, "objc/"))
basename -= 5;
else if (startswith (basename - f, basename-9, "treelang/"))
basename -= 9;
else if (startswith (basename - f, basename-6, "cobol/"))
basename -= 6;
return basename;
}
......@@ -643,6 +650,9 @@ get_base_file_bitmap (input_file)
|| strcmp (basename, "c-decl.c") == 0
|| strcmp (basename, "c-objc-common.c") == 0)
return 1 << BASE_FILE_C | 1 << BASE_FILE_OBJC;
else if (startswith (len, basename, "c-common.c"))
return 1 << BASE_FILE_C | 1 << BASE_FILE_OBJC| 1 << BASE_FILE_CPLUSPLUS
| 1 << BASE_FILE_TREELANG | 1 << BASE_FILE_COBOL;
else if (startswith (len, basename, "c-"))
return 1 << BASE_FILE_C | 1 << BASE_FILE_OBJC | 1 << BASE_FILE_CPLUSPLUS;
else
......
2002-06-10 Tim Josling <tej@melbpc.org.au>
Cleanup
* Make-lang.in (check-treelang). Add. Remove direct dependency of
'check' on 'treelang.check' as redundant.
PCH Garbage collection regime (gengtypes.c) phase 1.
* Make-lang.in (treelang/tree1.o). Depend on gt-treelang-tree1.h
gt-treelang-treelang.h gtype-treelang.h.
(gt-treelang-tree1.h) Depend on s-gtype.
(gt-treelang-treelang.h) Depend on s-gtype.
(gtype-treelang.h) Depend on s-gtype.
* config-lang.in (gtfiles): Define.
* lex.l (main): Remove '#if 0' dead code.
(main): Move undef of IN_GCC so define of tree typedef works.
(all): Replace token and production by prod_token_parm_item.
* parse.y
(all): Replace token and production by prod_token_parm_item.
* tree1.c (main): Remove include of "output.h".
(symbol_table): Add GTY details.
(symbol_table_ggc): Remove.
(treelang_init): Remove root definitions for garage collection.
(mark_production_used): Remove.
(mark_token_used): Remove.
(main, at end): include generated garage collection routines.
* treelang.h (category_enum ): Add parameter_category.
(all): Replace token and production and parameters by union
prod_token_parm_item containing production_part, token_part,
parameter_part.
(STATIC_STORAGE AUTOMATIC_STORAGE EXTERNAL_REFERENCE_STORAGE
EXTERNAL_DEFINITION_STORAGE SIGNED_CHAR UNSIGNED_CHAR SIGNED_INT
UNSIGNED_INT VOID_TYPE EXP_PLUS EXP_REFERENCE EXP_ASSIGN
EXP_FUNCTION_INVOCATION EXP_MINUS EXP_EQUALS): Move here from
treetree.h.
* treetree.c
(tm_p.h): Do not include.
(ansidecl.h): Move include after config.h.
(treelang.h): Include it.
(ADDROOT): Remove.
(all): Replace token, production and parameter by prod_token_parm_item.
(tree_parameter_list): Move to treelang.h as part of
prod_token_parm_item.
(STATIC_STORAGE AUTOMATIC_STORAGE EXTERNAL_REFERENCE_STORAGE
EXTERNAL_DEFINITION_STORAGE SIGNED_CHAR UNSIGNED_CHAR SIGNED_INT
UNSIGNED_INT VOID_TYPE EXP_PLUS EXP_REFERENCE EXP_ASSIGN
EXP_FUNCTION_INVOCATION EXP_MINUS EXP_EQUALS): Move from here to
treelang.h.
2002-05-19 Tim Josling <tej@melbpc.org.au>
* treetree.c (warn_format_zero_length): Add.
......
......@@ -90,7 +90,8 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par
# object file makes
treelang/tree1.o: $(srcdir)/treelang/tree1.c $(srcdir)/treelang/treelang.h $(srcdir)/treelang/parse.h
treelang/tree1.o: $(srcdir)/treelang/tree1.c $(srcdir)/treelang/treelang.h $(srcdir)/treelang/parse.h\
gt-treelang-tree1.h gt-treelang-treelang.h gtype-treelang.h
$(CC) -o $@ -c $(ALL_CFLAGS) $(INCLUDES) $<
treelang/treetree.o: $(srcdir)/treelang/treetree.c $(srcdir)/treelang/treetree.h
......@@ -114,6 +115,8 @@ $(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.h: $(srcdir)/treelang/parse.
--output=$(srcdir)/treelang/parse.c --defines
# -v
gt-treelang-tree1.h gt-treelang-treelang.h gtype-treelang.h : s-gtype; @true
#
# Build hooks:
......@@ -246,7 +249,7 @@ treelang.distdir:
# test hook
# the other languages are hard coded in the main makefile.in - that seems to be wrong
check: treelang.check
check-treelang: treelang.check
TESTSUITEDIR = testsuite
......
......@@ -35,3 +35,6 @@ stagestuff=
diff_excludes="-x lex.c -x parse.c -x parse.h"
headers=
build_by_default="no"
gtfiles="\$(srcdir)/treelang/tree1.c \$(srcdir)/treelang/treelang.h"
......@@ -33,22 +33,18 @@
*/
/* Avoid poisoned malloc problem. */
#undef IN_GCC
#if 0
/* tree is defined as void* here to avoid any knowledge of tree stuff in this file. */
typedef void *tree;
#endif
#include <stdio.h>
#if 0
#include <ctype.h>
#endif
#include <memory.h>
#include "ansidecl.h"
#include "config.h"
#include "system.h"
/* Avoid poisoned malloc problem. */
#undef IN_GCC
#include "config.h"
#include "diagnostic.h"
#include "tree.h"
/* Token defs. */
#include "treelang.h"
......@@ -81,9 +77,10 @@ static void dump_lex_value (int lexret);
%%
{
yylval = my_malloc (sizeof (struct token));
((struct token*)yylval)->lineno = next_tree_lineno;
((struct token*)yylval)->charno = next_tree_charno;
/* Should really allocate only what we need. lll;. */
yylval = my_malloc (sizeof (struct prod_token_parm_item));
((struct prod_token_parm_item *)yylval)->tp.tok.lineno = next_tree_lineno;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
}
[ \n]+ {
......@@ -221,8 +218,8 @@ static void dump_lex_value (int lexret);
[^\n] {
update_lineno_charno ();
fprintf (stderr, "%s:%i:%i: Unrecognized character %c\n", in_fname,
((struct token*)yylval)->lineno,
((struct token*)yylval)->charno, yytext[0]);
((struct prod_token_parm_item *)yylval)->tp.tok.lineno,
((struct prod_token_parm_item *)yylval)->tp.tok.charno, yytext[0]);
errorcount++;
}
......@@ -238,8 +235,8 @@ update_lineno_charno (void)
/* Update the values we send to caller in case we sometimes don't
tell them about all the 'tokens' eg comments etc. */
int yyl;
((struct token*)yylval)->lineno = next_tree_lineno;
((struct token*)yylval)->charno = next_tree_charno;
((struct prod_token_parm_item *)yylval)->tp.tok.lineno = next_tree_lineno;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
for ( yyl = 0; yyl < yyleng; ++yyl )
{
if ( yytext[yyl] == '\n' )
......@@ -257,16 +254,16 @@ update_lineno_charno (void)
void
update_yylval (int a)
{
struct token* tok;
struct prod_token_parm_item * tok;
tok=yylval;
tok->category = token_category;
tok->type = a;
tok->length = yyleng;
tok->tp.tok.length = yyleng;
/* Have to copy yytext as it is just a ptr into the buffer at the
moment. */
tok->chars = my_malloc (yyleng + 1);
memcpy (tok->chars, yytext, yyleng);
tok->tp.tok.chars = my_malloc (yyleng + 1);
memcpy (tok->tp.tok.chars, yytext, yyleng);
}
/* Trace the value LEXRET and the position and token details being
......@@ -277,9 +274,9 @@ dump_lex_value (int lexret)
{
int ix;
fprintf (stderr, " %d l:%d c:%d ln:%d text=", lexret,
((struct token*) yylval)->lineno,
((struct token*) yylval)->charno,
((struct token*) yylval)->length);
((struct prod_token_parm_item *) yylval)->tp.tok.lineno,
((struct prod_token_parm_item *) yylval)->tp.tok.charno,
((struct prod_token_parm_item *) yylval)->tp.tok.length);
for (ix = 0; ix < yyleng; ix++)
{
fprintf (stderr, "%c", yytext[ix]);
......
......@@ -35,7 +35,6 @@
#include "system.h"
#include "ansidecl.h"
#include "flags.h"
#include "output.h"
#include "toplev.h"
#include "ggc.h"
......@@ -55,7 +54,7 @@
extern int yyparse (void);
/* Linked list of symbols - all must be unique in treelang. */
struct production *symbol_table = NULL;
static GTY(()) struct prod_token_parm_item *symbol_table = NULL;
/* Language for usage for messages. */
......@@ -65,9 +64,6 @@ const char *const language_string = "TREELANG - sample front end for GCC ";
void version (void);
/* GC routine for symbol table. */
static void symbol_table_ggc (void *m);
/* Global variables. */
extern struct cbl_tree_struct_parse_tree_top* parse_tree_top;
......@@ -191,18 +187,6 @@ treelang_decode_option (num_options_left, first_option_left)
const char*
treelang_init (const char* filename)
{
/* Define my garbage collection routines. */
ggc_add_root (&symbol_table, 1,
/* Unused size. */ sizeof (void*), symbol_table_ggc);
/* Note: only storage that has to be kept across functions needs to
be protected from GC. */
/* Define my garbage collection routines. */
ggc_add_root (&symbol_table, 1,
/* Unused size. */ sizeof (void*), symbol_table_ggc);
/* Note: only storage that has to be kept across functions needs to
be protected from GC. */
/* Set up the declarations needed for this front end. */
input_filename = "";
......@@ -250,58 +234,6 @@ treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
yyparse ();
}
/* Scan the symbol table* M, marking storage used. */
static void
symbol_table_ggc (void *m)
{
struct production *pp;
pp = * (struct production**)m;
/* Actually it is a pointer to a pointer, to allow reallocation and
relinking. */
mark_production_used (pp);
}
/* Mark a production PP as used so it wont be garbage collected. */
void
mark_production_used (struct production *pp)
{
int sub_ix;
loop:
if (!pp)
return;
ggc_mark (pp);
if (pp->category == token_category)
{
mark_token_used ((struct token*)pp);
return;
}
if (pp->category != production_category)
abort ();
mark_token_used (pp->main_token);
for (sub_ix = 0; sub_ix < SUB_COUNT; sub_ix++)
mark_production_used (pp->sub[sub_ix]);
/* The macro tests for NULL so I don't need to. */
ggc_mark_tree (pp->code);
pp = pp->next;
goto loop;
}
/* Mark a token TT as used so it wont be garbage collected. */
void
mark_token_used (struct token* tt)
{
if (!tt)
return;
ggc_mark (tt);
if (tt->chars)
ggc_mark (tt->chars);
}
/* Allocate SIZE bytes and clear them. */
void *
......@@ -322,45 +254,46 @@ my_malloc (size_t size)
return the symbol table entry from the symbol table if found there,
else 0. */
struct production*
lookup_tree_name (struct production *prod)
struct prod_token_parm_item*
lookup_tree_name (struct prod_token_parm_item *prod)
{
struct production *this;
struct token* this_tok;
struct token* tok;
struct prod_token_parm_item *this;
struct prod_token_parm_item *this_tok;
struct prod_token_parm_item *tok;
tok = SYMBOL_TABLE_NAME (prod);
for (this = symbol_table; this; this = this->next)
for (this = symbol_table; this; this = this->tp.pro.next)
{
this_tok = this->main_token;
if (tok->length != this_tok->length)
this_tok = this->tp.pro.main_token;
if (tok->tp.tok.length != this_tok->tp.tok.length)
continue;
if (memcmp (tok->chars, this_tok->chars, this_tok->length))
if (memcmp (tok->tp.tok.chars, this_tok->tp.tok.chars, this_tok->tp.tok.length))
continue;
if (option_parser_trace)
fprintf (stderr, "Found symbol %s (%i:%i) as %i \n", tok->chars,
tok->lineno, tok->charno, NUMERIC_TYPE (this));
fprintf (stderr, "Found symbol %s (%i:%i) as %i \n", tok->tp.tok.chars,
tok->tp.tok.lineno, tok->tp.tok.charno, NUMERIC_TYPE (this));
return this;
}
if (option_parser_trace)
fprintf (stderr, "Not found symbol %s (%i:%i) as %i \n", tok->chars,
tok->lineno, tok->charno, tok->type);
fprintf (stderr, "Not found symbol %s (%i:%i) as %i \n", tok->tp.tok.chars,
tok->tp.tok.lineno, tok->tp.tok.charno, tok->type);
return NULL;
}
/* Insert name PROD into the symbol table. Return 1 if duplicate, 0 if OK. */
int
insert_tree_name (struct production *prod)
insert_tree_name (struct prod_token_parm_item *prod)
{
struct token* tok;
struct prod_token_parm_item *tok;
tok = SYMBOL_TABLE_NAME (prod);
if (lookup_tree_name (prod))
{
fprintf (stderr, "%s:%i:%i duplicate name %s\n", in_fname, tok->lineno, tok->charno, tok->chars);
fprintf (stderr, "%s:%i:%i duplicate name %s\n", in_fname, tok->tp.tok.lineno,
tok->tp.tok.charno, tok->tp.tok.chars);
errorcount++;
return 1;
}
prod->next = symbol_table;
prod->tp.pro.next = symbol_table;
NESTING_LEVEL (prod) = work_nesting_level;
symbol_table = prod;
return 0;
......@@ -368,15 +301,19 @@ insert_tree_name (struct production *prod)
/* Create a struct productions of type TYPE, main token MAIN_TOK. */
struct production *
make_production (int type, struct token* main_tok)
struct prod_token_parm_item *
make_production (int type, struct prod_token_parm_item *main_tok)
{
struct production *prod;
prod = my_malloc (sizeof (struct production));
struct prod_token_parm_item *prod;
prod = my_malloc (sizeof (struct prod_token_parm_item));
prod->category = production_category;
prod->type = type;
prod->main_token = main_tok;
prod->tp.pro.main_token = main_tok;
return prod;
}
/* New garbage collection regime see gty.texi. */
#include "gt-treelang-tree1.h"
/*#include "gt-treelang-treelang.h"*/
#include "gtype-treelang.h"
......@@ -35,64 +35,57 @@ enum category_enum
{ /* These values less likely to be there by chance unlike 0/1,
make checks more meaningful */
token_category = 111,
production_category = 222
production_category = 222,
parameter_category = 333
};
/* Input file name and FILE. */
extern unsigned char* in_fname;
extern FILE* yyin;
#if 0
extern int errorcount; /* In toplev.c. */
#endif
/* Forward references to satisfy mutually recursive definitions. */
struct token_part;
struct production_part;
struct prod_token_parm_item;
typedef struct GTY(()) prod_token_parm_item item;
struct token
/* A token from the input file. */
struct token_part GTY(())
{
enum category_enum category; /* Token or production. */
unsigned int type; /* Token type. */
/* Prior to this point, production must match token. */
unsigned int lineno;
unsigned int charno;
unsigned int length; /* The value. */
unsigned char* chars;
};
struct production
/* Definitions for fields in production. */
#define NESTING_LEVEL(a) a->tp.pro.info[0] /* Level used for variable definitions. */
#define NUMERIC_TYPE(a) a->tp.pro.info[1] /* Numeric type used in type definitions and expressions. */
#define SUB_COUNT 5
#define SYMBOL_TABLE_NAME(a) (a->tp.pro.sub[0]) /* Name token. */
#define EXPRESSION_TYPE(a) (a->tp.pro.sub[1]) /* Type identifier. */
#define OP1(a) (a->tp.pro.sub[2]) /* Exp operand1. */
#define PARAMETERS(a) (a->tp.pro.sub[2]) /* Function parameters. */
#define VARIABLE(a) (a->tp.pro.sub[2]) /* Parameter variable ptr. */
#define VAR_INIT(a) (a->tp.pro.sub[2]) /* Variable init. */
#define OP2(a) (a->tp.pro.sub[3]) /* Exp operand2. */
#define FIRST_PARMS(a) (a->tp.pro.sub[3]) /* Function parameters linked via struct tree_parameter_list. */
#define OP3(a) (a->tp.pro.sub[4]) /* Exp operand3. */
#define STORAGE_CLASS_TOKEN(a) (a->tp.pro.sub[4]) /* Storage class token. */
#define STORAGE_CLASS(a) a->tp.pro.flag1 /* Values in treetree.h. */
struct production_part GTY(())
{
enum category_enum category; /* Token or Production. */
unsigned int type; /* Production type - a fake token name. */
/* Prior to this point, production must match token. */
struct token* main_token; /* Main token for error msgs; variable name token. */
struct prod_token_parm_item *main_token; /* Main token for error msgs; variable name token. */
unsigned int info[2]; /* Extra information. */
#define NESTING_LEVEL(a) a->info[0] /* Level used for variable definitions. */
#define NUMERIC_TYPE(a) a->info[1] /* Numeric type used in type definitions and expressions. */
#define SUB_COUNT 5
void *sub[SUB_COUNT]; /* Sub productions or tokens. */
#define SYMBOL_TABLE_NAME(a) (a->sub[0]) /* Name token. */
#define EXPRESSION_TYPE(a) (a->sub[1]) /* Type identifier. */
#define OP1(a) (a->sub[2]) /* Exp operand1. */
#define PARAMETERS(a) (a->sub[2]) /* Function parameters. */
#define VARIABLE(a) (a->sub[2]) /* Parameter variable ptr. */
#define VAR_INIT(a) (a->sub[2]) /* Variable init. */
#define OP2(a) (a->sub[3]) /* Exp operand2. */
#define FIRST_PARMS(a) (a->sub[3]) /* Function parameters linked via struct tree_parameter_list. */
#define OP3(a) (a->sub[4]) /* Exp operand3. */
#define STORAGE_CLASS_TOKEN(a) (a->sub[4]) /* Storage class token. */
void *code; /* Back end hook for this item. */
struct production *next; /* Next in chains of various types. */
struct prod_token_parm_item *sub[SUB_COUNT]; /* Sub productions or tokens. */
tree code; /* Back end hook for this item. */
struct prod_token_parm_item *next; /* Next in chains of various types. */
unsigned int flag1:2;
#define STORAGE_CLASS(a) a->flag1 /* Values in treetree.h. */
unsigned int flag2:1;
unsigned int flag3:1;
unsigned int flag4:1;
......@@ -102,15 +95,58 @@ struct production
};
/* Storage modes. */
#define STATIC_STORAGE 0
#define AUTOMATIC_STORAGE 1
#define EXTERNAL_REFERENCE_STORAGE 2
#define EXTERNAL_DEFINITION_STORAGE 3
/* Numeric types. */
#define SIGNED_CHAR 1
#define UNSIGNED_CHAR 2
#define SIGNED_INT 3
#define UNSIGNED_INT 4
#define VOID_TYPE 5
/* Expression types. */
#define EXP_PLUS 0 /* Addition expression. */
#define EXP_REFERENCE 1 /* Variable reference. */
#define EXP_ASSIGN 2 /* Assignment. */
#define EXP_FUNCTION_INVOCATION 3 /* Call function. */
#define EXP_MINUS 4 /* Subtraction. */
#define EXP_EQUALS 5 /* Equality test. */
/* Parameter list passed to back end. */
struct parameter_part GTY(())
{
struct prod_token_parm_item *next; /* Next entry. */
unsigned char* variable_name; /* Name. */
tree * GTY ((length ("1"))) where_to_put_var_tree; /* Where to save decl. */
};
/* A production or a token. */
struct prod_token_parm_item GTY(())
{
enum category_enum category; /* Token or production. */
unsigned int type; /* Token or production type. */
union t_or_p
{
struct token_part GTY((tag ("token_category"))) tok;
struct production_part GTY((tag ("production_category"))) pro;
struct parameter_part GTY((tag ("parameter_category"))) par;
} GTY((desc ("((item *)&%1)->category"))) tp;
};
/* For parser. Alternatively you can define it using %union (bison) or
union. */
#define YYSTYPE void *
void *my_malloc (size_t size);
int insert_tree_name (struct production *prod);
struct production *lookup_tree_name (struct production *prod);
struct production *make_production (int type, struct token* main_tok);
void mark_production_used (struct production * pp);
void mark_token_used (struct token* tt);
int insert_tree_name (struct prod_token_parm_item *prod);
struct prod_token_parm_item *lookup_tree_name (struct prod_token_parm_item *prod);
struct prod_token_parm_item *make_production (int type, struct prod_token_parm_item *main_tok);
void mark_production_used (struct prod_token_parm_item *pp);
void mark_token_used (struct prod_token_parm_item *tt);
void treelang_debug (void);
......@@ -70,21 +70,21 @@
/* GCC headers. */
#include "ansidecl.h"
#include "config.h"
#include "ansidecl.h"
#include "system.h"
#include "tree.h"
#include "flags.h"
#include "output.h"
#include "c-tree.h"
#include "rtl.h"
#include "tm_p.h"
#include "ggc.h"
#include "toplev.h"
#include "varray.h"
#include "langhooks-def.h"
#include "langhooks.h"
#include "treelang.h"
#include "treetree.h"
extern int option_main;
......@@ -163,14 +163,6 @@ const char *const tree_code_name[] = {
unsigned int tree_code_int_size = 0;
unsigned int tree_code_char_size = 0;
/* In this case there is very little to keep between functions - we
keep the symbol table only and the things that hang off that - see
tree1.c. Garbage collection is only invoked when we call
rest_of_compilation at the end of a function. */
#define ADDROOT(where) ggc_add_root (&where, 1, /* Unused size. */ sizeof (void*), \
tree_ggc_storage_always_used);
/* Return the tree stuff for this type TYPE_NUM. */
tree
......@@ -242,13 +234,13 @@ tree
tree_code_create_function_prototype (unsigned char* chars,
unsigned int storage_class,
unsigned int ret_type,
struct tree_parameter_list* parms,
struct prod_token_parm_item* parms,
unsigned char* filename,
int lineno)
{
tree id;
struct tree_parameter_list* parm;
struct prod_token_parm_item* parm;
tree type_list = NULL_TREE;
tree type_node;
tree fn_type;
......@@ -256,7 +248,7 @@ tree_code_create_function_prototype (unsigned char* chars,
/* Build the type. */
id = get_identifier ((const char*)chars);
for (parm = parms; parm; parm = parm->next)
for (parm = parms; parm; parm = parm->tp.par.next)
{
type_node = get_type_for_numeric_type (parm->type);
type_list = tree_cons (NULL_TREE, type_node, type_list);
......@@ -328,7 +320,7 @@ void
tree_code_create_function_initial (tree prev_saved,
unsigned char* filename,
int lineno,
struct tree_parameter_list* parms)
struct prod_token_parm_item* parms)
{
tree fn_decl;
tree param_decl;
......@@ -337,8 +329,8 @@ tree_code_create_function_initial (tree prev_saved,
tree parm_decl;
tree parm_list;
tree resultdecl;
struct tree_parameter_list* this_parm;
struct tree_parameter_list* parm;
struct prod_token_parm_item* this_parm;
struct prod_token_parm_item* parm;
fn_decl = prev_saved;
if (!fn_decl)
......@@ -368,10 +360,11 @@ tree_code_create_function_initial (tree prev_saved,
/* Make the argument variable decls. */
parm_list = NULL_TREE;
for (parm = parms; parm; parm = parm->next)
for (parm = parms; parm; parm = parm->tp.par.next)
{
parm_decl = build_decl (PARM_DECL, get_identifier ((const char*) (parm->variable_name)),
get_type_for_numeric_type (parm->type));
parm_decl = build_decl (PARM_DECL, get_identifier
((const char*) (parm->tp.par.variable_name)),
get_type_for_numeric_type (parm->type));
/* Some languages have different nominal and real types. */
DECL_ARG_TYPE (parm_decl) = TREE_TYPE (parm_decl);
......@@ -395,11 +388,11 @@ tree_code_create_function_initial (tree prev_saved,
this_parm = parms;
param_decl;
param_decl = TREE_CHAIN (param_decl),
this_parm = this_parm->next)
this_parm = this_parm->tp.par.next)
{
if (!this_parm)
abort (); /* Too few. */
*this_parm->where_to_put_var_tree = param_decl;
*this_parm->tp.par.where_to_put_var_tree = param_decl;
}
if (this_parm)
abort (); /* Too many. */
......@@ -1032,8 +1025,16 @@ handle_format_arg_attribute (tree *node ATTRIBUTE_UNUSED,
int
cpp_handle_option (cpp_reader *pfile ATTRIBUTE_UNUSED,
int argc ATTRIBUTE_UNUSED,
char **argv ATTRIBUTE_UNUSED,
int ignore ATTRIBUTE_UNUSED)
char **argv ATTRIBUTE_UNUSED)
{
abort ();
}
/* Should not be called for treelang. */
void
cpp_assert (cpp_reader * cr ATTRIBUTE_UNUSED,
const char *s ATTRIBUTE_UNUSED)
{
abort ();
}
......
......@@ -31,15 +31,6 @@
*/
/* Parameter list passed to back end. */
struct tree_parameter_list
{
struct tree_parameter_list* next; /* Next entry. */
int type; /* See numeric types below. */
unsigned char* variable_name; /* Name. */
tree* where_to_put_var_tree; /* Where to save decl. */
};
tree tree_code_init_parameters (void);
tree tree_code_add_parameter (tree list, tree proto_exp, tree exp);
tree tree_code_get_integer_value (unsigned char *chars, unsigned int length);
......@@ -49,12 +40,12 @@ tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree
tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1);
void tree_code_create_function_initial (tree prev_saved,
unsigned char* filename, int lineno,
struct tree_parameter_list* parms);
struct prod_token_parm_item* parms);
void tree_code_create_function_wrapup (unsigned char* filename, int lineno);
tree tree_code_create_function_prototype (unsigned char* chars,
unsigned int storage_class,
unsigned int ret_type,
struct tree_parameter_list* parms,
struct prod_token_parm_item* parms,
unsigned char* filename,
int lineno);
tree tree_code_create_variable (unsigned int storage_class,
......@@ -78,24 +69,5 @@ void treelang_parse_file (int debug_flag);
void push_var_level (void);
void pop_var_level (void);
/* Storage modes. */
#define STATIC_STORAGE 0
#define AUTOMATIC_STORAGE 1
#define EXTERNAL_REFERENCE_STORAGE 2
#define EXTERNAL_DEFINITION_STORAGE 3
/* Numeric types. */
#define SIGNED_CHAR 1
#define UNSIGNED_CHAR 2
#define SIGNED_INT 3
#define UNSIGNED_INT 4
#define VOID_TYPE 5
#define EXP_PLUS 0 /* Addition expression. */
#define EXP_REFERENCE 1 /* Variable reference. */
#define EXP_ASSIGN 2 /* Assignment. */
#define EXP_FUNCTION_INVOCATION 3 /* Call function. */
#define EXP_MINUS 4 /* Subtraction. */
#define EXP_EQUALS 5 /* Equality test. */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment