summaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-07-05 20:40:54 -0400
committerSøren Sandmann <sandmann@redhat.com>2008-07-05 20:40:54 -0400
commit8d12d5a50e1f20e991a33501a1bc3a29ea1917b2 (patch)
tree7253a9a66ed268d706ecfd5ee79bc892f5a4b1fc /graph.c
parent0ab7d9fc87518d4ba524c714bbe94d0169cf99cc (diff)
Export node handling functions in separate node.c file
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c321
1 files changed, 1 insertions, 320 deletions
diff --git a/graph.c b/graph.c
index 008def4..11bbbdf 100644
--- a/graph.c
+++ b/graph.c
@@ -1,5 +1,5 @@
/* Ninja
- * Copyright 2007, Soren Sandmann Pedersen
+ * Copyright 2007, 2008, Soren Sandmann Pedersen
*
* 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
@@ -21,325 +21,6 @@
static node_t *graph_statement (ast_statement_t *statement,
node_t *node);
-static node_t *
-node_append (node_t *node, node_t *pred, ast_t *ast)
-{
- pred->common.next = node;
- node->common.prev = pred;
-
- return node;
-}
-
-static node_t *
-node_new (node_type_t type, node_t *node, ast_t *ast)
-{
- node_t *new = g_new0 (node_t, 1);
-
- new->common.type = type;
-
- if (node)
- node_append (new, node, ast);
-
- return new;
-}
-
-static node_t *
-node_new_fun_ref (node_t *prolog, node_t *pred, ast_t *ast)
-{
- node_t *fun_ref = node_new (NODE_FUN_REF, pred, ast);
-
- g_assert (prolog->common.type == NODE_PROLOG);
-
- fun_ref->fun_ref.prolog = &prolog->prolog;
-
- g_queue_push_tail (prolog->prolog.sources, fun_ref);
-
- return fun_ref;
-}
-
-static node_t *
-node_new_prolog (node_t *pred, ast_t *ast)
-{
- node_t *prolog = node_new (NODE_PROLOG, pred, ast);
-
- prolog->prolog.sources = g_queue_new ();
-
- return prolog;
-}
-
-static node_t *
-node_new_label (node_t *pred, ast_t *ast)
-{
- node_t *label = node_new (NODE_LABEL, pred, ast);
-
- label->label.sources = g_queue_new ();
-
- return label;
-};
-
-static node_t *
-node_new_goto (label_node_t *label,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_GOTO, pred, ast);
-
- node->goto_.label = label;
- g_queue_push_tail (label->sources, node);
-
- return node;
-}
-
-static node_t *
-node_new_return (ast_type_spec_t *type,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_RETURN, pred, ast);
-
- node->return_.type = type;
-
- return node;
-}
-
-static node_t *
-node_new_if (label_node_t *taken,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_IF, pred, ast);
- node->if_.taken = taken;
- g_queue_push_tail (taken->sources, node);
- return node;
-}
-
-static node_t *
-node_new_literal (value_t value,
- ast_type_spec_t *type,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_LITERAL, pred, ast);
-
- node->literal.value = value;
- node->literal.type_spec = type;
-
- return node;
-}
-
-static node_t *
-node_new_closure (ast_function_definition_t *function,
- ast_expression_t *expr,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_CLOSURE, pred, ast);
-
- g_assert (ast->type == AST_EXPRESSION);
-
- node->closure.function = function;
- node->closure.expression = expr;
-
- return node;
-}
-
-static node_t *
-node_new_dyn_closure (ast_function_definition_t *function,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_DYN_CLOSURE, pred, ast);
-
- g_assert (ast->type == AST_EXPRESSION);
-
- node->dyn_closure.function = function;
-
- return node;
-}
-
-static node_t *
-node_new_print (ast_type_spec_t *type_spec,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_PRINT, pred, ast);
-
- node->print.type_spec = type_spec;
-
- return node;
-}
-
-static node_t *
-node_new_call (node_t *pred,
- ast_t *ast)
-{
- return node_new (NODE_CALL, pred, ast);
-}
-
-static node_t *
-node_new_pop (node_t *pred,
- ast_t *ast)
-{
- return node_new (NODE_POP, pred, ast);
-}
-
-static node_t *
-node_new_dup (node_t *pred,
- ast_t *ast)
-{
- return node_new (NODE_DUP, pred, ast);
-}
-
-static node_t *
-node_new_nop (node_t *pred,
- ast_t *ast)
-{
- return node_new (NODE_NOP, pred, ast);
-}
-
-static node_t *
-node_new_load (ast_variable_definition_t *def,
- ast_expression_t *expr,
- node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_LOAD, pred, ast);
-
- node->load.definition = def;
- node->load.expression = expr;
-
- return node;
-}
-
-static node_t *
-node_new_load_ind (ast_variable_definition_t *def, node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_LOAD_IND, pred, ast);
-
- node->load_ind.definition = def;
-
- return node;
-}
-
-static node_t *
-node_new_load_array (node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_LOAD_ARRAY, pred, ast);
-
- return node;
-}
-
-static node_t *
-node_new_store (ast_variable_definition_t *def,
- ast_expression_t *expr,
- node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_STORE, pred, ast);
-
- node->store.definition = def;
- node->store.expression = expr;
-
- return node;
-}
-
-static node_t *
-node_new_store_ind (ast_variable_definition_t *def,
- node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_STORE_IND, pred, ast);
-
- node->store_ind.definition = def;
-
- return node;
-}
-
-static node_t *
-node_new_store_array (node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_STORE_ARRAY, pred, ast);
-
- return node;
-}
-
-static node_t *
-node_new_initialize (ast_variable_definition_t *def, node_t *pred, ast_t *ast)
-{
- node_t *node = node_new (NODE_INIT, pred, ast);
-
- node->initialize.definition = def;
-
- return node;
-}
-
-static node_t *
-node_new_binop (ast_binary_operator_t operator,
- ast_type_spec_t * left_type,
- ast_type_spec_t * right_type,
- ast_type_spec_t * type,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_BINOP, pred, ast);
-
- g_assert (operator != AST_AND && operator != AST_OR);
-
- node->binop.operator = operator;
- node->binop.left_type = left_type;
- node->binop.right_type = right_type;
- node->binop.type_spec = type;
-
- return node;
-}
-
-static node_t *
-node_new_unary (ast_unary_operator_t operator,
- ast_type_spec_t * child_type,
- ast_type_spec_t * type,
- node_t * pred,
- ast_t * ast)
-{
- node_t *node = node_new (NODE_UNARY, pred, ast);
-
- /* These were converted to load/store/binop in graph.c */
- g_assert (operator != AST_POSTFIX_INC &&
- operator != AST_POSTFIX_DEC &&
- operator != AST_PREFIX_INC &&
- operator != AST_PREFIX_DEC);
-
- node->unary.operator = operator;
- node->unary.child_type = child_type;
- node->unary.type_spec = type;
-
- return node;
-}
-
-static node_t *
-node_new_new (ast_class_definition_t *class,
- ast_expression_t *expr,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_NEW, pred, ast);
-
- node->new.expression = expr;
- node->new.class = class;
-
- return node;
-}
-
-static node_t *
-node_new_this (ast_class_definition_t *class,
- ast_expression_t *expr,
- node_t *pred,
- ast_t *ast)
-{
- node_t *node = node_new (NODE_THIS, pred, ast);
-
- node->this.expression = expr;
- node->this.class = class;
-
- return node;
-}
-
static void
graph_function (ast_function_definition_t *function)
{