Implement various SH_ instructions

Implement various shorthand instructions introduced in Alice 2010. This
is enough to get through the first scene in Haru Urare.
This commit is contained in:
Nunuhara Cabbage
2021-05-09 20:53:32 -07:00
parent 74230869ae
commit 2365fb3a01
6 changed files with 368 additions and 44 deletions
+2
View File
@@ -63,6 +63,8 @@ bool string_index_valid(int index);
struct page *heap_get_page(int index);
struct string *heap_get_string(int index);
void heap_set_page(int slot, struct page *page);
void heap_string_assign(int slot, struct string *string);
void heap_struct_assign(int lval, int rval);
int32_t heap_alloc_page(struct page *page);
int32_t heap_alloc_string(struct string *s);
+20
View File
@@ -61,6 +61,26 @@ struct page {
union vm_value values[];
};
static inline union vm_value page_get_var(struct page *page, int i)
{
#ifdef DEBUG_HEAP
if (i < 0 || i >= page->nr_vars)
VM_ERROR("Invalid page index: %d", i);
#endif
return page->values[i];
}
static inline void _page_set_var(struct page *page, int i, union vm_value v)
{
#ifdef DEBUG_HEAP
if (i < 0 || i >= page->nr_vars)
VM_ERROR("Invalid page index: %d", i);
#endif
page->values[i] = v;
}
#define page_set_var(page, i, v) _page_set_var(page, i, vm_value_cast(v))
// variables
union vm_value variable_initval(enum ain_data_type type);
void variable_fini(union vm_value v, enum ain_data_type type);