Handle double negation case specially. Update TODO

This commit is contained in:
Dale Weiler 2013-09-30 05:12:28 -04:00
parent 7249c2ec18
commit 03b56bd41f
2 changed files with 7 additions and 13 deletions

13
TODO
View file

@ -29,21 +29,10 @@ Optimizations:
Which can be replaced with calls to a shared subroutine. To
reduce duplicated code. (Size optimization)
The following are optimizations that can be implemented anywhere, ideally
these are functional language optimizations.
Removing Recursion:
Tail recursive algorithms can be converted to iteration, which
does not have to have call overhead.
Language Features:
The following are language features that we'd like to see implemented in the
future.
Enumerations:
Like C
AST Macros:
Macros with sanity. Not textual substiution.
@ -153,5 +142,3 @@ Testsuite:
Assembler:
Possibly support for a future assembler for QCASM. But we're not
entirely sure if it makes sense.

7
ast.c
View file

@ -518,8 +518,15 @@ ast_unary* ast_unary_new(lex_ctx_t ctx, int op,
self->op = op;
self->operand = expr;
if (ast_istype(expr, ast_unary) && OPTS_OPTIMIZATION(OPTIM_PEEPHOLE)) {
ast_unary *prev = (ast_unary*)((ast_unary*)expr)->operand;
ast_unary *cur = (ast_unary*)expr;
/* Handle for double negation */
if (cur->op == op && (op >= VINSTR_NEG_F && op <= VINSTR_NEG_V))
prev = cur;
if (ast_istype(prev, ast_unary)) {
ast_expression_delete((ast_expression*)self);
mem_d(self);