[chuck-dev] fixed multi array accesses (PATCH)

Robin Haberkorn robin.haberkorn at googlemail.com
Tue Sep 4 20:44:41 EDT 2012


Hi again,

nice to see that ChucK development is moving on rapidly and will move to
Github soon. Will send you pull requests then :-)

Here's a patch that fixes multi array accesses involving map accesses.
Previously a Chuck_Instr_Array_Access_Multi was emitted for every multi
array access even though the instruction cannot handle map keys.

Test case:

string a[0][2];

new string[2] @=> a["foo"];
new string[2] @=> a["bar"];

"23" => a["foo"][0];
"24" => a["foo"][1];
"32" => a["bar"][0];
"42" => a["bar"][1];

for (0 => int i; i < 2; i++)
	<<< a["foo"][i], a["bar"][i] >>>;

will die with an ArrayOutofBounds error.

Workaround for version <= 1.3.0.2:

string a[0][2];

new string[2] @=> a["foo"];
new string[2] @=> a["bar"];

"23" => (a["foo"])[0];
"24" => (a["foo"])[1];
"32" => (a["bar"])[0];
"42" => (a["bar"])[1];

for (0 => int i; i < 2; i++)
	<<< (a["foo"])[i], (a["bar"])[i] >>>;

will result in both a map access and normal (int) access instruction.

My patch revises the way access instructions are generated so the first
test case works flawlessly.
One can be applied on ChucK v1.3.0.2; the other one is an updated
version of my 64-bit array patch (still using it until next release) and
finally there's a version based on SVN trunk.

Hope to contribute on a regular basis from now on. I do really want to
use ChucK for my "music" project and I need it stable and a lot faster...

Best regards,
Robin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chuck-1.3.0.2-64-bit-arrays.patch
Type: text/x-patch
Size: 90615 bytes
Desc: not available
URL: <http://lists.cs.princeton.edu/pipermail/chuck-dev/attachments/20120905/1ddfa16e/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chuck-1.3.0.2-fixed-multi-array-access.patch
Type: text/x-patch
Size: 10247 bytes
Desc: not available
URL: <http://lists.cs.princeton.edu/pipermail/chuck-dev/attachments/20120905/1ddfa16e/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chuck-svn-fixed-multi-array-access.patch
Type: text/x-patch
Size: 9757 bytes
Desc: not available
URL: <http://lists.cs.princeton.edu/pipermail/chuck-dev/attachments/20120905/1ddfa16e/attachment-0005.bin>


More information about the chuck-dev mailing list