瀏覽代碼

Generics fix.

Mark Sibly 8 年之前
父節點
當前提交
cac829df69
共有 3 個文件被更改,包括 12 次插入23 次删除
  1. 5 14
      src/mx2cc/func.monkey2
  2. 2 2
      src/mx2cc/mx2cc.monkey2
  3. 5 7
      src/mx2cc/test.monkey2

+ 5 - 14
src/mx2cc/func.monkey2

@@ -383,16 +383,10 @@ Class FuncValue Extends Value
 	End
 	
 	Method SemantStmts()
-	
+
 		If block.IsGeneric SemantError( "FuncValue.SemantStmts(1)" )
 	
-		Try
-		
-			SemantParams()
-			
-		Catch ex:SemantEx
-		
-		End
+		SemantParams()
 		
 		If Not fdecl.IsAbstract
 			
@@ -403,10 +397,7 @@ Class FuncValue Extends Value
 				Local superType:=cscope.ctype.superType
 				If superType And Not superType.hasDefaultCtor
 				
-					Try
-						Throw New SemantEx( "Super class '"+superType.Name+"' has no default constructor",pnode )
-					Catch ex:SemantEx
-					End
+					New SemantEx( "Super class '"+superType.Name+"' has no default constructor",pnode )
 					
 				Endif
 			
@@ -432,7 +423,7 @@ Class FuncValue Extends Value
 				module.main=Self
 			Endif
 			
-			If instanceOf Or IsExtension
+			If instanceOf Or IsExtension Or (cscope And cscope.ctype.instanceOf)
 			
 				Local module:=Builder.semantingModule
 				module.genInstances.Push( Self )
@@ -457,7 +448,7 @@ Class FuncValue Extends Value
 	
 	Method TryGenInstance:FuncValue( types:Type[] )
 		If AnyTypeGeneric( types ) SemantError( "FuncValue.GenInstance()" )
-
+		
 		If types.Length<>Self.types.Length Return Null
 		
 		If Not instances instances=New Stack<FuncValue>

+ 2 - 2
src/mx2cc/mx2cc.monkey2

@@ -21,9 +21,9 @@ Using mx2..
 
 Global StartDir:String
 
-'Const TestArgs:="mx2cc makemods"
+Const TestArgs:="mx2cc makemods"
 
-Const TestArgs:="mx2cc makeapp src/mx2cc/test.monkey2"
+'Const TestArgs:="mx2cc makeapp src/mx2cc/test.monkey2"
 
 'Const TestArgs:="mx2cc makedocs mojo3d"
 

+ 5 - 7
src/mx2cc/test.monkey2

@@ -1,14 +1,12 @@
+#Import "<std>"
 
-Class Box<T>
-
-	Const Min:=New Box
-	
-End
+Using std..
 
 Function Main()
 
-	Local box:=New Box<Int>
+	Local m:=Mat3<Double>.Scaling( 0,0,0 )
 	
-	Print "Bye!"
+	Local m2:=New Mat3<Double>
 
 End
+