\r
For(Int i = 0, i < n, i++)\r
{\r
- total += *p;\r
-\r
- p = Pointer<Int>(Pointer<Byte>(p) + sizeof(int));\r
+ total += p[i];\r
}\r
\r
Return(total);\r
{\r
if(state.operation == ADD)\r
{\r
- total += *p;\r
+ total += p[i];\r
}\r
else if(state.operation == SUBTRACT)\r
{\r
- total -= *p;\r
+ total -= p[i];\r
}\r
else if(state.operation == AND)\r
{\r
- total &= *p;\r
+ total &= p[i];\r
}\r
else if(...)\r
{\r
...\r
}\r
-\r
- p = Pointer<Int>(Pointer<Byte>(p) + sizeof(int));\r
}\r
\r
Return(total);\r
RValue<Pointer<T>> operator=(const Reference<Pointer<T>> &rhs) const;
Reference<T> operator*();
+ Reference<T> operator[](int index);
+ Reference<T> operator[](RValue<Int> index);
static llvm::Type *getType();
Reference<T> operator[](int index);
Reference<T> operator[](RValue<Int> index);
- Reference<T> operator[](RValue<UInt> index);
};
// RValue<Array<T>> operator++(const Array<T> &val, int); // Post-increment
}
template<class T>
+ Reference<T> Pointer<T>::operator[](int index)
+ {
+ llvm::Value *element = Nucleus::createGEP(LValue::loadValue(), (llvm::Value*)Nucleus::createConstantInt(index));
+
+ return Reference<T>(element, alignment);
+ }
+
+ template<class T>
+ Reference<T> Pointer<T>::operator[](RValue<Int> index)
+ {
+ llvm::Value *element = Nucleus::createGEP(LValue::loadValue(), index.value);
+
+ return Reference<T>(element, alignment);
+ }
+
+ template<class T>
llvm::Type *Pointer<T>::getType()
{
return Nucleus::getPointerType(T::getType());
return Reference<T>(element);
}
- template<class T, int S>
- Reference<T> Array<T, S>::operator[](RValue<UInt> index)
- {
- llvm::Value *element = LValue::getAddress(index.value);
-
- return Reference<T>(element);
- }
-
// template<class T>
// RValue<Array<T>> operator++(const Array<T> &val, int)
// {