// current bug: if (!(a==b)) ... // generates wrong code. Should be similar to if (a!=b) ... // even though we can reduce several of these by DeMorgan etc, // need to fix the underlying bug first. // related: if we have a tree whose topmost members are &&, || or comparisons, // they can be lazy evaluated. However once you hit an arithmetic or other node, // the 'nextlab' etc params have to be reset to -1 and any conditions *within* that // expression must be evaluated independently // Also TO DO: fold constant conditions, do dead code removal in AST before generating stack code. // to do: add psects for code/data/initialisation etc // set all conditions to BoolAnd/BoolOr, and then have a pass over the // the tree where we change some of them to LazyBoolAnd/LazyBoolOr // The lazy versions do not need to save their results in a variable, even // a temporary one. // eg not(A && B) can't be inverted the way not(a==b && c==d) can. // so A&&B has to be canonicalised as 0/1 and not() => 1/0 // we may end up trying a full application of demorgans to a tree and then // throwing it away if the resulting tree is worse (eg by pushing all the // not(a)'s to the leaves rather than the root. // one more thing... forgot it :-( // need code to determine side-effects in conditions, for above. Eg if (getc()*0 == 0) ... // related: (a < 'a' || a > 'z') ? val1 : val2 // - '||' or '&&' causes a branch that is not wanted - should leave a truth value on the stack instead. // need a lazy/non-lazy parameter in evaluating conditions? defaults to non-lazy except in special // circumstances surrounding if/while/for ? /* Here are the ones to work on next. Not very many! ; AST_AddressOf ; AST_Cast ; AST_Goto ; AST_Label ; AST_Post_Dec ; AST_Post_Inc ; AST_SizeOf */