Ejemplo n.º 1
0
  public void handleStatement(ASTStatement node) {

    // System.out.println(node.getCode());

    // Drawing
    connector.startSnap(node.getLineNumber());

    // FIXME we'll see how this works

    // Nested scope for by macro
    SimpleNode s = (SimpleNode) node.jjtGetChild(0);

    if (s instanceof ASTStatementList) {
      System.out.println("This'll never happen");
      SymbolTable st = new SymbolTable(Global.getCurrentSymbolTable());
      st.setName("nested");
      Global.setCurrentSymbolTable(st);
      s.jjtAccept(this, null);
      Global.setCurrentSymbolTable(st.getPrevious());
    } else {

      node.jjtGetChild(0).jjtAccept(this, null);
      if (((SimpleNode) node.jjtGetChild(0)).getId() == JJTCALL) {
        ((ASTCall) (node.jjtGetChild(0))).setLineNumber(node.getLineNumber());
      }

      update(node.getLineNumber(), UPDATE_REASON_STATEMENT);
    }
    // System.out.println("endStatement");
    connector.endSnap();
  }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
  private static Statement convertAstToBindStatement(String source, ASTStatement ast)
      throws SyntaxException {

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

    // Get identifier and create path.
    Path path = createPathFromIdentifier(ast);

    // Verify that there is exactly one child.
    assert (ast.jjtGetNumChildren() == 1);

    // Now check to see if the node is a FullTypeSpec or DML.
    SimpleNode child = (SimpleNode) ast.jjtGetChild(0);
    FullType fullType = null;
    if (child instanceof ASTFullTypeSpec) {
      fullType = astToFullType(source, (ASTFullTypeSpec) child);
    } else if (child instanceof ASTOperation) {
      Operation dml = astToDml((ASTOperation) child, true);
      AliasType elementType = new AliasType(null, child.getSourceRange(), "element", null);
      fullType = new FullType(source, child.getSourceRange(), elementType, null, dml);
    } else {
      assert (false);
    }

    return new BindStatement(ast.getSourceRange(), path, fullType);
  }
Ejemplo n.º 4
0
  private static Statement convertAstToIncludeStatement(ASTStatement ast) throws SyntaxException {

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

    // Include statement must always have an associated DML block. If it
    // evaluates to a compile time constant, then the operation will be
    // optimized into a static include statement.
    assert (ast.jjtGetNumChildren() == 1);

    ASTOperation child = (ASTOperation) ast.jjtGetChild(0);
    Operation dml = astToDml(child, true);

    return IncludeStatement.newIncludeStatement(ast.getSourceRange(), dml);
  }
Ejemplo n.º 5
0
  private static Statement convertAstToFunctionStatement(ASTStatement ast) throws SyntaxException {

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

    // Get identifier and verify it isn't null.
    String fname = ast.getIdentifier();
    assert (fname != null);
    assert (ast.jjtGetNumChildren() == 1);

    // Create the assignment statement.
    ASTOperation child = (ASTOperation) ast.jjtGetChild(0);
    Operation dml = astToDml(child, true);
    return new FunctionStatement(ast.getSourceRange(), fname, dml);
  }
Ejemplo n.º 6
0
  private static Statement convertAstToTypeStatement(String source, ASTStatement ast)
      throws SyntaxException {

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

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

    // Create the assignment statement.
    ASTFullTypeSpec child = (ASTFullTypeSpec) ast.jjtGetChild(0);
    FullType fullType = astToFullType(source, child);
    return new TypeStatement(ast.getSourceRange(), tname, fullType);
  }
Ejemplo n.º 7
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());
  }