Skip to content

Commit 1769ad7

Browse files
committed
Allow [static] shared byref variables to be initialized with byref variable
1 parent 2e106bc commit 1769ad7

File tree

4 files changed

+56
-13
lines changed

4 files changed

+56
-13
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Version 1.06.0
1414
- Under X11, ScreenControl GET_WINDOW_HANDLE places the Display ptr in param2
1515
- Updated bindings: SDL2 2.0.6, SDL2_image 2.0.1, SDL2_mixer 2.0.1, SDL2_net 2.0.1, SDL2_ttf 2.0.14
1616
- allow overload operator SQR()
17+
- allow [static] shared byref variables to be initialized with byref variable
1718

1819
[fixed]
1920
- win/d3dx9.bi no longer has a hard-coded #inclib "d3dx9d". d3dx9d.dll is apparently not a generally valid choice. In practice programs have to be linked against d3dx9_33.dll or d3dx9_39.dll, etc.

src/compiler/parser-decl-var.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ private function hResolveRefToRefInitializer( byval dtype as integer, byval expr
866866

867867
if( expr andalso astIsDEREF( expr ) ) then
868868
if( expr->l andalso astIsVAR( expr->l ) ) then
869-
if( expr->l->sym andalso symbIsRef( expr->l->sym ) ) then
869+
if( expr->l->sym andalso symbIsRef( expr->l->sym ) andalso symbIsVar( expr->l->sym ) ) then
870870
tree = expr->l->sym->var_.initree
871871
if( tree andalso astIsTYPEINI( tree ) ) then
872872
if( tree->l andalso tree->l->class = AST_NODECLASS_TYPEINI_ASSIGN ) then

tests/dim/byref-init-from-byref.bas

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ dim shared byref as T T73 = T72
115115
static shared byref as T T74 = T73
116116

117117

118-
'' UDT with static byref fields
118+
'' UDT2 with static byref fields
119119

120120
type T1
121121
dim as integer F
@@ -129,9 +129,9 @@ type T2
129129
static byref as T1 R4
130130
end type
131131

132-
dim shared T2_Initializer as T1
132+
dim shared T1_Initializer as T1
133133

134-
dim byref as T1 T2.R1 = T2_Initializer
134+
dim byref as T1 T2.R1 = T1_Initializer
135135
dim byref as T1 T2.R2 = T2.R1
136136
dim byref as T1 T2.R3 = T2.R2
137137
dim byref as T1 T2.R4 = T2.R3
@@ -141,6 +141,11 @@ dim shared byref as T1 RT2 = T2.R2
141141
dim shared byref as T1 RT3 = T2.R3
142142
dim shared byref as T1 RT4 = T2.R4
143143

144+
static shared byref as T1 SRT1 = RT1
145+
static shared byref as T1 SRT2 = RT2
146+
static shared byref as T1 SRT3 = RT3
147+
static shared byref as T1 SRT4 = RT4
148+
144149

145150
SUITE( fbc_tests.dim_.byref_init_from_byref )
146151

@@ -274,10 +279,10 @@ SUITE( fbc_tests.dim_.byref_init_from_byref )
274279
END_TEST
275280

276281
TEST( UDT_static_local_to_static_shared )
277-
static byref as T b = T51
278-
static byref as T c = T54
282+
static byref as T b = T71
283+
static byref as T c = T74
279284
dim byref as T d = c
280-
CheckAddrs( T51, b, c, d )
285+
CheckAddrs( T71, b, c, d )
281286
END_TEST
282287

283288
'' -------- UDT2 -------------------
@@ -290,5 +295,47 @@ SUITE( fbc_tests.dim_.byref_init_from_byref )
290295
CheckAddrs( RT1, RT2, RT3, RT4 )
291296
END_TEST
292297

293-
298+
TEST( UDT2_static_to_shared )
299+
CheckAddrs( SRT1, SRT2, SRT3, SRT4 )
300+
END_TEST
301+
302+
TEST( UDT2_check_all )
303+
static byref as T1 a = T2.R1
304+
static byref as T1 b = RT1
305+
dim byref as T1 c = SRT1
306+
dim byref as T1 d = c
307+
CheckAddrs( T2.R1, RT1, SRT1, a )
308+
CheckAddrs( T2.R2, RT2, SRT2, b )
309+
CheckAddrs( T2.R3, RT3, SRT3, c )
310+
CheckAddrs( T2.R4, RT4, SRT4, d )
311+
END_TEST
312+
313+
TEST( UDT2_local_to_shared )
314+
static byref as T1 b = RT1
315+
dim byref as T1 c = RT4
316+
dim byref as T1 d = c
317+
CheckAddrs( RT1, b, c, d )
318+
END_TEST
319+
320+
TEST( UDT2_local_to_static_shared )
321+
static byref as T1 b = SRT1
322+
dim byref as T1 c = SRT4
323+
dim byref as T1 d = c
324+
CheckAddrs( SRT1, b, c, d )
325+
END_TEST
326+
327+
TEST( UDT2_static_local_to_shared )
328+
static byref as T1 b = RT1
329+
static byref as T1 c = RT4
330+
dim byref as T1 d = c
331+
CheckAddrs( RT1, b, c, d )
332+
END_TEST
333+
334+
TEST( UDT2_static_local_to_static_shared )
335+
static byref as T1 b = SRT1
336+
static byref as T1 c = SRT4
337+
dim byref as T1 d = c
338+
CheckAddrs( SRT1, b, c, d )
339+
END_TEST
340+
294341
END_SUITE

tests/dim/byref-shared-from-shared-ref.bas

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)