feat: implemented box access expression in SET

This commit is contained in:
Sven Vogel 2024-10-22 00:40:05 +02:00
parent 26bc5a796a
commit 22cd01997c
7 changed files with 1505 additions and 1506 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -114,18 +114,8 @@ _start:
.type "std::io::getStdoutHandle",@function
"std::io::getStdoutHandle":
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movq %rsp, %rax
leaq -16(%rax), %rsp
movl $0, -16(%rax)
xorl %eax, %eax
movq %rbp, %rsp
popq %rbp
.cfi_def_cfa %rsp, 8
movl $1, -8(%rsp)
movl $1, %eax
retq
.Lfunc_end4:
.size "std::io::getStdoutHandle", .Lfunc_end4-"std::io::getStdoutHandle"

View File

@ -21,5 +21,5 @@ fun print(in ref u8: buf, in u32: n) {
Handle: stdout = std::io::getStdoutHandle()
write(1 as i32, buf, n as u64)
write(stdout.fd as i32, buf, n as u64)
}

View File

@ -107,8 +107,11 @@ BackendError impl_storage_expr(LLVMBackendCompileUnit* unit,
BoxMember* member = g_array_index(expr->impl.boxAccess.member, BoxMember*, i);
LLVMTypeRef member_type = NULL;
Type* type = mem_alloc(MemoryNamespaceLlvm, sizeof(Type));
type->kind = TypeKindBox;
type->impl.box = member->box;
err = get_type_impl(unit, scope->func_scope->global_scope,
expr->target_type, &member_type);
type, &member_type);
if (err.kind != Success) {
return err;
}

View File

@ -1365,7 +1365,7 @@ int createBitNotOperation(Expression* ParentExpression,
*/
GArray* getBoxMember(Type* currentBoxType, GArray* names) {
GArray* members = mem_new_g_array(MemoryNamespaceSet, sizeof(BoxMember));
GArray* members = mem_new_g_array(MemoryNamespaceSet, sizeof(BoxMember*));
// list of members of the type
GHashTable* memberList = currentBoxType->impl.box->member;
@ -1392,7 +1392,7 @@ GArray* getBoxMember(Type* currentBoxType, GArray* names) {
return NULL;
}
g_array_append_vals(members, (BoxMember*) otherMember->data,
g_array_append_vals(members, (BoxMember**) otherMember->data,
otherMember->len);
return members;
@ -1428,18 +1428,20 @@ int createBoxAccess(Expression* ParentExpression, AST_NODE_PTR currentNode) {
}
// filling boxAccess variable
ParentExpression->impl.variable = mem_alloc(MemoryNamespaceSet, sizeof(Variable));
ParentExpression->impl.variable->kind = VariableKindBoxMember;
ParentExpression->impl.variable->nodePtr = currentNode;
ParentExpression->impl.variable->name = NULL;
ParentExpression->impl.variable->name = boxVariable->name;
ParentExpression->impl.variable->impl.member.nodePtr = currentNode;
// filling boxacces.variable
ParentExpression->impl.variable->impl.member.variable = boxVariable;
ParentExpression->kind = ExpressionKindVariable;
// first one is the box itself
GArray* names = mem_alloc(MemoryNamespaceSet, sizeof(GArray));
GArray* names = mem_new_g_array(MemoryNamespaceSet, sizeof(char*));
if (currentNode->kind == AST_IdentList) {
for (size_t i = 1; i < currentNode->children->len; i++) {
for (size_t i = 1; i < AST_get_child_count(currentNode); i++) {
g_array_append_val(names, AST_get_node(currentNode, i)->value);
}
} else if (currentNode->kind == AST_List) {
@ -1455,7 +1457,7 @@ int createBoxAccess(Expression* ParentExpression, AST_NODE_PTR currentNode) {
GArray* boxMember = getBoxMember(boxType, names);
ParentExpression->impl.variable->impl.member.member = boxMember;
ParentExpression->result =
g_array_index(boxMember, BoxMember, boxMember->len).type;
g_array_index(boxMember, BoxMember*, boxMember->len - 1)->type;
return SEMANTIC_OK;
}

File diff suppressed because it is too large Load Diff