change workflow to support other plateforms

This commit is contained in:
William Bell
2025-08-15 19:06:00 +01:00
parent ed1b77a78e
commit 663797d1fb
8 changed files with 65 additions and 26 deletions

View File

@@ -26,7 +26,7 @@ void darray_resize(DArray *arr, size_t new_size) {
// Determine number of full chunks needed to store new_size elements
size_t required_bytes = new_size * arr->element_size;
size_t new_capacity_bytes = ((required_bytes + CHUNK_SIZE - 1) / CHUNK_SIZE) * CHUNK_SIZE;
size_t new_capacity_bytes = required_bytes*2;
size_t new_capacity = new_capacity_bytes / arr->element_size;
if (!new_capacity) {
return;

View File

@@ -158,7 +158,7 @@ int load_cache(Translated *translated_dest, char *joined_paths, uint64_t hash,
char *source_path) {
FILE *bytecode_file = fopen(joined_paths, "rb");
if (!bytecode_file) {
printf("cache doesnt exist... compiling from source.\n");
fprintf(stderr,"cache doesnt exist... compiling from source.\n");
return 1;
}
@@ -194,7 +194,7 @@ int load_cache(Translated *translated_dest, char *joined_paths, uint64_t hash,
XXH64_freeState(state);
if (calc_hash != stored_hash) {
printf("cache hash mismatch (corrupted?)\n");
fprintf(stderr,"cache hash mismatch (corrupted?)\n");
goto FAILED;
}
@@ -268,11 +268,11 @@ int load_cache(Translated *translated_dest, char *joined_paths, uint64_t hash,
goto FAILED;
}
printf("cache exists and is valid, so will be used.\n");
fprintf(stderr,"cache exists and is valid, so will be used.\n");
fclose(bytecode_file);
return 0;
FAILED:
printf("cache is invalid... compiling from source.\n");
fprintf(stderr,"cache is invalid... compiling from source.\n");
fclose(bytecode_file);
return 1;
}
@@ -346,7 +346,7 @@ Execution execute(char *path, Stack *stack) {
end = clock();
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
total_time_spent += time_spent;
printf("Lexer time taken: %f seconds\n", time_spent);
fprintf(stderr,"Lexer time taken: %f seconds\n", time_spent);
fclose(state.file);
DArray ast;
@@ -363,7 +363,7 @@ Execution execute(char *path, Stack *stack) {
end = clock();
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
total_time_spent += time_spent;
printf("Parser time taken: %f seconds\n", time_spent);
fprintf(stderr,"Parser time taken: %f seconds\n", time_spent);
darray_free(&tokens, free_token);
start = clock();
@@ -380,7 +380,7 @@ Execution execute(char *path, Stack *stack) {
end = clock();
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
total_time_spent += time_spent;
printf("Translation time taken: %f seconds\n", time_spent);
fprintf(stderr,"Translation time taken: %f seconds\n", time_spent);
darray_free(&ast, free_parsed);
#if defined(__linux__)
@@ -452,8 +452,8 @@ Execution execute(char *path, Stack *stack) {
end = clock();
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
total_time_spent += time_spent;
printf("Execution time taken: %f seconds\n", time_spent);
printf("total time taken: %f seconds\n", total_time_spent);
fprintf(stderr,"Execution time taken: %f seconds\n", time_spent);
fprintf(stderr,"total time taken: %f seconds\n", total_time_spent);
return (Execution){err, *main_scope};
}

View File

@@ -23,7 +23,6 @@
#include "return/return.h"
#include "string/string.h"
#include <gmp.h>
#include <gmp.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
@@ -75,6 +74,8 @@ ParsedValueReturn parse_token_full(char *file, DArray *tokens, size_t *index,
return parse_if(file, tokens, index);
case TOKEN_RETURN:
return parse_return(file, tokens, index);
case TOKEN_LET:
return parse_declaration(file, tokens, index);
default:
break;
};
@@ -121,9 +122,6 @@ ParsedValueReturn parse_token_full(char *file, DArray *tokens, size_t *index,
(*index)++;
output = parse_number(token, file);
break;
case TOKEN_LET:
output = parse_declaration(file, tokens, index);
break;
case TOKEN_DO:
output = parse_dowrap(file, tokens, index);
break;

View File

@@ -36,8 +36,7 @@ void darray_armem_resize(darray_armem *arr, size_t new_size) {
}
size_t required_bytes = new_size * arr->element_size;
size_t new_capacity_bytes =
((required_bytes + CHUNK_SIZE - 1) / CHUNK_SIZE) * CHUNK_SIZE;
size_t new_capacity_bytes =required_bytes*2;
size_t new_capacity = new_capacity_bytes / arr->element_size;
if (!new_capacity) {

View File

@@ -10,12 +10,14 @@
#include <stdio.h>
#include <string.h>
#include "string.h"
#include "../number/number.h"
ArgonObject *ARGON_STRING_TYPE = NULL;
ArgonObject *new_string_object(char*data, size_t length) {
ArgonObject * object = new_object();
add_field(object, "__class__", ARGON_STRING_TYPE);
add_field(object, "length", new_number_object_from_long(length, 1));
object->type = TYPE_STRING;
object->value.as_str.data = ar_alloc_atomic(length);
memcpy(object->value.as_str.data, data, length);

View File

@@ -14,6 +14,7 @@ size_t translate_parsed_call(Translated *translated, ParsedCall *call,
}
push_instruction_byte(translated, OP_INIT_CALL);
push_instruction_code(translated, call->args.size);
push_instruction_byte(translated, OP_NEW_SCOPE);
DArray *old_return_jumps = translated->return_jumps;
translated->return_jumps = NULL;
@@ -28,6 +29,7 @@ size_t translate_parsed_call(Translated *translated, ParsedCall *call,
}
translated->return_jumps = old_return_jumps;
push_instruction_byte(translated, OP_POP_SCOPE);
push_instruction_byte(translated, OP_SOURCE_LOCATION);
push_instruction_code(translated, call->line);