Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_CLngPtr pseudo-function #580

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion source/subs_functions/subs_functions.bas
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,20 @@ SUB reginternal
clearid
id.n = "_Continue": id.subfunc = 2: id.callname = "sub_stub": regid

clearid
id.n = "_CLngPtr"
id.subfunc = 1
id.args = 1
id.arg = MKL$(UOFFSETTYPE - ISPOINTER)
id.ret = UINTEGER64TYPE - ISPOINTER
id.hr_syntax = "_CLngPtr(offsetValue)"
regid

clearid
id.n = "_IIf"
id.subfunc = 1
id.args = 3
id.arg = MKL$(OFFSETTYPE - ISPOINTER) + MKL$(STRINGTYPE - ISPOINTER) + MKL$(STRINGTYPE - ISPOINTER) ' overridden in qb64pe.bas
id.specialformat = "?,?,?"
id.ret = STRINGTYPE - ISPOINTER ' overridden in qb64pe.bas
id.hr_syntax = "_IIF(expression, truePart, falsePart)"
regid
Expand Down
2 changes: 1 addition & 1 deletion source/subs_functions/syntax_highlighter_list.bas
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ listOfKeywords$ = listOfKeywords$ +_

' [C] - Keywords alphabetical (1st line = QB64, 2nd line = QB4.5, 3rd line = OpenGL)
listOfKeywords$ = listOfKeywords$ +_
"_CAPSLOCK@_CEIL@_CINP@_CLEAR@_CLEARCOLOR@_CLIP@_CLIPBOARD$@_CLIPBOARDIMAGE@_CLOCKWISE@_COLORCHOOSERDIALOG@_COMMANDCOUNT@_CONNECTED@_CONNECTIONADDRESS@_CONNECTIONADDRESS$@_CONSOLE@_CONSOLECURSOR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LCOLOR4UIV@_GLCOLOR4US@_GLCOLOR4USV@_GLCOLORMASK@_GLCOLORMATERIAL@_GLCOLORPOINTER@_GLCOPYPIXELS@_GLCOPYTEXIMAGE1D@_GLCOPYTEXIMAGE2D@_GLCOPYTEXSUBIMAGE1D@_GLCOPYTEXSUBIMAGE2D@_GLCULLFACE@"

Expand Down
33 changes: 33 additions & 0 deletions tests/compile_tests/clngptr/clngptr_test.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$CONSOLE:ONLY
OPTION _EXPLICIT

DIM myArray(1 TO 10) AS LONG
DIM i AS LONG

FOR i = LBOUND(myArray) TO UBOUND(myArray)
myArray(i) = 2 ^ i
NEXT i

PrintArray myArray()

DIM arrMem AS _MEM: arrMem = _MEM(myArray())

FOR i = 0 TO (_CLNGPTR(arrMem.SIZE) \ _SIZE_OF_LONG) - 1
_MEMPUT arrMem, arrMem.OFFSET + (i * _SIZE_OF_LONG), i + 1 AS LONG
NEXT i

_MEMFREE arrMem

PrintArray myArray()

SYSTEM

SUB PrintArray (arr() AS LONG)
DIM i AS LONG

PRINT "Array("; LBOUND(arr); "To"; UBOUND(arr); ") = {";
FOR i = LBOUND(arr) TO UBOUND(arr)
PRINT arr(i); _IIF(i < UBOUND(arr), ",", "");
NEXT i
PRINT "}"
END SUB
2 changes: 2 additions & 0 deletions tests/compile_tests/clngptr/clngptr_test.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Array( 1 To 10 ) = { 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 }
Array( 1 To 10 ) = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }