checkpoint on eval2

This commit is contained in:
Ryan Fleury
2026-06-16 17:56:48 -07:00
parent b8bad9a82e
commit 11b3f25842
3 changed files with 1218 additions and 1168 deletions
+34 -15
View File
@@ -141,7 +141,7 @@ e2_msgf(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, char *fmt, ...)
} }
//////////////////////////////// ////////////////////////////////
//~ rjf: Types //~ rjf: Type Keys
internal E2_TypeKey internal E2_TypeKey
e2_type_key_basic(E2_TypeKind kind) e2_type_key_basic(E2_TypeKind kind)
@@ -579,9 +579,10 @@ e2_parse_from_string(Arena *arena, E2_ParseState *state, E2_SpaceMap *space_map,
E2_Expr *finished_expr = expr; E2_Expr *finished_expr = expr;
for(;state->top_task != 0;) for(;state->top_task != 0;)
{ {
//- rjf: add finished expression to current parent; increase task child count //- rjf: gather finished expression to current task; increase task child count
E2_Expr *finished_expr_parent = state->top_task->parent; E2_ExprNode *n = push_array(arena, E2_ExprNode, 1);
SLLQueuePush_NZ(&e2_expr_nil, finished_expr_parent->first, finished_expr_parent->last, finished_expr, next); SLLQueuePush(state->top_task->first_child, state->top_task->last_child, n);
n->v = finished_expr;
state->top_task->child_count += 1; state->top_task->child_count += 1;
//- rjf: task child count hits limit -> complete this child //- rjf: task child count hits limit -> complete this child
@@ -593,8 +594,11 @@ e2_parse_from_string(Arena *arena, E2_ParseState *state, E2_SpaceMap *space_map,
SLLStackPush(state->free_task, completed_task); SLLStackPush(state->free_task, completed_task);
//- rjf: finish expression with operator info, if applicable //- rjf: finish expression with operator info, if applicable
finished_expr = completed_task->parent;
E2_Expr *lhs = completed_task->first_child ? completed_task->first_child->v : &e2_expr_nil;
E2_Expr *rhs = completed_task->last_child ? completed_task->last_child->v : &e2_expr_nil;
{ {
E2_Expr *root = completed_task->parent; E2_Expr *root = finished_expr;
switch(completed_task->op_kind) switch(completed_task->op_kind)
{ {
default:{}break; default:{}break;
@@ -602,20 +606,38 @@ e2_parse_from_string(Arena *arena, E2_ParseState *state, E2_SpaceMap *space_map,
//- rjf: dereference //- rjf: dereference
case E2_OpKind_Deref: case E2_OpKind_Deref:
{ {
#if 0
// rjf: unpack operand // rjf: unpack operand
E2_Expr *rhs = root->first; E2_TypeKey rhs_type_key = e2_type_key_unwrap(rhs->type_key, E2_TypeUnwrapFlag_AllDecorative & ~E2_TypeUnwrapFlag_Enums);
// E2_TypeKey rhs_type_key = e2_type_key_unwrap(rhs->type_key, E2_TypeUnwrapFlag_AllDecorative & ~E2_TypeUnwrapFlag_Enums); E2_TypeKind rhs_type_kind = e2_type_kind_from_key(rhs_type_key);
// E2_TypeKind rhs_type_kind = e2_type_kind_from_key(rhs_type_key); E2_TypeKey dereferenced_type = e2_type_key_unwrap(rhs->type_key, E2_TypeUnwrapFlag_All & ~E2_TypeUnwrapFlag_Enums);
// E2_TypeKey dereferenced_type = e2_type_key_unwrap(rhs->type_key, E2_TypeUnwrapFlag_All & ~E2_TypeUnwrapFlag_Enums); U64 dereferenced_type_size = e2_byte_size_from_type_key(dereferenced_type);
// U64 dereferenced_type_size = e2_byte_size_from_type_key(dereferenced_type);
// rjf: collect info about malformed situations // rjf: collect info about malformed situations
B32 malformed = 0; B32 malformed = 0;
// if(dereferenced_type_size == 0 && e2_type_kind_is_ptr_or_ref(rhs_type_kind)) if(dereferenced_type_size == 0 && e2_type_kind_is_ptr_or_ref(rhs_type_kind))
{ {
malformed = 1; malformed = 1;
// e2_msgf(arena, &parse.msgs, src->root_range, ""); e2_msgf(arena, &parse.msgs, src->root_range, "Cannot dereference pointers to zero-sized types.");
} }
else if(dereferenced_type_size == 0 && rhs_type_kind == E2_TypeKind_Array)
{
malformed = 1;
e2_msgf(arena, &parse.msgs, src->root_range, "Cannot dereference arrays of zero-sized types.");
}
else if(!e2_type_kind_is_ptr_or_ref(rhs_type_kind) && rhs_type_kind != E2_TypeKind_Array)
{
malformed = 1;
e2_msgf(arena, &parse.msgs, src->root_range, "Cannot dereference this type.");
}
// rjf: not malformed -> equip info
if(!malformed)
{
E2_Expr *addr_value_tree = e2_expr_resolve_to_value(arena, rhs);
SLLQueuePush_NZ(&e2_expr_nil, finished_expr->first, finished_expr->last, addr_value_tree, next);
}
#endif
}break; }break;
case E2_OpKind_Address:{}break; case E2_OpKind_Address:{}break;
@@ -644,9 +666,6 @@ e2_parse_from_string(Arena *arena, E2_ParseState *state, E2_SpaceMap *space_map,
case E2_OpKind_Define:{}break; case E2_OpKind_Define:{}break;
} }
} }
//- rjf: iterate to the completed task's expression node next, to try & finish it for *its* parent
finished_expr = completed_task->parent;
} }
} }
+24 -1
View File
@@ -205,6 +205,20 @@ struct E2_Val
typedef U64 E2_SpaceID; typedef U64 E2_SpaceID;
typedef struct E2_DbgInfo E2_DbgInfo;
struct E2_DbgInfo
{
DI_Key dbgi_key;
RDI_Parsed *rdi;
};
typedef struct E2_Assets E2_Assets;
struct E2_Assets
{
U32 dbg_infos_count;
E2_DbgInfo *dbg_infos;
};
//////////////////////////////// ////////////////////////////////
//~ rjf: Evaluation Contexts //~ rjf: Evaluation Contexts
@@ -279,6 +293,13 @@ struct E2_Expr
E2_Val val; E2_Val val;
}; };
typedef struct E2_ExprNode E2_ExprNode;
struct E2_ExprNode
{
E2_ExprNode *next;
E2_Expr *v;
};
typedef struct E2_ExprMapNode E2_ExprMapNode; typedef struct E2_ExprMapNode E2_ExprMapNode;
struct E2_ExprMapNode struct E2_ExprMapNode
{ {
@@ -299,6 +320,8 @@ struct E2_ParseTask
{ {
E2_ParseTask *next; E2_ParseTask *next;
E2_Expr *parent; E2_Expr *parent;
E2_ExprNode *first_child;
E2_ExprNode *last_child;
U64 child_count; U64 child_count;
U64 child_count_target; U64 child_count_target;
S64 max_precedence; S64 max_precedence;
@@ -409,7 +432,7 @@ internal E2_Msg *e2_msg(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, Strin
internal E2_Msg *e2_msgf(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, char *fmt, ...); internal E2_Msg *e2_msgf(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, char *fmt, ...);
//////////////////////////////// ////////////////////////////////
//~ rjf: Types //~ rjf: Type Keys
internal E2_TypeKey e2_type_key_basic(E2_TypeKind kind); internal E2_TypeKey e2_type_key_basic(E2_TypeKind kind);
+8
View File
@@ -13,14 +13,22 @@
//- rjf: [h] //- rjf: [h]
#include "base/base_inc.h" #include "base/base_inc.h"
#include "x64/x64.h" #include "x64/x64.h"
#include "http/http_inc.h"
#include "artifact_cache/artifact_cache.h"
#include "symbol_server/symbol_server_inc.h"
#include "rdi/rdi_local.h" #include "rdi/rdi_local.h"
#include "dbg_info/dbg_info.h"
#include "arch/arch_inc.h" #include "arch/arch_inc.h"
#include "eval2/eval2.h" #include "eval2/eval2.h"
//- rjf: [c] //- rjf: [c]
#include "base/base_inc.c" #include "base/base_inc.c"
#include "x64/x64.c" #include "x64/x64.c"
#include "http/http_inc.c"
#include "artifact_cache/artifact_cache.c"
#include "symbol_server/symbol_server_inc.c"
#include "rdi/rdi_local.c" #include "rdi/rdi_local.c"
#include "dbg_info/dbg_info.c"
#include "arch/arch_inc.c" #include "arch/arch_inc.c"
#include "eval2/eval2.c" #include "eval2/eval2.c"