Răsfoiți Sursa

Merge pull request #672 from bmx-ng/task/objectnew-cast

Fixed incorrect cast on calls to ObjectNew.
Brucey 10 luni în urmă
părinte
comite
a7d4c0abd7
2 a modificat fișierele cu 10 adăugiri și 6 ștergeri
  1. 9 5
      ctranslator.bmx
  2. 1 1
      translator.bmx

+ 9 - 5
ctranslator.bmx

@@ -569,14 +569,18 @@ Type TCTranslator Extends TTranslator
 		InternalErr "TCTranslator.TransValue"
 	End Method
 	
-	Method TransArgs$( args:TExpr[],decl:TFuncDecl, objParam:String = Null )
+	Method TransArgs$( args:TExpr[],decl:TFuncDecl, objParam:String = Null, objectNew:Int = False )
 'If decl.ident="AddS" DebugStop
 
 		Local t$
 		If objParam And (decl.IsMethod() Or decl.isCtor()) And ((Not decl.IsExtern()) Or (decl.IsExtern() And TClassDecl(decl.scope) And Not TClassDecl(decl.scope).IsStruct())) Then
 			' object cast to match param type
-			If TClassDecl(decl.scope) Then
-				t :+ Bra(TransObject(TClassDecl(decl.scope).GetLatestFuncDecl(decl).scope, TClassDecl(decl.scope).IsStruct()))
+			If objectNew Then
+				t :+ Bra("BBClass *")
+			Else
+				If TClassDecl(decl.scope) Then
+					t :+ Bra(TransObject(TClassDecl(decl.scope).GetLatestFuncDecl(decl).scope, TClassDecl(decl.scope).IsStruct()))
+				End If
 			End If
 			t:+ objParam
 		End If
@@ -1850,12 +1854,12 @@ t:+"NULLNULLNULL"
 				End If
 			Else
 				If ClassHasObjectField(expr.classDecl) And Not expr.classDecl.IsStruct() Then
-					t = "_" + ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor, "&" + expr.classDecl.actual.munged )
+					t = "_" + ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor, "&" + expr.classDecl.actual.munged, True )
 				Else
 					If expr.classDecl.IsStruct() Then
 						t = ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor)
 					Else
-						t = "_" + ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor, "&" + expr.classDecl.actual.munged)
+						t = "_" + ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor, "&" + expr.classDecl.actual.munged, True)
 					End If
 				End If
 			End If

+ 1 - 1
translator.bmx

@@ -878,7 +878,7 @@ op = mapSymbol(op)
 	
 	Method TransIntrinsicExpr$( decl:TDecl,expr:TExpr,args:TExpr[]=Null ) Abstract
 	
-	Method TransArgs$( args:TExpr[],decl:TFuncDecl, objParam:String = Null ) Abstract
+	Method TransArgs$( args:TExpr[],decl:TFuncDecl, objParam:String = Null, objectNew:Int = False ) Abstract
 
 	Method EmitDebugEnterScope(block:TBlockDecl) Abstract