Skip to content

Commit

Permalink
Merge pull request #1735 from jemmaissroff/remove-pm-scope-node-init
Browse files Browse the repository at this point in the history
Remove pm_scope_node_init
  • Loading branch information
kddnewton authored Oct 26, 2023
2 parents 6499cf5 + 75ab9d0 commit 3491b08
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 89 deletions.
3 changes: 0 additions & 3 deletions include/prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ void pm_print_node(pm_parser_t *parser, pm_node_t *node);

void pm_parser_metadata(pm_parser_t *parser, const char *metadata);

// Generate a scope node from the given node.
void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous, pm_parser_t *parser);

// The prism version and the serialization format.
PRISM_EXPORTED_FUNCTION const char * pm_version(void);

Expand Down
86 changes: 0 additions & 86 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,92 +648,6 @@ pm_arguments_validate_block(pm_parser_t *parser, pm_arguments_t *arguments, pm_b
pm_parser_err_node(parser, (pm_node_t *) block, PM_ERR_ARGUMENT_UNEXPECTED_BLOCK);
}

/******************************************************************************/
/* Scope node functions */
/******************************************************************************/

// Generate a scope node from the given node.
void
pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous, pm_parser_t *parser) {
scope->base.type = PM_SCOPE_NODE;
scope->base.location.start = node->location.start;
scope->base.location.end = node->location.end;

scope->previous = previous;
scope->parser = parser;
scope->ast_node = (pm_node_t *)node;
scope->parameters = NULL;
scope->body = NULL;
scope->constants = NULL;
if (previous) {
scope->constants = previous->constants;
}
scope->index_lookup_table = NULL;

pm_constant_id_list_init(&scope->locals);

switch (PM_NODE_TYPE(node)) {
case PM_BLOCK_NODE: {
pm_block_node_t *cast = (pm_block_node_t *) node;
if (cast->parameters) scope->parameters = cast->parameters->parameters;
scope->body = cast->body;
scope->locals = cast->locals;
break;
}
case PM_CLASS_NODE: {
pm_class_node_t *cast = (pm_class_node_t *) node;
scope->body = cast->body;
scope->locals = cast->locals;
break;
}
case PM_DEF_NODE: {
pm_def_node_t *cast = (pm_def_node_t *) node;
scope->parameters = cast->parameters;
scope->body = cast->body;
scope->locals = cast->locals;
break;
}
case PM_FOR_NODE: {
pm_for_node_t *cast = (pm_for_node_t *)node;
scope->body = (pm_node_t *)cast->statements;
break;
}
case PM_LAMBDA_NODE: {
pm_lambda_node_t *cast = (pm_lambda_node_t *) node;
if (cast->parameters) scope->parameters = cast->parameters->parameters;
scope->body = cast->body;
scope->locals = cast->locals;
break;
}
case PM_MODULE_NODE: {
pm_module_node_t *cast = (pm_module_node_t *) node;
scope->body = cast->body;
scope->locals = cast->locals;
break;
}
case PM_POST_EXECUTION_NODE: {
pm_post_execution_node_t *cast = (pm_post_execution_node_t *) node;
scope->body = (pm_node_t *) cast->statements;
break;
}
case PM_PROGRAM_NODE: {
pm_program_node_t *cast = (pm_program_node_t *) node;
scope->body = (pm_node_t *) cast->statements;
scope->locals = cast->locals;
break;
}
case PM_SINGLETON_CLASS_NODE: {
pm_singleton_class_node_t *cast = (pm_singleton_class_node_t *) node;
scope->body = cast->body;
scope->locals = cast->locals;
break;
}
default:
assert(false && "unreachable");
break;
}
}

/******************************************************************************/
/* Node creation functions */
/******************************************************************************/
Expand Down

0 comments on commit 3491b08

Please sign in to comment.