ソースを参照

Interfaces can now declare functions. Fixes #310.

woollybah 7 年 前
コミット
4b25e0e135
2 ファイル変更9 行追加9 行削除
  1. 2 3
      ctranslator.bmx
  2. 7 6
      parser.bmx

+ 2 - 3
ctranslator.bmx

@@ -3334,15 +3334,14 @@ End Rem
 					While link<>list._head
 					While link<>list._head
 						Local ofdecl:TFuncDecl = TFuncDecl(link._value)
 						Local ofdecl:TFuncDecl = TFuncDecl(link._value)
 						If fdecl.ident = ofdecl.ident And fdecl.EqualsArgs(ofdecl) Then
 						If fdecl.ident = ofdecl.ident And fdecl.EqualsArgs(ofdecl) Then
+
 							If fdecl.overrides Then
 							If fdecl.overrides Then
 								link._value = fdecl
 								link._value = fdecl
 								ignore = True
 								ignore = True
 								Exit
 								Exit
 							End If
 							End If
 							
 							
-							If TFuncDecl(link._value).IsMethod() Then
-								ignore = True
-							End If
+							ignore = True
 						EndIf
 						EndIf
 						link = link._succ
 						link = link._succ
 					Wend
 					Wend

+ 7 - 6
parser.bmx

@@ -3190,7 +3190,8 @@ End Rem
 
 
 		Repeat
 		Repeat
 			Local method_attrs:Int=decl_attrs|FUNC_METHOD | (attrs & DECL_NODEBUG)
 			Local method_attrs:Int=decl_attrs|FUNC_METHOD | (attrs & DECL_NODEBUG)
-			If attrs & CLASS_INTERFACE method_attrs:|DECL_ABSTRACT
+			Local abst_attrs:Int = 0
+			If attrs & CLASS_INTERFACE abst_attrs:|DECL_ABSTRACT
 		
 		
 			SkipEols
 			SkipEols
 			Select _toke
 			Select _toke
@@ -3265,13 +3266,13 @@ End Rem
 				If (attrs & CLASS_STRUCT) And (attrs & DECL_EXTERN) Then
 				If (attrs & CLASS_STRUCT) And (attrs & DECL_EXTERN) Then
 					Err "Structs can only contain fields."
 					Err "Structs can only contain fields."
 				EndIf
 				EndIf
-				Local decl:TFuncDecl=ParseFuncDecl( _toke,method_attrs,classDecl )
+				Local decl:TFuncDecl=ParseFuncDecl( _toke,method_attrs | abst_attrs,classDecl )
 				If decl.IsCtor() decl.retTypeExpr=New TObjectType.Create( classDecl )
 				If decl.IsCtor() decl.retTypeExpr=New TObjectType.Create( classDecl )
 				classDecl.InsertDecl decl
 				classDecl.InsertDecl decl
 			Case "function"
 			Case "function"
-				If (attrs & CLASS_INTERFACE)
-					Err "Interfaces can only contain constants and methods."
-				EndIf
+				'If (attrs & CLASS_INTERFACE)
+				'	Err "Interfaces can only contain constants and methods."
+				'EndIf
 				If attrs & CLASS_STRUCT Then
 				If attrs & CLASS_STRUCT Then
 					If (attrs & DECL_EXTERN) Then
 					If (attrs & DECL_EXTERN) Then
 						Err "Structs can only contain fields."
 						Err "Structs can only contain fields."
@@ -3282,7 +3283,7 @@ End Rem
 				If attrs & DECL_EXTERN Then
 				If attrs & DECL_EXTERN Then
 					Err "Extern Types can only contain methods."
 					Err "Extern Types can only contain methods."
 				End If
 				End If
-				Local decl:TFuncDecl=ParseFuncDecl( _toke,decl_attrs,classDecl )
+				Local decl:TFuncDecl=ParseFuncDecl( _toke,decl_attrs | abst_attrs,classDecl )
 				classDecl.InsertDecl decl
 				classDecl.InsertDecl decl
 			Case "type"
 			Case "type"
 				If templateDets Then
 				If templateDets Then