浏览代码

Generate roots for globals.

woollybah 7 年之前
父节点
当前提交
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 + ");"