Saturday, August 18, 2012

Tuesday, August 7, 2012

Multidimensional indexing and end

This week I added support for multidimensional matrix indexing and using end in jit. Support for the end keyword is interesting. Take the following for example,
y = A(1, sin (end));
From that line alone, it is not clear what end refers to. If sin is a matrix, then end will be the end of sin. If sin is a function, then end will be the end of A.

I have solved this problem by keeping track of the full context information for each end. Lets take a look at a slightly more complicated example
y = A(1, 2, B(sin (end), 5));
then during type inference our context might look something like this
type     identifier index count
function sin        0     1
matrix   B          0     2
matrix   A          2     4
In this context end then refers to the end of matrix B at index 0.