Methods Summary |
---|
public java.lang.String | createBeanshellCode()
code = new StringBuffer();
//code.append("boolean " + RET_NAME + " = false;\n");
expr.accept(this);
return code.toString();
|
private void | createLoopCode(LoopExpression expr, boolean breakType)
String declaration = expr.getDeclaration();
String collection = expr.getCollection();
Expression body = expr.getBody();
indent();
code.append("for (" + declaration + " : " + collection + "){\n");
indent++;
if (body instanceof BooleanExpression)
{
indent();
code.append("if (");
if (!breakType)
{
code.append("!");
}
code.append("(");
body.accept(this);
code.append(")){\n");
indent++;
indent();
code.append("return "+ breakType + ";\n");
indent--;
indent();
code.append("}\n");
}
else if (body instanceof ImpliesExpression)
{
body.accept(this);
}
else
{
body.accept(this);
}
indent--;
indent();
code.append("}\n");
if (expr.isTopLevel())
{
indent();
code.append("return "+ !breakType + ";\n");
}
|
private void | indent()
for (int i = 0 ; i < indent * 2 ; i++)
{
code.append(" ");
}
|
public void | visit(Expression expr)
expr.accept(this);
|
public void | visit(BooleanExpression expr)
if (expr.isTopLevel())
{
code.append("return (" + expr.getExpression() + ");\n");
}
else
{
code.append(expr.getExpression());
}
|
public void | visit(ForAllExpression expr)
createLoopCode(expr, false);
|
public void | visit(ExistsExpression expr)
createLoopCode(expr, true);
|
public void | visit(ImpliesExpression expr)
indent();
code.append("if (");
expr.getLhs().accept(this);
code.append("){\n");
indent++;
indent();
code.append("if(!(");
expr.getRhs().accept(this);
code.append(")){\n");
indent++;
indent();
code.append("return false;\n");
indent--;
indent();
code.append("}\n");
indent--;
indent();
code.append("}\n");
if (expr.isTopLevel())
{
code.append("return true;\n");
}
|
public void | visit(JavaExpression expr)
code.append(expr.getJava());
code.append("\nreturn true;\n");
|