FIRM_CFLAGS = -I$(FIRM_HOME)/libfirm/include -I$(FIRM_HOME)/obstack -I$(FIRM_HOME)/libcore -I$(FIRM_HOME)/libcore/libcore -I$(FIRM_HOME)
FIRM_LIBS = -L$(FIRM_BUILD) -lfirm -llpp -lcore -lm -ldl
-CFLAGS += -Wall -W -Werror -std=c99 -pedantic
+CFLAGS += -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Werror -std=c99 -pedantic
CFLAGS += -DHAVE_CONFIG_H
CFLAGS += -I .
CFLAGS += -O0 -g3
#error You have to redefine hashset_remove_iterator
#endif
+/* prototypes to silence warnings */
+size_t hashset_size(const HashSet *this);
+void hashset_init(HashSet *this);
+void hashset_init_size(HashSet *this, size_t size);
+void hashset_destroy(HashSet *this);
+InsertReturnValue hashset_insert(HashSet *this, KeyType key);
+ValueType hashset_find(const HashSet *this, ConstKeyType key);
+void hashset_remove(HashSet *this, ConstKeyType key);
+void hashset_iterator_init(HashSetIterator *this, const HashSet *hashset);
+ValueType hashset_iterator_next(HashSetIterator *this);
+void hashset_remove_iterator(HashSet *this, const HashSetIterator *iter);
+
/**
* Returns the number of elements in the hashset
*/
void print_expression(const expression_t *expression);
void print_initializer(const initializer_t *initializer);
void print_ast(const translation_unit_t *unit);
-void print_indent();
+void print_indent(void);
void print_declaration(const declaration_t *declaration);
void change_indent(int delta);
void *allocate_ast(size_t size);
#include <libfirm/firm.h>
#include <libfirm/adt/obst.h>
+#include "ast2firm.h"
+
#include "adt/error.h"
#include "token_t.h"
#include "type_t.h"
return new_id_from_str(buf);
}
-#if 0
-static symbol_t *unique_symbol(const char *tag)
-{
- obstack_printf(&symbol_obstack, "%s.%d", tag, unique_id);
- unique_id++;
-
- const char *string = obstack_finish(&symbol_obstack);
- symbol_t *symbol = symbol_table_insert(string);
-
- assert(symbol->string == string);
-
- return symbol;
-}
-#endif
-
static type_t *skip_typeref(type_t *type)
{
while(1) {
expression_to_firm(statement->expression);
}
+static void if_statement_to_firm(if_statement_t *statement)
+{
+ dbg_info *dbgi = get_dbg_info(&statement->statement.source_position);
+ ir_node *condition = expression_to_firm(statement->condition);
+ assert(condition != NULL);
+ assert(get_irn_mode(condition) == mode_b);
+
+ ir_node *cond = new_d_Cond(dbgi, condition);
+ ir_node *true_proj = new_d_Proj(dbgi, cond, mode_X, pn_Cond_true);
+ ir_node *false_proj = new_d_Proj(dbgi, cond, mode_X, pn_Cond_false);
+
+ ir_node *fallthrough_block = new_immBlock();
+
+ /* the true (blocks) */
+ ir_node *true_block = new_immBlock();
+ add_immBlock_pred(true_block, true_proj);
+ mature_immBlock(true_block);
+
+ statement_to_firm(statement->true_statement);
+ if(get_cur_block() != NULL) {
+ ir_node *jmp = new_Jmp();
+ add_immBlock_pred(fallthrough_block, jmp);
+ }
+
+ /* the false (blocks) */
+ if(statement->false_statement != NULL) {
+ ir_node *false_block = new_immBlock();
+ add_immBlock_pred(false_block, false_proj);
+ mature_immBlock(false_block);
+
+ statement_to_firm(statement->false_statement);
+ if(get_cur_block() != NULL) {
+ ir_node *jmp = new_Jmp();
+ add_immBlock_pred(fallthrough_block, jmp);
+ }
+ } else {
+ add_immBlock_pred(fallthrough_block, false_proj);
+ }
+ mature_immBlock(fallthrough_block);
+
+ set_cur_block(fallthrough_block);
+}
+
static void statement_to_firm(statement_t *statement)
{
switch(statement->type) {
case STATEMENT_EXPRESSION:
expression_statement_to_firm((expression_statement_t*) statement);
return;
+ case STATEMENT_IF:
+ if_statement_to_firm((if_statement_t*) statement);
+ return;
default:
break;
}
}
}
-static void parse_preprocessor_directive()
+static void parse_preprocessor_directive(void)
{
next_pp_token();
#define eat(token_type) do { assert(token.type == token_type); next_token(); } while(0)
-void error(void)
+static void error(void)
{
#ifdef ABORT_ON_ERROR
abort();
#endif
}
-void parser_print_prefix_pos(const source_position_t source_position)
+static void parser_print_prefix_pos(const source_position_t source_position)
{
fputs(source_position.input_name, stderr);
fputc(':', stderr);
fputs(": ", stderr);
}
-void parser_print_error_prefix_pos(const source_position_t source_position)
+static void parser_print_error_prefix_pos(
+ const source_position_t source_position)
{
parser_print_prefix_pos(source_position);
fputs("error: ", stderr);
error();
}
-void parser_print_error_prefix(void)
+static void parser_print_error_prefix(void)
{
parser_print_prefix_pos(token.source_position);
error();
-void register_expression_parser(parse_expression_function parser,
- int token_type, unsigned precedence)
+static void register_expression_parser(parse_expression_function parser,
+ int token_type, unsigned precedence)
{
expression_parser_function_t *entry = &expression_parsers[token_type];
entry->precedence = precedence;
}
-void register_expression_infix_parser(parse_expression_infix_function parser,
- int token_type, unsigned precedence)
+static void register_expression_infix_parser(
+ parse_expression_infix_function parser, int token_type,
+ unsigned precedence)
{
expression_parser_function_t *entry = &expression_parsers[token_type];
#include <errno.h>
#include <string.h>
+#include "write_fluffy.h"
#include "ast_t.h"
#include "type_t.h"
#include "type.h"