2
0
Эх сурвалжийг харах

Fixes to type alias equality checking.

Mark Sibly 8 жил өмнө
parent
commit
899585bce1

+ 6 - 4
src/mx2cc/balance.monkey2

@@ -31,16 +31,18 @@ End
 
 Function BalancePrimTypes:Type( lhs:PrimType,rhs:PrimType )
 
+	If Not lhs And Not rhs
+		Throw New SemantEx( "Types must be primitive" )
+	Endif
+	
+	If Not lhs lhs=rhs Else If Not rhs rhs=lhs
+
 	If lhs=Type.VariantType Or rhs=Type.VariantType Return Type.VariantType
 
 	If lhs=Type.StringType Or rhs=Type.StringType Return Type.StringType
 	
 	If lhs=Type.BoolType Or rhs=Type.BoolType Return Type.BoolType
 	
-	If Not lhs Or Not rhs
-		Throw New SemantEx( "Types must be primitive" )
-	Endif
-
 	Return BalanceNumericTypes( lhs,rhs )
 End
 

+ 1 - 1
src/mx2cc/mung.monkey2

@@ -39,7 +39,7 @@ End
 
 Function MungArg:String( type:Type )
 
-	If type.Dealias=Type.VoidType Return "v"
+	If type=Type.VoidType Return "v"
 	
 	Local ptype:=TCast<PrimType>( type )
 	If ptype

+ 0 - 17
src/mx2cc/property.monkey2

@@ -72,15 +72,10 @@ Class PropertyList Extends FuncList
 		If pdecl.IsExtension selfType=selfType.superType
 		
 		If Not instance.type.ExtendsType( selfType )
-'			Print instance.type.ToString()
-'			Print cscope.ctype.ToString()
 			Throw New SemantEx( "Property '"+pdecl.ident+"' cannot be accessed from an instance of a different class" )
 		Endif
 		
 		Return New PropertyValue( Self,instance )
-	
-		'If instance Return New PropertyValue( Self,instance )
-		'Return Null
 	End
 	
 End
@@ -110,13 +105,6 @@ Class PropertyValue Extends Value
 		Return plist.getFunc.ToValue( instance ).Invoke( Null )
 	End
 	
-	#rem
-	Method UpCast:Value( type:Type ) Override
-	
-		Return ToRValue().UpCast( type )
-	End
-	#end
-	
 	Method Assign:Stmt( pnode:PNode,op:String,rvalue:Value,block:Block ) Override
 	
 		Local inst:=instance
@@ -141,10 +129,6 @@ Class PropertyValue Extends Value
 				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
@@ -171,4 +155,3 @@ Class PropertyValue Extends Value
 	End
 	
 End
-

+ 2 - 8
src/mx2cc/type.monkey2

@@ -39,24 +39,18 @@ Class Type Extends SNode
 		_alias=Self
 	End
 	
-	Property Dealias:Type()
-		Return _alias
-	End
-	
 	Property IsGeneric:Bool()
 		Return flags & TYPE_GENERIC
 	End
 	
 	'Not nice - should fix comparison ops
 	Operator=:Bool( type:Type )
-		If Not Self Return Object(type)=Null
-		If Not type Return Object(_alias)=Null
+		If Not Self Or Not type Throw New SemantEx( "Type.Operator=()" )
 		Return Object(type._alias)=_alias
 	End
 	
 	Operator<>:Bool( type:Type )
-		If Not Self Return Object(type)<>Null
-		If Not type Return Object(_alias)<>Null
+		If Not Self Or Not type Throw New SemantEx( "Type.Operator<>()" )
 		Return Object(type._alias)<>_alias
 	End
 	

+ 1 - 1
src/mx2cc/value.monkey2

@@ -297,7 +297,7 @@ Class LiteralValue Extends Value
 	End
 	
 	Property HasSideEffects:Bool() Override
-		Return type.Dealias=Type.StringType
+		Return type=Type.StringType
 	End
 	
 	Method RemoveSideEffects:Value( block:Block ) Override