Skip to content

Commit

Permalink
refatoring owner -> _Owner
Browse files Browse the repository at this point in the history
  • Loading branch information
thradams committed Jun 26, 2024
1 parent 643c5ca commit 17a524b
Show file tree
Hide file tree
Showing 27 changed files with 2,457 additions and 2,474 deletions.
10 changes: 5 additions & 5 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const char* get_posix_error_message(int error)
case EPIPE:
return "Broken pipe";
case EDOM:
return "Math argument out of domain of func";
return "Math argument _Out of domain of func";
case ERANGE:
return "Math result not representable";
case EDEADLK:
Expand Down Expand Up @@ -163,7 +163,7 @@ const char* get_posix_error_message(int error)
return "Transport endpoint is not connected";

case ETIMEDOUT:
return "Connection timed out";
return "Connection timed _Out";
case ECONNREFUSED:
return "Connection refused";

Expand All @@ -177,15 +177,15 @@ const char* get_posix_error_message(int error)
case ENOTBLK:
return "Block device required";
case ECHRNG:
return "Channel number out of range";
return "Channel number _Out of range";
case EL2NSYNC:
return "Level 2 not synchronized";
case EL3HLT:
return "Level 3 halted";
case EL3RST:
return "Level 3 reset";
case ELNRNG:
return "Link number out of range";
return "Link number _Out of range";
case EUNATCH:
return "Protocol driver not attached";
case ENOCSI:
Expand Down Expand Up @@ -244,7 +244,7 @@ const char* get_posix_error_message(int error)
case ELIBBAD:
return "Accessing a corrupted shared library";
case ELIBSCN:
return ".lib section in a.out corrupted";
return ".lib section in a._Out corrupted";
case ELIBMAX:
return "Attempting to link in too many shared libraries";
case ELIBEXEC:
Expand Down
232 changes: 116 additions & 116 deletions src/expressions.c

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions src/expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ struct argument_expression_list
assignment-expression
argument-expression-list , assignment-expression
*/
struct argument_expression* owner opt head;
struct argument_expression* opt tail;
struct argument_expression* _Owner _Opt head;
struct argument_expression* _Opt tail;
};

void argument_expression_list_destroy(struct argument_expression_list * obj_owner p);
void argument_expression_list_push(struct argument_expression_list * list, struct argument_expression* owner p);
void argument_expression_list_destroy(struct argument_expression_list * _Obj_owner p);
void argument_expression_list_push(struct argument_expression_list * list, struct argument_expression* _Owner p);

struct generic_association
{
Expand All @@ -105,25 +105,25 @@ struct generic_association
*/

struct type type;
struct type_name* owner p_type_name;
struct expression* owner expression;
struct type_name* _Owner p_type_name;
struct expression* _Owner expression;

struct token* first_token;
struct token* last_token;

struct generic_association* owner next;
struct generic_association* _Owner next;
};

void generic_association_delete(struct generic_association* owner opt p);
void generic_association_delete(struct generic_association* _Owner _Opt p);

struct generic_assoc_list
{
struct generic_association* owner opt head;
struct generic_association* opt tail;
struct generic_association* _Owner _Opt head;
struct generic_association* _Opt tail;
};

void generic_assoc_list_add(struct generic_assoc_list * p, struct generic_association* owner item);
void generic_assoc_list_destroy(struct generic_assoc_list * obj_owner p);
void generic_assoc_list_add(struct generic_assoc_list * p, struct generic_association* _Owner item);
void generic_assoc_list_destroy(struct generic_assoc_list * _Obj_owner p);

struct generic_selection
{
Expand All @@ -144,8 +144,8 @@ struct generic_selection
*/


struct expression* owner opt expression;
struct type_name* owner opt type_name;
struct expression* _Owner _Opt expression;
struct type_name* _Owner _Opt type_name;
/*
* Points to the matching expression
*/
Expand All @@ -156,7 +156,7 @@ struct generic_selection
struct token* last_token;
};

void generic_selection_delete(struct generic_selection * owner opt p);
void generic_selection_delete(struct generic_selection * _Owner _Opt p);

