當前位置: 首頁>>代碼示例>>Golang>>正文


Golang eval.Thread類代碼示例

本文整理匯總了Golang中bitbucket/org/binet/go-eval/pkg/eval.Thread的典型用法代碼示例。如果您正苦於以下問題:Golang Thread類的具體用法?Golang Thread怎麽用?Golang Thread使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Thread類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: wrapper_InstallDir

// Signature: func InstallDir(srcPath, dstPath string)
func wrapper_InstallDir(t *eval.Thread, in []eval.Value, out []eval.Value) {
	srcPath := in[0].(eval.StringValue).Get(t)
	dstPath := in[1].(eval.StringValue).Get(t)

	var err error

	// Check the 'srcPath', make it relative to the local root
	{
		srcPath, err = cleanAndCheckPath(t, srcPath)
		if err != nil {
			t.Abort(err)
			return
		}

		srcPath = pathutil.Join(currentConfig.parent.path, srcPath)
		if _, alreadyPresent := installationCommands_bySrcPath[srcPath]; alreadyPresent {
			t.Abort(errors.New("duplicate installation of \"" + srcPath + "\""))
			return
		}
	}

	// Clean the 'dstPath'
	dstPath = pathutil.Clean(dstPath)

	if *flag_debug {
		fmt.Printf("(read config) install dir \"%s\" --> \"%s\"\n", srcPath, dstPath)
	}

	cmd := new_installDir(srcPath, dstPath)
	installationCommands = append(installationCommands, cmd)
	installationCommands_bySrcPath[srcPath] = cmd
}
開發者ID:remogatto,項目名稱:goam,代碼行數:33,代碼來源:config.go

示例2: wrapper_MinGoamVersion

// Signature: func MinGoamVersion(version uint)
func wrapper_MinGoamVersion(t *eval.Thread, in []eval.Value, out []eval.Value) {
	minVersion := in[0].(eval.UintValue).Get(t)

	if *flag_debug {
		println("(read config) Goam min version:", minVersion)
	}

	if VERSION < minVersion {
		msg := fmt.Sprintf("insufficient GOAM version: %d, minimum required version is %d", VERSION, minVersion)
		t.Abort(errors.New(msg))
		return
	}
}
開發者ID:remogatto,項目名稱:goam,代碼行數:14,代碼來源:config.go

示例3: wrapper_IgnoreDir

// Signature: func IgnoreDir(path string)
func wrapper_IgnoreDir(t *eval.Thread, in []eval.Value, out []eval.Value) {
	path := in[0].(eval.StringValue).Get(t)

	var err error
	path, err = cleanAndCheckPath(t, path)
	if err != nil {
		t.Abort(err)
		return
	}

	path = pathutil.Join(currentConfig.parent.path, path)

	if *flag_debug {
		println("(read config) ignore dir \"" + path + "\"")
	}
	ignoredDirs[path] = 0
}
開發者ID:remogatto,項目名稱:goam,代碼行數:18,代碼來源:config.go

示例4: wrapper_Package

// Signature: func Package(path string)
func wrapper_Package(t *eval.Thread, in []eval.Value, out []eval.Value) {
	pkg := in[0].(eval.StringValue).Get(t)

	if len(currentConfig.targetPackage_orEmpty) != 0 {
		t.Abort(errors.New("duplicate target package specification"))
		return
	}

	pkg = strings.TrimSpace(pkg)
	if len(pkg) == 0 {
		t.Abort(errors.New("the target package cannot be an empty string"))
		return
	}

	if *flag_debug {
		println("(read config) target package = \"" + pkg + "\"")
	}
	currentConfig.targetPackage_orEmpty = pkg
}
開發者ID:remogatto,項目名稱:goam,代碼行數:20,代碼來源:config.go

示例5: wrapper_InstallPackage

// Signature: func InstallPackage()
func wrapper_InstallPackage(t *eval.Thread, in []eval.Value, out []eval.Value) {
	pkg := currentConfig.targetPackage_orEmpty
	if len(pkg) == 0 {
		t.Abort(errors.New("no target package has been defined"))
		return
	}

	if _, alreadyPresent := installationCommands_packagesByImport[pkg]; alreadyPresent {
		t.Abort(errors.New("duplicate installation of package \"" + pkg + "\""))
		return
	}

	if *flag_debug {
		fmt.Printf("(read config) install package \"" + pkg + "\"\n")
	}

	cmd := new_installPackage(pkg)
	installationCommands = append(installationCommands, cmd)
	installationCommands_packagesByImport[pkg] = cmd
}
開發者ID:remogatto,項目名稱:goam,代碼行數:21,代碼來源:config.go

示例6: wrapper_InstallExecutable

