diff options
author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-06-02 19:15:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:50 -0700 |
commit | 8642a0b9da3e5ad5dbfe6e90b63be08959d36133 (patch) | |
tree | 75fa93907be7138e91b66529601a69e9c99607ae /inline.c | |
parent | Get rid of "#pragma" lines for now, while still keeping a (diff) | |
download | sparse-8642a0b9da3e5ad5dbfe6e90b63be08959d36133.tar.gz sparse-8642a0b9da3e5ad5dbfe6e90b63be08959d36133.tar.bz2 sparse-8642a0b9da3e5ad5dbfe6e90b63be08959d36133.zip |
Create "inline.c", which contains the function "copy_statement()",
used for inlining. Right now the copying is totally broken, since
we don't actually do any symbol replacement, but hey, we'll get there
some day.
Make "inline_function()" call the new copy_statement() function.
Diffstat (limited to 'inline.c')
-rw-r--r-- | inline.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/inline.c b/inline.c new file mode 100644 index 0000000..7b80f5c --- /dev/null +++ b/inline.c @@ -0,0 +1,43 @@ +/* + * Sparse - a semantic source parser. + * + * Copyright (C) 2003 Transmeta Corp. + * + * Licensed under the Open Software License version 1.1 + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "lib.h" +#include "token.h" +#include "parse.h" +#include "symbol.h" + +#define copy_one_statement(stmt) (stmt) +#define copy_expression(expr) (expr) + +/* + * Copy a stateemnt tree from 'src' to 'dst', where both + * source and destination are of type STMT_COMPOUND. + * + * We do this for the tree-level inliner. + * + * This doesn't do the symbol replacements right, duh. + */ +void copy_statement(struct statement *src, struct statement *dst) +{ + struct statement *stmt; + struct symbol *sym; + + FOR_EACH_PTR(src->syms, sym) { + struct symbol *newsym = alloc_symbol(sym->pos, sym->type); + newsym->ctype = sym->ctype; + newsym->initializer = copy_expression(sym->initializer); + add_symbol(&dst->syms, newsym); + } END_FOR_EACH_PTR; + + FOR_EACH_PTR(src->stmts, stmt) { + add_statement(&dst->stmts, copy_one_statement(stmt)); + } END_FOR_EACH_PTR; +} |