Skip to content

Commit

Permalink
Implement _CLngPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
a740g committed Nov 27, 2024
1 parent bb82976 commit 6db75fe
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
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@_CONSOLEFONT@_CONSOLEINPUT@_CONSOLETITLE@_CONTINUE@_CONTROLCHR@_COPYIMAGE@_COPYPALETTE@_COSH@_COT@_COTH@_CRC32@_CSC@_CSCH@_CV@_CWD$@" +_
"_C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_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 }

0 comments on commit 6db75fe

Please sign in to comment.