Example #1
0
func compilePackage(compiler llgo.Compiler, fset *token.FileSet, files map[string]*ast.File, importpath string) (*llgo.Module, error) {
	// make a package (resolve all identifiers)
	pkg, err := ast.NewPackage(fset, files, types.GcImport, types.Universe)
	if err != nil {
		report(err)
		return nil, err
	}

	// an empty importpath means the same as the package name
	if importpath == "" {
		importpath = pkg.Name
	}

	exprTypes, err := types.Check(importpath, compiler, fset, pkg)
	if err != nil {
		report(err)
		return nil, err
	}

	if *dumpast {
		ast.Fprint(os.Stderr, fset, pkg, nil)
		os.Exit(0)
	}

	return compiler.Compile(fset, pkg, importpath, exprTypes)
}
Example #2
0
File: llgo.go Project: payco/llgo
func compileFiles(compiler llgo.Compiler, filenames []string, importpath string) (*llgo.Module, error) {
	i := 0
	for _, filename := range filenames {
		switch _, err := os.Stat(filename); {
		case err != nil:
			report(err)
		default:
			filenames[i] = filename
			i++
		}
	}
	if i == 0 {
		return nil, errors.New("No Go source files were specified")
	}
	fset := token.NewFileSet()
	files := parseFiles(fset, filenames[0:i])
	return compiler.Compile(fset, files, importpath)
}
Example #3
0
File: llgo.go Project: pcc/llgo
func compileFiles(compiler llgo.Compiler, filenames []string, importpath string) (*llgo.Module, error) {
	return compiler.Compile(filenames, importpath)
}