Skip to content

Commit

Permalink
Updated insight to incorporate latest bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacShelton committed Feb 8, 2024
1 parent e3a0c65 commit a77c47d
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/backend/INSIGHT/include/AST/TYPE/ast_type_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
typedef struct { set_t impl; } ast_type_set_t;

void ast_type_set_init(ast_type_set_t *set, length_t num_buckets);
bool ast_type_set_insert(ast_type_set_t *set, const ast_type_t *type);
bool ast_type_set_insert(ast_type_set_t *set, ast_type_t *type);
void ast_type_set_traverse(ast_type_set_t *set, void (*run_func)(ast_type_t*));
void ast_type_set_free(ast_type_set_t *set);

Expand Down
2 changes: 1 addition & 1 deletion src/backend/INSIGHT/include/BRIDGE/rtti_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void rtti_collector_free(rtti_collector_t *collector);

// ---------------- rtti_collector_mention ----------------
// Mentions an AST type to an RTTI collector
void rtti_collector_mention(rtti_collector_t *collector, const ast_type_t *type);
void rtti_collector_mention(rtti_collector_t *collector, ast_type_t *type);

// ---------------- rtti_collector_mention_base ----------------
// Helper to mention a simple base AST type to an RTTI collector.
Expand Down
22 changes: 19 additions & 3 deletions src/backend/INSIGHT/src/AST/TYPE/ast_type_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,27 @@ static ast_type_t *ast_type_clone_on_heap(const ast_type_t *type){
return result;
}

static hash_t ast_type_set_hash_function(const void *value) {
return ast_type_hash((const ast_type_t*) value);
}

static bool ast_type_set_equals_function(const void *a, const void *b){
return ast_types_identical((const ast_type_t*) a, (const ast_type_t*) b);
}

static void *ast_type_set_preinsert_clone_function(const void *value){
return ast_type_clone_on_heap((const ast_type_t*) value);
}

static void ast_type_set_free_function(void *value){
ast_type_free_fully((ast_type_t*) value);
}

void ast_type_set_init(ast_type_set_t *set, length_t num_buckets){
set_init(&set->impl, num_buckets, (set_hash_func_t) &ast_type_hash, (set_equals_func_t) &ast_types_identical, (set_preinsert_clone_func_t) &ast_type_clone_on_heap);
set_init(&set->impl, num_buckets, &ast_type_set_hash_function, &ast_type_set_equals_function, &ast_type_set_preinsert_clone_function);
}

