This commit is contained in:
Andre Wagner
2026-05-16 12:14:11 -05:00
parent 4d7282a30b
commit d4aa83869c
7 changed files with 76 additions and 14 deletions

View File

@@ -39,6 +39,9 @@ TycheVM* tyc_new(void)
.cap = 4,
.sz = 0,
};
expr_init();
return t;
}
@@ -177,13 +180,16 @@ TYC_RESULT tyc_tointeger(TycheVM* T, int idx, int32_t* value)
return r;
}
TYC_RESULT tyc_expr(TycheVM* T, TYC_EXPR expr)
TYC_RESULT tyc_expr(TycheVM* T, TYC_EXPR op)
{
// TODO
VALUE v1, v2;
TYC_RESULT r;
VALUE v1, v2, result;
stack_pop(T->stack, &v2);
stack_pop(T->stack, &v1);
stack_push(T->stack, create_value_integer(value_integer(v1) + value_integer(v2)));
TRY(binary_expr(op, v1, v2, &result))
stack_push(T->stack, result);
return T_OK;
}
@@ -203,13 +209,24 @@ static TYC_RESULT step(TycheVM* T)
switch (inst.operator) {
//
// stack manipulation
//
case TO_PUSHI:
tyc_pushinteger(T, inst.operand);
break;
case TO_SUM:
TRY(tyc_expr(T, TX_SUM))
break;
//
// expressions
//
case TO_SUM: TRY(tyc_expr(T, TX_SUM)); break;
case TO_SUB: TRY(tyc_expr(T, TX_SUBTRACT)); break;
//
// function calls
//
case TO_RET:
TRY(stack_pop(T->stack, &a))