diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2014-02-02 16:17:01 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2014-02-02 16:17:01 -0500 |
commit | 1fed2a7fe0e5f69ca1b3b89959846c499926628e (patch) | |
tree | 2e43650b1ffbedecdccab63c114b86ba875b408a | |
parent | ee684dab2b5e4bb1c487a529285f53a43de05653 (diff) |
TODO, formatting
-rw-r--r-- | TODO | 27 | ||||
-rw-r--r-- | graph.c | 21 |
2 files changed, 30 insertions, 18 deletions
@@ -80,15 +80,30 @@ Preliminary conclusions: - expression stack must become a heap allocated tree + - there is a global current_stack + - environments need to contain - prev_env [the environment to restore after return] - outer_env [pointer to containing environment] - return address [where to jump when returning] - - stack pointer [pointer to node of the expression tree] + - return stack [stack to restore when returning] + + = Expressions: + - Operate on current stack + + = Call: + - Allocate new env + - Store current env as prev_env + - Store closure env as outer_env + - Store current stack as prev_stack + - Set stack pointer to NULL + - Set return address to current address + - Jump to function = Returning: - - push the return value on top of the stack in the return environment + - push the return value on top of prev_stack - restore outer environment + - set stack to prev_stack - jump to return address = Generating a label: @@ -99,14 +114,6 @@ - set expression stack pointer to NULL - goto code pointer - = Call: - - Allocate new env - - Store current env as prev_env - - Store closure env as outer - - Set stack pointer to NULL - - Set return address to current address - - Jump to function - - Short-term tasks: - Test suite @@ -93,7 +93,8 @@ graph_expression_store (ast_expression_t *expr, case AST_INDEX_EXPRESSION: node = graph_expression (expr->index.right, node); node = graph_expression (expr->index.left, node); - node = node_new_store_array (&(expr->index.left->common.type_spec->array), node, (ast_t *)expr); + node = node_new_store_array ( + &(expr->index.left->common.type_spec->array), node, (ast_t *)expr); break; default: @@ -480,7 +481,9 @@ graph_expression (ast_expression_t *expr, element_size = ast_type_spec_get_size (array->child_type); - node = node_new_new_array ((ast_array_type_spec_t *)expr->new.type, element_size, node, ast); + node = node_new_new_array ( + (ast_array_type_spec_t *)expr->new.type, + element_size, node, ast); } break; @@ -490,7 +493,8 @@ graph_expression (ast_expression_t *expr, case AST_DEFINITION_EXPRESSION: node = graph_expression (expr->definition.initializer, node); - node = node_new_store (&(expr->definition.definition->variable), expr, node, ast); + node = node_new_store ( + &(expr->definition.definition->variable), expr, node, ast); break; case AST_DOT_EXPRESSION: @@ -505,7 +509,8 @@ graph_expression (ast_expression_t *expr, node = graph_expression (index->right, node); node = graph_expression (index->left, node); - node = node_new_load_array (&(expr->index.left->common.type_spec->array), node, ast); + node = node_new_load_array ( + &(expr->index.left->common.type_spec->array), node, ast); break; } @@ -565,10 +570,10 @@ graph_switch_statement (ast_switch_statement_t *switch_, node_t *node) { ast_expression_case_t *case_ = &cases[i]->expression; - /* We code generate the condition expression for each case. This is not - * a problem because the parser has made sure that the expression - * is just a variable load so there are no issues with the expression - * having side-effects. + /* We code generate the condition expression for each case. + * This is not a problem because the parser has made sure that the + * expression is just a variable load so there are no issues with + * the expression having side-effects. */ node = graph_expression (switch_->condition, node); node = node_new_literal (case_->expr->common.constant_value, |