Parcourir la source

Don't cast to structs.

Brucey il y a 4 ans
Parent
commit
90db9b0882
2 fichiers modifiés avec 7 ajouts et 3 suppressions
  1. 6 2
      ctranslator.bmx
  2. 1 1
      translator.bmx

+ 6 - 2
ctranslator.bmx

@@ -4922,7 +4922,11 @@ End Rem
 						Else If TInvokeExpr(decl.init) And Not TInvokeExpr(decl.init).invokedWithBraces Then
 							fld :+ "= " + TInvokeExpr(decl.init).decl.munged + ";"
 						Else If TObjectType(decl.ty) Then
-							fld :+ "= " + Bra(TransObject(TObjectType(decl.ty).classDecl)) + decl.init.Trans() + ";"
+							fld :+ "= "
+							If Not TObjectType(decl.ty).classDecl.IsStruct() Then
+								fld :+ Bra(TransObject(TObjectType(decl.ty).classDecl))
+							End If
+							fld :+ decl.init.Trans() + ";"
 						Else If TArrayType(decl.ty) And TArrayType(decl.ty).isStatic Then
 							fld = "for(int i=0;i<" + TArrayType(decl.ty).length + ";i++) " + TransFieldRef(decl, "o") + "[i]=" + TransValue(TArrayType(decl.ty).elemType,Null,False) + ";"
 						Else
@@ -6201,7 +6205,7 @@ End If
 			End If
 		Else
 			If Not decl.funcGlobal Then
-				If TObjectType(decl.ty) Then
+				If TObjectType(decl.ty) And Not TObjectType(decl.ty).classDecl.IsStruct() Then
 					Emit TransGlobal( decl )+"="+Bra(TransObject(TObjectType(decl.ty).classDecl))+decl.init.Trans()+";"
 				Else
 					Emit TransGlobal( decl )+"="+decl.init.Trans()+";"

+ 1 - 1
translator.bmx

@@ -1106,7 +1106,7 @@ End Rem
 					Local s:String
 					
 					' cast to function return type
-					If TObjectType(stmt.fRetType) Then
+					If TObjectType(stmt.fRetType) And Not TObjectType(stmt.fRetType).classDecl.IsStruct() Then
 						s :+ Bra(TransType(stmt.fRetType, ""))
 					End If