2
0
Эх сурвалжийг харах

Generate roots for globals.

woollybah 7 жил өмнө
parent
commit
e874b4792a
1 өөрчлөгдсөн 21 нэмэгдсэн , 0 устгасан
  1. 21 0
      ctranslator.bmx

+ 21 - 0
ctranslator.bmx

@@ -5729,6 +5729,27 @@ End If
 		Emit "if (!" + app.munged + "_inited) {"
 		Emit app.munged + "_inited = 1;"
 
+		' add global roots
+		Local first:TGlobalDecl
+		Local last:TGlobalDecl
+				
+		For Local decl:TGlobalDecl=EachIn app.semantedGlobals
+
+			If decl.declImported Continue
+
+			decl.Semant
+
+			If Not first Then
+				first = decl
+			End If
+			
+			last = decl
+		Next
+
+		If first Then
+			Emit "GC_add_roots(&" + first.munged + ", &" + last.munged + " + 1);"
+		End If
+
 		' register incbins
 		For Local ib:TIncbin = EachIn app.incbins
 			Emit "bbIncbinAdd(&" + TStringConst(app.stringConsts.ValueForKey(ib.file)).id + ",&" + app.munged + "_ib_" + ib.id + "," + ib.length + ");"