Mark Sibly vor 7 Jahren
Ursprung
Commit
429f6bb255
4 geänderte Dateien mit 35 neuen und 62 gelöschten Zeilen
  1. 17 21
      src/mx2cc/builder.monkey2
  2. 7 5
      src/mx2cc/geninfo/geninfo.monkey2
  3. 9 14
      src/mx2cc/mx2cc.monkey2
  4. 2 22
      src/mx2cc/test.monkey2

+ 17 - 21
src/mx2cc/builder.monkey2

@@ -216,10 +216,6 @@ Class BuilderInstance
 			
 			Local parser:=New Parser
 			
-			Local cd:=currentDir
-
-			currentDir=ExtractDir( path )
-			
 			Local fdecl:=parser.ParseFile( ident,path,ppsyms )
 			
 			fdecl.module=module
@@ -229,6 +225,14 @@ Class BuilderInstance
 
 			module.fileDecls.Push( fdecl )
 			
+			product.reflects.AddAll( fdecl.reflects )
+			
+			'process imports...
+			'
+			If opts.passes=1 Continue
+			'
+			Local cd:=currentDir
+			currentDir=ExtractDir( fdecl.path )
 			BuildEx.srcpath=fdecl.path
 			BuildEx.srcpos=-1
 			
@@ -236,7 +240,6 @@ Class BuilderInstance
 				
 				Local path:=fdecl.imports[imp]
 				
-				
 				Local i:=path.FindLast( "[" )
 				If i<>-1 And path.EndsWith( "]" )
 					BuildEx.srcpos=Int( path.Slice( i+1,-1 ) )
@@ -250,20 +253,8 @@ Class BuilderInstance
 			Next
 			
 			BuildEx.srcpath=""
-			
 			currentDir=cd
 			
-			product.reflects.AddAll( fdecl.reflects )
-			
-			#rem
-			For Local ref:=Eachin fdecl.reflects
-				
-				ref="#define BB_R_"+ref.Replace( "_","_0" ).Replace( ".","_" )+" 1"
-				
-				product.reflects.Push( ref )
-			Next
-			#end
-			
 		Forever
 	
 	End
@@ -713,7 +704,8 @@ Class BuilderInstance
 			Local src:=path.Slice( 0,i )
 			
 			If GetFileType( src )=FileType.None
-				If Not opts.geninfo New BuildEx( "Asset '"+src+"' not found" )
+'				If Not opts.geninfo
+				New BuildEx( "Asset '"+src+"' not found" )
 				Return
 			Endif
 			
@@ -730,7 +722,8 @@ Class BuilderInstance
 			Local dir:=ExtractDir( path )
 			
 			If GetFileType( dir )<>FILETYPE_DIR
-				If Not opts.geninfo New BuildEx( "Directory '"+dir+"' not found" )
+'				If Not opts.geninfo
+				New BuildEx( "Directory '"+dir+"' not found" )
 				Return
 			Endif
 			
@@ -780,7 +773,8 @@ Class BuilderInstance
 			
 			If opts.toolchain="gcc"
 				If GetFileType( path )<>FileType.Directory
-					If Not opts.geninfo New BuildEx( "Framework not found "+qpath )
+'					If Not opts.geninfo 
+					New BuildEx( "Framework not found "+qpath )
 				Endif
 				
 				Return
@@ -791,11 +785,13 @@ Class BuilderInstance
 			If GetFileType( path )=FileType.Directory
 				
 				product.ASSET_FILES.Push( path )
+				
 				Return
 				
 			Else If GetFileType( path )<>FileType.File
 				
-				If Not opts.geninfo New BuildEx( "File not found "+qpath )
+'				If Not opts.geninfo
+ 				New BuildEx( "File not found "+qpath )
 					
 				Return
 			

+ 7 - 5
src/mx2cc/geninfo/geninfo.monkey2

@@ -14,12 +14,14 @@ Possible optimizations:
 #end
 
 Class GeninfoGenerator
-
-	Method GenParseInfo:JsonValue( fdecl:FileDecl )
 	
-		Local node:=GenNode( fdecl )
+	Method GenParseInfo()
 		
-		Return node
+		Local fdecl:=Builder.mainModule.fileDecls[0]		
+	
+		Local jobj:=GenNode( fdecl )
+		
+		Print jobj.ToJson()
 	End
 	
 	Method GenSemantInfo()
@@ -30,7 +32,7 @@ Class GeninfoGenerator
 			
 '			Print "path="+fdecl.path+" gpath="+fdecl.gpath
 			
-			Local jobj:=GenParseInfo( fdecl )
+			Local jobj:=GenNode( fdecl )
 			
 			Local json:=jobj.ToJson()
 			

+ 9 - 14
src/mx2cc/mx2cc.monkey2

@@ -24,7 +24,7 @@ Global StartDir:String
 
 Global profileName:String
 
-'Const TestArgs:="mx2cc makemods monkey"
+'Const TestArgs:="mx2cc makemods"
 
 Const TestArgs:="mx2cc geninfo -semant src/mx2cc/test.monkey2"
 
@@ -171,7 +171,7 @@ Function GenInfo:Bool( args:String[] )
 	
 	args=ParseOpts( opts,args )
 	If args.Length<>1 Fail( "Invalid app source file" )
-	
+		
 	Local cd:=CurrentDir()
 	ChangeDir( StartDir )
 	opts.mainSource=RealPath( args[0].Replace( "\","/" ) )
@@ -182,20 +182,17 @@ Function GenInfo:Bool( args:String[] )
 	Print ""
 
 	New BuilderInstance( opts )
+
+	Local gen:=New GeninfoGenerator
 	
 	Builder.Parse()
+	
 	If opts.passes=1
-		Local gen:=New GeninfoGenerator
-		Local jobj:=gen.GenParseInfo( Builder.mainModule.fileDecls[0] )
-		Print jobj.ToJson()
-		Return Builder.errors.Length=0
+		gen.GenParseInfo()
+	Else
+		If Not Builder.errors.Length Builder.Semant()
+		gen.GenSemantInfo()
 	Endif
-	If Builder.errors.Length Return False
-	
-	Builder.Semant()
-	
-	Local gen:=New GeninfoGenerator
-	gen.GenSemantInfo()
 	
 	Return Builder.errors.Length=0
 End
@@ -432,8 +429,6 @@ Function ParseOpts:String[]( opts:BuildOpts,args:String[] )
 				opts.verbose=-1
 			Case "-verbose"
 				opts.verbose=1
-			Case "-geninfo"
-				opts.geninfo=True
 			Case "-time"
 				opts_time=True
 			Default

+ 2 - 22
src/mx2cc/test.monkey2

@@ -1,27 +1,7 @@
 
-Namespace test
-
-#Import "<windows.h>"
-
-Extern
-
-Alias DWORD:UInt
-Alias LPDWORD:DWORD Ptr
-
-Public
-
-Function Test( p:LPDWORD )
-	
-	Print p[0]
-End
-
-Function Test2( p:LPDWORD )
-
-End
+#Import "<blah>"
 
 Function Main()
 	
-	Local t:DWORD=10
-	
-	Test( Varptr t )
+	Print "Hello World!"
 End