[Swift-devel] a different way to do array/structure accesses

Mihael Hategan hategan at mcs.anl.gov
Fri Jun 29 20:36:59 CDT 2007


VDLFunction.parsePath(Object, VariableStack) is probably somewhat
related.

I think the problem was that paths with indices were sometimes
non-static, which was an exception to what the compiler was initially
doing, so it was easier at the time to push things into the above
function.

It should be fixed, but sensible reduction should be applied.

Mihael



On Sat, 2007-06-30 at 01:24 +0000, Ben Clifford wrote:
> I rememebred why I was poking round this way in the first place.
> 
> The present implementation takes expressions like a[2] and passes them all 
> the way through to the karajan layer, where the vdl runtime library code 
> interprets the 2:
> 
>    <print>
>      <parallel>
>        <vdl:getfield var="{a}" path="[2]"/>
>      </parallel>
>    </print>
> 
> But this doesn't work in the case where 2 becomes a more complex 
> expression, such as a[2+2].
> 
> Accesses like a[2+2] or a[i+1] don't seem to work at all at the moment. 
> (that's bug 54).
> 
> I don't want to put a complete SwiftScript parser/evaluator in the runtime 
> library, so I think in the case where array accesses are not simple 
> variable names or constants, the code should break up array accesses into 
> separate getfield calls so that the same code can be generated for that 
> indexing expression as when that expression is used elsewhere.
> 
> However, it doesn't need to do this for simple accesses (simple variable 
> names and or constants) if the present path handling is also retained - 
> that's more complication at the compiler layer but it sounds like its 
> needed.
> 




More information about the Swift-devel mailing list