Prechádzať zdrojové kódy

Removed hasty Finalizers...later/properly.

Mark Sibly 8 rokov pred
rodič
commit
54a4a1776b

+ 0 - 6
src/mx2cc/decl.monkey2

@@ -19,8 +19,6 @@ Const DECL_SETTER:=			$020000
 Const DECL_OPERATOR:=		$040000
 Const DECL_IFACEMEMBER:=	$080000
 
-Const DECL_HASFINALIZER:=	$100000
-
 Const DECL_ACCESSMASK:=DECL_PUBLIC|DECL_PRIVATE|DECL_PROTECTED|DECL_INTERNAL
 
 Class Decl Extends PNode
@@ -94,10 +92,6 @@ Class Decl Extends PNode
 		Return (flags & DECL_DEFAULT)<>0
 	End
 	
-	Property HasFinalizer:Bool()
-		Return (flags & DECL_HASFINALIZER)<>0
-	End
-	
 	Method ToNode:SNode( scope:Scope ) Virtual
 		Return Null
 	End

+ 2 - 1
src/mx2cc/mung.monkey2

@@ -92,7 +92,8 @@ Function MungArg:String( type:Type )
 		Return "P"+MungArg( qtype.elemType )
 	Endif
 	
-	Return "????? MungArg "+String.FromCString( type.typeName() )+" ?????"
+'	Return "????? MungArg "+String.FromCString( type.typeName() )+" ?????"
+	Return "????? MungArg ?????"
 End
 
 Function MungArgs:String( types:Type[] )

+ 3 - 3
src/mx2cc/node.monkey2

@@ -118,14 +118,14 @@ Class SNode Extends UNode
 	End
 	
 	Method ToValue:Value( instance:Value ) Virtual
-		Print String.FromCString( typeName() )
+'		Print String.FromCString( typeName() )
 		SemantError( "SNode.ToValue()" )
 		Return Null
 	End
 	
-	Method ToString:String() override
+	Method ToString:String() Override
 		If pnode Return pnode.ToString()
-		Print String.FromCString( typeName() )
+'		Print String.FromCString( typeName() )
 		Return "????? SNode.ToString() ?????"
 	End
 	

+ 0 - 16
src/mx2cc/parser.monkey2

@@ -404,10 +404,6 @@ Class Parser
 		
 		decl.members=ParseDecls( mflags,False )
 		
-		For Local mdecl:=Eachin decl.members
-			If mdecl.ident="finalize" decl.flags|=DECL_HASFINALIZER
-		Next
-		
 		Try
 			Parse( "end" )
 			CParse( decl.kind )
@@ -476,8 +472,6 @@ Class Parser
 			
 				If CParse( "new" )
 					ident="new"
-				Else If CParse( "finalize" )
-					ident="finalize"
 				Else If CParse( "to" )
 					ident="to"
 				Else
@@ -499,8 +493,6 @@ Class Parser
 			
 			genArgs=ParseGenArgs()
 			
-'			If genArgs And ident="finalize" Error( "Finalizers cannot be generic" )
-
 			If CParse( ":" )
 				type=Cast<FuncTypeExpr>( ParseType() )
 				If Not type Error( "Expecting function type" )
@@ -508,8 +500,6 @@ Class Parser
 				type=ParseFuncType( New IdentExpr( "void",SrcPos,SrcPos ) )
 			Endif
 			
-'			If type.argTypes And ident="finalize" Error( "Finalizers cannot have any parameters" )
-			
 			If kind="lambda"
 				For Local p:=Eachin type.params
 					If p.init Error( "Lambda function parameters cannot have default values" )
@@ -564,17 +554,11 @@ Class Parser
 				
 			End
 			
-'			If Not (flags & DECL_OVERRIDE) And ident="finalize" Error( "Finalizers must be declared 'Override'" )
-			
 			If CParse( "=" )
 				
 				If Not (flags & DECL_EXTERN) Error( "Non-extern declarations cannot be assigned an extern symbol" )
 					
 				symbol=ParseString()
-			
-'			Else If ident="finalize"
-				
-'				symbol="gcFinalize"
 			Endif
 
 			If CParse( "where" )

+ 10 - 26
src/mx2cc/translator_cpp.monkey2

@@ -462,7 +462,7 @@ Class Translator_CPP Extends Translator
 		
 		'Emit fields...
 		'
