mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-13 07:52:22 -07:00
adding arena (p8) - done
This commit is contained in:
@@ -663,13 +663,6 @@ main:
|
||||
size: MD_u64,
|
||||
}
|
||||
|
||||
@send(MemoryOperations)
|
||||
@doc("Allocates @code 'size' bytes. This memory cannot be freed.")
|
||||
@func MD_AllocZero:
|
||||
{
|
||||
size: MD_u64,
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Characters
|
||||
|
||||
@@ -1888,6 +1881,7 @@ MD_ParseWholeFile:
|
||||
|
||||
@send(ExpressionParsingHelper)
|
||||
@func MD_C_MakeExpr: {
|
||||
arena: *MD_Arena,
|
||||
node: *MD_Node,
|
||||
kind: MD_ExprKind,
|
||||
left: *MD_C_Expr,
|
||||
@@ -1897,6 +1891,7 @@ MD_ParseWholeFile:
|
||||
|
||||
@send(ExpressionParsingHelper)
|
||||
@func MD_C_ParseAsExpr: {
|
||||
arena: *MD_Arena,
|
||||
first: *MD_Node,
|
||||
last: *MD_Node,
|
||||
return: *MD_C_Expr,
|
||||
@@ -1904,6 +1899,7 @@ MD_ParseWholeFile:
|
||||
|
||||
@send(ExpressionParsingHelper)
|
||||
@func MD_C_ParseAsType: {
|
||||
arena: *MD_Arena,
|
||||
first: *MD_Node,
|
||||
last: *MD_Node,
|
||||
return: *MD_C_Expr,
|
||||
|
||||
@@ -160,13 +160,13 @@ EvaluateScope(NamespaceNode *ns, MD_Node *code)
|
||||
//- rjf: declaration
|
||||
if(first->next == opl && first->string.size != 0 && !MD_NodeIsNil(first->first_child))
|
||||
{
|
||||
MD_C_Expr *expr = MD_C_ParseAsExpr(first->first_child, first->last_child);
|
||||
MD_C_Expr *expr = MD_C_ParseAsExpr(arena, first->first_child, first->last_child);
|
||||
InsertValueToNamespace(&local_namespace, first->string, EvaluateExpr(&local_namespace, expr));
|
||||
}
|
||||
//- rjf: expr
|
||||
else
|
||||
{
|
||||
MD_C_Expr *expr = MD_C_ParseAsExpr(first, opl);
|
||||
MD_C_Expr *expr = MD_C_ParseAsExpr(arena, first, opl);
|
||||
if(!MD_C_ExprIsNil(expr))
|
||||
{
|
||||
result = EvaluateExpr(&local_namespace, expr);
|
||||
|
||||
+4
-38
@@ -3,7 +3,6 @@
|
||||
// NOTE(allen): Notes on overrides/macro options:
|
||||
// Individual Overridables:
|
||||
// #define MD_IMPL_FileIterIncrement
|
||||
// #define MD_IMPL_Alloc
|
||||
// #define MD_IMPL_Reserve
|
||||
// #define MD_IMPL_Commit
|
||||
// #define MD_IMPL_Decommit
|
||||
@@ -20,24 +19,6 @@
|
||||
// TODO(allen): not real! Don't put into API
|
||||
MD_FUNCTION MD_Arena* MD_Scratch(void);
|
||||
|
||||
//~/////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////// Default Implementation ///////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !MD_NO_DEFAULT_IMPL
|
||||
|
||||
#if !defined(MD_IMPL_Alloc)
|
||||
# define MD_IMPL_Alloc(size) MD_MALLOC_Alloc(size)
|
||||
#endif
|
||||
|
||||
static void*
|
||||
MD_MALLOC_Alloc(MD_u64 size)
|
||||
{
|
||||
return(malloc(size));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//~/////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////// Win32 Implementation ////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -319,9 +300,6 @@ MD_ArenaDefaultRelease(MD_Arena *arena_opq){
|
||||
//////////////////////// MD Library Implementation /////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(MD_IMPL_Alloc)
|
||||
# error Missing implementation for MD_IMPL_Alloc
|
||||
#endif
|
||||
#if !defined(MD_IMPL_ArenaNew)
|
||||
# error Missing implementation for MD_IMPL_ArenaNew
|
||||
#endif
|
||||
@@ -330,7 +308,6 @@ MD_ArenaDefaultRelease(MD_Arena *arena_opq){
|
||||
#endif
|
||||
|
||||
#define MD_FUNCTION_IMPL MD_FUNCTION
|
||||
#define MD_PRIVATE_FUNCTION_IMPL MD_FUNCTION_IMPL
|
||||
#define MD_UNTERMINATED_TOKEN_LEN_CAP 20
|
||||
|
||||
#define STB_SPRINTF_IMPLEMENTATION
|
||||
@@ -376,18 +353,6 @@ MD_MemoryCopy(void *dest, void *src, MD_u64 size)
|
||||
return(dest);
|
||||
}
|
||||
|
||||
MD_FUNCTION_IMPL void *
|
||||
MD_AllocZero(MD_u64 size)
|
||||
{
|
||||
#if !defined(MD_IMPL_Alloc)
|
||||
# error Missing implementation detail MD_IMPL_Alloc
|
||||
#else
|
||||
void *result = MD_IMPL_Alloc(size);
|
||||
MD_MemoryZero(result, size);
|
||||
return(result);
|
||||
#endif
|
||||
}
|
||||
|
||||
//~ Arena Functions
|
||||
|
||||
MD_FUNCTION_IMPL void*
|
||||
@@ -2936,7 +2901,7 @@ MD_MakeCmdLineFromOptions(MD_Arena *arena, MD_String8List options)
|
||||
|
||||
//- rjf: insert the fully parsed option
|
||||
{
|
||||
MD_CmdLineOption *opt = MD_PushArray(MD_CmdLineOption, 1);
|
||||
MD_CmdLineOption *opt = MD_PushArrayAr(arena, MD_CmdLineOption, 1);
|
||||
MD_MemoryZero(opt, sizeof(*opt));
|
||||
opt->name = option_name;
|
||||
opt->values = option_values;
|
||||
@@ -3007,13 +2972,14 @@ MD_FUNCTION_IMPL MD_String8
|
||||
MD_LoadEntireFile(MD_Arena *arena, MD_String8 filename)
|
||||
{
|
||||
MD_String8 file_contents = MD_ZERO_STRUCT;
|
||||
FILE *file = fopen((char*)MD_S8Copy(arena, filename).str, "rb");
|
||||
MD_String8 filename_copy = MD_S8Copy(arena, filename);
|
||||
FILE *file = fopen((char*)filename_copy.str, "rb");
|
||||
if(file)
|
||||
{
|
||||
fseek(file, 0, SEEK_END);
|
||||
MD_u64 file_size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
file_contents.str = MD_PushArray(MD_u8, file_size+1);
|
||||
file_contents.str = MD_PushArrayAr(arena, MD_u8, file_size+1);
|
||||
if(file_contents.str)
|
||||
{
|
||||
file_contents.size = file_size;
|
||||
|
||||
@@ -687,9 +687,6 @@ struct MD_FileIter
|
||||
MD_FUNCTION void* MD_MemoryZero(void *memory, MD_u64 size);
|
||||
MD_FUNCTION void* MD_MemoryCopy(void *dst, void *src, MD_u64 size);
|
||||
|
||||
MD_FUNCTION void* MD_AllocZero(MD_u64 size);
|
||||
#define MD_PushArray(T,c) (T*)MD_AllocZero(sizeof(T)*(c))
|
||||
|
||||
//~ Arena Functions
|
||||
|
||||
MD_FUNCTION void* MD_ArenaPush(MD_Arena *arena, MD_u64 v);
|
||||
|
||||
+41
-41
@@ -171,9 +171,10 @@ MD_C_ExprPrecFromExprKind(MD_C_ExprKind kind)
|
||||
}
|
||||
|
||||
MD_FUNCTION_IMPL MD_C_Expr *
|
||||
MD_C_MakeExpr(MD_Node *node, MD_C_ExprKind kind, MD_C_Expr *left, MD_C_Expr *right)
|
||||
MD_C_MakeExpr(MD_Arena *arena, MD_Node *node, MD_C_ExprKind kind, MD_C_Expr *left,
|
||||
MD_C_Expr *right)
|
||||
{
|
||||
MD_C_Expr *expr = MD_PushArray(MD_C_Expr, 1);
|
||||
MD_C_Expr *expr = MD_PushArrayAr(arena, MD_C_Expr, 1);
|
||||
if(left == 0) left = MD_C_NilExpr();
|
||||
if(right == 0) right = MD_C_NilExpr();
|
||||
expr->node = node;
|
||||
@@ -190,7 +191,7 @@ struct _MD_NodeParseCtx
|
||||
MD_Node *one_past_last;
|
||||
};
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_b32
|
||||
MD_FUNCTION_IMPL MD_b32
|
||||
_MD_NodeParse_ConsumeAtom(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
{
|
||||
MD_b32 result = 0;
|
||||
@@ -207,7 +208,7 @@ _MD_NodeParse_ConsumeAtom(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
return result;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_b32
|
||||
MD_FUNCTION_IMPL MD_b32
|
||||
_MD_NodeParse_ConsumeSet(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
{
|
||||
MD_b32 result = 0;
|
||||
@@ -229,7 +230,7 @@ _MD_NodeParse_ConsumeSet(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
return result;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_b32
|
||||
MD_FUNCTION_IMPL MD_b32
|
||||
_MD_NodeParse_ConsumeLiteral(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
{
|
||||
MD_b32 result = 0;
|
||||
@@ -246,7 +247,7 @@ _MD_NodeParse_ConsumeLiteral(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
return result;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_b32
|
||||
MD_FUNCTION_IMPL MD_b32
|
||||
_MD_NodeParse_Consume(_MD_NodeParseCtx *ctx, MD_String8 string, MD_Node **out)
|
||||
{
|
||||
MD_b32 result = 0;
|
||||
@@ -262,20 +263,18 @@ _MD_NodeParse_Consume(_MD_NodeParseCtx *ctx, MD_String8 string, MD_Node **out)
|
||||
return result;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL void
|
||||
MD_FUNCTION_IMPL void
|
||||
_MD_NodeParse_Next(_MD_NodeParseCtx *ctx)
|
||||
{
|
||||
ctx->at = ctx->at->next;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseExpr_(_MD_NodeParseCtx *ctx, int precedence_in);
|
||||
MD_FUNCTION MD_C_Expr * _MD_ParseExpr_(MD_Arena *arena, _MD_NodeParseCtx *ctx,
|
||||
int precedence_in);
|
||||
MD_FUNCTION MD_C_Expr * _MD_ParseExpr(MD_Arena *arena, _MD_NodeParseCtx *ctx);
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseExpr(_MD_NodeParseCtx *ctx);
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseUnaryExpr(_MD_NodeParseCtx *ctx)
|
||||
MD_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseUnaryExpr(MD_Arena *arena, _MD_NodeParseCtx *ctx)
|
||||
{
|
||||
MD_C_Expr *result = MD_C_NilExpr();
|
||||
MD_Node *set = 0;
|
||||
@@ -284,37 +283,37 @@ _MD_ParseUnaryExpr(_MD_NodeParseCtx *ctx)
|
||||
// NOTE(rjf): Sub-expression
|
||||
if(_MD_NodeParse_ConsumeSet(ctx, &set))
|
||||
{
|
||||
result = MD_C_ParseAsExpr(set->first_child, set->last_child);
|
||||
result = MD_C_ParseAsExpr(arena, set->first_child, set->last_child);
|
||||
}
|
||||
|
||||
// NOTE(rjf): Literal
|
||||
else if(_MD_NodeParse_ConsumeLiteral(ctx, &node))
|
||||
{
|
||||
result = MD_C_MakeExpr(node, MD_C_ExprKind_Atom, 0, 0);
|
||||
result = MD_C_MakeExpr(arena, node, MD_C_ExprKind_Atom, 0, 0);
|
||||
}
|
||||
|
||||
// NOTE(rjf): Literal
|
||||
else if(_MD_NodeParse_ConsumeAtom(ctx, &node))
|
||||
{
|
||||
result = MD_C_MakeExpr(node, MD_C_ExprKind_Atom, 0, 0);
|
||||
result = MD_C_MakeExpr(arena, node, MD_C_ExprKind_Atom, 0, 0);
|
||||
}
|
||||
|
||||
// NOTE(rjf): Negative
|
||||
else if(_MD_NodeParse_Consume(ctx, MD_S8Lit("-"), &node))
|
||||
{
|
||||
result = MD_C_MakeExpr(node, MD_C_ExprKind_Negative, 0, _MD_ParseExpr(ctx));
|
||||
result = MD_C_MakeExpr(arena, node, MD_C_ExprKind_Negative, 0, _MD_ParseExpr(arena, ctx));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Bitwise Negate
|
||||
else if(_MD_NodeParse_Consume(ctx, MD_S8Lit("~"), &node))
|
||||
{
|
||||
result = MD_C_MakeExpr(node, MD_C_ExprKind_BitNot, 0, _MD_ParseExpr(ctx));
|
||||
result = MD_C_MakeExpr(arena, node, MD_C_ExprKind_BitNot, 0, _MD_ParseExpr(arena, ctx));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Boolean Negate
|
||||
else if(_MD_NodeParse_Consume(ctx, MD_S8Lit("!"), &node))
|
||||
{
|
||||
result = MD_C_MakeExpr(node, MD_C_ExprKind_BoolNot, 0, _MD_ParseExpr(ctx));
|
||||
result = MD_C_MakeExpr(arena, node, MD_C_ExprKind_BoolNot, 0, _MD_ParseExpr(arena, ctx));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Post-Unary Sets (calls and subscripts)
|
||||
@@ -322,21 +321,21 @@ _MD_ParseUnaryExpr(_MD_NodeParseCtx *ctx)
|
||||
{
|
||||
if(set->flags & MD_NodeFlag_HasParenLeft && set->flags & MD_NodeFlag_HasParenRight)
|
||||
{
|
||||
result = MD_C_MakeExpr(set, MD_C_ExprKind_Call, result, 0);
|
||||
result = MD_C_MakeExpr(arena, set, MD_C_ExprKind_Call, result, 0);
|
||||
}
|
||||
else if(set->flags & MD_NodeFlag_HasBracketLeft && set->flags & MD_NodeFlag_HasBracketRight)
|
||||
{
|
||||
result = MD_C_MakeExpr(set, MD_C_ExprKind_Subscript, result, MD_C_ParseAsExpr(set->first_child, set->last_child));
|
||||
result = MD_C_MakeExpr(arena, set, MD_C_ExprKind_Subscript, result, MD_C_ParseAsExpr(arena, set->first_child, set->last_child));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseExpr_(_MD_NodeParseCtx *ctx, int precedence_in)
|
||||
MD_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseExpr_(MD_Arena *arena, _MD_NodeParseCtx *ctx, int precedence_in)
|
||||
{
|
||||
MD_C_Expr *expr = _MD_ParseUnaryExpr(ctx);
|
||||
MD_C_Expr *expr = _MD_ParseUnaryExpr(arena, ctx);
|
||||
MD_C_ExprKind expr_kind;
|
||||
if(MD_C_ExprIsNil(expr))
|
||||
{
|
||||
@@ -367,7 +366,7 @@ _MD_ParseExpr_(_MD_NodeParseCtx *ctx, int precedence_in)
|
||||
|
||||
_MD_NodeParse_Next(ctx);
|
||||
|
||||
MD_C_Expr *right = _MD_ParseExpr_(ctx, precedence+1);
|
||||
MD_C_Expr *right = _MD_ParseExpr_(arena, ctx, precedence+1);
|
||||
if(MD_C_ExprIsNil(right))
|
||||
{
|
||||
// TODO(rjf): Error: "Expected right-hand-side of binary expression."
|
||||
@@ -375,7 +374,7 @@ _MD_ParseExpr_(_MD_NodeParseCtx *ctx, int precedence_in)
|
||||
}
|
||||
|
||||
MD_C_Expr *left = expr;
|
||||
expr = MD_C_MakeExpr(op_node, expr_kind, left, right);
|
||||
expr = MD_C_MakeExpr(arena, op_node, expr_kind, left, right);
|
||||
expr->sub[0] = left;
|
||||
expr->sub[1] = right;
|
||||
}
|
||||
@@ -386,22 +385,22 @@ _MD_ParseExpr_(_MD_NodeParseCtx *ctx, int precedence_in)
|
||||
return expr;
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseExpr(_MD_NodeParseCtx *ctx)
|
||||
MD_FUNCTION_IMPL MD_C_Expr *
|
||||
_MD_ParseExpr(MD_Arena *arena, _MD_NodeParseCtx *ctx)
|
||||
{
|
||||
return _MD_ParseExpr_(ctx, 1);
|
||||
return _MD_ParseExpr_(arena, ctx, 1);
|
||||
}
|
||||
|
||||
MD_FUNCTION_IMPL MD_C_Expr *
|
||||
MD_C_ParseAsExpr(MD_Node *first, MD_Node *opl)
|
||||
MD_C_ParseAsExpr(MD_Arena *arena, MD_Node *first, MD_Node *opl)
|
||||
{
|
||||
_MD_NodeParseCtx ctx_ = { first, opl };
|
||||
_MD_NodeParseCtx *ctx = &ctx_;
|
||||
return _MD_ParseExpr(ctx);
|
||||
return _MD_ParseExpr(arena, ctx);
|
||||
}
|
||||
|
||||
MD_FUNCTION_IMPL MD_C_Expr *
|
||||
MD_C_ParseAsType(MD_Node *first, MD_Node *opl)
|
||||
MD_C_ParseAsType(MD_Arena *arena, MD_Node *first, MD_Node *opl)
|
||||
{
|
||||
MD_C_Expr *expr = MD_C_NilExpr();
|
||||
MD_C_Expr *last_expr = expr;
|
||||
@@ -416,28 +415,29 @@ MD_C_ParseAsType(MD_Node *first, MD_Node *opl)
|
||||
{
|
||||
if(_MD_NodeParse_Consume(ctx, MD_S8Lit("*"), &ptr))
|
||||
{
|
||||
MD_C_Expr *t = MD_C_MakeExpr(ptr, MD_C_ExprKind_Pointer, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
MD_C_Expr *t = MD_C_MakeExpr(arena, ptr, MD_C_ExprKind_Pointer,
|
||||
MD_C_NilExpr(), MD_C_NilExpr());
|
||||
_MD_PushType(t);
|
||||
}
|
||||
else if(_MD_NodeParse_Consume(ctx, MD_S8Lit("volatile"), &node))
|
||||
{
|
||||
MD_C_Expr *t = MD_C_MakeExpr(node, MD_C_ExprKind_Volatile, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
MD_C_Expr *t = MD_C_MakeExpr(arena, node, MD_C_ExprKind_Volatile, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
_MD_PushType(t);
|
||||
}
|
||||
else if(_MD_NodeParse_Consume(ctx, MD_S8Lit("const"), &node))
|
||||
{
|
||||
MD_C_Expr *t = MD_C_MakeExpr(node, MD_C_ExprKind_Const, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
MD_C_Expr *t = MD_C_MakeExpr(arena, node, MD_C_ExprKind_Const, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
_MD_PushType(t);
|
||||
}
|
||||
else if(_MD_NodeParse_ConsumeSet(ctx, &set))
|
||||
{
|
||||
MD_C_Expr *t = MD_C_MakeExpr(set, MD_C_ExprKind_Array, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
t->sub[1] = MD_C_ParseAsExpr(set->first_child, set->last_child);
|
||||
MD_C_Expr *t = MD_C_MakeExpr(arena, set, MD_C_ExprKind_Array, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
t->sub[1] = MD_C_ParseAsExpr(arena, set->first_child, set->last_child);
|
||||
_MD_PushType(t);
|
||||
}
|
||||
else if(_MD_NodeParse_ConsumeAtom(ctx, &base_type))
|
||||
{
|
||||
MD_C_Expr *t = MD_C_MakeExpr(base_type, MD_C_ExprKind_Atom, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
MD_C_Expr *t = MD_C_MakeExpr(arena, base_type, MD_C_ExprKind_Atom, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
_MD_PushType(t);
|
||||
}
|
||||
else
|
||||
@@ -600,7 +600,7 @@ MD_C_Generate_Expr(FILE *file, MD_C_Expr *expr)
|
||||
}
|
||||
}
|
||||
|
||||
MD_PRIVATE_FUNCTION_IMPL MD_b32
|
||||
MD_FUNCTION_IMPL MD_b32
|
||||
_MD_OutputType_C_NeedsParens(MD_C_Expr *type)
|
||||
{
|
||||
MD_b32 result = 0;
|
||||
@@ -704,7 +704,7 @@ MD_C_Generate_Decl(FILE *file, MD_Node *node)
|
||||
{
|
||||
if(node)
|
||||
{
|
||||
MD_C_Expr *type = MD_C_ParseAsType(node->first_child, node->last_child);
|
||||
MD_C_Expr *type = MD_C_ParseAsType(MD_Scratch(), node->first_child, node->last_child);
|
||||
MD_C_Generate_DeclByNameAndType(file, node->string, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,10 @@ MD_FUNCTION MD_b32 MD_C_ExprIsNil(MD_C_Expr *expr);
|
||||
MD_FUNCTION MD_C_ExprKind MD_C_PreUnaryExprKindFromNode(MD_Node *node);
|
||||
MD_FUNCTION MD_C_ExprKind MD_C_BinaryExprKindFromNode(MD_Node *node);
|
||||
MD_FUNCTION MD_C_ExprPrec MD_C_ExprPrecFromExprKind(MD_C_ExprKind kind);
|
||||
MD_FUNCTION MD_C_Expr * MD_C_MakeExpr(MD_Node *node, MD_C_ExprKind kind, MD_C_Expr *left, MD_C_Expr *right);
|
||||
MD_FUNCTION MD_C_Expr * MD_C_ParseAsExpr(MD_Node *first, MD_Node *opl);
|
||||
MD_FUNCTION MD_C_Expr * MD_C_ParseAsType(MD_Node *first, MD_Node *opl);
|
||||
MD_FUNCTION MD_C_Expr * MD_C_MakeExpr(MD_Arena *arena, MD_Node *node, MD_C_ExprKind kind,
|
||||
MD_C_Expr *left, MD_C_Expr *right);
|
||||
MD_FUNCTION MD_C_Expr * MD_C_ParseAsExpr(MD_Arena *arena, MD_Node *first, MD_Node *opl);
|
||||
MD_FUNCTION MD_C_Expr * MD_C_ParseAsType(MD_Arena *arena, MD_Node *first, MD_Node *opl);
|
||||
MD_FUNCTION MD_i64 MD_C_EvaluateExpr_I64(MD_C_Expr *expr);
|
||||
MD_FUNCTION MD_f64 MD_C_EvaluateExpr_F64(MD_C_Expr *expr);
|
||||
MD_FUNCTION MD_b32 MD_C_ExprMatch(MD_C_Expr *a, MD_C_Expr *b, MD_MatchFlags flags);
|
||||
|
||||
@@ -73,20 +73,20 @@ MakeTestNode(MD_NodeKind kind, MD_String8 string)
|
||||
static MD_C_Expr *
|
||||
AtomExpr(char *str)
|
||||
{
|
||||
return MD_C_MakeExpr(MakeTestNode(MD_NodeKind_Main, MD_S8CString(str)),
|
||||
return MD_C_MakeExpr(arena, MakeTestNode(MD_NodeKind_Main, MD_S8CString(str)),
|
||||
MD_C_ExprKind_Atom, MD_C_NilExpr(), MD_C_NilExpr());
|
||||
}
|
||||
|
||||
static MD_C_Expr *
|
||||
BinOpExpr(MD_C_ExprKind kind, MD_C_Expr *left, MD_C_Expr *right)
|
||||
{
|
||||
return MD_C_MakeExpr(MD_NilNode(), kind, left, right);
|
||||
return MD_C_MakeExpr(arena, MD_NilNode(), kind, left, right);
|
||||
}
|
||||
|
||||
static MD_C_Expr *
|
||||
TypeExpr(MD_C_ExprKind kind, MD_C_Expr *sub)
|
||||
{
|
||||
return MD_C_MakeExpr(MD_NilNode(), kind, sub, MD_C_NilExpr());
|
||||
return MD_C_MakeExpr(arena, MD_NilNode(), kind, sub, MD_C_NilExpr());
|
||||
}
|
||||
|
||||
static MD_b32
|
||||
@@ -100,7 +100,7 @@ static MD_b32
|
||||
MatchParsedWithExpr(MD_String8 string, MD_C_Expr *expr)
|
||||
{
|
||||
MD_ParseResult parse = MD_ParseOneNode(arena, string, 0);
|
||||
MD_C_Expr *parse_expr = MD_C_ParseAsExpr(parse.node->first_child, parse.node->last_child);
|
||||
MD_C_Expr *parse_expr = MD_C_ParseAsExpr(arena, parse.node->first_child, parse.node->last_child);
|
||||
return MD_C_ExprDeepMatch(expr, parse_expr, 0);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ static MD_b32
|
||||
MatchParsedWithType(MD_String8 string, MD_C_Expr *expr)
|
||||
{
|
||||
MD_ParseResult parse = MD_ParseOneNode(arena, string, 0);
|
||||
MD_C_Expr *parse_expr = MD_C_ParseAsType(parse.node->first_child, parse.node->last_child);
|
||||
MD_C_Expr *parse_expr = MD_C_ParseAsType(arena, parse.node->first_child, parse.node->last_child);
|
||||
return MD_C_ExprDeepMatch(expr, parse_expr, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user