enum constant_value_type {
TYPE_NOT_CONSTANT,
Expand Down Expand Up @@ -193,11 +193,11 @@ struct expression

struct constant_value constant_value;

struct type_name* owner type_name;
struct type_name* owner type_name2; /*is_same*/
struct braced_initializer* owner braced_initializer;
struct compound_statement* owner compound_statement; //function literal (lambda)
struct generic_selection* owner generic_selection; //_Generic
struct type_name* _Owner type_name;
struct type_name* _Owner type_name2; /*is_same*/
struct braced_initializer* _Owner braced_initializer;
struct compound_statement* _Owner compound_statement; //function literal (lambda)
struct generic_selection* _Owner generic_selection; //_Generic

struct token* first_token;
struct token* last_token;
Expand All @@ -213,9 +213,9 @@ struct expression
/*se for POSTFIX_FUNCTION_CALL post*/
struct argument_expression_list argument_expression_list; //este node eh uma chamada de funcao

struct expression* owner condition_expr;
struct expression* owner left;
struct expression* owner right;
struct expression* _Owner condition_expr;
struct expression* _Owner left;
struct expression* _Owner right;

bool is_assigment_expression;

Expand All @@ -228,11 +228,11 @@ struct expression
bool expression_is_malloc(const struct expression* p);
bool expression_is_calloc(const struct expression* p);

void expression_delete(struct expression* owner opt p);
void expression_delete(struct expression* _Owner _Opt p);

struct expression* owner assignment_expression(struct parser_ctx* ctx);
struct expression* owner expression(struct parser_ctx* ctx);
struct expression* owner constant_expression(struct parser_ctx* ctx, bool show_error_if_not_constant);
struct expression* _Owner assignment_expression(struct parser_ctx* ctx);
struct expression* _Owner expression(struct parser_ctx* ctx);
struct expression* _Owner constant_expression(struct parser_ctx* ctx, bool show_error_if_not_constant);
bool expression_is_subjected_to_lvalue_conversion(struct expression*);
bool expression_is_zero(struct expression*);
bool expression_is_lvalue(const struct expression* expr);
Expand Down
44 changes: 22 additions & 22 deletions src/flow_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static void object_state_to_string_core(enum object_state e)

}