// Signature: func InstallExecutable(srcPath string)
func wrapper_InstallExecutable(t *eval.Thread, in []eval.Value, out []eval.Value) {
	srcPath := in[0].(eval.StringValue).Get(t)

	var err error

	// Check the 'srcPath', make it relative to the local root
	{
		srcPath, err = cleanAndCheckPath(t, srcPath)
		if err != nil {
			t.Abort(err)
			return
		}

		_, file := pathutil.Split(srcPath)
		if file == testExeName {
			t.Abort(errors.New("cannot install: executables named \"" + srcPath + "\" are used for tests"))
			return
		}

		srcPath = pathutil.Join(currentConfig.parent.path, srcPath)
		if _, alreadyPresent := installationCommands_bySrcPath[srcPath]; alreadyPresent {
			t.Abort(errors.New("duplicate installation of \"" + srcPath + "\""))
			return
		}
	}

	if *flag_debug {
		fmt.Printf("(read config) install exe \"%s\"\n", srcPath)
	}

	cmd := new_installExecutable(srcPath)
	installationCommands = append(installationCommands, cmd)
	installationCommands_bySrcPath[srcPath] = cmd
}
開發者ID:remogatto,項目名稱:goam,代碼行數:35,代碼來源:config.go

示例7: wrapper_DisableGoFmt

// Signature: func DisableGoFmt(path string)
func wrapper_DisableGoFmt(t *eval.Thread, in []eval.Value, out []eval.Value) {
	path := in[0].(eval.StringValue).Get(t)

	var err error
	path, err = cleanAndCheckPath(t, path)
	if err != nil {
		t.Abort(err)
		return
	}

	path = pathutil.Join(currentConfig.parent.path, path)

	if _, alreadyPresent := disabledGoFmt[path]; alreadyPresent {
		t.Abort(errors.New("gofmt already disabled: \"" + path + "\""))
		return
	}

	if *flag_debug {
		println("(read config) disable gofmt \"" + path + "\"")
	}
	disabledGoFmt[path] = 0
}
開發者ID:remogatto,項目名稱:goam,代碼行數:23,代碼來源:config.go

示例8: wrapper_MinCompilerVersion

// Signature: func MinCompilerVersion(version uint)
func wrapper_MinCompilerVersion(t *eval.Thread, in []eval.Value, out []eval.Value) {
	minVersion := in[0].(eval.UintValue).Get(t)

	if *flag_debug {
		println("(read config) Go compiler min version:", minVersion)
	}

	if *flag_gcc {
		t.Abort(errors.New("function MinCompilerVersion is incompatible with gccgo"))
		return
	}

	version, err := getGoCompilerVersion()
	if err != nil {
		t.Abort(err)
		return
	}

	if uint64(version) < minVersion {
		msg := fmt.Sprintf("insufficient Go compiler version: %d, minimum required version is %d", version, minVersion)
		t.Abort(errors.New(msg))
		return
	}
}
開發者ID:remogatto,項目名稱:goam,代碼行數:25,代碼來源:config.go

示例9: wrapper_RemotePackage

