예제 #1
0
  private static Statement convertAstToAssignStatement(ASTStatement ast, Path prefix)
      throws SyntaxException {

    // Sanity check. Ensure that this is a assignment statement.
    assert (ast.getStatementType() == StatementType.ASSIGN);

    AssignmentStatement statement = null;

    // Get the identifier and create the path. Resolve this against the
    // prefix if the given path is relative.
    Path path = createPathFromIdentifier(ast);
    path = Path.resolve(prefix, path);

    // Create the assignment statement.
    assert (ast.jjtGetNumChildren() <= 1);
    if (ast.jjtGetNumChildren() == 0) {

      // This is a delete statement.
      Element element = Null.VALUE;
      statement =
          AssignmentStatement.createAssignmentStatement(
              ast.getSourceRange(), path, element, ast.getConditionalFlag(), !ast.getFinalFlag());
    } else {

      // This is a normal assignment statement.
      ASTOperation child = (ASTOperation) ast.jjtGetChild(0);
      Operation dml = astToDml(child, true);
      statement =
          AssignmentStatement.createAssignmentStatement(
              ast.getSourceRange(), path, dml, ast.getConditionalFlag(), !ast.getFinalFlag());
    }

    return statement;
  }
예제 #2
0
  private static Statement convertAstToVariableStatement(ASTStatement ast) throws SyntaxException {

    // Sanity check.
    assert (ast.getStatementType() == StatementType.VARIABLE);

    // Verify that the identifier is not null.
    String vname = ast.getIdentifier();
    assert (vname != null);
    assert (ast.jjtGetNumChildren() == 1);

    // Create the assignment statement.
    ASTOperation child = (ASTOperation) ast.jjtGetChild(0);
    Operation dml = astToDml(child, true);
    return VariableStatement.getInstance(
        ast.getSourceRange(), vname, dml, ast.getConditionalFlag(), !ast.getFinalFlag());
  }