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

Ben Clifford benc at hawaga.org.uk
Fri Jun 29 20:24:58 CDT 2007


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