mirror of
				https://github.com/golang/go.git
				synced 2025-11-01 09:10:57 +00:00 
			
		
		
		
	 bc13a1a374
			
		
	
	
		bc13a1a374
		
	
	
	
	
		
			
			if an import file is missing, the corresponding source is compiled automatically, if found R=r OCL=13990 CL=13990
		
			
				
	
	
		
			62 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2009 The Go Authors.  All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| package Compilation
 | |
| 
 | |
| import Utils "utils"
 | |
| import Globals "globals"
 | |
| import Object "object"
 | |
| import Type "type"
 | |
| import Universe "universe"
 | |
| import Scanner "scanner"
 | |
| import AST "ast"
 | |
| import Parser "parser"
 | |
| import Export "export"
 | |
| import Printer "printer"
 | |
| import Verifier "verifier"
 | |
| 
 | |
| 
 | |
| export func Compile(flags *Globals.Flags, filename string) {
 | |
| 	// setup compilation
 | |
| 	comp := new(Globals.Compilation);
 | |
| 	comp.flags = flags;
 | |
| 	comp.Compile = &Compile;
 | |
| 	
 | |
| 	src, ok := sys.readfile(filename);
 | |
| 	if !ok {
 | |
| 		print "cannot open ", filename, "\n"
 | |
| 		return;
 | |
| 	}
 | |
| 	
 | |
| 	print filename, "\n";
 | |
| 	
 | |
| 	scanner := new(Scanner.Scanner);
 | |
| 	scanner.Open(filename, src);
 | |
| 	
 | |
| 	var tstream *chan *Scanner.Token;
 | |
| 	if comp.flags.token_chan {
 | |
| 		tstream = new(chan *Scanner.Token, 100);
 | |
| 		go scanner.Server(tstream);
 | |
| 	}
 | |
| 
 | |
| 	parser := new(Parser.Parser);
 | |
| 	parser.Open(comp, scanner, tstream);
 | |
| 
 | |
| 	parser.ParseProgram();
 | |
| 	if parser.S.nerrors > 0 {
 | |
| 		return;
 | |
| 	}
 | |
| 	
 | |
| 	if !comp.flags.ast {
 | |
| 		return;
 | |
| 	}
 | |
| 	
 | |
| 	Verifier.Verify(comp);
 | |
| 	
 | |
| 	if comp.flags.print_interface {
 | |
| 		Printer.PrintObject(comp, comp.pkg_list[0].obj, false);
 | |
| 	}
 | |
| 	
 | |
| 	Export.Export(comp, filename);
 | |
| }
 |