TYPE ConstFlattened = flat(snum) State = Var -> ConstFlattened PROBLEM Sign_Detection 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 procedur 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 case valLeft+valRight of 0 => if valLeft=valRight then lift(0) else top endif; _ => lift(sgn(valLeft+valRight)); endcase; "-" => let valLeft <= evalAExp(expSubLeft(expression), state), valRight <= evalAExp(expSubRight(expression), state) in case valLeft-valRight of 0 => if valLeft=valRight then lift(0) else top endif; _ => lift(sgn(valLeft-valRight)); endcase; "*" => let valLeft <= evalAExp(expSubLeft(expression), state), valRight <= evalAExp(expSubRight(expression), state) in lift(valLeft * valRight); "/" => let valLeft <= evalAExp(expSubLeft(expression), state), valRight <= evalAExp(expSubRight(expression), state) in if valRight = 0 then top else lift(valLeft / valRight) endif; endcase; "ARITH_UNARY" => case expOp(expression) of "-" => let value <= evalAExp(expSub(expression), state) in lift(-(value)); endcase; "VAR" => state ( expVar(expression) ); "CONST" => lift(sgn(expVal(expression))); _ => error("Runtime Error: evalAExp applied to nonarithmetic Expression"); endcase