Commit Graph
12 Commits
Author SHA1 Message Date
Nunuhara Cabbage 91af527def Implement A_FIND instruction
This one is not supported by the SDK compiler, so no automated tests.
2019-11-30 15:47:06 -08:00
Nunuhara Cabbage b11319eb66 Initialize struct members with variable_initval
Fix bug where ref members were initialized to 0 instead of -1 (NULL).
2019-11-30 11:57:29 -08:00
Nunuhara Cabbage 6039ab9bd0 Fix multiple VM memory leaks
Also implement a feature to track leaked heap memory (DEBUG_HEAP).

With this, it is now possible to hold CTRL through the entire Rance II
digest version without crashing.
2019-11-27 18:11:07 -08:00
Nunuhara Cabbage a40467fe92 Allocate global structs before calling ctors
Global constructors can write to other global structs, so memory must be
allocated for all global structs before any constructors are called.
2019-11-25 18:40:49 -08:00
Nunuhara Cabbage 0e54f24941 Initialize ref variables to -1 (NULL) 2019-11-16 14:49:06 -08:00
Nunuhara Cabbage 9dfc6c480c Fix segfault when copying struct with array member
If the array member is unallocated, its page is NULL. So we have to
handle this case in copy_page.
2019-11-15 19:40:24 -08:00
Nunuhara Cabbage d3de009e1d Import CG reading code from xsystem35
Plus a bit of SACT2 implementation, and fix a bug where global arrays
were not initialized properly.
2019-11-15 19:01:08 -08:00
Nunuhara Cabbage ec9ab8954c Distinguish between global/local pages
Fix bug when calling variable_type on global variable (e.g. in A_ALLOC
on global).
2019-11-08 22:02:47 -08:00
Nunuhara Cabbage 470c051124 Implement full suite of array instructions
All array instructions supported by the SDK compiler, anyway. There are
a few instructions that were added in later versions, like A_FIND and
A_REVERSE.
2019-10-28 20:31:50 -07:00
Nunuhara Cabbage 33ec7a34e1 Basic arrays implementation
Just .Alloc() and .Free() for now.
2019-10-22 17:33:26 -07:00
Nunuhara Cabbage ac5859adfe Allocate all pages with malloc
Local pages need to be reference counted like any other page. It is
possible to create references to local variables which escape the extent
of their function call, so using a stack doesn't work.

Caching is implemented for small page sizes to avoid invoking
malloc/free on every function call.
2019-10-21 18:54:36 -07:00
Nunuhara Cabbage e5ef9f4d2d Implement constructors and methods
Implement CALLMETHOD, SH_STRUCTREF and PUSHSTRUCTPAGE instructions.

Constructors are a bit tricky since SH_LOCALCREATE has to implicitly
call an arbitrary number of functions before it returns (just changing
the instruction pointer only allows for calling a single function).

To get around this, there is now a vm_call() function which is used to
call a function synchronously, before returning from the current
instruction.

Methods are implemented as functions, except that they get a struct page
as local variable -1.

Destructors are still not implemented.
2019-10-20 17:33:22 -07:00