TYPE ConstFlattened = flat(snum) State = Var -> ConstFlattened PROBLEM Parity_Analysis direction : forward carrier : State init : bot init_start : [-> top] combine : lub TRANSFER // in assignments calculate the new value of the variable and add it // to the state ASSIGN(variable, expression) = @\[variable -> evalAExp(expression, @)] // in procedure calls pass the value of the actual argument to the // formal parameter CALL(_, param, exp), call_edge = @\[param -> evalAExp(exp, @)] CALL(_, _, _), local_edge = bot // at the end of procedures reset the formal parameter END(_, param) = @\[param -> top] SUPPORT evalAExp :: Expression * State -> ConstFlattened evalAExp(expression, state) = case expType(expression) of "ARITH_BINARY" => case expOp(expression) of "+" => let valLeft <= evalAExp(expSubLeft(expression), state), valRight <= evalAExp(expSubRight(expression), state) in lift((valLeft + valRight) % 2); "-" => let valLeft <= evalAExp(expSubLeft(expression), state), valRight <= evalAExp(expSubRight(expression), state) in lift((valLeft + valRight) % 2); "*" => let valLeft = evalAExp(expSubLeft(expression), state), valRight = evalAExp(expSubRight(expression), state) in if ((valLeft = lift (0)) || (valRight = lift (0))) then lift (0) else if ((valLeft = lift (1)) && (valRight = lift (1))) then lift (1) else bot endif endif; "/" => bot; endcase; "ARITH_UNARY" => case expOp(expression) of "-" => evalAExp(expSub(expression), state); endcase; "VAR" => let val <= state (expVar(expression)) in lift(val % 2); "CONST" => lift(expVal(expression) % 2); _ => error("Runtime Error: bad voodoo"); endcase