WitchLord said:
Nice work. I look forward to seeing the implementation.
PshVPtr is OK, assuming the range object is always a local variable.
To get rid of the Warning, you need to tell the compiler that the variable 'i' is initialized, by setting sVariable::isInitialized = true for the ‘i’ variable.
- So the
PshVPtr
solution might have problem with a global variable as range object? If the global variable is a problem, is there any better solution? - I added code to tell the variable is initialized. Now the compiler won't complain about this.
I also added code to resolve the auto type using the return type of opForValue
. Thus, the scripter can write code like this
foreach(auto i : range)
// Do something. Don't care about the element type of range
However, I tried to implement a reference type for iteration, in order to support script like
foreach(int& i : range)
i = some_function(i); // Modifying the element
But I found that asCParser::ParseType
cannot parse a reference type. Should I combine it with the asCParser::ParseTypeMod
and add corresponding compiler code to support reference in foreach loop?