Skip to content

Commit

Permalink
more const
Browse files Browse the repository at this point in the history
  • Loading branch information
apache-hb committed Apr 19, 2024
1 parent 5e71394 commit 0e42fb2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/language/ctu/include/ctu/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ typedef struct ctu_t {
/* eCtuDeclVariant */
struct {
ctu_t *underlying;
vector_t *cases;
const vector_t *cases;
};

/* eCtuVariantCase */
Expand Down Expand Up @@ -308,7 +308,7 @@ ctu_t *ctu_decl_typealias(scan_t *scan, where_t where, bool exported, char *name
ctu_t *ctu_decl_union(scan_t *scan, where_t where, bool exported, char *name, vector_t *fields);
ctu_t *ctu_decl_struct(scan_t *scan, where_t where, bool exported, char *name, vector_t *fields);

ctu_t *ctu_decl_variant(scan_t *scan, where_t where, bool exported, char *name, ctu_t *underlying, vector_t *cases);
ctu_t *ctu_decl_variant(scan_t *scan, where_t where, bool exported, char *name, ctu_t *underlying, const vector_t *cases);

///
/// internal components
Expand Down
2 changes: 1 addition & 1 deletion src/language/ctu/src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ ctu_t *ctu_decl_struct(scan_t *scan, where_t where, bool exported, char *name, v
return ast;
}

ctu_t *ctu_decl_variant(scan_t *scan, where_t where, bool exported, char *name, ctu_t *underlying, vector_t *cases)
ctu_t *ctu_decl_variant(scan_t *scan, where_t where, bool exported, char *name, ctu_t *underlying, const vector_t *cases)
{
ctu_t *ast = ctu_decl(scan, where, eCtuDeclVariant, name, exported);
ast->underlying = underlying;
Expand Down
6 changes: 3 additions & 3 deletions src/language/ctu/src/ctu.y
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ void ctuerror(where_t *where, void *state, scan_t *scan, const char *msg);
attrib_args
expr_list
type_list
variant_field_list opt_variant_field_list
variant_field_list
initList
attribs attrib attrib_body attrib_list

%type<cvector>
modspec imports opt_type_list opt_expr_list decls
modspec imports opt_type_list opt_expr_list decls opt_variant_field_list

/**
* order of operations, tightest first
Expand Down Expand Up @@ -268,7 +268,7 @@ underlying: %empty { $$ = NULL; }
| COLON type { $$ = $2; }
;

opt_variant_field_list: %empty { $$ = &gEmptyVector; }
opt_variant_field_list: %empty { $$ = &kEmptyVector; }
| variant_field_list { $$ = $1; }
;

Expand Down
5 changes: 3 additions & 2 deletions src/language/ctu/src/sema/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ static tree_t *sema_local(ctu_sema_t *sema, const ctu_t *stmt)
return tree_stmt_assign(stmt->node, self, value);
}

return tree_stmt_block(stmt->node, &gEmptyVector); // TODO: good enough
// TODO: maybe a nop node would be better
return tree_stmt_block(stmt->node, &kEmptyVector);
}

static tree_t *sema_stmts(ctu_sema_t *sema, const ctu_t *stmt)
Expand Down Expand Up @@ -685,7 +686,7 @@ static tree_t *sema_while(ctu_sema_t *sema, const ctu_t *stmt)
tree_t *save = ctu_current_loop(sema);

tree_t *cond = ctu_sema_rvalue(sema, stmt->cond, ctu_get_bool_type());
tree_t *loop = tree_stmt_loop(stmt->node, cond, tree_stmt_block(stmt->node, &gEmptyVector),
tree_t *loop = tree_stmt_loop(stmt->node, cond, tree_stmt_block(stmt->node, &kEmptyVector),
NULL);

if (stmt->name != NULL)
Expand Down
5 changes: 2 additions & 3 deletions src/language/pl0/src/sema.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,10 @@ static void sema_proc(tree_t *sema, tree_t *tree, pl0_t *node)
tree_add_local(tree, it);
}

tree_t *ret = tree_stmt_return(node->node, tree_expr_unit(node->node, gVoidType));

vector_t *inner = sema_stmt_vector(nest, node->body);

vector_push(&inner, inner);
// make sure we always have a return statement
tree_t *ret = tree_stmt_return(node->node, tree_expr_unit(node->node, gVoidType));
vector_push(&inner, ret);

// make sure we have a return statement
Expand Down

0 comments on commit 0e42fb2

Please sign in to comment.