private void convertString(AssignStatContext c) { if (c.StringLiteral() != null) { String content = c.StringLiteral().getText().replace("\\n", "\n"); content = content.substring(1, content.length() - 1); String id = c.ID().getText(); String newId = this.generateNewName(id); StringRepresentation rep = new StringRepresentation(newId, content); // System.out.println(rep.getConstraints()); ssa.addAll(rep.getConstraints()); } else { ExprContext expr = c.expr(); if (expr.getChildCount() == 1) { String id = c.ID().getText(); String newId = this.generateNewName(id); String constraint = "(assert (= " + newId + " " + this.getExpr(expr) + "))"; this.ssa.add(constraint); } else { String id = c.ID().getText(); String newId = this.generateNewName(id); String constraint = "(assert (= " + "(valueOf " + newId + ") (charOf " + this.getExpr(expr.expr(0)) + " " + this.getExpr(expr.expr(1)) + ")))"; this.ssa.add(constraint); } } }
private void covertPointerAssgin(AssignStatContext assign) { String ID = assign.ID().getText(); ExprContext temp = assign.expr(); String id = this.variableTrack.get(ID); String newId = generateNewName(id); String constraint = "(assert (= valueOf " + newId + " " + getExpr(temp) + "))"; ssa.add(constraint); }
private void converNonString(AssignStatContext c) { String expr = getExpr(c.expr()); String id = this.variableTrack.get(c.ID().getText()); String newId = generateNewName(id); String constraint = ""; if (c.assiginOperator().getText().equals("=")) { constraint = "(assert(= " + newId + " " + expr + "))"; } else { char operater = c.assiginOperator().getText().charAt(0); constraint = "(assert(= " + newId + "( " + operater + " " + id + " " + expr + " )))"; } ssa.add(constraint); }