Skip to content

Commit

Permalink
monaco editor marks
Browse files Browse the repository at this point in the history
  • Loading branch information
thradams committed Jun 30, 2024
1 parent 627f8b5 commit 863f541
Show file tree
Hide file tree
Showing 13 changed files with 3,355 additions and 3,209 deletions.
8 changes: 4 additions & 4 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,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 @@ -180,15 +180,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 @@ -247,7 +247,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
44 changes: 26 additions & 18 deletions src/expressions.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,12 @@ struct generic_selection* _Owner _Opt generic_selection(struct parser_ctx* ctx)
}
current = current->next;
}

type_destroy(&lvalue_type);

if (ctx->current == NULL) throw;
p_generic_selection->last_token = ctx->current;

if (parser_match_tk(ctx, ')') != 0)
{
throw;
Expand Down Expand Up @@ -1211,6 +1211,7 @@ struct expression* _Owner _Opt character_constant_expression(struct parser_ctx*
{
int c = 0;
p = utf8_decode(p, &c);

if (c == '\\')
p = escape_sequences_decode_opt(p, &c);

Expand Down Expand Up @@ -1562,6 +1563,8 @@ struct expression* _Owner _Opt primary_expression(struct parser_ctx* ctx)
else if (ctx->current->type == '(')
{
p_expression_node = calloc(1, sizeof * p_expression_node);
if (p_expression_node == NULL) throw;

p_expression_node->expression_type = PRIMARY_EXPRESSION_PARENTESIS;
p_expression_node->first_token = ctx->current;
parser_match(ctx);
Expand Down Expand Up @@ -1747,8 +1750,7 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
if (ctx->current->type == '[')
{
struct expression* _Owner _Opt p_expression_node_new = calloc(1, sizeof * p_expression_node_new);

static_set(*p_expression_node_new, "zero");
if (p_expression_node_new == NULL) throw;

p_expression_node_new->first_token = ctx->current;
p_expression_node_new->expression_type = POSTFIX_ARRAY;
Expand Down Expand Up @@ -1811,8 +1813,8 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
else if (ctx->current->type == '(')
{
struct expression* _Owner _Opt p_expression_node_new = calloc(1, sizeof * p_expression_node_new);
if (p_expression_node_new == NULL) throw;

static_set(*p_expression_node_new, "zero");
p_expression_node_new->first_token = p_expression_node->first_token;
p_expression_node_new->expression_type = POSTFIX_FUNCTION_CALL;

Expand Down Expand Up @@ -1850,7 +1852,8 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
else if (ctx->current->type == '.')
{
struct expression* _Owner _Opt p_expression_node_new = calloc(1, sizeof * p_expression_node_new);
static_set(*p_expression_node_new, "zero");
if (p_expression_node_new == NULL) throw;

p_expression_node_new->first_token = ctx->current;
p_expression_node_new->expression_type = POSTFIX_DOT;
p_expression_node_new->left = p_expression_node;
Expand Down Expand Up @@ -1926,7 +1929,8 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
else if (ctx->current->type == '->')
{
struct expression* _Owner _Opt p_expression_node_new = calloc(1, sizeof * p_expression_node_new);
static_set(*p_expression_node_new, "zero");
if (p_expression_node_new == NULL) throw;

p_expression_node_new->first_token = p_expression_node->first_token;// ctx->current;
p_expression_node_new->expression_type = POSTFIX_ARROW;

Expand Down Expand Up @@ -2029,8 +2033,8 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
}

struct expression* _Owner _Opt p_expression_node_new = calloc(1, sizeof * p_expression_node_new);
if (p_expression_node_new == NULL) throw;

static_set(*p_expression_node_new, "zero");
p_expression_node_new->first_token = ctx->current;
p_expression_node_new->expression_type = POSTFIX_INCREMENT;

Expand All @@ -2046,7 +2050,7 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
compiler_diagnostic_message(C_ERROR_OPERATOR_DECREMENT_CANNOT_BE_USED_IN_OWNER,
ctx,
p_expression_node->first_token,
"operator -- cannot be used in _Owner pointers");
"operator -- cannot be used in owner pointers");
}

if (!expression_is_lvalue(p_expression_node))
Expand All @@ -2058,8 +2062,8 @@ struct expression* _Owner _Opt postfix_expression_tail(struct parser_ctx* ctx, s
}

struct expression* _Owner _Opt p_expression_node_new = calloc(1, sizeof * p_expression_node_new);
if (p_expression_node_new == NULL) throw;

static_set(*p_expression_node_new, "zero");
p_expression_node_new->first_token = ctx->current;
p_expression_node_new->expression_type = POSTFIX_DECREMENT;

Expand Down Expand Up @@ -2291,6 +2295,8 @@ struct expression* _Owner _Opt unary_expression(struct parser_ctx* ctx)
if (ctx->current->type == '++' || ctx->current->type == '--')
{
struct expression* _Owner _Opt new_expression = calloc(1, sizeof * new_expression);
if (new_expression == NULL) throw;

new_expression->first_token = ctx->current;

static_set(*new_expression, "zero");
Expand All @@ -2314,7 +2320,8 @@ struct expression* _Owner _Opt unary_expression(struct parser_ctx* ctx)
{

struct expression* _Owner _Opt new_expression = calloc(1, sizeof * new_expression);
static_set(*new_expression, "zero");
if (new_expression == NULL) throw;

new_expression->first_token = ctx->current;

struct token* op_position = ctx->current; // marcar posicao
Expand Down Expand Up @@ -2453,8 +2460,8 @@ struct expression* _Owner _Opt unary_expression(struct parser_ctx* ctx)

parser_match(ctx);
struct expression* _Owner _Opt new_expression = calloc(1, sizeof * new_expression);
if (new_expression == NULL) throw;

static_set(*new_expression, "zero");
new_expression->first_token = ctx->current;

if (first_of_type_name_ahead(ctx))
Expand Down Expand Up @@ -2520,8 +2527,8 @@ struct expression* _Owner _Opt unary_expression(struct parser_ctx* ctx)
struct token* traits_token = ctx->current;

struct expression* _Owner _Opt new_expression = calloc(1, sizeof * new_expression);
if (new_expression == NULL) throw;

static_set(*new_expression, "zero");
new_expression->first_token = ctx->current;
new_expression->expression_type = UNARY_EXPRESSION_TRAITS;

Expand Down Expand Up @@ -2618,6 +2625,7 @@ struct expression* _Owner _Opt unary_expression(struct parser_ctx* ctx)
else if (ctx->current->type == TK_KEYWORD_ASSERT)
{
struct expression* _Owner _Opt new_expression = calloc(1, sizeof * new_expression);
if (new_expression == NULL) throw;

static_set(*new_expression, "zero");
new_expression->expression_type = UNARY_EXPRESSION_ASSERT;
Expand Down Expand Up @@ -2650,8 +2658,8 @@ struct expression* _Owner _Opt unary_expression(struct parser_ctx* ctx)
else if (ctx->current->type == TK_KEYWORD__ALIGNOF)
{
struct expression* _Owner _Opt new_expression = calloc(1, sizeof * new_expression);
if (new_expression == NULL) throw;

static_set(*new_expression, "zero");
new_expression->expression_type = UNARY_EXPRESSION_ALIGNOF;
new_expression->first_token = ctx->current;
parser_match(ctx);
Expand Down Expand Up @@ -2743,6 +2751,8 @@ struct expression* _Owner _Opt cast_expression(struct parser_ctx* ctx)
// Achar que era um cast_expression foi um engano...
// porque apareceu o { então é compound literal que eh postfix.
struct expression* _Owner _Opt new_expression = postfix_expression_type_name(ctx, p_expression_node->type_name);
if (new_expression == NULL) throw;

p_expression_node->type_name = NULL; // MOVED

expression_delete(p_expression_node);
Expand Down Expand Up @@ -3492,7 +3502,6 @@ struct expression* _Owner _Opt and_expression(struct parser_ctx* ctx)
new_expression = calloc(1, sizeof * new_expression);
if (new_expression == NULL)
throw;
static_set(*new_expression, "zero");

new_expression->first_token = ctx->current;
new_expression->expression_type = AND_EXPRESSION;
Expand Down Expand Up @@ -3554,7 +3563,6 @@ struct expression* _Owner _Opt exclusive_or_expression(struct parser_ctx* ctx)
if (new_expression == NULL)
throw;

static_set(*new_expression, "zero");
new_expression->first_token = ctx->current;
new_expression->expression_type = EXCLUSIVE_OR_EXPRESSION;
new_expression->left = p_expression_node;
Expand Down Expand Up @@ -4002,7 +4010,7 @@ struct expression* _Owner _Opt expression(struct parser_ctx* ctx)
if (p_expression_node_new == NULL)
throw;

static_set(*p_expression_node_new, "zero");

p_expression_node_new->first_token = ctx->current;
p_expression_node_new->expression_type = ASSIGNMENT_EXPRESSION;
p_expression_node_new->left = p_expression_node;
Expand Down Expand Up @@ -4077,7 +4085,7 @@ struct expression* _Owner _Opt conditional_expression(struct parser_ctx* ctx)
struct expression* _Owner _Opt p_conditional_expression = calloc(1, sizeof * p_conditional_expression);
if (p_conditional_expression == NULL) throw;

static_set(*p_conditional_expression, "zero");

p_conditional_expression->first_token = ctx->current;
p_conditional_expression->expression_type = CONDITIONAL_EXPRESSION;
p_conditional_expression->condition_expr = p_expression_node;
Expand Down
8 changes: 4 additions & 4 deletions src/flow_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void expand_pointer_object(struct flow_visit_ctx* ctx, struct type* p_type, stru
struct type t2 = type_remove_pointer(p_type);
if (!type_is_void(&t2))
{
struct flow_object* p_object2 = make_object(ctx, &t2, p_object->p_declarator_origin, p_object->p_expression_origin);
struct flow_object* _Opt p_object2 = make_object(ctx, &t2, p_object->p_declarator_origin, p_object->p_expression_origin);
if (p_object2)
{
const bool is_nullable = type_is_nullable(&t2, nullable_enabled);
Expand Down Expand Up @@ -329,7 +329,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 _Opt 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 @@ -577,7 +577,7 @@ struct flow_object* _Opt make_object_core(struct flow_visit_ctx* ctx,
{
if (p_member_declaration->member_declarator_list_opt)
{
struct member_declarator* p_member_declarator =
struct member_declarator* _Opt p_member_declarator =
p_member_declaration->member_declarator_list_opt->head;

while (p_member_declarator)
Expand Down Expand Up @@ -3578,7 +3578,7 @@ void print_object_line(struct flow_object* p_object, int extra_cols)


int cols = 0;
struct flow_object_state* p_state = &p_object->current;
struct flow_object_state* _Opt p_state = &p_object->current;
while (p_state)
{
cols++;
Expand Down
18 changes: 9 additions & 9 deletions src/flow_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ struct flow_object_state {
struct flow_object_state* _Owner _Opt next;
};

void flow_object_state_copy(struct flow_object_state *to, const struct flow_object_state * from);
void flow_object_state_delete(struct flow_object_state * _Owner _Opt p);
void flow_object_state_copy(struct flow_object_state* to, const struct flow_object_state* from);
void flow_object_state_delete(struct flow_object_state* _Owner _Opt p);


/*
Expand All @@ -94,11 +94,11 @@ struct flow_object
const struct expression* _Opt p_expression_origin;

struct objects_view members;

struct flow_object_state current;

int id; //helps debugging
bool is_temporary;
bool is_temporary;
};

void flow_object_set_is_moved(struct flow_object* p_object);
Expand All @@ -108,7 +108,7 @@ void flow_object_update_current(struct flow_object* p);
void flow_object_set_current_state_to_can_be_null(struct flow_object* p);
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);

bool flow_object_is_zero_or_null(const struct flow_object* p_object);

Expand Down Expand Up @@ -140,10 +140,10 @@ void print_object_line(struct flow_object* p_object, int cols);
void print_object_state_to_str(enum object_state e, char str[], int sz);

struct declarator;
struct flow_object* make_object(struct flow_visit_ctx* ctx,
struct type* p_type,
const struct declarator* _Opt p_declarator_opt,
const struct expression* _Opt p_expression_origin);
struct flow_object* _Opt make_object(struct flow_visit_ctx* ctx,
struct type* p_type,
const struct declarator* _Opt p_declarator_opt,
const struct expression* _Opt p_expression_origin);

void flow_object_add_new_state_as_a_copy_of_current_state(struct flow_object* object, const char* name, int state_number);
struct token* object_get_token(const struct flow_object* object);
Expand Down
29 changes: 0 additions & 29 deletions src/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,33 +975,6 @@ static const char* file_stddef_h =
"typedef typeof(nullptr) nullptr_t;\n"
"\n";

const char* file_ownership_h =
"#ifndef __OWNERSHIP_H__\n"
"#define __OWNERSHIP_H__\n"
"\n"
"#pragma ownership enable\n"
"#ifdef __STDC_OWNERSHIP__\n"
"#define _Out _Out\n"
"#define _Opt _Opt\n"
"#define _Owner _Owner\n"
"#define _Obj_owner _Obj_owner\n"
"#define _View _View\n"

"\n"
"#else\n"
"#define _Out \n"
"#define _Opt \n"
"#define _Owner\n"
"#define _Obj_owner\n"
"#define _View\n"
"#define static_debug(x)\n"
"#define static_set(x, s)\n"

"#endif\n"
"\n"
"#endif\n"
"\n"
"";

const char* file_limits_h =
"//\n"
Expand Down Expand Up @@ -1068,8 +1041,6 @@ char* _Owner read_file(const char* path)
return strdup(file_string_h);
else if (strcmp(path, "c:/assert.h") == 0)
return strdup(file_assert_h);
else if (strcmp(path, "c:/ownership.h") == 0)
return strdup(file_ownership_h);
else if (strcmp(path, "c:/limits.h") == 0)
return strdup(file_limits_h);
printf("read %s\n", path);
Expand Down
Loading

0 comments on commit 863f541

Please sign in to comment.