Skip to content
Merged
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
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Version 1.06.0
- #880: Overload binary operators now support covariant arguments, overloaded procedure resolution changed especially with respect to CONST and non-CONST parameters
- Fix for debugging lines in include files but not in procedures. Filename debugging information added for module level statements in included files.
- #699: fix new[0] causing infinite loop when calling constructor/destructor list
- #883: when mapping 32 & 64 bit functions for PALETTE [GET] USING, check the data type pointed to and choose one of LONG PTR, LONGINT PTR, INTEGER PTR


Version 1.05.0
Expand Down
16 changes: 14 additions & 2 deletions src/compiler/parser-quirk-gfx.bas
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ end function
''
function cGfxPalette as integer
dim as ASTNODE ptr arrayexpr, attexpr, rexpr, gexpr, bexpr
dim as integer isget
dim as integer isget, dptrsize

function = FALSE

Expand All @@ -892,7 +892,19 @@ function cGfxPalette as integer
errReport( FB_ERRMSG_EXPECTEDIDENTIFIER )
exit function
end if
function = rtlGfxPaletteUsing( arrayexpr, isget )

'' Choose either the 32 or 64-bit version

assert( typeIsPtr( astGetDataType( arrayexpr ) ) )

'' get the size of the data pointed to
dptrsize = typeGetSize( typeDeref( astGetDataType( arrayexpr ) ) )

if( dptrsize <> typeGetSize( FB_DATATYPE_LONG ) and dptrsize <> typeGetSize( FB_DATATYPE_LONGINT ) ) then
dptrsize = typeGetSize( FB_DATATYPE_INTEGER )
end if

function = rtlGfxPaletteUsing( arrayexpr, isget, (dptrsize = typeGetSize( FB_DATATYPE_LONGINT )) )
else
attexpr = NULL
rexpr = NULL
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/rtl-gfx.bas
Original file line number Diff line number Diff line change
Expand Up @@ -2015,15 +2015,16 @@ end function
function rtlGfxPaletteUsing _
( _
byval arrayexpr as ASTNODE ptr, _
byval isget as integer _
byval isget as integer, _
byval is64bit as integer _
) as integer

dim as ASTNODE ptr proc = any
dim as FBSYMBOL ptr f = any

function = FALSE

if( typeGetSize( astGetDataType( arrayexpr ) ) = 8 ) then
if( is64bit ) then
if( isget ) then
f = PROCLOOKUP( GFXPALETTEGETUSING64 )
else
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/rtl.bi
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,8 @@ declare function rtlGfxPalette _
declare function rtlGfxPaletteUsing _
( _
byval arrayexpr as ASTNODE ptr, _
byval isget as integer _
byval isget as integer, _
byval is64bit as integer _
) as integer

declare function rtlGfxPut _
Expand Down
60 changes: 59 additions & 1 deletion tests/gfx/image-expr.bas
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ SUITE( fbc_tests.gfx.image_expr )
CU_ASSERT( hImageIsFilledWithColor( a, rgb(255,0,0) ) )
hResetImageToBlack( a )

'' TODO: Palette Using
'' Palette Get Using is in tests/gfx/palette.bas

CU_ASSERT( hImageIsFilledWithColor( b, rgb(255,0,0) ) )
put a, (0, 0), b, pset
Expand Down Expand Up @@ -212,6 +212,12 @@ SUITE( fbc_tests.gfx.image_expr )
'' @array(0)
line @array(0), (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(255,0,0), bf
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(255,0,0) ) )

'' byref pointer = @array(0)
var array0idx = @array(0)
var byref array0 = array0idx
line array0, (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(0,0,255), bf
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,0,255) ) )
end scope

'' array on heap:
Expand All @@ -235,6 +241,12 @@ SUITE( fbc_tests.gfx.image_expr )
'' @array(0)
line @array(0), (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(255,0,0), bf
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(255,0,0) ) )

'' byref pointer = @array(0)
var array0idx = @array(0)
var byref array0 = array0idx
line array0, (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(0,0,255), bf
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,0,255) ) )
end scope

'' dynamic array, descriptor on stack:
Expand All @@ -258,6 +270,12 @@ SUITE( fbc_tests.gfx.image_expr )
'' @array(0)
line @array(0), (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(255,0,0), bf
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(255,0,0) ) )

'' byref pointer = @array(0)
var array0idx = @array(0)
var byref array0 = array0idx
line array0, (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(0,0,255), bf
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,0,255) ) )
end scope

'' array field:
Expand Down Expand Up @@ -304,6 +322,11 @@ SUITE( fbc_tests.gfx.image_expr )
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array(0)
CU_ASSERT( hImageIsFilledWithColor( array(0), rgb(0,255,0) ) )

'' GET into pointer from byref array access
var byref array0 = array(0)
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array0
CU_ASSERT( hImageIsFilledWithColor( array(0), rgb(0,255,0) ) )

imagedestroy( array(0) )
end scope

Expand Down Expand Up @@ -365,6 +388,12 @@ SUITE( fbc_tests.gfx.image_expr )
'' @array(0)
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), @array(0)
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )

'' byref pointer = @array(0)
var array0idx = @array(0)
var byref array0 = array0idx
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array0
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )
end sub

private sub hTestUdtWithMatchingCastArrayTarget( )
Expand All @@ -376,9 +405,20 @@ SUITE( fbc_tests.gfx.image_expr )
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )

'' array(0)
'' not tested, cast() is known to be used in this case

'' @array(0)
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), @array(0)
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )

'' byref pointer = @array(0)
var array0idx = @array(0)
var byref array0 = array0idx
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array0
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )


end sub

'' GET from screen into some array...
Expand Down Expand Up @@ -433,6 +473,15 @@ SUITE( fbc_tests.gfx.image_expr )
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )
end scope

'' byref pointer = @array(0)
scope
dim array(0 to IMAGE_BUFFER_SIZE-1) as ubyte
var array0idx = @array(0)
var byref array0 = array0idx
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array0
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )
end scope

'' @array(1)
scope
dim array(0 to IMAGE_BUFFER_SIZE+1-1) as ubyte
Expand Down Expand Up @@ -540,6 +589,15 @@ SUITE( fbc_tests.gfx.image_expr )
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )
end scope

'' byref pointer = @array(0)
scope
dim array(0 to (IMAGE_BUFFER_SIZE\4)-1) as ulong
var array0idx = @array(0)
var byref array0 = array0idx
get (0, 0) - (SCREEN_W-1, SCREEN_H-1), array0
CU_ASSERT( hImageIsFilledWithColor( @array(0), rgb(0,255,0) ) )
end scope

'' array(1)
scope
dim array(0 to (IMAGE_BUFFER_SIZE\4)+1-1) as ulong
Expand Down
Loading