Browse Source

mx2cc cleanups.

Mark Sibly 9 years ago
parent
commit
ddfffa3694

+ 8 - 3
src/mx2new/class.monkey2

@@ -593,10 +593,15 @@ Class OpIndexValue Extends Value
 				args[0]=rvalue
 				rvalue=node.Invoke( args )
 			Else
-				ValidateAssignOp( op,value.type )
-				Local rtype:=value.type
-				If op2="shl" Or op2="shr" rtype=Type.IntType
+
+				Local rtype:=BalanceAssignTypes( op,value.type,rvalue.type )
 				rvalue=New BinaryopValue( value.type,op2,value,rvalue.UpCast( rtype ) )
+				
+'				ValidateAssignOp( op,value.type )
+'				Local rtype:=value.type
+'				If op2="shl" Or op2="shr" rtype=Type.IntType
+'				rvalue=New BinaryopValue( value.type,op2,value,rvalue.UpCast( rtype ) )
+
 			Endif
 		
 		Endif

+ 1 - 1
src/mx2new/errors.monkey2

@@ -1,7 +1,7 @@
 
 Namespace mx2
 
-Class ErrorEx Extends Exception'Throwable
+Class ErrorEx Extends Throwable
 	Field msg:String
 	
 	Method New( msg:String )

+ 2 - 1
src/mx2new/mx2.monkey2

@@ -25,6 +25,7 @@ Namespace mx2
 #Import "alias.monkey2"
 #Import "namespace.monkey2"
 #Import "overload.monkey2"
+#Import "balance.monkey2"
 #Import "module.monkey2"
 
 #Import "translator.monkey2"
@@ -47,4 +48,4 @@ Using lib.c
 ' 3) edit .sh and .bat files to use new version (common.sh, updatemx2cc.bat, rebuildmx2cc.bat)
 ' 4) ./rebuildall
 '
-Const MX2CC_VERSION:="008"
+Const MX2CC_VERSION:="009"

+ 8 - 2
src/mx2new/mx2cc.monkey2

@@ -17,9 +17,9 @@ Using mx2..
 
 Global StartDir:String
 
-'Const TestArgs:="mx2cc makemods -clean"
+'Const TestArgs:="mx2cc makemods"
 
-Const TestArgs:="mx2cc makedocs monkey std mojo"
+Const TestArgs:="mx2cc makedocs std"
 
 'Const TestArgs:="mx2cc makeapp src/mx2new/test.monkey2"
 
@@ -140,6 +140,7 @@ Function MakeMods( args:String[] )
 	opts.verbose=0
 	
 	args=ParseOpts( opts,args )
+
 	If Not args args=EnumModules()
 	
 	For Local modid:=Eachin args
@@ -156,6 +157,8 @@ Function MakeMods( args:String[] )
 		Local builder:=New Builder( opts )
 		
 		builder.Parse()
+		If builder.errors.Length Continue
+
 		builder.Semant()
 		If builder.errors.Length Continue
 		
@@ -202,7 +205,10 @@ Function MakeDocs( args:String[] )
 		Local builder:=New Builder( opts )
 
 		builder.Parse()
+		If builder.errors.Length Continue
+		
 		builder.Semant()
+		If builder.errors.Length Continue
 		
 		Local tree:=docsMaker.MakeDocs( builder.modules.Top )
 		

+ 7 - 4
src/mx2new/property.monkey2

@@ -131,11 +131,14 @@ Class PropertyValue Extends Value
 				args[0]=rvalue
 				rvalue=node.Invoke( args )
 			Else
-				ValidateAssignOp( op,value.type )
-				Local rtype:=value.type
-				If op2="shl" Or op2="shr" rtype=Type.IntType
+			
+				Local rtype:=BalanceAssignTypes( op,value.type,rvalue.type )
 				rvalue=New BinaryopValue( value.type,op2,value,rvalue.UpCast( rtype ) )
-'				rvalue=New BinaryopValue( value.type,op,value,rvalue.UpCast( type ) )
+				
+				'ValidateAssignOp( op,value.type )
+				'Local rtype:=value.type
+				'If op2="shl" Or op2="shr" rtype=Type.IntType
+				'rvalue=New BinaryopValue( value.type,op2,value,rvalue.UpCast( rtype ) )
 			Endif
 		
 		Endif

+ 2 - 2
src/mx2new/type.monkey2

@@ -538,10 +538,10 @@ Class FuncType Extends Type
 	End
 	
 	Method DistanceToType:Int( type:Type ) Override
-	
+
 		If Equals( type ) Return 0
 		
-		If type.Dealias Return MAX_DISTANCE
+'		If type.Dealias Return MAX_DISTANCE
 		
 		Return -1
 	End

+ 12 - 3
src/mx2new/value.monkey2

@@ -68,9 +68,14 @@ Class Value Extends SNode
 	
 	Method Assign:Stmt( pnode:PNode,op:String,value:Value,block:Block ) Virtual
 		If Not IsAssignable SemantError( "Value.Assign()" )
-		ValidateAssignOp( op,type )
-		value=value.UpCast( type )
-		Return New AssignStmt( pnode,op,Self,value )
+		
+		Local rtype:=BalanceAssignTypes( op,type,value.type )
+		Return New AssignStmt( pnode,op,Self,value.UpCast( rtype ) )
+		
+'		ValidateAssignOp( op,type )
+'		value=value.UpCast( type )
+'		Return New AssignStmt( pnode,op,Self,value )
+
 	End
 	
 	Method CheckAccess( tscope:Scope ) Virtual
@@ -114,6 +119,7 @@ Class Value Extends SNode
 		
 	End
 	
+	#rem
 	Function IsValidAssignOp:Bool( op:String,type:Type )
 
 		If op="=" Return True
@@ -132,6 +138,8 @@ Class Value Extends SNode
 		
 		If TCast<EnumType>( type ) Return op="&=" Or op="|=" Or op="~="
 		
+		If TCast<PointerType>( type ) Return op="+=" Or op="-="
+		
 		If TCast<FuncType>( type ) Return op="+=" Or op="-="
 		
 		Return False
@@ -140,6 +148,7 @@ Class Value Extends SNode
 	Function ValidateAssignOp( op:String,type:Type )
 		If Not IsValidAssignOp( op,type ) Throw New SemantEx( "Assignment operator '"+op+"' cannot be used with type '"+type.ToString()+"'" )
 	End
+	#end
 	
 End