示例#1
0
/*!
  \brief Get area boundary points (PostGIS Topology)
  
  Used by Vect_build_line_area() and Vect_get_area_points().

  \param Map pointer to Map_info struct
  \param lines array of boundary lines
  \param n_lines number of lines in array
  \param[out] APoints pointer to output line_pnts struct

  \return number of points
  \return -1 on error
*/
int Vect__get_area_points_pg(const struct Map_info *Map, const plus_t *lines, int n_lines,
                             struct line_pnts *APoints)
{
    int i, direction;
    
    struct Format_info_pg *pg_info;
    
    PGresult *res;
    
    pg_info = (struct Format_info_pg *)&(Map->fInfo.pg);
   
    Vect_reset_line(APoints);

    res = build_stmt(&(Map->plus), pg_info, lines, n_lines);
    if (!res)
        return -1;
    
    for (i = 0; i < n_lines; i++) {
        Vect__cache_feature_pg(PQgetvalue(res, i, 0), FALSE, FALSE,
                               &(pg_info->cache), NULL); /* do caching in readable way */
	direction = lines[i] > 0 ? GV_FORWARD : GV_BACKWARD;
	Vect_append_points(APoints, pg_info->cache.lines[0], direction);
	APoints->n_points--;	/* skip last point, avoids duplicates */
    }
    APoints->n_points++;	/* close polygon */

    PQclear(res);
    
    return APoints->n_points;
}
示例#2
0
tree
add_scope_stmt (int begin_p, int partial_p)
{
    tree *stack_ptr = current_scope_stmt_stack ();
    tree ss;
    tree top = *stack_ptr;

    /* Build the statement.  */
    ss = build_stmt (SCOPE_STMT, NULL_TREE);
    SCOPE_BEGIN_P (ss) = begin_p;
    SCOPE_PARTIAL_P (ss) = partial_p;

    /* Keep the scope stack up to date.  */
    if (begin_p)
    {
        top = tree_cons (ss, NULL_TREE, top);
        *stack_ptr = top;
    }
    else
    {
        if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top)))
            abort ();
        TREE_VALUE (top) = ss;
        *stack_ptr = TREE_CHAIN (top);
    }

    /* Add the new statement to the statement-tree.  */
    add_stmt (ss);

    return top;
}
示例#3
0
文件: except.c 项目: Fokycnuk/gcc
tree
begin_eh_spec_block (void)
{
  tree r = build_stmt (EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
  add_stmt (r);
  return r;
}
示例#4
0
void
cilk_install_body_with_frame_cleanup (tree fndecl, tree orig_body, void *wd)
{
  tree frame = make_cilk_frame (fndecl);
  tree dtor = create_cilk_function_exit (frame, false, false);
  add_local_decl (cfun, frame);

  cfun->language = ggc_cleared_alloc<language_function> ();
  
  location_t loc = EXPR_LOCATION (orig_body);
  tree list = alloc_stmt_list ();
  DECL_SAVED_TREE (fndecl) = list;
  tree fptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (frame)), frame);
  tree body = cilk_install_body_pedigree_operations (fptr);
  gcc_assert (TREE_CODE (body) == STATEMENT_LIST);
  tree detach_expr = build_call_expr (cilk_detach_fndecl, 1, fptr);
  append_to_statement_list (detach_expr, &body);
  cilk_outline (fndecl, &orig_body, (struct wrapper_data *) wd);
  append_to_statement_list (orig_body, &body);
  if (flag_exceptions)
    {
      tree except_flag = set_cilk_except_flag (frame);
      tree except_data = set_cilk_except_data (frame);
      tree catch_list = alloc_stmt_list ();
      append_to_statement_list (except_flag, &catch_list);
      append_to_statement_list (except_data, &catch_list);
      body = create_try_catch_expr (body, catch_list);
    }
  append_to_statement_list (build_stmt (loc, TRY_FINALLY_EXPR, body, dtor),
			    &list);
}
示例#5
0
tree
begin_eh_spec_block (void)
{
  tree r = build_stmt (EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
  add_stmt (r);
  EH_SPEC_STMTS (r) = push_stmt_list ();
  return r;
}
示例#6
0
void
add_decl_stmt (tree decl)
{
    tree decl_stmt;

    /* We need the type to last until instantiation time.  */
    decl_stmt = build_stmt (DECL_STMT, decl);
    add_stmt (decl_stmt);
}
示例#7
0
tree
begin_eh_spec_block (void)
{
  tree r;
  location_t spec_location = DECL_SOURCE_LOCATION (current_function_decl);

  /* A noexcept specification (or throw() with -fnothrow-opt) is a
     MUST_NOT_THROW_EXPR.  */
  if (TYPE_NOEXCEPT_P (TREE_TYPE (current_function_decl)))
    {
      r = build_stmt (spec_location, MUST_NOT_THROW_EXPR,
		      NULL_TREE, NULL_TREE);
      TREE_SIDE_EFFECTS (r) = 1;
    }
  else
    r = build_stmt (spec_location, EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
  add_stmt (r);
  TREE_OPERAND (r, 0) = push_stmt_list ();
  return r;
}
示例#8
0
void AST::build(ASTNode *parent, Node *node)
{
    std::vector<Node*>::iterator it;
    switch (node->type) {
        case Node::PROG:
        case Node::STMTS:
            for (it = node->children.begin(); it != node->children.end(); it++) {
                build(parent, (*it));
            }
            break;
        case Node::STMT:
            build_stmt(parent, node);
            break;
        case Node::TOKEN:
            if (node->token.type == Token::SEMICOLON) {
                /* Do nothing. Correct location has been checked in parser. */
                break;
            }
        default:
			std::string e_str = "AST::build - Invalid node location in parse tree for node type ";
            report_error(e_str.append(node->type_str()));
    }
}
示例#9
0
文件: lambda.c 项目: nguyentu1602/gcc
void
insert_capture_proxy (tree var)
{
  cp_binding_level *b;
  tree stmt_list;

  /* Put the capture proxy in the extra body block so that it won't clash
     with a later local variable.  */
  b = current_binding_level;
  for (;;)
    {
      cp_binding_level *n = b->level_chain;
      if (n->kind == sk_function_parms)
	break;
      b = n;
    }
  pushdecl_with_scope (var, b, false);

  /* And put a DECL_EXPR in the STATEMENT_LIST for the same block.  */
  var = build_stmt (DECL_SOURCE_LOCATION (var), DECL_EXPR, var);
  stmt_list = (*stmt_list_stack)[1];
  gcc_assert (stmt_list);
  append_to_statement_list_force (var, &stmt_list);
}
示例#10
0
tree
build_case_label (location_t loc,
		  tree low_value, tree high_value, tree label_decl)
{
  return build_stmt (loc, CASE_LABEL_EXPR, low_value, high_value, label_decl);
}
示例#11
0
文件: c-semantics.c 项目: 0mp/freebsd
tree
build_case_label (tree low_value, tree high_value, tree label_decl)
{
  return build_stmt (CASE_LABEL_EXPR, low_value, high_value, label_decl);
}
示例#12
0
tree
build_continue_stmt (void)
{
    return (build_stmt (CONTINUE_STMT));
}
示例#13
0
tree
build_break_stmt (void)
{
    return (build_stmt (BREAK_STMT));
}
示例#14
0
tree
build_return_stmt (tree expr)
{
    return (build_stmt (RETURN_STMT, expr));
}