Add asm_assert

This commit is contained in:
Felipe Martinez 2024-07-07 12:51:13 +00:00
parent f173f1b1d5
commit 350567a6d2
2 changed files with 24 additions and 10 deletions

View file

@ -126,7 +126,7 @@ void ASM::run() {
case SetLabelText: {
Value str = pop();
assert(str.type == String);
Value obj = pop(); // TODO: Check type
Value obj = pop(LvglObject);
lv_label_set_text(obj.data.obj, str.data.s);
break;
@ -141,7 +141,7 @@ void ASM::run() {
int16_t y = pop_uint32();
int16_t x = pop_uint32();
uint8_t align = pop_uint32();
Value obj = pop(); // TODO: Check type
Value obj = pop(LvglObject);
lv_obj_align(obj.data.obj, lv_scr_act(), align, x, y);
break;
}
@ -153,7 +153,7 @@ void ASM::run() {
uint32_t value = pop_uint32();
uint32_t prop = pop_uint32();
uint32_t part = pop_uint32();
Value obj = pop(); // TODO: Check type
Value obj = pop(LvglObject);
switch (opcode) {
case SetStyleLocalInt:
@ -200,3 +200,11 @@ void ASM::run() {
void ASM::Refresh() {
run();
}
void ASM::asm_assert(bool condition) {
if (!condition) {
// TODO: Handle better
for (;;) {
}
}
}

View file

@ -74,7 +74,7 @@ namespace Pinetime {
SetStyleLocalColor,
SetStyleLocalOpa,
SetStyleLocalFont,
WaitRefresh,
WaitRefresh
};
enum OpcodeLong : uint16_t {};
@ -94,20 +94,26 @@ namespace Pinetime {
uint8_t stack_pointer = 0;
void run();
void asm_assert(bool condition);
Value pop() {
assert(stack_pointer > 0);
asm_assert(stack_pointer > 0);
return stack[--stack_pointer];
}
Value pop(DataType type) {
asm_assert(stack_pointer > 0);
Value v = stack[--stack_pointer];
asm_assert(v.type == type);
return v;
}
uint32_t pop_uint32() {
Value v = pop();
assert(v.type == Integer);
return v.data.i;
return pop(Integer).data.i;
}
void push(Value v) {
assert(stack_pointer < stack_size);
asm_assert(stack_pointer < stack_size);
stack[stack_pointer] = v;
stack_pointer++;
}