void flow_object_state_delete(struct flow_object_state* owner opt p)
void flow_object_state_delete(struct flow_object_state* _Owner _Opt p)
{
if (p)
{
Expand Down Expand Up @@ -228,7 +228,7 @@ void object_swap(struct flow_object* a, struct flow_object* b)
*b = temp;
}

void object_delete(struct flow_object* owner opt p)
void object_delete(struct flow_object* _Owner _Opt p)
{
if (p)
{
Expand All @@ -242,22 +242,22 @@ void object_set_pointer(struct flow_object* p_object, struct flow_object* p_obje
p_object->current.pointed = p_object2;
}

void object_destroy(struct flow_object* obj_owner p)
void object_destroy(struct flow_object* _Obj_owner p)
{
objects_view_destroy(&p->members);

struct flow_object_state* owner p_flow_object_state = p->current.next;
struct flow_object_state* _Owner p_flow_object_state = p->current.next;
while (p_flow_object_state)
{
struct flow_object_state* owner temp = p_flow_object_state->next;
struct flow_object_state* _Owner temp = p_flow_object_state->next;
p_flow_object_state->next = NULL;
flow_object_state_delete(p_flow_object_state);
p_flow_object_state = temp;
}
objects_view_destroy(&p->current.alternatives);
}

void flow_object_destroy(struct flow_object_state* obj_owner opt p)
void flow_object_destroy(struct flow_object_state* _Obj_owner _Opt p)
{
assert(p->next == NULL);
objects_view_destroy(&p->alternatives);
Expand Down Expand Up @@ -294,7 +294,7 @@ void flow_object_set_current_state_to_is_null(struct flow_object* p)
}
}

int flow_object_add_state(struct flow_object* p, struct flow_object_state* owner pnew)
int flow_object_add_state(struct flow_object* p, struct flow_object_state* _Owner pnew)
{
assert(pnew->next == NULL);
pnew->next = p->current.next;
Expand All @@ -306,7 +306,7 @@ int flow_object_add_state(struct flow_object* p, struct flow_object_state* owner



void objects_view_destroy(struct objects_view* obj_owner p)
void objects_view_destroy(struct objects_view* _Obj_owner p)
{
free(p->data);
}
Expand All @@ -321,7 +321,7 @@ int objects_view_reserve(struct objects_view* p, int n)
return EOVERFLOW;
}

void* owner pnew = realloc(p->data, n * sizeof(p->data[0]));
void* _Owner pnew = realloc(p->data, n * sizeof(p->data[0]));
if (pnew == NULL) return ENOMEM;

static_set(p->data, "moved"); //p->data was moved to pnew
Expand Down Expand Up @@ -412,7 +412,7 @@ bool objects_view_find(const struct objects_view* p, const struct flow_object* p
}
return false;
}
void objects_destroy(struct objects* obj_owner p) /*unchecked*/
void objects_destroy(struct objects* _Obj_owner p)
{
for (int i = 0; i < p->size; i++)
{
Expand All @@ -439,7 +439,7 @@ int objects_reserve(struct objects* p, int n)
return EOVERFLOW;
}

void* owner pnew = realloc(p->data, n * sizeof(p->data[0]));
void* _Owner pnew = realloc(p->data, n * sizeof(p->data[0]));
if (pnew == NULL) return ENOMEM;

static_set(p->data, "moved"); //p->data was moved to pnew
Expand All @@ -460,7 +460,7 @@ const struct flow_object* objects_find(const struct objects* p_objects, const st
return NULL;
}

int objects_push_back(struct objects* p, struct flow_object* owner p_object)
int objects_push_back(struct objects* p, struct flow_object* _Owner p_object)
{
if (p->size == INT_MAX)
{
Expand Down Expand Up @@ -689,7 +689,7 @@ struct token* object_get_token(const struct flow_object* object)

void flow_object_add_new_state_as_a_copy_of_current_state(struct flow_object* object, const char* name, int state_number)
{
struct flow_object_state* owner pnew = calloc(1, sizeof * pnew);
struct flow_object_state* _Owner pnew = calloc(1, sizeof * pnew);
if (pnew == NULL) return;//ENOMEM;

pnew->dbg_name = name;
Expand All @@ -711,7 +711,7 @@ void object_remove_state(struct flow_object* object, int state_number)
{
if (it->state_number == state_number)
{
struct flow_object_state* owner p_it_next = it->next;
struct flow_object_state* _Owner p_it_next = it->next;
it->next = NULL;
flow_object_state_delete(previous->next);
previous->next = p_it_next;
Expand Down Expand Up @@ -2283,7 +2283,7 @@ void checked_read_object(struct flow_visit_ctx* ctx,
const struct token* position_token,
bool check_pointed_object)
{
const char* owner s = NULL;
const char* _Owner s = NULL;
const char* name = "";
if (p_object->p_declarator_origin)
name = p_object->p_declarator_origin->name ? p_object->p_declarator_origin->name->lexeme : "?";
Expand All @@ -2292,7 +2292,7 @@ void checked_read_object(struct flow_visit_ctx* ctx,
if (p_object->p_expression_origin->first_token &&
p_object->p_expression_origin->last_token)
{
view struct token_list list = { .head = p_object->p_expression_origin->first_token,
_View struct token_list list = { .head = p_object->p_expression_origin->first_token,
.tail = p_object->p_expression_origin->last_token
};
s = get_code_as_we_see(&list, true);
Expand All @@ -2315,7 +2315,7 @@ void checked_read_object(struct flow_visit_ctx* ctx,
check_pointed_object,
name,
s_visit_number++);
free((void* owner)s);
free((void* _Owner)s);
}


Expand Down Expand Up @@ -2498,7 +2498,7 @@ static void end_of_storage_visit_core(struct flow_visit_ctx* ctx,
}
else if (type_is_owner(p_visitor->p_type) && !type_is_pointer(p_visitor->p_type))
{
//non-pointer owner
//non-pointer _Owner
if (p_visitor->p_object->current.state == OBJECT_STATE_UNINITIALIZED ||
p_visitor->p_object->current.state == OBJECT_STATE_NULL ||
p_visitor->p_object->current.state == OBJECT_STATE_MOVED)
Expand Down Expand Up @@ -2631,7 +2631,7 @@ static void flow_assignment_core(
return;
}

/*general check passing possible null to non opt*/
/*general check passing possible null to non _Opt*/
if (type_is_pointer(p_visitor_a->p_type) &&
(!type_is_nullable(p_visitor_a->p_type, ctx->ctx->options.null_checks_enabled)) &&
p_visitor_b->p_object->current.state & OBJECT_STATE_NULL)
Expand Down Expand Up @@ -2697,7 +2697,7 @@ static void flow_assignment_core(
}
}

/*copying to void * owner*/
/*copying to void * _Owner*/
if (type_is_void_ptr(p_visitor_a->p_type) && type_is_pointer(p_visitor_b->p_type))
{
p_visitor_a->p_object->current.state = p_visitor_b->p_object->current.state;
Expand All @@ -2707,7 +2707,7 @@ static void flow_assignment_core(

if (!a_type_is_view && type_is_owner(p_visitor_a->p_type))
{
//*b must be empty before copying to void* owner
//*b must be empty before copying to void* _Owner
struct type t = type_remove_pointer(p_visitor_b->p_type);


Expand Down Expand Up @@ -2766,7 +2766,7 @@ static void flow_assignment_core(
#endif
struct type t = type_remove_pointer(p_visitor_a->p_type);

/*if the parameter points to out object, then we don´t need to check
/*if the parameter points to _Out object, then we don´t need to check
argument pointed object.
*/
const bool checked_pointed_object_read = !type_is_out(&t);
Expand Down
Loading

0 comments on commit 17a524b

Please sign in to comment.