Minimize package size

This commit is contained in:
Krzosa Karol
2024-04-14 09:27:47 +02:00
parent 320a13ddfd
commit 34f83e444f
15 changed files with 71 additions and 68 deletions

View File

@@ -154,7 +154,7 @@ bool add_dynamic_array_macro() {
// that is going to be imported into every other package, for now we use only the current package
For(array_of_to_gen) {
LC_AST *ast = LC_ParseDeclf("ArrayOf%s :: struct { data: *%s; len: int; cap: int; }", (char *)it, (char *)it);
LC_AST *file = package->apackage.ffile;
LC_AST *file = package->apackage.ext->ffile;
LC_DLLAdd(file->afile.fdecl, file->afile.ldecl, ast);
}

View File

@@ -78,11 +78,11 @@ bool sandbox() {
//
LC_AST *package = LC_GetPackageByName(name);
LC_AST *dynamic_array_file = NULL;
LC_ASTFor(it, package->apackage.ffile) {
LC_ASTFor(it, package->apackage.ext->ffile) {
S8_String path = S8_MakeFromChar((char *)it->afile.x->file);
if (S8_EndsWith(path, "dynamic_array.lc")) {
dynamic_array_file = it;
DLL_QUEUE_REMOVE(package->apackage.ffile, package->apackage.lfile, it);
DLL_QUEUE_REMOVE(package->apackage.ext->ffile, package->apackage.ext->lfile, it);
break;
}
}
@@ -94,7 +94,7 @@ bool sandbox() {
walker.user_data = (void *)⁢
LC_WalkAST(&walker, new_array_file);
LC_DLLAdd(package->apackage.ffile, package->apackage.lfile, new_array_file);
LC_DLLAdd(package->apackage.ext->ffile, package->apackage.ext->lfile, new_array_file);
}
LC_OrderAndResolveTopLevelDecls(name);

View File

@@ -19,18 +19,18 @@ bool use_as_data_format_with_typechecking() {
// Constants
{
LC_Decl *int_value = LC_FindDeclInScope(package->apackage.scope, LC_ILit("IntValue"));
LC_Decl *int_value = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("IntValue"));
int64_t IntValue = LC_Bigint_as_signed(&int_value->val.i);
IO_Assert(IntValue == 232);
}
{
LC_Decl *decl = LC_FindDeclInScope(package->apackage.scope, LC_ILit("FloatValue"));
LC_Decl *decl = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("FloatValue"));
IO_Assert(decl->val.d == 13.0);
}
{
LC_Decl *decl = LC_FindDeclInScope(package->apackage.scope, LC_ILit("SomeString"));
LC_Decl *decl = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("SomeString"));
IO_Assert(decl->val.name == LC_ILit("Thing"));
}
@@ -38,7 +38,7 @@ bool use_as_data_format_with_typechecking() {
int64_t LEVEL_BEGIN = -1;
{
LC_Decl *int_value = LC_FindDeclInScope(package->apackage.scope, LC_ILit("LEVEL_BEGIN"));
LC_Decl *int_value = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("LEVEL_BEGIN"));
LEVEL_BEGIN = LC_Bigint_as_signed(&int_value->val.i);
IO_Assert(LEVEL_BEGIN == 2);
}
@@ -52,7 +52,7 @@ bool use_as_data_format_with_typechecking() {
double Variable = GetFloatValue(p, "Variable");
*/
LC_Decl *decl = LC_FindDeclInScope(package->apackage.scope, LC_ILit("Player"));
LC_Decl *decl = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("Player"));
LC_ResolvedCompo *items = decl->ast->dvar.expr->ecompo.resolved_items;
for (LC_ResolvedCompoItem *it = items->first; it; it = it->next) {
LC_Intern name = it->t->name;
@@ -71,12 +71,12 @@ bool use_as_data_format_with_typechecking() {
}
{
LC_Decl *decl = LC_FindDeclInScope(package->apackage.scope, LC_ILit("Variable"));
LC_Decl *decl = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("Variable"));
IO_Assert(decl->val.d == 32.0);
}
{
LC_Decl *decl = LC_FindDeclInScope(package->apackage.scope, LC_ILit("Reference"));
LC_Decl *decl = LC_FindDeclInScope(package->apackage.ext->scope, LC_ILit("Reference"));
IO_Assert(decl->val.d == 64.0);
}