-		Local needsInit:=NeedsFinalize( ctype )
+		Local needsInit:=False
 		Local needsMark:=False
 
 		EmitBr()		
@@ -601,16 +601,6 @@ Class Translator_CPP Extends Translator
 		
 	End
 	
-	Method NeedsFinalize:Bool( ctype:ClassType )
-		If Not ctype Or Not ctype.cdecl.HasFinalizer Return false
-		ctype=ctype.superType
-		While ctype And ctype<>Type.ObjectClass 
-			If ctype.cdecl.HasFinalizer Return False
-			ctype=ctype.superType
-		Wend
-		Return True
-	End
-	
 	Method EmitClassMembers( ctype:ClassType )
 	
 		Local cdecl:=ctype.cdecl
@@ -620,7 +610,7 @@ Class Translator_CPP Extends Translator
 		
 		'Emit fields...
 		'
-		Local needsInit:=NeedsFinalize( ctype )
+		Local needsInit:=False
 		Local needsMark:=False
 
 		EmitBr()
@@ -638,8 +628,6 @@ Class Translator_CPP Extends Translator
 			EmitBr()
 			Emit( "void "+cname+"::init(){" )
 			
-			If NeedsFinalize( ctype ) Emit( "gcNeedsFinalize();" )
-			
 			BeginGCFrame()
 			
 			For Local vvar:=Eachin ctype.fields
@@ -1026,7 +1014,8 @@ Class Translator_CPP Extends Translator
 		Emit( "return &"+rcname+"::instance;" )
 		Emit( "}" )
 	End
-	
+
+	'For later...
 	Method DiscardGCFields( ctype:ClassType,prefix:String )
 		
 		For Local vvar:=Eachin ctype.fields
@@ -1069,14 +1058,6 @@ Class Translator_CPP Extends Translator
 			_gctmps=0
 		Endif
 		
-		If func.fdecl.ident="finalize"
-			
-			Local ctype:=func.cscope.ctype
-			
-			DiscardGCFields( ctype,"" )
-			
-		Endif
-		
 		If init Emit( "init();" )
 			
 		'is it 'main'?
@@ -1306,7 +1287,8 @@ Class Translator_CPP Extends Translator
 		Local printStmt:=Cast<PrintStmt>( stmt )
 		If printStmt EmitStmt( printStmt ) ; Return
 		
-		Throw New TransEx( "Translator_CPP.EmitStmt() Stmt '"+String.FromCString( stmt.typeName() )+"' not recognized" )
+'		Throw New TransEx( "Translator_CPP.EmitStmt() Stmt '"+String.FromCString( stmt.typeName() )+"' not recognized" )
+		Throw New TransEx( "Translator_CPP.EmitStmt() Stmt not recognized" )
 	End
 	
 	Method EmitStmt( stmt:PrintStmt )
@@ -1632,7 +1614,8 @@ Class Translator_CPP Extends Translator
 		Local typeofTypeValue:=Cast<TypeofTypeValue>( value )
 		If typeofTypeValue Return Trans( typeofTypeValue )
 		
-		Return "{* "+value.ToString()+" "+String.FromCString( value.typeName() )+" *}"
+'		Return "{* "+value.ToString()+" "+String.FromCString( value.typeName() )+" *}"
+		Return "{* "+value.ToString()+" *}"
 	End
 	
 	Method Trans:String( value:UpCastValue )
@@ -2105,7 +2088,8 @@ Class Translator_CPP Extends Translator
 		Local genArgType:=TCast<GenArgType>( type )
 		If genArgType Return TransType( genArgType )
 		
-		Throw New TransEx( "Translator_CPP.Trans() Type '"+String.FromCString( type.typeName() )+"' not recognized" )
+		'Throw New TransEx( "Translator_CPP.Trans() Type '"+String.FromCString( type.typeName() )+"' not recognized" )
+		Throw New TransEx( "Translator_CPP.Trans() Type not recognized" )
 	End
 	
 	Method TransType:String( type:ClassType )

+ 2 - 1
src/mx2cc/value.monkey2

@@ -10,7 +10,8 @@ Class Value Extends SNode
 	Field flags:Int
 	
 	Method ToString:String() Override
-		Return "????? VALUE ????? "+String.FromCString( typeName() )
+'		Return "????? VALUE ????? "+String.FromCString( typeName() )
+		Return "????? VALUE ????? "
 	End
 	
 	Method ToValue:Value( instance:Value ) Override