Now it should be possible to do this:
const SOME_VAL = 1;
emit const.pri -SOME_VAL
or this:
static some_array[] = { 0, 1, 2, 3, 4, 5 };
static some_var;
emit { const.pri some_var };
new some_var_offset = emit { add.c -some_array };
Example:
main()
{
new x;
emit load.pri x
}
Before this commit:
error 017: undefined symbol "x"
After:
error 001: expected token: "-data offset-", but found "-local variable-"
This changes the way 'switch', 'casetbl' and 'case' are handled; now 'casetbl' can't be used directly and the arguments for the first case table entry (the number of entries and 'default' label) are specified to 'switch'.
Example:
emit
{
load.s.pri my_var
switch 3 lbl_deafult
case 0 lbl_0
case 2 lbl_2
case 4 lbl_4
}
Add a new "dumpn" pseudo-opcode that dumps N copies of the same value
to the stage buffer. It's basically the same as "dump" but much faster
when dumping the same value a lot of times, for example, when writing
initial values for large arrays.
On my Linux system the time it took to dump a 100000000 cell array went
down from 20 to 8 seconds in Release configuration, i.e. 2.5 times faster!
I haven't profiled further yet (Visual Studio 2017 profiler is broken,
gprof won't output anything (I'm probably doing it wrong), I might try
valgrind later).
static const Test[2][][2] = { { { 9, 8 } }, { { 6, 7 } } };
The above code causes a memory corruption as the compiler does not
correctly calculate the size of the array.
This commit adds code to fix it.
Solves the bug described in issue #117
new [][2][3] = { //default values };
The compiler does not create enough room for the indirection tables and
hence adjust_indirectiontables overwrites the default values leaving the
array wrongly initilized.
Adds a generic code which works for any n-dimensional arrays (n = 1,
2,3,4,5... infinity). The code fixes the issue for any dimension but the
number of dimensions is limited to 4 (sDIMEN_MAX). A review of this code
won't be required if the limit is increased in the future.