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

Function Inline initial support.

woollybah 5 жил өмнө
parent
commit
18d8b3d4bc
5 өөрчлөгдсөн 23 нэмэгдсэн , 2 устгасан
  1. 11 0
      ctranslator.bmx
  2. 1 0
      decl.bmx
  3. 1 1
      options.bmx
  4. 9 0
      parser.bmx
  5. 1 1
      toker.bmx

+ 11 - 0
ctranslator.bmx

@@ -3345,6 +3345,13 @@ End Rem
 					pre = ""
 				End If
 			End If
+			If decl.attrs & DECL_INLINE Then
+				pre = "inline "
+			Else
+				bk = ";"
+			End If
+		Else If decl.attrs & DECL_INLINE Then
+			pre = "extern "
 			bk = ";"
 		End If
 
@@ -3381,6 +3388,10 @@ End Rem
 				Emit t
 			Next
 		End If
+		
+		If decl.attrs & DECL_INLINE Then
+			proto = Not proto
+		End If
 
 		If Not proto Then
 

+ 1 - 0
decl.bmx

@@ -28,6 +28,7 @@ Const DECL_ABSTRACT:Int=      $040000
 Const DECL_FINAL:Int=         $080000
 Const DECL_READ_ONLY:Int=     $000100
 Const DECL_OVERRIDE:Int=    $40000000
+Const DECL_INLINE:Int=      $80000000
 
 Const DECL_SEMANTED:Int=      $100000
 Const DECL_SEMANTING:Int=     $200000

+ 1 - 1
options.bmx

@@ -25,7 +25,7 @@ SuperStrict
 
 Import "base.configmap.bmx"
 
-Const version:String = "0.115"
+Const version:String = "0.116"
 
 Const BUILDTYPE_APP:Int = 0
 Const BUILDTYPE_MODULE:Int = 1

+ 9 - 0
parser.bmx

@@ -2834,6 +2834,15 @@ End Rem
 				declaredAttrs :| DECL_OVERRIDE
 				Continue
 			End If
+			
+			If CParse("inline") Then
+				If classDecl Then
+					Err "Inline can only be used with global functions"
+				End If
+				If declaredAttrs & DECL_INLINE Then Err "Duplicate modifier 'Inline'"
+				declaredAttrs :| DECL_INLINE
+				Continue
+			End If
 				
 			Exit
 		Wend

+ 1 - 1
toker.bmx

@@ -50,7 +50,7 @@ Type TToker
 		"next,return,alias,rem,endrem,throw,assert,try,catch,finally,nodebug,incbin,endselect,endmethod," + ..
 		"endfunction,endtype,endextern,endtry,endwhile,pi,release,defdata,readdata,restoredata,interface," + ..
 		"endinterface,implements,size_t,uint,ulong,struct,endstruct,operator,where,readonly,export,override," + ..
-		"enum,endenum,stackalloc"
+		"enum,endenum,stackalloc,inline"
 	Global _keywords:TMap
 
 	Field _path$