// Signature: func RemotePackage(importPaths, type, repository string, installCommand []string)
func wrapper_RemotePackage(t *eval.Thread, in []eval.Value, out []eval.Value) {
	importPaths := in[0].(eval.StringValue).Get(t)
	kindString := in[1].(eval.StringValue).Get(t)
	repositoryPath := in[2].(eval.StringValue).Get(t)
	installCommand_sliceValue := in[3].(eval.SliceValue).Get(t)

	var importPaths_array []string
	{
		importPaths_array = strings.Split(importPaths, " ")

		// Remove empty strings from 'importPaths_array'
		{
			i, j := 0, 0
			for i < len(importPaths_array) {
				if len(importPaths_array[i]) != 0 {
					importPaths_array[j] = importPaths_array[i]
					i++
					j++
				} else {
					i++
				}
			}

			importPaths_array = importPaths_array[0:j]
		}

		if len(importPaths_array) == 0 {
			t.Abort(errors.New("repository \"" + repositoryPath + "\": empty list of import paths"))
			return
		}

		// Check for duplicated import paths
		if len(importPaths_array) > 1 {
			importPaths_set := make(map[string]byte)
			for _, importPath := range importPaths_array {
				if _, alreadyExists := importPaths_set[importPath]; alreadyExists {
					t.Abort(errors.New("repository \"" + repositoryPath + "\": duplicate import path \"" + importPath + "\""))
					return
				}

				importPaths_set[importPath] = 0
			}
		}
	}

	var kind int
	switch strings.ToLower(kindString) {
	case "github":
		kind = GITHUB
	case "bitbucket":
		kind = BITBUCKET
	default:
		t.Abort(errors.New("repository \"" + repositoryPath + "\": \"" + kindString + "\" is an invalid repository type"))
		return
	}

	// Check 'repositoryPath'
	{
		repositoryPath = strings.TrimSpace(repositoryPath)

		err := checkRepositoryPath(kind, repositoryPath)
		if err != nil {
			t.Abort(err)
			return
		}
	}

	var installCommand []string
	{
		var array eval.ArrayValue = installCommand_sliceValue.Base
		var length int64 = installCommand_sliceValue.Len

		installCommand = make([]string, length)
		for i := int64(0); i < length; i++ {
			installCommand[i] = array.Elem(t, i).(eval.StringValue).Get(t)
		}

		if len(installCommand) == 0 {
			t.Abort(errors.New("repository \"" + repositoryPath + "\": empty installation command"))
			return
		}
	}

	if *flag_debug {
		fmt.Printf("(read config) remote package: %v %s \"%s\"\n", importPaths_array, kindString, repositoryPath)
	}

	// Find or create an instance of 'remote_package_t'
	var remotePkg *remote_package_t
	{
		if remotePkg1, alreadyExists := remotePackages_byRepository[repositoryPath]; alreadyExists {
			if remotePkg1.repository.Kind() != kind {
				t.Abort(errors.New("repository \"" + repositoryPath + "\" redefined with a different repository type"))
				return
			}

			if len(remotePkg1.installCmd) != len(installCommand) {
				t.Abort(errors.New("repository \"" + repositoryPath + "\" redefined with a different installation command"))
				return
//.........這裏部分代碼省略.........
開發者ID:remogatto,項目名稱:goam,代碼行數:101,代碼來源:config.go

示例10: wrapper_Executable

// Signature: func Executable(name string, sources string)
func wrapper_Executable(t *eval.Thread, in []eval.Value, out []eval.Value) {
	name := in[0].(eval.StringValue).Get(t)
	_sources := in[1].(eval.StringValue).Get(t)

	// Check the name, make the name relative to the local root
	{
		var err error
		name, err = cleanAndCheckPath(t, name)
		if err != nil {
			t.Abort(err)
			return
		}

		_, file := pathutil.Split(name)
		if file == testExeName {
			t.Abort(errors.New("executables named \"" + name + "\" are used for tests"))
			return
		}

		name = pathutil.Join(currentConfig.parent.path, name)
		if _, alreadyPresent := executable2sources[name]; alreadyPresent {
			t.Abort(errors.New("duplicate executable \"" + name + "\""))
			return
		}
	}

	var sources []string
	{
		sources = strings.Fields(_sources)
		if len(sources) == 0 {
			t.Abort(errors.New("empty list of sources"))
			return
		}

		// Check 'sources[i]', make 'sources[i]' relative to the local root
		for i := 0; i < len(sources); i++ {
			source, err := cleanAndCheckPath(t, sources[i])
			if err != nil {
				t.Abort(err)
				return
			}

			if !strings.HasSuffix(source, ".go") {
				t.Abort(errors.New("the name of file \"" + source + "\" does not end with \".go\""))
				return
			}

			source = pathutil.Join(currentConfig.parent.path, source)

			if _, alreadyPresent := source2executable[source]; alreadyPresent {
				t.Abort(errors.New("cannot associate file \"" + source + "\" with more than one executable"))
				return
			}

			if !fileExists(source) {
				t.Abort(errors.New("executable \"" + name + "\" depends on non-existent file \"" + source + "\""))
				return
			}

			sources[i] = source
		}
	}

	if *flag_debug {
		fmt.Printf("(read config) exe \"%s\" <-- %v\n", name, sources)
	}

	executable2sources[name] = sources
	for _, source := range sources {
		source2executable[source] = name
	}
}
開發者ID:remogatto,項目名稱:goam,代碼行數:73,代碼來源:config.go

示例11: wrapper_PackageFiles

// Signature: func PackageFiles(files string)
func wrapper_PackageFiles(t *eval.Thread, in []eval.Value, out []eval.Value) {
	_files := in[0].(eval.StringValue).Get(t)

	if currentConfig.packageFiles_orNil != nil {
		t.Abort(errors.New("package files already defined"))
		return
	}

	var files []string
	{
		files = strings.Fields(_files)
		if len(files) == 0 {
			t.Abort(errors.New("empty list of files"))
			return
		}

		// Check 'files[i]'
		for i := 0; i < len(files); i++ {
			file, err := cleanAndCheckPath(t, files[i])
			if err != nil {
				t.Abort(err)
				return
			}

			if !strings.HasSuffix(file, ".go") {
				t.Abort(errors.New("the name of file \"" + file + "\" does not end with \".go\""))
				return
			}

			dir, _ := pathutil.Split(file)
			if len(dir) > 0 {
				t.Abort(errors.New("package file \"" + file + "\" uses a relative path"))
				return
			}

			path := pathutil.Join(currentConfig.parent.path, file)

			if !fileExists(path) {
				t.Abort(errors.New("file \"" + path + "\" does not exist"))
				return
			}

			files[i] = file
		}
	}

	if *flag_debug {
		fmt.Printf("(read config) package files %v\n", files)
	}

	packageFiles := make(map[string]byte)
	for _, file := range files {
		packageFiles[file] = 0
	}
	currentConfig.packageFiles_orNil = packageFiles
}
開發者ID:remogatto,項目名稱:goam,代碼行數:57,代碼來源:config.go


注:本文中的bitbucket/org/binet/go-eval/pkg/eval.Thread類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。