More info... notice how it works perfectly fine if i generate a STRING array:
#COMPILE EXE
#COMPILER OXYGEN
#OPTIONS X64
#DIM ALL
GLOBAL RK() as STRING
FUNCTION PBMAIN() AS LONG
DIM RK(10)
RK(1) = "22"
PRINTBR RK(1)
END FUNCTION
Generated code:
'Generated with PluriBASIC 6.0.123201.0
$ filename "C:\Users\Diamante\Documents\PluriBASIC\projects\pluridll\overflow.exe"
uses rtl64
#def __dim1 (d1-bnd[1])
#def __dim2 (d2-bnd[3])
#def __dim3 (d3-bnd[5])
#def __class_name_define class _arr_%1
Declare Function PluriBASICMessageBox Lib "user32.dll" Alias "MessageBoxA"
' STARTS PLURIBASIC_PREPARE.BIN
' This code is executed before anything else, if you want to do something after defining other things, see PLURIBASIC_INIT
' END OF PLURIBASIC_PREPARE.BIN
' STARTS ARRAY_DIM.BIN
macro __declare_array_ndtt(dtype)
__class_name_define(dtype)
public dtype t ' for use with typeof on this array.
int dims ' Number of dimensions
int elems ' Number of elements.
int elemsize ' Number of elements.
int slength ' length of strings.
int ispointer ' is pointer flag.
sys hBuffer ' Address of the buffer
sys hCustAddr ' Address provided by the inline code.
int BuffLen ' length of the buffer in bytes
string dtType ' Data type for the array.
int iType ' Data type ID for the array.
int elemsize ' Data type size.
int dimensioned' -1 if dimensioned.
int Head ' size of the array header
int bnd[10] ' bounds.
function redim(int pr, int * d, n)
int i
dimensioned = -1
int ne = 1
for i = 1 to n step 2
bnd[i+0] = d[i+0]
bnd[i+1] = d[i+1]
ne *= ((d[i+1]+1)-d[i+0])
next
if ne < elems then
if dtType = "STR" then
if hBuffer then
dtype dt at (hBuffer + head)
for i = ne+1 to elems
frees dt(i)
next
end if
end if
end if
elems = ne
int nBufLen
nBufLen = (elems * sizeof(sys)) + head + 32
sys nBuffer = getmemory(nBufLen)
int eBfCopy = BuffLen
if BuffLen
if BuffLen>nBufLen then
eBfCopy = nBufLen
end if
copy nBuffer, hBuffer, eBfCopy
freememory hBuffer
endif
hBuffer = nBuffer
BuffLen = nBufLen
end function
method constructor(int * d, n, isptr, slen, string dtyp, int dtID, int dtSize, sys hAddr)
head = 0
ispointer = isptr
dtType = dtyp
slength = slen
hCustAddr = hAddr
iType = dtID
elemsize = dtSize
dims = n / 2
if n > -1 then
this.redim(0, d, n)
end if
end method
function destructor()
int i
if (dtType = "STR") then
dtype dt at (hBuffer + head)
for i = 0 to elems
frees dt(i)
next
end if
freememory(hBuffer)
hBuffer = 0
BuffLen = 0
end function
function b() as string
return ""
end function
'======================================================================
function c(int d1, dtype v)
dtype dt at (hBuffer + head)
print "setting"
dt(__dim1) = v
end function
function c(int d1) as dtype
dtype dt at (hBuffer + head)
print "getting"
return dt(__dim1)
end function
function c(int d1, d2, dtype v)
dtype dt at (hBuffer + head)
dt(__dim1 * __dim2) = v
end function
function c(int d1, d2) as dtype
dtype dt at (hBuffer + head)
return dt(__dim1 * __dim2)
end function
function c(int d1, d2, d3, dtype v)
dtype dt at (hBuffer + head)
dt(__dim1 * __dim2 + __dim3) = v
end function
function c(int d1, d2, d3) as dtype
dtype dt at (hBuffer + head)
return dt(__dim1 * __dim2 + __dim3)
end function
'======================================================================
function p(int d1) as dtype*
dtype dt at (hBuffer + head)
return @dt(__dim1)
end function
function p(int d1, d2) as dtype*
dtype dt at (hBuffer + head)
return @dt(__dim1 * __dim2)
end function
function p(int d1, d2, d3) as dtype*
dtype dt at (hBuffer + head)
return @dt(__dim1 * __dim2 + __dim3)
end function
'======================================================================
function strptr(int d1) as sys
dtype dt at (hBuffer + head)
int i = __dim1
return strptr(dt(i))
end function
function strptr(int d1, d2) as sys
dtype dt at (hBuffer + head)
int i = __dim1 * __dim2
return strptr(dt(i))
end function
function strptr(int d1, d2, d3) as sys
dtype dt at (hBuffer + head)
int i = __dim1 * __dim2 + __dim3
return strptr(dt(i))
end function
'======================================================================
function lbound(int d) as int
return bnd[d]
end function
function ubound(int d) as int
return bnd[d+1]
end function
function arrayattr(int d) as int
// not yet implemented.
if d = 0 then return dimensioned
if d = 1 then return iType
if d = 2 then return ispointer
if d = 3 then return dims
if d = 4 then return elems
if d = 5 then return elemsize
return 0
end function
end class
end macro
' END OF ARRAY_DIM.BIN
' STARTS PRINTR.BIN
' STARTS MSGBOX.BIN
FUNCTION MSGBOX(string sText, sys mOptions = 0, string sCaption = "PluriBASIC") AS LONG
FUNCTION = PluriBASICMessageBox(0, sText, sCaption, mOptions)
END FUNCTION
' END OF MSGBOX.BIN
' CONTINUES (1) PRINTR.BIN
macro PRINTR(p1, p2)
MSGBOX(p1 + p2)
end macro
' END OF PRINTR.BIN
' STARTS PLURIBASIC_INIT.BIN
' This code is executed before anything else, if you want to do something before nything else, see PLURIBASIC_PREPARE
' END OF PLURIBASIC_INIT.BIN
' STARTS CALLBACKDATA.BIN
' END OF CALLBACKDATA.BIN
' SYSTEM DECLARES FOR ARRAYS
__declare_array_ndtt(bstring)
DECLARE FUNCTION PBMAIN() AS LONG
new _arr_bstring rk(int{0, 0}, -1, 0, 0, "STR", 23, 4, 0)
' Initializes various things in the script.
FUNCTION PluriBASIC_Initialize() AS LONG
END FUNCTION
FUNCTION PBMAIN() AS INT
INT _05FUNCTION = 0
rk.redim(0, int{0, 10}, countof)
rk.c(1) = "22"
PRINTR(rk.c(1), "</br>")
END FUNCTION
PBMAIN() ' invoke entry point