Browse Source

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

Fixed incorrect cast on calls to ObjectNew.
Brucey 10 tháng trước cách đây
mục cha
commit
a7d4c0abd7
2 tập tin đã thay đổi với 10 bổ sung6 xóa
  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"
 		InternalErr "TCTranslator.TransValue"
 	End Method
 	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
 'If decl.ident="AddS" DebugStop
 
 
 		Local t$
 		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
 		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
 			' 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
 			End If
 			t:+ objParam
 			t:+ objParam
 		End If
 		End If
@@ -1850,12 +1854,12 @@ t:+"NULLNULLNULL"
 				End If
 				End If
 			Else
 			Else
 				If ClassHasObjectField(expr.classDecl) And Not expr.classDecl.IsStruct() Then
 				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
 				Else
 					If expr.classDecl.IsStruct() Then
 					If expr.classDecl.IsStruct() Then
 						t = ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor)
 						t = ctorMunged + "_ObjectNew" + TransArgs( expr.args,expr.ctor)
 					Else
 					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
 				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 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
 	Method EmitDebugEnterScope(block:TBlockDecl) Abstract