Browse Source

Enum members no longer have 'scope'.

Mark Sibly 7 years ago
parent
commit
66f213e3e0
4 changed files with 18 additions and 4 deletions
  1. 5 1
      src/mx2cc/expr.monkey2
  2. 2 0
      src/mx2cc/mx2cc.monkey2
  3. 10 2
      src/mx2cc/test.monkey2
  4. 1 1
      src/mx2cc/type.monkey2

+ 5 - 1
src/mx2cc/expr.monkey2

@@ -192,6 +192,11 @@ Class MemberExpr Extends Expr
 		
 		
 		Local tvalue:=Cast<TypeValue>( evalue )
 		Local tvalue:=Cast<TypeValue>( evalue )
 		
 		
+		If Not tvalue And TCast<EnumType>( evalue.type )
+			
+			tvalue=New TypeValue( expr.SemantType( scope ) )
+		Endif
+		
 		If tvalue
 		If tvalue
 			
 			
 			Local ctype:=TCast<ClassType>( tvalue.ttype )
 			Local ctype:=TCast<ClassType>( tvalue.ttype )
@@ -206,7 +211,6 @@ Class MemberExpr Extends Expr
 			If Not value Throw New SemantEx( "Type '"+tvalue.ttype.Name+"' has no member named '"+ident+"'" )
 			If Not value Throw New SemantEx( "Type '"+tvalue.ttype.Name+"' has no member named '"+ident+"'" )
 				
 				
 			Return value
 			Return value
-		
 		Endif
 		Endif
 		
 		
 		Local value:=evalue.FindValue( ident )
 		Local value:=evalue.FindValue( ident )

+ 2 - 0
src/mx2cc/mx2cc.monkey2

@@ -24,6 +24,8 @@ Global opts_time:Bool
 
 
 Global StartDir:String
 Global StartDir:String
 
 
+'Const TestArgs:="mx2cc makedocs std"
+ 
 'Const TestArgs:="mx2cc makemods -target=ios"' monkey libc"
 'Const TestArgs:="mx2cc makemods -target=ios"' monkey libc"
  
  
 Const TestArgs:="mx2cc makeapp -clean src/mx2cc/test.monkey2"
 Const TestArgs:="mx2cc makeapp -clean src/mx2cc/test.monkey2"

+ 10 - 2
src/mx2cc/test.monkey2

@@ -1,6 +1,14 @@
-Namespace test
+
+Namespace myapp
+
+Enum E
+	A,B,C
+End
 
 
 Function Main()
 Function Main()
 	
 	
-	Print "Hello world"
+	Local e:=E.A.B
+	
+	Print Int(e)
+
 End
 End

+ 1 - 1
src/mx2cc/type.monkey2

@@ -74,7 +74,7 @@ Class Type Extends SNode
 	End
 	End
 	
 	
 	Method FindType:Type( ident:String ) Virtual
 	Method FindType:Type( ident:String ) Virtual
-		Throw New SemantEx( "Type '"+ToString()+"' has no scope" )
+		Throw New SemantEx( "Type '"+ToString()+"' has no inner type named '"+ident+"'" )
 		Return Null
 		Return Null
 	End
 	End