bool ast_type_set_insert(ast_type_set_t *set, const ast_type_t *type){
bool ast_type_set_insert(ast_type_set_t *set, ast_type_t *type){
return set_insert(&set->impl, (void*) type);
}

Expand All @@ -23,5 +39,5 @@ void ast_type_set_traverse(ast_type_set_t *set, void (*run_func)(ast_type_t*)){
}

void ast_type_set_free(ast_type_set_t *set){
set_free(&set->impl, (set_free_item_func_t) &ast_type_free_fully);
set_free(&set->impl, &ast_type_set_free_function);
}
2 changes: 1 addition & 1 deletion src/backend/INSIGHT/src/BRIDGE/rtti_collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void rtti_collector_free(rtti_collector_t *collector){
ast_type_set_free(&collector->ast_types_used);
}

void rtti_collector_mention(rtti_collector_t *collector, const ast_type_t *type){
void rtti_collector_mention(rtti_collector_t *collector, ast_type_t *type){
ast_type_set_insert(&collector->ast_types_used, type);
}

Expand Down
5 changes: 4 additions & 1 deletion src/backend/INSIGHT/src/DRVR/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ errorcode_t parse_arguments(compiler_t *compiler, object_t *object, int argc, ch
compiler->debug_traits |= COMPILER_DEBUG_NO_VERIFICATION;
} else if(streq(arg, "--no-result")){
compiler->debug_traits |= COMPILER_DEBUG_NO_RESULT;
} else if(streq(arg, "--no-update")){
// Ignore, this argument is handled before argument parsing
}
else {
redprintf("Invalid argument: %s\n", arg);
Expand Down Expand Up @@ -705,7 +707,7 @@ void show_help(bool show_advanced_options){
printf(" /▔▔\\\n");
printf(" / \\ \n");
printf(" / \\ \n");
printf(" / /\\ \\ The Adept Compiler v%s - (c) 2016-2023 Isaac Shelton\n", ADEPT_VERSION_STRING);
printf(" / /\\ \\ The Adept Compiler v%s - (c) 2016-2024 Isaac Shelton\n", ADEPT_VERSION_STRING);
printf(" / /\\__ \\\n");
printf("/___/ \\___\\\n\n");
terminal_set_color(TERMINAL_COLOR_DEFAULT);
Expand Down Expand Up @@ -776,6 +778,7 @@ void show_help(bool show_advanced_options){
printf(" --ignore-partial-support Ignore partial compiler support warnings\n");
printf(" --ignore-unrecognized-directives Ignore unrecognized pragma directives\n");
printf(" --ignore-unused Ignore unused variables\n");
printf(" --no-update Don't check for available compiler updates\n");
}

#ifdef ENABLE_DEBUG_FEATURES
Expand Down
16 changes: 15 additions & 1 deletion src/backend/INSIGHT/src/PARSE/parse_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ errorcode_t parse_composite_body(
}
}

if(backfill != 0){
compiler_panicf(ctx->compiler, sources[*i], "Expected field type for last field");
return FAILURE;
}

return SUCCESS;

failure:
Expand Down Expand Up @@ -584,6 +589,11 @@ errorcode_t parse_anonymous_composite(
}
}

if(backfill != 0){
compiler_panicf(ctx->compiler, sources[*i], "Expected field type for last field");
return FAILURE;
}

ast_layout_endpoint_increment(inout_next_endpoint);
(*i)++;
return SUCCESS;
Expand Down Expand Up @@ -655,8 +665,12 @@ errorcode_t parse_create_record_constructor(parse_ctx_t *ctx, weak_cstr_t name,

for(length_t i = 0; i != field_map->arrows_length; i++){
ast_field_arrow_t *arrow = &field_map->arrows[i];

ast_type_t *type = ast_layout_skeleton_get_type(skeleton, arrow->endpoint);
assert(type != NULL);

func->arg_names[i] = strclone(arrow->name);
func->arg_types[i] = ast_type_clone(ast_layout_skeleton_get_type(skeleton, arrow->endpoint));
func->arg_types[i] = ast_type_clone(type);
func->arg_flows[i] = FLOW_IN;
func->arg_sources[i] = NULL_SOURCE;
func->arg_type_traits[i] = AST_FUNC_ARG_TYPE_TRAIT_POD;
Expand Down
6 changes: 3 additions & 3 deletions src/backend/INSIGHT/src/UTIL/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ void set_free(set_t *set, set_free_item_func_t optional_free_func){
}

bool set_insert(set_t *set, void *item){
hash_t hash = (*set->hash_func)(item);
hash_t hash = (*set->hash_func)((const void*) item);
set_entry_t **slot = &set->entries[hash % set->capacity];

if(*slot == NULL){
*slot = malloc_init(set_entry_t, {
.data = set->optional_preinsert_clone_func ? (*set->optional_preinsert_clone_func)(item) : item,
.data = set->optional_preinsert_clone_func ? (*set->optional_preinsert_clone_func)((const void*) item) : item,
.next = NULL,
});
} else {
Expand All @@ -56,7 +56,7 @@ bool set_insert(set_t *set, void *item){
}

prev->next = malloc_init(set_entry_t, {
.data = set->optional_preinsert_clone_func ? (*set->optional_preinsert_clone_func)(item) : item,
.data = set->optional_preinsert_clone_func ? (*set->optional_preinsert_clone_func)((const void*) item) : item,
.next = NULL,
});
}
Expand Down
11 changes: 8 additions & 3 deletions src/backend/INSIGHT/src/UTIL/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ strong_cstr_t string_to_escaped_string(const char *array, length_t length, char
}

strong_cstr_t string = malloc(length + special_characters + 3);
if(escaped_quote && surround) string[put_index++] = escaped_quote;

if(escaped_quote && surround){
string[put_index++] = escaped_quote;
}

for(length_t i = 0; i != length; i++){
if(array[i] <= 0x1F || array[i] == '\\' || (array[i] == escaped_quote && escaped_quote)){
Expand All @@ -47,11 +50,13 @@ strong_cstr_t string_to_escaped_string(const char *array, length_t length, char
}

switch(array[i]){
case '\0': string[put_index++] = '0'; break;
case '\t': string[put_index++] = 't'; break;
case '\n': string[put_index++] = 'n'; break;
case '\r': string[put_index++] = 'r'; break;
case '\t': string[put_index++] = 't'; break;
case '\b': string[put_index++] = 'b'; break;
case '\f': string[put_index++] = 'f'; break;
case '\v': string[put_index++] = 'v'; break;
case '\0': string[put_index++] = '0'; break;
case '\\': string[put_index++] = '\\'; break;
case 0x1B: string[put_index++] = 'e'; break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/datatypes.adept
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import basics
import JSON

record Source (object String, index, stride usize)

record Position (line, character usize) {
constructor(json JSON) {
this.line = json.field("line").number().orElse(0.0) as usize
Expand Down

0 comments on commit a77c47d

Please sign in to comment.